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
Feedback
  • Loading branch information
Steve Pfister committed Feb 13, 2023
commit ba37138bfeeb6c000c62ce71488c0935a31fc440
3 changes: 2 additions & 1 deletion eng/testing/tests.android.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

<PropertyGroup>
<AndroidBuildAppDependsOn>PrepareForAndroidBuildApp;$(AndroidBuildAppDependsOn);_CopyTestArchive</AndroidBuildAppDependsOn>

<BundleTestAndroidAppDependsOn>AndroidBuildApp</BundleTestAndroidAppDependsOn>

<GenerateAppBundle Condition="'$(GenerateAppBundle)' == ''">true</GenerateAppBundle>
</PropertyGroup>

<!-- Target that kicks off the whole test build and run flow -->
Expand Down
4 changes: 2 additions & 2 deletions src/mono/msbuild/android/build/AndroidApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
Exclude="$(AndroidAppDir)\*-stub-static.a" />
<_RuntimeLibraries
Condition="'$(_TargetsDevice)' == ''"
Include="$(AndroidAppDir)\*.dylib;$(AndroidAppDir)\libmonosgen*.a;$(AndroidAppDir)\*-static.a"
Exclude="$(AndroidAppDir)\libmonosgen*.dylib;$(AndroidAppDir)\*-stub-static.a" />
Include="$(AndroidAppDir)\*.so;$(AndroidAppDir)\libmonosgen*.a;$(AndroidAppDir)\*-static.a"
Exclude="$(AndroidAppDir)\libmonosgen*.so;$(AndroidAppDir)\*-stub-static.a" />

<!-- and not contains %(_UsedComponents)-static*.a -->
<!-- if count > 0, remove all *-static components except in _UsedComponents -->
Expand Down
2 changes: 1 addition & 1 deletion src/mono/msbuild/apple/build/AppleApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<!-- common linker arguments for app and library builds -->
<ItemGroup>
<_CommonLinkerArgs Include="-framework Foundation" />
<_CommonLinkerArgs Include="-framework GSS" />
<_CommonLinkerArgs Condition="'$(TargetOS)' != 'tvos'" Include="-framework GSS" />
<_CommonLinkerArgs Include="-framework Security" />
<_CommonLinkerArgs Include="-framework UIKit" />
<_CommonLinkerArgs Include="-lz" />
Expand Down
1 change: 0 additions & 1 deletion src/tasks/AndroidAppBuilder/ApkBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ public ApkBuilder(TaskLoggingHelper logger)
Utils.GetEmbeddedResource("MainActivity.java")
.Replace("%EntryPointLibName%", Path.GetFileName(mainLibraryFileName)));


if (!string.IsNullOrEmpty(NativeMainSource))
File.Copy(NativeMainSource, javaActivityPath, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include_directories("%MonoInclude%")

target_link_libraries(
monodroid
PUBLIC
%NativeLibrariesToLink%
%APP_LINKER_ARGS%
)
15 changes: 2 additions & 13 deletions src/tasks/AppleAppBuilder/AppleAppBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ public string TargetOS
[Required]
public ITaskItem[] Assemblies { get; set; } = Array.Empty<ITaskItem>();

/// <summary>
/// List of paths to native libraries that will make up the framework project for the app
/// </summary>
public ITaskItem[] FrameworkLibraries { get; set; } = Array.Empty<ITaskItem>();

/// <summary>
/// Additional linker arguments that apply to the app being built
/// </summary>
Expand Down Expand Up @@ -277,12 +272,6 @@ public override bool Execute()
}
}

List<string> frameworkLibraries = new List<string>();
foreach (ITaskItem libItem in FrameworkLibraries)
{
frameworkLibraries.Add(libItem.ItemSpec);
}

if (!ForceInterpreter && (isDevice || ForceAOT) && (assemblerFiles.Count == 0 && !UseNativeAOTRuntime))
{
throw new InvalidOperationException("Need list of AOT files for device builds.");
Expand Down Expand Up @@ -318,7 +307,7 @@ public override bool Execute()

if (GenerateXcodeProject)
{
XcodeProjectPath = generator.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles, assemblerDataFiles, assemblerFilesToLink, frameworkLibraries, extraLinkerArgs,
XcodeProjectPath = generator.GenerateXCode(ProjectName, MainLibraryFileName, assemblerFiles, assemblerDataFiles, assemblerFilesToLink, extraLinkerArgs,
AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource, UseNativeAOTRuntime);

if (BuildAppBundle)
Expand All @@ -344,7 +333,7 @@ public override bool Execute()
}
else if (GenerateCMakeProject)
{
generator.GenerateCMake(ProjectName, MainLibraryFileName, assemblerFiles, assemblerDataFiles, assemblerFilesToLink, frameworkLibraries, extraLinkerArgs,
generator.GenerateCMake(ProjectName, MainLibraryFileName, assemblerFiles, assemblerDataFiles, assemblerFilesToLink, extraLinkerArgs,
AppDir, binDir, MonoRuntimeHeaders, !isDevice, UseConsoleUITemplate, ForceAOT, ForceInterpreter, InvariantGlobalization, Optimized, EnableRuntimeLogging, EnableAppSandbox, DiagnosticPorts, RuntimeComponents, NativeMainSource, UseNativeAOTRuntime);
}

Expand Down
6 changes: 4 additions & 2 deletions src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if(NOT %UseNativeAOTRuntime%)
include_directories("%MonoInclude%")
endif()

set_target_properties(%ProjectName% PROPERTIES
set_target_properties(%ProjectName% %AotTargetsList% PROPERTIES
XCODE_ATTRIBUTE_SUPPORTS_MACCATALYST "YES"
)

Expand Down Expand Up @@ -66,5 +66,7 @@ endif()

target_link_libraries(
%ProjectName%
%APP_LINKER_ARGS%
PUBLIC
%NativeLibrariesToLink%
%APP_LINKER_ARGS%
)
20 changes: 2 additions & 18 deletions src/tasks/AppleAppBuilder/Xcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public string GenerateXCode(
IEnumerable<string> asmFiles,
IEnumerable<string> asmDataFiles,
IEnumerable<string> asmLinkFiles,
IEnumerable<string> frameworkLibraries,
IEnumerable<string> extraLinkerArgs,
string workspace,
string binDir,
Expand All @@ -191,7 +190,7 @@ public string GenerateXCode(
string? nativeMainSource = null,
bool useNativeAOTRuntime = false)
{
var cmakeDirectoryPath = GenerateCMake(projectName, entryPointLib, asmFiles, asmDataFiles, asmLinkFiles, frameworkLibraries, extraLinkerArgs, workspace, binDir, monoInclude, preferDylibs, useConsoleUiTemplate, forceAOT, forceInterpreter, invariantGlobalization, optimized, enableRuntimeLogging, enableAppSandbox, diagnosticPorts, runtimeComponents, nativeMainSource, useNativeAOTRuntime);
var cmakeDirectoryPath = GenerateCMake(projectName, entryPointLib, asmFiles, asmDataFiles, asmLinkFiles, extraLinkerArgs, workspace, binDir, monoInclude, preferDylibs, useConsoleUiTemplate, forceAOT, forceInterpreter, invariantGlobalization, optimized, enableRuntimeLogging, enableAppSandbox, diagnosticPorts, runtimeComponents, nativeMainSource, useNativeAOTRuntime);
CreateXcodeProject(projectName, cmakeDirectoryPath);
return Path.Combine(binDir, projectName, projectName + ".xcodeproj");
}
Expand Down Expand Up @@ -234,7 +233,6 @@ public string GenerateCMake(
IEnumerable<string> asmFiles,
IEnumerable<string> asmDataFiles,
IEnumerable<string> asmLinkFiles,
IEnumerable<string> frameworkLibraries,
IEnumerable<string> extraLinkerArgs,
string workspace,
string binDir,
Expand Down Expand Up @@ -401,27 +399,13 @@ public string GenerateCMake(
toLink += $" {asmLinkFile}{Environment.NewLine}";
}

string frameworks = "";
if ((Target == TargetNames.iOS) || (Target == TargetNames.iOSsim) || (Target == TargetNames.MacCatalyst))
{
frameworks = "\"-framework GSS\"";
}

string frameworkLibrariesPaths = "";
foreach(string frameworkPath in frameworkLibraries)
{
frameworkLibrariesPaths += $"{frameworkPath} ";
}

string appLinkerArgs = "";
foreach(string linkerArg in extraLinkerArgs)
{
appLinkerArgs += $" {linkerArg}{Environment.NewLine}";
appLinkerArgs += $" \"{linkerArg}\"{Environment.NewLine}";
}

cmakeLists = cmakeLists.Replace("%FrameworksToLink%", frameworks);
cmakeLists = cmakeLists.Replace("%NativeLibrariesToLink%", toLink);
cmakeLists = cmakeLists.Replace("%FRAMEWORK_LIBRARIES%", frameworkLibrariesPaths);
cmakeLists = cmakeLists.Replace("%APP_LINKER_ARGS%", appLinkerArgs);
cmakeLists = cmakeLists.Replace("%AotSources%", aotSources);
cmakeLists = cmakeLists.Replace("%AotTargetsList%", aotList);
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/Common/Builders/AppBuilderTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void GatherCompiledAssemblies()
compiledAssembly.LibraryFile = file.GetMetadata("LibraryFile");
compiledAssembly.DataFile = file.GetMetadata("AotDataFile");
compiledAssembly.LlvmObjectFile = file.GetMetadata("LlvmObjectFile");
compiledAssembly.LlvmBitCodeFile = file.GetMetadata("LllvmBitcodeFile");
compiledAssembly.LlvmBitCodeFile = file.GetMetadata("LlvmBitcodeFile");
compiledAssembly.ExportsFile = file.GetMetadata("ExportSymbolsFile");

CompiledAssemblies.Add(compiledAssembly);
Expand Down
12 changes: 12 additions & 0 deletions src/tasks/LibraryBuilder/LibraryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public override bool Execute()
StringBuilder extraSources = new StringBuilder();
StringBuilder linkerArgs = new StringBuilder();

if (!ValidateValidTargetOS())
{
throw new ArgumentException($"{TargetOS} is not yet supported by the librarybuilder task.");
}

if (!base.Execute())
{
// log something here
Expand Down Expand Up @@ -278,4 +283,11 @@ private string GetLibraryName()

return $"{libPrefix}{Name}{libExtension}";
}

private bool ValidateValidTargetOS() =>
TargetOS switch
{
"android" or "ios" or "tvos" or "maccatalyst" => true,
_ => false
};
}
2 changes: 2 additions & 0 deletions src/tasks/LibraryBuilder/Templates/CMakeLists.txt.template
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ add_library(
)
target_link_libraries(
aot_library
PUBLIC
${DOTNET_AOT_OBJECTS}
)

Expand All @@ -33,6 +34,7 @@ add_library(

target_link_libraries(
%LIBRARY_NAME%
PUBLIC
aot_library
%LIBRARY_LINKER_ARGS%
)
2 changes: 1 addition & 1 deletion src/tasks/LibraryBuilder/Templates/autoinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void keep_init()
appctx_values[1] = "APP_CONTEXT_BASE_DIRECTORY";
appctx_values[2] = "System.TimeZoneInfo.LocalDateTimeOffset";
Copy link
Member

Choose a reason for hiding this comment

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

this isn't setting any real values, just strings?

Copy link
Member Author

Choose a reason for hiding this comment

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

right, first this is temporary until #82253 lands. It's here because on Android monovm_initialize and monovm_runtimeconfig_initialize weren't being preserved as symbols and so a test app would not build. The library will not export these functions at all.


int ret = monovm_initialize (3, appctx_keys, appctx_values);
int ret = monovm_initialize (3, appctx_keys, appctx_values);
}

void
Expand Down