Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MonoAotCompiler msbuild task #35961

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 40 additions & 16 deletions eng/testing/tests.mobile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
<!-- OutDir is not set early enough to set this property in .props file. -->
<BundleDir>$([MSBuild]::NormalizeDirectory('$(OutDir)', 'AppBundle'))</BundleDir>
<RunScriptOutputPath>$([MSBuild]::NormalizePath('$(BundleDir)', '$(RunScriptOutputName)'))</RunScriptOutputPath>
<RunAOTCompilation Condition="'$(TargetOS)' == 'iOS' and ('$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm')">true</RunAOTCompilation>
</PropertyGroup>

<!-- Generate a self-contained app bundle for Android with tests. -->
<UsingTask TaskName="AndroidAppBuilderTask"
AssemblyFile="$(AndroidAppBuilderDir)AndroidAppBuilder.dll" />

<Target Condition="'$(TargetOS)' == 'Android'" Name="BundleTestAndroidApp">
<PropertyGroup>
<AndroidAbi Condition="'$(TargetArchitecture)'=='arm64'">arm64-v8a</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)'=='arm'">armeabi</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)'=='x64'">x86_64</AndroidAbi>
<AndroidAbi Condition="'$(AndroidAbi)'==''">$(TargetArchitecture)</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'arm64'">arm64-v8a</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'arm'">armeabi</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'x64'">x86_64</AndroidAbi>
<AndroidAbi Condition="'$(TargetArchitecture)' == 'x86'">x86</AndroidAbi>
</PropertyGroup>
<ItemGroup>
<AndroidTestRunnerBinaries Include="$(AndroidTestRunnerDir)*.*" />
Expand All @@ -22,7 +24,6 @@
<Error Condition="'@(AndroidTestRunnerBinaries)' == ''" Text="Could not find AndroidTestRunner in $(AndroidTestRunnerDir)" />
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />

<RemoveDir Directories="$(BundleDir)" />
<Copy SourceFiles="@(AndroidTestRunnerBinaries)" DestinationFolder="$(PublishDir)%(RecursiveDir)" SkipUnchangedFiles="true"/>

<!-- TEMP: consume OpenSSL binaries from external sources via env. variables -->
Expand All @@ -35,10 +36,11 @@

<WriteLinesToFile File="$(PublishDir)xunit-excludes.txt" Lines="$(_withoutCategories.Replace(';', '%0dcategory='))" />

<AndroidAppBuilderTask
<RemoveDir Directories="$(BundleDir)" />
<AndroidAppBuilderTask
Abi="$(AndroidAbi)"
ProjectName="$(AssemblyName)"
MonoRuntimeHeaders="$(RuntimePackNativeDir)\include\mono-2.0"
MonoRuntimeHeaders="$(RuntimePackNativeDir)include\mono-2.0"
MainLibraryFileName="AndroidTestRunner.dll"
OutputDir="$(BundleDir)"
SourceDir="$(PublishDir)">
Expand All @@ -53,32 +55,56 @@
<!-- Generate a self-contained app bundle for iOS with tests. -->
<UsingTask TaskName="AppleAppBuilderTask"
AssemblyFile="$(AppleAppBuilderDir)AppleAppBuilder.dll" />
<UsingTask TaskName="MonoAOTCompiler"
AssemblyFile="$(MonoAOTCompilerDir)MonoAOTCompiler.dll" />

<Import Project="$(MonoProjectRoot)msbuild\AotCompilerTask\MonoAOTCompiler.props" />

<Target Condition="'$(TargetOS)' == 'iOS'" Name="BundleTestAppleApp">
<ItemGroup>
<AppleTestRunnerBinaries Include="$(AppleTestRunnerDir)*.*" />
</ItemGroup>

<Error Condition="'@(AppleTestRunnerBinaries)' == ''" Text="Could not find AppleTestRunner in $(AppleTestRunnerDir) doesn't exist" />
<Error Condition="!Exists('$(RuntimePackRidDir)')" Text="RuntimePackRidDir=$(RuntimePackRidDir) doesn't exist" />
<Error Condition="('$(TargetArchitecture)' == 'arm64' or '$(TargetArchitecture)' == 'arm') and '$(DevTeamProvisioning)' == ''"
Text="'DevTeamProvisioning' needs to be set for device builds. Set it to 'UBF8T346G9' if you're part of the Microsoft team account." />

<RemoveDir Directories="$(BundleDir)" />
<Copy SourceFiles="@(AppleTestRunnerBinaries)" DestinationFolder="$(PublishDir)%(RecursiveDir)" SkipUnchangedFiles="true"/>

<WriteLinesToFile File="$(PublishDir)xunit-excludes.txt" Lines="$(_withoutCategories.Replace(';', '%0dcategory='))" />
<!-- Run App bundler, it should AOT libs (if needed), link all native bits, compile simple UI (written in ObjC)

<ItemGroup>
<AotInputAssemblies Condition="'$(RunAOTCompilation)' == 'true'" Include="$(PublishDir)*.dll" Exclude="$(PublishDir)System.Runtime.WindowsRuntime.dll">
<AotArguments>@(MonoAOTCompilerDefaultAotArguments, ';')</AotArguments>
<ProcessArguments>@(MonoAOTCompilerDefaultProcessArguments, ';')</ProcessArguments>
</AotInputAssemblies>
<BundleAssemblies Condition="'$(RunAOTCompilation)' != 'true'" Include="$(PublishDir)*.dll" />
</ItemGroup>

<MonoAOTCompiler Condition="'$(RunAOTCompilation)' == 'true'"
CompilerBinaryPath="$(RuntimePackNativeDir)cross\mono-aot-cross"
Mode="Full"
OutputType="AsmOnly"
Assemblies="@(AotInputAssemblies)"
UseLLVM="$(MonoEnableLLVM)"
LLVMPath="$(RuntimePackNativeDir)cross">
<Output TaskParameter="CompiledAssemblies" ItemName="BundleAssemblies" />
</MonoAOTCompiler>

<!-- Run App bundler, it uses AOT libs (if needed), link all native bits, compile simple UI (written in ObjC)
and produce an app bundle (with xcode project) -->
<AppleAppBuilderTask
<RemoveDir Directories="$(BundleDir)" />
<AppleAppBuilderTask
Arch="$(TargetArchitecture)"
ProjectName="$(AssemblyName)"
MonoRuntimeHeaders="$(RuntimePackNativeDir)\include\mono-2.0"
CrossCompiler="$(RuntimePackNativeDir)\cross\mono-aot-cross"
MonoRuntimeHeaders="$(RuntimePackNativeDir)include\mono-2.0"
Assemblies="@(BundleAssemblies)"
MainLibraryFileName="AppleTestRunner.dll"
UseConsoleUITemplate="True"
GenerateXcodeProject="True"
BuildAppBundle="True"
Optimized="True"
UseLlvm="$(MonoEnableLLVM)"
LlvmPath="$(RuntimePackNativeDir)\cross"
DevTeamProvisioning="$(DevTeamProvisioning)"
OutputDirectory="$(BundleDir)"
AppDir="$(PublishDir)">
Expand All @@ -87,8 +113,6 @@
</AppleAppBuilderTask>
<Message Importance="High" Text="Xcode: $(XcodeProjectPath)"/>
<Message Importance="High" Text="App: $(AppBundlePath)"/>
<Error Condition="$(TargetArchitecture.StartsWith('arm')) and '$(DevTeamProvisioning)' == ''"
Text="'DevTeamProvisioning' shouldn't be empty for arm64" />
<!-- This app is now can be consumed by xharness CLI to deploy on a device or simulator -->
</Target>

Expand Down
1 change: 1 addition & 0 deletions eng/testing/tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<AppleTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AppleTestRunner', '$(MobileHelpersDirSuffix)'))</AppleTestRunnerDir>
<AndroidAppBuilderDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidAppBuilder', '$(MobileHelpersDirSuffix)'))</AndroidAppBuilderDir>
<AndroidTestRunnerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'AndroidTestRunner', '$(MobileHelpersDirSuffix)'))</AndroidTestRunnerDir>
<MonoAOTCompilerDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'MonoAOTCompiler', '$(MobileHelpersDirSuffix)'))</MonoAOTCompilerDir>

<RuntimeIdentifier>$(PackageRID)</RuntimeIdentifier>
<SelfContained>true</SelfContained>
Expand Down
1 change: 1 addition & 0 deletions src/mono/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,6 @@
<AppleTestRunnerProjDirectory>$([MSBuild]::NormalizeDirectory('$(MonoProjectRoot)', 'msbuild', 'AppleTestRunner'))</AppleTestRunnerProjDirectory>
<AndroidAppBuilderProjDirectory>$([MSBuild]::NormalizeDirectory('$(MonoProjectRoot)', 'msbuild', 'AndroidAppBuilder'))</AndroidAppBuilderProjDirectory>
<AndroidTestRunnerProjDirectory>$([MSBuild]::NormalizeDirectory('$(MonoProjectRoot)', 'msbuild', 'AndroidTestRunner'))</AndroidTestRunnerProjDirectory>
<MonoAOTCompilerProjDirectory>$([MSBuild]::NormalizeDirectory('$(MonoProjectRoot)', 'msbuild', 'AotCompilerTask'))</MonoAOTCompilerProjDirectory>
</PropertyGroup>
</Project>
Loading