Skip to content

Commit

Permalink
Trimmer switches to reduce size
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpeppers committed Jan 31, 2024
1 parent 8f18a50 commit 98626d5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion DotNet/libdotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<InvariantGlobalization>true</InvariantGlobalization>
<PublishAot>true</PublishAot>
<PublishAotUsingRuntimePack>true</PublishAotUsingRuntimePack>
<RuntimeIdentifier Condition=" '$(RuntimeIdentifier)' == '' ">linux-bionic-arm64</RuntimeIdentifier>
<!-- SkiaSharp nightly feed -->
<RestoreAdditionalProjectSources>https://aka.ms/skiasharp-eap/index.json</RestoreAdditionalProjectSources>
</PropertyGroup>

<!-- Trimmer switches -->
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<!-- From Android workload: https://github.com/xamarin/xamarin-android/blob/80ee320ed0bb245768ba436b76f9309aca18abc3/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.DefaultProperties.targets#L95-L110 -->
<InvariantGlobalization>true</InvariantGlobalization>
<UseSystemResourceKeys>true</UseSystemResourceKeys>
<NullabilityInfoContextSupport>false</NullabilityInfoContextSupport>
<_AggressiveAttributeTrimming>true</_AggressiveAttributeTrimming>
<!-- From SmolSharp: https://github.com/ascpixi/smolsharp/blob/54a4aeb6e8f6cdd64d049862dee611301082e71b/src/SmolSharp.props#L48-L57 -->
<IlcDisableReflection>true</IlcDisableReflection>
<StackTraceSupport>false</StackTraceSupport>
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
<IlcDehydrate>false</IlcDehydrate>
<IlcGenerateWin32Resources>false</IlcGenerateWin32Resources>
<OptimizationPreference>Size</OptimizationPreference>
</PropertyGroup>

<ItemGroup>
<!-- https://github.com/exelix11/SysDVR/blob/master/Client/Client.csproj -->
<!-- Android needs a proper soname property or it will refuse to load the library -->
Expand Down
Binary file modified Native/app/src/main/libs/arm64-v8a/libdotnet.so
Binary file not shown.
Binary file modified Native/app/src/main/libs/arm64-v8a/libdotnet.so.dbg
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ A breakdown of the files inside:
1981-01-01 01:01:02 10569629 4629574 25 files
```

`libdotnet.so` is ~1.9MB, and `libSkiaSharp.so` is ~8.5MB!
`libdotnet.so` is ~1.3MB, and `libSkiaSharp.so` is ~8.5MB!

If we reduce this to a "Hello World" example:

Expand Down

0 comments on commit 98626d5

Please sign in to comment.