-
Notifications
You must be signed in to change notification settings - Fork 546
Embed some data files in libxamarin-app.so
#9367
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
Draft
grendello
wants to merge
55
commits into
main
Choose a base branch
from
dev/grendel/embed-binaries-in-xamarinapp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
466e052
Embed some data files in `libxamarin-app.so`
grendello e510709
Use llvm-mc to embed the binary, this way we have full control
grendello 0e15b9d
Runtime config binary blob is now fully embedded
grendello 6340183
Remove debug spam
grendello 19df4bb
New target to build embedded assembly store
grendello 7acf5f7
New task to build embedded assembly store
grendello dc63ef0
Move some of assembly packaging code to a helper class
grendello e439290
Move more assembly packaging code to the helper class
grendello 9878608
Almost there, TBC
grendello ef290af
Assembly store embedding works
grendello f8461e6
Actually use the embedded assembly store
grendello 955170e
A handful of bugfixes and performance tweaks
grendello 8d62e3a
Fix DSO count when building
grendello aa86a9d
Don't allocate memory for ZIP Central Directory data
grendello 447cbb2
Experimenting with zip scanning performance
grendello f697a01
Post rebase fixups
grendello e542c9a
More post rebase fixups
grendello 907bd19
seek and ye shall read
grendello 100b71d
Details, details...
grendello f40e9c8
Cleanup
grendello 3c05a34
Teach assembly store explorer about embedded stores
grendello 2ea11d3
Teach store v2 reader to look in `libxamarin-app.so`, too
grendello 07d13ba
Nicer
grendello ffd9151
The runtime configuration blob is now part of `libxamarin-app.so`
grendello 9a9104f
Optionally produce "empty" embed.*.s files
grendello 5fe3d4c
Don't embed assembly store when fastdev is used
grendello e992196
Let's see if designer tests pass now
grendello e955f19
Expect the unexpected, DTB doesn't specify any ABIs
grendello 2c8b676
[WIP] Builds but doesn't work
grendello 184636f
Let's see how it works now
grendello e5799df
Always generate embedded store sources in CreateEmbeddedAssemblyStore
grendello eaf589c
Let's see...
grendello ff832d1
Don't assume assemblies exist
grendello 3ea3e3b
better
grendello a67f936
Update apkdesc files
grendello 2d196a3
Load embedded assembly store also in filesystem mode
grendello 39324dd
Log it when an assembly is missing in ManifestDocument
grendello 48144f5
Don't throw
grendello c9102a2
Always create the destination directory
grendello 1a609bc
Post-rebase fixups
grendello f0060bd
Let's see what's in the override dir listing
grendello 5822876
Let's see
grendello 9aec552
Cleanup
grendello eb2c2d7
Address feedback
grendello 8459cd0
Let's see what breaks
grendello be38e90
Revert "Let's see what breaks"
grendello 9c70658
Restore [Require]
grendello 1fc7f4b
Remove comment, no longer valid
grendello e20f262
Fix after rebase
grendello a1665db
Post-rebase fixes
grendello db53272
A handful of NRT fixes + reuse shared code
grendello 275241b
MSBuild updates + cleanup
grendello 71bc545
Embed runtime config for MonoVM
grendello d6e9013
Fix DSO counts
grendello 661aa5c
Fix MonoVM diagnostic messages
grendello File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...id.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AssemblyStores.targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<UsingTask TaskName="Xamarin.Android.Tasks.CreateEmbeddedAssemblyStore" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" /> | ||
<UsingTask TaskName="Xamarin.Android.Tasks.PrepareAbiItems" AssemblyFile="$(_XamarinAndroidBuildTasksAssembly)" /> | ||
|
||
<Target Name="_PrepareCreateEmbeddedAssemblyStoreOutputItems"> | ||
<PrepareAbiItems | ||
BuildTargetAbis="@(_BuildTargetAbis)" | ||
NativeSourcesDir="$(_NativeAssemblySourceDir)" | ||
Mode="EmbeddedAssemblyStore"> | ||
<Output TaskParameter="AssemblySources" ItemName="_EmbeddedAssemblyStoreSourceFiles" /> | ||
</PrepareAbiItems> | ||
|
||
<ItemGroup> | ||
<_CreateEmbeddedAssemblyStoreAssembly Include="@(_ShrunkUserAssemblies);@(_AndroidResolvedSatellitePaths);@(_ShrunkFrameworkAssemblies)"/> | ||
<_CreateEmbeddedAssemblyStoreAssembly Condition=" '@(_CreateEmbeddedAssemblyStoreAssembly->Count())' == '0' " Include="@(_ResolvedUserAssemblies);@(_ResolvedFrameworkAssemblies);@(_AndroidResolvedSatellitePaths)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<Target Name="_CreateEmbeddedAssemblyStore" | ||
DependsOnTargets="_PrepareCreateEmbeddedAssemblyStoreOutputItems" | ||
Inputs="@(_CreateEmbeddedAssemblyStoreAssembly)" | ||
Outputs="@(_EmbeddedAssemblyStoreSourceFiles)"> | ||
<CreateEmbeddedAssemblyStore | ||
AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)" | ||
AppSharedLibrariesDir="$(_AndroidApplicationSharedLibraryPath)" | ||
AssemblySourcesDir="$(IntermediateOutputPath)android" | ||
AssemblyStoreEmbeddedInRuntime="$(_EmbedAssemblyStoreInRuntime)" | ||
IncludeDebugSymbols="$(AndroidIncludeDebugSymbols)" | ||
ResolvedUserAssemblies="@(_ShrunkUserAssemblies);@(_AndroidResolvedSatellitePaths)" | ||
ResolvedFrameworkAssemblies="@(_ShrunkFrameworkAssemblies)" | ||
SupportedAbis="@(_BuildTargetAbis)" /> | ||
|
||
<ItemGroup> | ||
<FileWrites Include="@(_EmbeddedAssemblyStoreSourceFiles)" /> | ||
</ItemGroup> | ||
</Target> | ||
</Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 0 additions & 59 deletions
59
src/Xamarin.Android.Build.Tasks/Tasks/CollectRuntimeConfigFilesForArchive.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/Xamarin.Android.Build.Tasks/Tasks/CreateEmbeddedAssemblyStore.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
using Microsoft.Android.Build.Tasks; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
using Xamarin.Android.Tools; | ||
|
||
namespace Xamarin.Android.Tasks; | ||
|
||
public class CreateEmbeddedAssemblyStore : AndroidTask | ||
{ | ||
public override string TaskPrefix => "CEAS"; | ||
|
||
[Required] | ||
public string AndroidBinUtilsDirectory { get; set; } = ""; | ||
|
||
[Required] | ||
public string AppSharedLibrariesDir { get; set; } = ""; | ||
|
||
[Required] | ||
public string AssemblySourcesDir { get; set; } = ""; | ||
|
||
[Required] | ||
public bool AssemblyStoreEmbeddedInRuntime { get; set; } | ||
|
||
[Required] | ||
public bool IncludeDebugSymbols { get; set; } | ||
|
||
[Required] | ||
public ITaskItem[] ResolvedUserAssemblies { get; set; } = []; | ||
|
||
[Required] | ||
public ITaskItem[] ResolvedFrameworkAssemblies { get; set; } = []; | ||
|
||
[Required] | ||
public string [] SupportedAbis { get; set; } = []; | ||
|
||
public override bool RunTask () | ||
{ | ||
if (AssemblyStoreEmbeddedInRuntime) { | ||
return EmbedAssemblyStore (); | ||
} | ||
|
||
// Generate sources to satisfy libmonodroid's ABI requirements | ||
foreach (string abi in SupportedAbis) { | ||
ELFEmbeddingHelper.EmbedBinary ( | ||
Log, | ||
abi, | ||
AndroidBinUtilsDirectory, | ||
inputFile: null, | ||
ELFEmbeddingHelper.KnownEmbedItems.AssemblyStore, | ||
AssemblySourcesDir, | ||
missingContentOK: true | ||
); | ||
} | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
|
||
bool EmbedAssemblyStore () | ||
{ | ||
var assemblies = ResolvedFrameworkAssemblies.Concat (ResolvedUserAssemblies).Where (asm => !(AssemblyPackagingHelper.ShouldSkipAssembly (Log, asm))); | ||
var assemblyStorePaths = AssemblyPackagingHelper.CreateAssemblyStore ( | ||
Log, assemblies, | ||
Path.Combine (AppSharedLibrariesDir, "embedded"), | ||
SupportedAbis, | ||
IncludeDebugSymbols | ||
); | ||
|
||
foreach (var kvp in assemblyStorePaths) { | ||
string abi = MonoAndroidHelper.ArchToAbi (kvp.Key); | ||
string inputFile = kvp.Value; | ||
|
||
ELFEmbeddingHelper.EmbedBinary ( | ||
Log, | ||
abi, | ||
AndroidBinUtilsDirectory, | ||
inputFile, | ||
ELFEmbeddingHelper.KnownEmbedItems.AssemblyStore, | ||
AssemblySourcesDir, | ||
missingContentOK: false | ||
); | ||
} | ||
|
||
return !Log.HasLoggedErrors; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change needed? I didn't see anything in here that is trying to reorder MSBuild targets?
Maybe it's from before, trying to workaround the bug in #9452?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's possible, I don't remember exactly which test was affected by this change. I'll revert this bit and we'll see what (if anything) breaks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this revert work?