-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[android][ios] Add LibraryBuilder task to support aot library mode #81919
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
Changes from all commits
1d8483b
6cc724f
bbf6992
0055975
76cdbe4
9caea1f
9c3d805
37fde1a
e3d1fd4
3911d2c
9bb0dd9
4ed46bf
fde2bda
d6fd785
cde3f9d
6ba6aa9
ba37138
d3c03ac
04acf6c
f4c204f
2ccf282
807844e
55e98f5
340a02f
09aab3c
c99889b
223cf3a
e641c28
6a23439
e272bb0
f30804d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
|
|
||
| <PropertyGroup> | ||
| <AndroidGenerateAppBundle Condition="'$(AndroidGenerateAppBundle)' == ''">true</AndroidGenerateAppBundle> | ||
| <!-- Unable to properly integrate nativelib into app build, so not supported for now. --> | ||
| <AndroidGenerateAppBundle Condition="'$(_IsLibraryMode)' == 'true'">false</AndroidGenerateAppBundle> | ||
| </PropertyGroup> | ||
|
|
||
| <Target Name="AndroidBuildApp" AfterTargets="$(AndroidBuildAppAfterThisTarget)" /> | ||
|
|
@@ -16,6 +18,36 @@ | |
| <PropertyGroup> | ||
| <_MobileIntermediateOutputPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'mobile'))</_MobileIntermediateOutputPath> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <BundleDir>$(AndroidAppBundleDir)</BundleDir> | ||
| <_MonoHeaderPath>$(MicrosoftNetCoreAppRuntimePackNativeDir)include\mono-2.0</_MonoHeaderPath> | ||
| <_AotModuleTablePath>$(AndroidAppBundleDir)\modules.c</_AotModuleTablePath> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <RuntimeComponents Condition="'$(RuntimeComponents)' == ''" >marshal-ilgen</RuntimeComponents> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup Condition="'$(_IsLibraryMode)' == 'true'"> | ||
| <!-- add all non stub libs first --> | ||
| <!-- if RuntimeComponents is empty, exclude -static.a and include -stub-static.a instead --> | ||
| <!-- if RuntimeComponents is *, we're ok because all -static.a is included --> | ||
| <!-- if RuntimeComponents is a list, add to items and only pull in -static.a --> | ||
|
|
||
| <_UsedComponents | ||
| Condition="'$(RuntimeComponents)' != '' and '$(RuntimeComponents)' != '*'" | ||
| Include="$(RuntimeComponents)" /> | ||
|
|
||
| <_RuntimeLibraries | ||
| Include="$(AndroidAppDir)\*-stub-static.a" /> | ||
| <_RuntimeLibraries | ||
| Include="$(AndroidAppDir)\*.a" | ||
| Exclude="$(AndroidAppDir)\*-static.a" /> | ||
|
|
||
| <_RuntimeLibraries Remove="$(AndroidAppDir)\libmono-component-%(_UsedComponents.Identity)-stub-static.a" /> | ||
| <_RuntimeLibraries Include="$(AndroidAppDir)\libmono-component-%(_UsedComponents.Identity)-static.a" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
| <Target Name="_BeforeAndroidBuildApp"> | ||
|
|
@@ -29,11 +61,11 @@ | |
|
|
||
| <Target Name="_AndroidResolveReferences"> | ||
| <ItemGroup> | ||
| <_AndroidAssembliesInternal Remove="@(_AndroidAssembliesInternal)" /> | ||
| <_AndroidAssembliesInternal Include="@(AndroidAssembliesToBundle)"> | ||
| <AppAssembliesInternal Remove="@(AppAssembliesInternal)" /> | ||
| <AppAssembliesInternal Include="@(AndroidAssembliesToBundle)"> | ||
| <_InternalForceInterpret>%(AndroidAssembliesToBundle._InternalForceInterpret)</_InternalForceInterpret> | ||
| <_IsNative>%(AndroidAssembliesToBundle._IsNative)</_IsNative> | ||
| </_AndroidAssembliesInternal> | ||
| </AppAssembliesInternal> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
|
|
@@ -52,6 +84,7 @@ | |
|
|
||
| <MonoAOTCompilerDefaultAotArguments Include="static" /> | ||
| <MonoAOTCompilerDefaultAotArguments Include="dwarfdebug" /> | ||
| <MonoAOTCompilerDefaultAotArguments Condition="'$(_IsLibraryMode)' == 'true'" Include="direct-icalls" /> | ||
|
|
||
| <MonoAOTCompilerDefaultAotArguments Include="nimt-trampolines=2000" /> | ||
| <MonoAOTCompilerDefaultAotArguments Include="ntrampolines=10000" /> | ||
|
|
@@ -67,14 +100,14 @@ | |
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <_AotInputAssemblies Include="@(_AndroidAssembliesInternal)" | ||
| Condition="'%(_AndroidAssembliesInternal._InternalForceInterpret)' != 'true'"> | ||
| <_AotInputAssemblies Include="@(AppAssembliesInternal)" | ||
| Condition="'%(AppAssembliesInternal._InternalForceInterpret)' != 'true'"> | ||
| <AotArguments>$(AotArguments)</AotArguments> | ||
| <ProcessArguments>$(ProcessArguments)</ProcessArguments> | ||
| </_AotInputAssemblies> | ||
|
|
||
| <_AOT_InternalForceInterpretAssemblies Include="@(_AndroidAssembliesInternal->WithMetadataValue('_InternalForceInterpret', 'true'))" /> | ||
| <_AndroidAssembliesInternal Remove="@(_AndroidAssembliesInternal)" /> | ||
| <_AOT_InternalForceInterpretAssemblies Include="@(AppAssembliesInternal->WithMetadataValue('_InternalForceInterpret', 'true'))" /> | ||
| <AppAssembliesInternal Remove="@(AppAssembliesInternal)" /> | ||
| </ItemGroup> | ||
|
|
||
| <MakeDir Directories="$(_MobileIntermediateOutputPath)" /> | ||
|
|
@@ -104,22 +137,39 @@ | |
| <ProfiledAOTProfilePaths Include="$(MibcFilePath)" /> | ||
| </ItemGroup> | ||
|
|
||
| <!-- | ||
| In order for the runtime to work when static linking, we must supply | ||
| a list of direct pinvokes otherwise the runtime will crash | ||
| --> | ||
| <ItemGroup Condition="'$(_IsLibraryMode)' == 'true'"> | ||
| <DirectPInvokes Include="libSystem.Native" /> | ||
| <DirectPInvokes Include="libSystem.IO.Compression.Native" /> | ||
| <DirectPInvokes Include="libSystem.Security.Cryptography.Native.Android" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is missing libSystem.Net.Security.Native and libSystem.Security.Cryptography.Native (for Linux Bionic) and libSystem.Globalization.Native (for Filip's ICU PR). I wonder if we should generate this list based on the .a files instead of hardcoding. I'm ok with addressing this in a follow-up PR.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be addressed in a follow up. |
||
| </ItemGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <_EnableUnmanagedCallersOnlyMethodsExport Condition="'$(_IsLibraryMode)' == 'true'">true</_EnableUnmanagedCallersOnlyMethodsExport> | ||
| </PropertyGroup> | ||
|
|
||
| <MonoAOTCompiler | ||
| CompilerBinaryPath="@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier','$(TargetOS)-$(TargetArchitecture.ToLowerInvariant())'))" | ||
| OutputDir="$(_MobileIntermediateOutputPath)" | ||
| Mode="$(_AOTMode)" | ||
| OutputType="AsmOnly" | ||
| AotModulesTablePath="$(_AotModuleTablePath)" | ||
| Assemblies="@(_AotInputAssemblies)" | ||
| AotModulesTablePath="$(AndroidAppBundleDir)\modules.c" | ||
| CompilerBinaryPath="@(MonoAotCrossCompiler->WithMetadataValue('RuntimeIdentifier','$(TargetOS.ToLowerInvariant())-$(TargetArchitecture.ToLowerInvariant())'))" | ||
| DirectPInvokes="@(DirectPInvokes)" | ||
| DirectPInvokeLists="@(DirectPInvokeLists)" | ||
| EnableUnmanagedCallersOnlyMethodsExport="$(_EnableUnmanagedCallersOnlyMethodsExport)" | ||
| IntermediateOutputPath="$(_MobileIntermediateOutputPath)" | ||
| LLVMPath="$(MonoAotCrossDir)" | ||
| MibcProfilePath="@(ProfiledAOTProfilePaths)" | ||
| UseLLVM="$(MonoEnableLLVM)" | ||
| LLVMPath="$(MonoAotCrossDir)"> | ||
| <Output TaskParameter="CompiledAssemblies" ItemName="_AndroidAssembliesInternal" /> | ||
| Mode="$(_AOTMode)" | ||
| OutputDir="$(_MobileIntermediateOutputPath)" | ||
| OutputType="AsmOnly" | ||
| UseLLVM="$(MonoEnableLLVM)"> | ||
| <Output TaskParameter="CompiledAssemblies" ItemName="AppAssembliesInternal" /> | ||
| </MonoAOTCompiler> | ||
|
|
||
| <ItemGroup> | ||
| <_AndroidAssembliesInternal Include="@(_AOT_InternalForceInterpretAssemblies)" /> | ||
| <AppAssembliesInternal Include="@(_AOT_InternalForceInterpretAssemblies)" /> | ||
| </ItemGroup> | ||
| </Target> | ||
|
|
||
|
|
@@ -129,27 +179,30 @@ | |
| Condition="$(AndroidGenerateAppBundle) == 'true'" | ||
| DependsOnTargets="_AndroidGenerateRuntimeConfig"> | ||
|
|
||
| <PropertyGroup> | ||
| <RuntimeComponents Condition="'$(RuntimeComponents)' == ''" >marshal-ilgen</RuntimeComponents> | ||
| </PropertyGroup> | ||
| <ItemGroup Condition="'$(_IsLibraryMode)' == 'true'"> | ||
| <_NativeDependencies Include="$(LibraryOutputPath)" /> | ||
| </ItemGroup> | ||
|
|
||
| <AndroidAppBuilderTask | ||
| RuntimeIdentifier="$(RuntimeIdentifier)" | ||
| ProjectName="$(AssemblyName)" | ||
| MonoRuntimeHeaders="$(MicrosoftNetCoreAppRuntimePackNativeDir)include\mono-2.0" | ||
| Assemblies="@(_AndroidAssembliesInternal)" | ||
| MainLibraryFileName="$(MainLibraryFileName)" | ||
| AppDir="$(AndroidAppDir)" | ||
| Assemblies="@(AppAssembliesInternal)" | ||
| DiagnosticPorts="$(DiagnosticPorts)" | ||
| EnvironmentVariables="@(AndroidEnv)" | ||
| ExtraLinkerArguments="@(ExtraAppLinkerArgs)" | ||
| ForceAOT="$(RunAOTCompilation)" | ||
| ForceFullAOT="$(ForceFullAOT)" | ||
| ForceInterpreter="$(MonoForceInterpreter)" | ||
| StripDebugSymbols="False" | ||
| RuntimeComponents="$(RuntimeComponents)" | ||
| DiagnosticPorts="$(DiagnosticPorts)" | ||
| IsLibraryMode="$(_IsLibraryMode)" | ||
| MainLibraryFileName="$(MainLibraryFileName)" | ||
| MonoRuntimeHeaders="$(_MonoHeaderPath)" | ||
| NativeDependencies="@(_NativeDependencies)" | ||
| OutputDir="$(AndroidAppBundleDir)" | ||
| AppDir="$(AndroidAppDir)"> | ||
| <Output TaskParameter="ApkPackageId" PropertyName="ApkPackageId" /> | ||
| ProjectName="$(AssemblyName)" | ||
| RuntimeComponents="$(RuntimeComponents)" | ||
| RuntimeIdentifier="$(RuntimeIdentifier)" | ||
| StripDebugSymbols="False"> | ||
| <Output TaskParameter="ApkBundlePath" PropertyName="ApkBundlePath" /> | ||
| <Output TaskParameter="ApkPackageId" PropertyName="ApkPackageId" /> | ||
| </AndroidAppBuilderTask> | ||
|
|
||
| <Message Importance="High" Text="PackageId: $(ApkPackageId)"/> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,7 @@ | |
| <DevTeamProvisioning Condition="'$(DevTeamProvisioning)' == '' and '$(TargetOS)' == 'maccatalyst'">adhoc</DevTeamProvisioning> | ||
| </PropertyGroup> | ||
|
|
||
| <!-- TODO: this breaks runtime tests on Helix due to the file not being there for some reason. Once this is fixed we can remove the UpdateRuntimePack target here --> | ||
| <!--<Import Project="$(RepositoryEngineeringDir)targetingpacks.targets" Condition="'$(TargetingpacksTargetsImported)' != 'true'"/>--> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we keep this? |
||
| <Import Project="..\..\common\LibraryBuilder.targets" /> | ||
| <Import Project="$(MSBuildThisFileDirectory)AppleApp.targets" /> | ||
|
|
||
| <!-- Use local runtime pack --> | ||
|
|
@@ -24,22 +23,4 @@ | |
| </ItemGroup> | ||
| <Message Text="Used runtime pack: %(ResolvedRuntimePack.PackageDirectory)" Importance="high" /> | ||
| </Target> | ||
|
|
||
| <Target Name="CopyAppZipToHelixTestDir" | ||
| Condition="'$(AppleCopyAppZipToHelixTestDir)' == 'true'" | ||
| AfterTargets="Build" | ||
| DependsOnTargets="Publish"> | ||
| <PropertyGroup> | ||
| <WasmHelixTestAppRelativeDir Condition="'$(WasmHelixTestAppRelativeDir)' == ''">$(MSBuildProjectName)</WasmHelixTestAppRelativeDir> | ||
| <!-- Helix properties --> | ||
| <!-- AnyCPU as Platform--> | ||
| <OSPlatformConfig>$(TargetOS).AnyCPU.$(Configuration)</OSPlatformConfig> | ||
| <HelixArchiveRoot>$([MSBuild]::NormalizeDirectory($(ArtifactsDir), 'helix'))</HelixArchiveRoot> | ||
| <HelixArchiveRunOnlyRoot>$([MSBuild]::NormalizeDirectory($(HelixArchiveRoot), 'runonly'))</HelixArchiveRunOnlyRoot> | ||
| <HelixArchiveRunOnlyAppsDir>$([MSBuild]::NormalizeDirectory($(HelixArchiveRunOnlyRoot), $(OSPlatformConfig), $(WasmHelixTestAppRelativeDir)))</HelixArchiveRunOnlyAppsDir> | ||
| <ZippedApp>$(OutputPath)$(AssemblyName).zip</ZippedApp> | ||
| </PropertyGroup> | ||
| <ZipDirectory SourceDirectory="$(WasmAppDir)" DestinationFile="$(ZippedApp)" /> | ||
| <Copy SourceFiles="$(ZippedApp)" DestinationFolder="$(HelixArchiveRunOnlyAppsDir)" /> | ||
| </Target> | ||
| </Project> | ||
Uh oh!
There was an error while loading. Please reload this page.