-
Notifications
You must be signed in to change notification settings - Fork 550
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
60
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
60 commits
Select commit
Hold shift + click to select a range
f3dfe90
Embed some data files in `libxamarin-app.so`
grendello 58197ba
Use llvm-mc to embed the binary, this way we have full control
grendello d01e4e1
Runtime config binary blob is now fully embedded
grendello 514a28a
Remove debug spam
grendello 0081c36
New target to build embedded assembly store
grendello 5d91471
New task to build embedded assembly store
grendello 0c225e1
Move some of assembly packaging code to a helper class
grendello 297097b
Move more assembly packaging code to the helper class
grendello 45ad89a
Almost there, TBC
grendello 2652e5e
Assembly store embedding works
grendello c188d66
Actually use the embedded assembly store
grendello 12afaf7
A handful of bugfixes and performance tweaks
grendello 15a5bf4
Fix DSO count when building
grendello 9391224
Don't allocate memory for ZIP Central Directory data
grendello 955da11
Experimenting with zip scanning performance
grendello dee133a
Post rebase fixups
grendello a27f435
More post rebase fixups
grendello 963d760
seek and ye shall read
grendello 460dc65
Details, details...
grendello 001cfd8
Cleanup
grendello 0907f4d
Teach assembly store explorer about embedded stores
grendello 94d1a6a
Teach store v2 reader to look in `libxamarin-app.so`, too
grendello fd91482
Nicer
grendello 7a063b3
The runtime configuration blob is now part of `libxamarin-app.so`
grendello f9f5556
Optionally produce "empty" embed.*.s files
grendello b04f22e
Don't embed assembly store when fastdev is used
grendello d53f711
Let's see if designer tests pass now
grendello 1070f1c
Expect the unexpected, DTB doesn't specify any ABIs
grendello 91f740f
[WIP] Builds but doesn't work
grendello 525dd96
Let's see how it works now
grendello f95cc1f
Always generate embedded store sources in CreateEmbeddedAssemblyStore
grendello b3b644d
Let's see...
grendello 23e2b2f
Don't assume assemblies exist
grendello 85d9a16
better
grendello bdc737e
Update apkdesc files
grendello 5acd749
Load embedded assembly store also in filesystem mode
grendello 7ce1f65
Log it when an assembly is missing in ManifestDocument
grendello b1adce3
Don't throw
grendello 9f85883
Always create the destination directory
grendello 0cfed0e
Post-rebase fixups
grendello fe9d6cd
Let's see what's in the override dir listing
grendello d580269
Let's see
grendello 76295b6
Cleanup
grendello 1aebcf1
Address feedback
grendello 0f868e9
Let's see what breaks
grendello 98514e5
Revert "Let's see what breaks"
grendello 1d9ad15
Restore [Require]
grendello 3e5ca7d
Remove comment, no longer valid
grendello 5fd11d3
Fix after rebase
grendello 5a34466
Post-rebase fixes
grendello c73b422
A handful of NRT fixes + reuse shared code
grendello 0af0848
MSBuild updates + cleanup
grendello f1b5ccc
Embed runtime config for MonoVM
grendello a32cd9f
Fix DSO counts
grendello 6421670
Fix MonoVM diagnostic messages
grendello 3714379
Add support for CoreCLR
grendello 97751d6
It's gone
grendello 67cf8be
Remove unnecessary app config field
grendello ac64906
Update apkdesc files
grendello 9b79c81
Add a couple of tests
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?