Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1d8483b
Apple side of the library builder
Jan 11, 2023
6cc724f
Embed framework through cmake on iOS. Add android fragments
Jan 12, 2023
bbf6992
Android library build
Jan 18, 2023
0055975
Bring back android exports
Jan 19, 2023
76cdbe4
Fix android library build by getting rid of force_load as that is onl…
Jan 21, 2023
9caea1f
Merge remote-tracking branch 'upstream/main' into lib-builder-mobile
Jan 24, 2023
9c3d805
Android builds library in separate cmake. iOS does too, but there are…
Feb 1, 2023
37fde1a
Add ability to pass in library projects to the main app
Feb 6, 2023
e3d1fd4
Clean up Android and scale back iOS to just building the library.
Feb 8, 2023
3911d2c
Merge remote-tracking branch 'upstream/main' into lib-builder-mobile
Feb 8, 2023
9bb0dd9
Move symbol table stripping to its own method
Feb 8, 2023
4ed46bf
Revert aotcompiler.c workaround
Feb 8, 2023
fde2bda
Condition some of the library builder specific items
Feb 8, 2023
d6fd785
Cleanup
Feb 9, 2023
cde3f9d
Add library builder tasks as a correlation payload.
Feb 10, 2023
6ba6aa9
Remove unnecessary librarybuilder props import
Feb 10, 2023
ba37138
Feedback
Feb 13, 2023
d3c03ac
Make sure sample provides linker arg items
Feb 14, 2023
04acf6c
Linker args in runtime test build
Feb 14, 2023
f4c204f
Merge remote-tracking branch 'upstream/main' into lib-builder-mobile
Feb 22, 2023
2ccf282
Make the runtime libraries to link actually work
Feb 23, 2023
807844e
Add default list of pinvokes for android aot
Feb 23, 2023
55e98f5
Merge remote-tracking branch 'upstream/main' into lib-builder-mobile
Feb 28, 2023
340a02f
Feedback
Feb 28, 2023
09aab3c
Remove extra symbols to keep. Condition direct icalls and direct pinv…
Mar 1, 2023
c99889b
PR feedback. Add test UnmanagedCallersOnly back in
Mar 1, 2023
223cf3a
Remove autoinit.c as it will come back in a follow up
Mar 1, 2023
e641c28
Generate list of assemblies that contained unmanagedcallersonly attri…
Mar 4, 2023
6a23439
More feedback
Mar 6, 2023
e272bb0
Merge remote-tracking branch 'upstream/main' into lib-builder-mobile
Mar 6, 2023
f30804d
Ignore CA1850 in the library builder
Mar 6, 2023
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
Prev Previous commit
Next Next commit
Clean up Android and scale back iOS to just building the library.
  • Loading branch information
Steve Pfister committed Feb 8, 2023
commit e3d1fd480f9d1d8fb1d8b8041024eebe73bcb019
3 changes: 2 additions & 1 deletion src/mono/msbuild/android/build/AndroidApp.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<UseMonoRuntime>true</UseMonoRuntime>
<UseMonoJustInterp Condition="'$(RunAOTCompilation)' == 'true' and '$(MonoForceInterpreter)' == 'true'">true</UseMonoJustInterp>

<_NativeLibraryTarget Condition="'$(NativeLibrary)' != ''">_BuildNativeLibrary;</_NativeLibraryTarget>
<_IsLibraryMode Condition="'$(NativeLib)' != ''">true</_IsLibraryMode>
<_NativeLibraryTarget Condition="'$(_IsLibraryMode)' == 'true'">_BuildNativeLibrary;</_NativeLibraryTarget>

<AndroidBuildAppAfterThisTarget Condition="'$(AndroidBuildAppAfterThisTarget)' == ''">Publish</AndroidBuildAppAfterThisTarget>
<AndroidBuildAppDependsOn>
Expand Down
88 changes: 45 additions & 43 deletions src/mono/msbuild/android/build/AndroidApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<PropertyGroup>
<AndroidGenerateAppBundle Condition="'$(GenerateAppBundle)' != ''">$(GenerateAppBundle)</AndroidGenerateAppBundle>
<AndroidGenerateAppBundle Condition="'$(AndroidGenerateAppBundle)' == '' and '$(NativeLibrary)' != ''">false</AndroidGenerateAppBundle>
<AndroidGenerateAppBundle Condition="'$(AndroidGenerateAppBundle)' == '' and '$(_IsLibraryMode)' == 'true'">false</AndroidGenerateAppBundle>
<AndroidGenerateAppBundle Condition="'$(AndroidGenerateAppBundle)' == ''">true</AndroidGenerateAppBundle>
</PropertyGroup>

Expand All @@ -25,47 +25,44 @@
<_AotModuleTablePath>$(AndroidAppBundleDir)\modules.c</_AotModuleTablePath>
</PropertyGroup>

<PropertyGroup>
<_RuntimeSymbolsToKeep>
register_aot_modules
mono_jit_init_version
mono_jit_exec
mono_assembly_get_name
mono_assembly_name_get_culture
mono_assembly_name_get_name
mono_assembly_open
mono_class_get_method_from_name
mono_class_get_name
mono_class_get_namespace
mono_debug_init
mono_dllmap_insert
mono_domain_get
mono_gc_init_finalizer_thread
mono_get_exception_class
mono_install_assembly_preload_hook
mono_install_load_aot_data_hook
mono_install_unhandled_exception_hook
mono_jit_cleanup
mono_jit_parse_options
mono_jit_set_aot_mode
mono_object_get_class
mono_object_get_virtual_method
mono_runtime_invoke
mono_set_crash_chaining
mono_set_signal_chaining
mono_string_to_utf8
mono_trace_set_log_handler
monovm_initialize
monovm_runtimeconfig_initialize
mono_aot_register_module
mono_polling_required
mono_thread_interruption_request_flag

</_RuntimeSymbolsToKeep>
</PropertyGroup>
<ItemGroup>
<_RuntimeSymbolsToKeep Include="
register_aot_modules;
mono_jit_init_version;
mono_jit_exec;
mono_assembly_get_name;
mono_assembly_name_get_culture;
mono_assembly_name_get_name;
mono_assembly_open;
mono_class_get_method_from_name;
mono_class_get_name;
mono_class_get_namespace;
mono_debug_init;
mono_dllmap_insert;
mono_domain_get;
mono_gc_init_finalizer_thread;
mono_get_exception_class;
mono_install_assembly_preload_hook;
mono_install_load_aot_data_hook;
mono_install_unhandled_exception_hook;
mono_jit_cleanup;
mono_jit_parse_options;
mono_jit_set_aot_mode;
mono_object_get_class;
mono_object_get_virtual_method;
mono_runtime_invoke;
mono_set_crash_chaining;
mono_set_signal_chaining;
mono_string_to_utf8;
mono_trace_set_log_handler;
monovm_initialize;
monovm_runtimeconfig_initialize;
mono_aot_register_module;
mono_polling_required;
mono_thread_interruption_request_flag;" />
</ItemGroup>

<ItemGroup>
<!-- static vs dylibs -->
<!-- add all non stub libs first -->
<!-- if runtimecompoents is empty, exclude -static.a and include -stub-static.a instead -->
<!-- if runtimecomponents is *, we're ok because all -static.a is included -->
Expand Down Expand Up @@ -205,7 +202,7 @@ mono_thread_interruption_request_flag
</ItemGroup>

<PropertyGroup>
<_EnableUnmanagedCallersOnlyMethodsExport Condition="'$(NativeLibrary)' != ''">true</_EnableUnmanagedCallersOnlyMethodsExport>
<_EnableUnmanagedCallersOnlyMethodsExport Condition="'$(_IsLibraryMode)' == 'true'">true</_EnableUnmanagedCallersOnlyMethodsExport>
</PropertyGroup>

<MonoAOTCompiler
Expand Down Expand Up @@ -239,8 +236,11 @@ mono_thread_interruption_request_flag
<RuntimeComponents Condition="'$(RuntimeComponents)' == ''" >marshal-ilgen</RuntimeComponents>
</PropertyGroup>

<ItemGroup Condition="'$(NativeLibrary)' != ''">
<_ExtraAppLinkerArgs Include="$(LibraryOutputPath)" />
<ItemGroup Condition="'$(_IsLibraryMode)' == 'true'">
<_NativeDependencies Include="$(LibraryOutputPath)" />
</ItemGroup>
<ItemGroup>
<_ExtraAppLinkerArgs Include="@(_CommonLinkerArgs)" />
</ItemGroup>

<AndroidAppBuilderTask
Expand All @@ -252,8 +252,10 @@ mono_thread_interruption_request_flag
ForceAOT="$(RunAOTCompilation)"
ForceFullAOT="$(ForceFullAOT)"
ForceInterpreter="$(MonoForceInterpreter)"
IsLibraryMode="$(_IsLibraryMode)"
MainLibraryFileName="$(MainLibraryFileName)"
MonoRuntimeHeaders="$(_MonoHeaderPath)"
NativeDependencies="@(_NativeDependencies)"
OutputDir="$(AndroidAppBundleDir)"
ProjectName="$(AssemblyName)"
RuntimeComponents="$(RuntimeComponents)"
Expand Down
2 changes: 1 addition & 1 deletion src/mono/msbuild/apple/build/AppleApp.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<!--<ShouldILStrip Condition="'$(RunAOTCompilation)' == 'true' and '$(MonoForceInterpreter)' != 'true'">true</ShouldILStrip>-->

<_NativeLibraryTarget Condition="'$(NativeLibrary)' != ''">_BuildNativeLibrary;</_NativeLibraryTarget>
<_NativeLibraryTarget Condition="'$(NativeLib)' != ''">_BuildNativeLibrary;</_NativeLibraryTarget>

<AppleBuildAppAfterThisTarget Condition="'$(AppleBuildAppAfterThisTarget)' == ''">Publish</AppleBuildAppAfterThisTarget>
<AppleBuildAppDependsOn>
Expand Down
88 changes: 42 additions & 46 deletions src/mono/msbuild/apple/build/AppleApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
AssemblyFile="$(MonoTargetsTasksAssemblyPath)" />

<PropertyGroup>
<AppleGenerateAppBundle Condition="'$(GenerateAppBundle)' != ''">$(GenerateAppBundle)</AppleGenerateAppBundle>
<AppleGenerateAppBundle Condition="'$(AppleGenerateAppBundle)' == '' and '$(NativeLibrary)' != ''">false</AppleGenerateAppBundle>
<AppleGenerateAppBundle Condition="'$(AppleGenerateAppBundle)' == ''">true</AppleGenerateAppBundle>
<!-- Unable to properly integrate nativelib into app build, so not supported for now. -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: looks like this applies to _IsLibraryMode so move it one line down

<AppleGenerateAppBundle Condition="'$(NativeLib)' != ''">false</AppleGenerateAppBundle>
</PropertyGroup>

<Target Name="AppleBuildApp" AfterTargets="$(AppleBuildAppAfterThisTarget)" />
Expand All @@ -34,7 +33,6 @@
</PropertyGroup>

<ItemGroup>
<!-- static vs dylibs -->
<!-- add all non stub libs first -->
<!-- if runtimecompoents is empty, exclude -static.a and include -stub-static.a instead -->
<!-- if runtimecomponents is *, we're ok because all -static.a is included -->
Expand Down Expand Up @@ -73,48 +71,47 @@
<!-- common linker arguments for app and library builds -->
<ItemGroup>
<_CommonLinkerArgs Include="-framework Foundation" />
<_CommonLinkerArgs Include="-framework Security" />
<_CommonLinkerArgs Include="-framework GSS" />
<_CommonLinkerArgs Include="-framework Security" />
<_CommonLinkerArgs Include="-framework UIKit" />
<_CommonLinkerArgs Include="-lz" />
<_CommonLinkerArgs Include="-lc++" />
<_CommonLinkerArgs Include="-liconv" />
</ItemGroup>

<PropertyGroup>
<_RuntimeSymbolsToKeep>
_register_aot_modules
_mono_jit_init_version
_mono_jit_exec
_mono_assembly_get_name
_mono_assembly_name_get_culture
_mono_assembly_name_get_name
_mono_assembly_open
_mono_class_get_method_from_name
_mono_class_get_name
_mono_class_get_namespace
_mono_debug_init
_mono_dllmap_insert
_mono_domain_get
_mono_gc_init_finalizer_thread
_mono_get_exception_class
_mono_install_assembly_preload_hook
_mono_install_load_aot_data_hook
_mono_install_unhandled_exception_hook
_mono_jit_cleanup
_mono_jit_parse_options
_mono_jit_set_aot_mode
_mono_object_get_class
_mono_object_get_virtual_method
_mono_runtime_invoke
_mono_set_crash_chaining
_mono_set_signal_chaining
_mono_string_to_utf8
_mono_trace_set_log_handler
_monovm_initialize
_monovm_runtimeconfig_initialize

</_RuntimeSymbolsToKeep>
</PropertyGroup>
<ItemGroup>
<_RuntimeSymbolsToKeep Include="
_register_aot_modules;
_mono_jit_init_version;
_mono_jit_exec;
_mono_assembly_get_name;
_mono_assembly_name_get_culture;
_mono_assembly_name_get_name;
_mono_assembly_open;
_mono_class_get_method_from_name;
_mono_class_get_name;
_mono_class_get_namespace;
_mono_debug_init;
_mono_dllmap_insert;
_mono_domain_get;
_mono_gc_init_finalizer_thread;
_mono_get_exception_class;
_mono_install_assembly_preload_hook;
_mono_install_load_aot_data_hook;
_mono_install_unhandled_exception_hook;
_mono_jit_cleanup;
_mono_jit_parse_options;
_mono_jit_set_aot_mode;
_mono_object_get_class;
_mono_object_get_virtual_method;
_mono_runtime_invoke;
_mono_set_crash_chaining;
_mono_set_signal_chaining;
_mono_string_to_utf8;
_mono_trace_set_log_handler;
_monovm_initialize;
_monovm_runtimeconfig_initialize;" />
</ItemGroup>
</Target>

<Target Name="_BeforeAppleBuildApp">
Expand Down Expand Up @@ -145,7 +142,7 @@ _monovm_runtimeconfig_initialize
</PropertyGroup>

<PropertyGroup>
<_EnableUnmanagedCallersOnlyMethodsExport Condition="'$(NativeLibrary)' != ''">true</_EnableUnmanagedCallersOnlyMethodsExport>
<_EnableUnmanagedCallersOnlyMethodsExport Condition="'$(NativeLib)' != ''">true</_EnableUnmanagedCallersOnlyMethodsExport>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -224,12 +221,12 @@ _monovm_runtimeconfig_initialize
<RuntimeComponents Condition="'$(RuntimeComponents)' == ''">marshal-ilgen</RuntimeComponents>
</PropertyGroup>

<Error Condition="'$(NativeMainSource)' != '' and !Exists('$(NativeMainSource)')" Text="Project property NativeMainSource is defined, but the specified file: '$(NativeMainSource)' does not exist." />

<ItemGroup Condition="'$(NativeLibrary)' != ''">
<_FrameworkLibraries Include="$(LibraryOutputPath)" />
<ItemGroup>
<_ExtraAppLinkerArgs Include="@(_CommonLinkerArgs)" />
</ItemGroup>

<Error Condition="'$(NativeMainSource)' != '' and !Exists('$(NativeMainSource)')" Text="Project property NativeMainSource is defined, but the specified file: '$(NativeMainSource)' does not exist." />

<AppleAppBuilderTask
AppDir="$(AppleAppDir)"
Arch="$(TargetArchitecture)"
Expand All @@ -241,7 +238,6 @@ _monovm_runtimeconfig_initialize
ExtraLinkerArguments="@(_ExtraAppLinkerArgs)"
ForceAOT="$(RunAOTCompilation)"
ForceInterpreter="$(MonoForceInterpreter)"
FrameworkLibraries="@(_FrameworkLibraries)"
GenerateCMakeProject="$(GenerateCMakeProject)"
GenerateXcodeProject="$(GenerateXcodeProject)"
InvariantGlobalization="$(InvariantGlobalization)"
Expand Down
15 changes: 6 additions & 9 deletions src/mono/msbuild/common/LibraryBuilder.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@
<Target Name="_BuildNativeLibrary"
Condition="'$(RunAOTCompilation)' == 'true'">

<PropertyGroup>
<_IsSharedLibrary Condition="'$(NativeLib)' == 'shared'">true</_IsSharedLibrary>
</PropertyGroup>

<ItemGroup>
<_ExtraLibrarySources Include="$(_AotModuleTablePath)" />
<_ExtraLinkerArgs Include="@(_CommonLinkerArgs)" />
</ItemGroup>

<!--
Consider passing as items into library builder
-->
<WriteLinesToFile
Condition="'$(_RuntimeSymbolsToKeep.Length)' &gt; 0"
File="$(BundleDir)mobile_symbols.txt"
Lines="$(_RuntimeSymbolsToKeep)"
Overwrite="true" />

<LibraryBuilderTask
Assemblies="@(AppAssembliesInternal)"
ExtraLinkerArguments="@(_ExtraLinkerArgs)"
ExtraSources="@(_ExtraLibrarySources)"
ExtraSymbolsToExport="@(_RuntimeSymbolsToKeep)"
IsSharedLibrary="$(_IsSharedLibrary)"
Name="$(AssemblyName)"
MonoRuntimeHeaders="$(_MonoHeaderPath)"
OutputDirectory="$(BundleDir)"
Expand Down
12 changes: 12 additions & 0 deletions src/tasks/AndroidAppBuilder/AndroidAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ public class AndroidAppBuilderTask : Task
/// </summary>
public bool ForceFullAOT { get; set; }

/// <summary>
/// Mode to control whether runtime is a self-contained library or not
/// </summary>
public bool IsLibraryMode { get; set; }

/// <summary>
/// Extra native dependencies to link into the app
/// </summary>
public string[] NativeDependencies { get; set; } = Array.Empty<string>();

/// <summary>
/// Static linked runtime
/// </summary>
Expand Down Expand Up @@ -125,6 +135,8 @@ public override bool Execute()
apkBuilder.RuntimeComponents = RuntimeComponents;
apkBuilder.DiagnosticPorts = DiagnosticPorts;
apkBuilder.Assemblies = Assemblies;
apkBuilder.IsLibraryMode = IsLibraryMode;
apkBuilder.NativeDependencies = NativeDependencies;
apkBuilder.ExtraLinkerArguments = ExtraLinkerArguments;
(ApkBundlePath, ApkPackageId) = apkBuilder.BuildApk(RuntimeIdentifier, MainLibraryFileName, MonoRuntimeHeaders);

Expand Down
Loading