Skip to content

Commit

Permalink
Add Android build for SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
Perksey committed Dec 27, 2024
1 parent dde8e23 commit 1071026
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 21 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ jobs:
name: natives-${{ matrix.flat.target }}-${{ matrix.flat.runtime }}
path: |
./.workaround-*.txt
./${{ matrix.flat.dir }}/runtimes/${{ matrix.flat.runtime }}/**/*
./${{ matrix.flat.dir}}/lib/*${{ matrix.flat.runtime }}*/**/*
./${{ matrix.flat.dir }}/runtimes/${{ format('{0}{1}', matrix.flat.runtime, !contains(matrix.flat.runtime, '-') && '*' || '') }}/**/*
./${{ matrix.flat.dir }}/lib/*${{ matrix.flat.runtime }}*/**/*
./${{ matrix.flat.dir }}/*${{ matrix.flat.runtime }}*/**/*
commit:
name: Commit Binaries
needs: [prerequisites, build]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,4 @@ src/Website/Silk.NET.Statiq/cache
!**/lib/**/*.aar
build/
!eng/build/
.workaround*
9 changes: 0 additions & 9 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,4 @@
<VersionDependsOn>SilkShippingControl;$(VersionDependsOn)</VersionDependsOn>
<PackageVersionDependsOn>SilkShippingControl;$(PackageVersionDependsOn)</PackageVersionDependsOn>
</PropertyGroup>

<!-- SourceLink -->
<PropertyGroup Condition="'$(SilkSourceLinkExempt)' == ''">
<DebugType>portable</DebugType>
<EmbedAllSources>true</EmbedAllSources>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
</Project>
28 changes: 21 additions & 7 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,28 @@
</UsingTask>

<Target Name="SilkShippingControl" BeforeTargets="BeforeBuild">
<!-- SourceLink -->
<PropertyGroup Condition="'$(SilkSourceLinkExempt)' == '' and '$(SilkNativePackage)' != 'true' and '$(SilkMetapackage)' != 'true'">
<DebugType>portable</DebugType>
<EmbedAllSources>true</EmbedAllSources>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<!-- Non-C# packages (i.e. metapackages, natives) -->
<PropertyGroup Condition="'$(SilkNativePackage)' == 'true' or '$(SilkMetapackage)' == 'true'">
<IncludeBuildOutput>false</IncludeBuildOutput>
<NoWarn>NU5128</NoWarn>
</PropertyGroup>
<!-- Public API -->
<PropertyGroup Condition="'$(SilkTrackPublicAPI)' != 'true' or '$(TargetFramework)' == ''">
<SilkTrackPublicAPI>false</SilkTrackPublicAPI>
</PropertyGroup>
<ItemGroup Condition="'$(SilkTrackPublicAPI)' == 'true'">
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(SilkSourceLinkExempt)' == ''">
<!-- SourceLink -->
<ItemGroup Condition="'$(SilkSourceLinkExempt)' == '' and '$(SilkNativePackage)' != 'true' and '$(SilkMetapackage)' != 'true'">
<PackageReference Include="DotNet.ReproducibleBuilds" PrivateAssets="All"/>
<PackageReference Include="DotNet.ReproducibleBuilds.Isolated" PrivateAssets="All"/>
</ItemGroup>
Expand Down Expand Up @@ -178,12 +192,12 @@
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(SilkVersion)-$(VersionSuffix)</PackageVersion>
</PropertyGroup>
<!-- Trimming -->
<PropertyGroup>
<IsTrimmable Condition="'$(SilkTrimmingExempt)' == ''">true</IsTrimmable>
<EnableTrimAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableTrimAnalyzer>
<EnableAotAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableAotAnalyzer>
<EnableSingleFileAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableSingleFileAnalyzer>
<TrimMode Condition="'$(SilkTrimmingExempt)' == ''">full</TrimMode>
<PropertyGroup Condition="'$(SilkTrimmingExempt)' == ''">
<IsTrimmable>true</IsTrimmable>
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<EnableAotAnalyzer>true</EnableAotAnalyzer>
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
<TrimMode>full</TrimMode>
</PropertyGroup>
</Target>
</Project>
4 changes: 1 addition & 3 deletions sources/Core/Silk.NET/Silk.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
<Nullable>enable</Nullable>
<SilkDescription>A package that will pull in all non-extension Silk.NET packages for every API.</SilkDescription>
<SilkExtendedDescription>You probably don't want all that, and it is strongly recommended to pull in only the packages you need instead. This package exists just to simplify project bring-up.</SilkExtendedDescription>
<IncludeBuildOutput>false</IncludeBuildOutput>
<SilkSourceLinkExempt>true</SilkSourceLinkExempt>
<NoWarn>NU5128</NoWarn>
<SilkMetapackage>true</SilkMetapackage>
</PropertyGroup>

<ItemGroup>
Expand Down
19 changes: 19 additions & 0 deletions sources/SDL/Native/build-android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env -S bash -eu

if [ ! -e ../../../eng/submodules/sdl/CMakeLists.txt ]; then
git submodule update --init --recursive --depth 1 ../../../eng/submodules/sdl
fi

if [ ! -z "$GITHUB_ACTIONS" ]; then
# NDK already installed: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
sdkmanager --install "platforms;android-19"
fi

../../../eng/submodules/sdl/build-scripts/build-release.py --actions android --root ../../../eng/submodules/sdl
mkdir -p runtimes/android-x86/native runtimes/android-x64/native runtimes/android-arm/native runtimes/android-arm64/native android
cp ../../../eng/submodules/sdl/install-android/arm64-v8a-install/lib/libSDL3.so runtimes/android-arm64/native
cp ../../../eng/submodules/sdl/install-android/armeabi-v7a-install/lib/libSDL3.so runtimes/android-arm/native
cp ../../../eng/submodules/sdl/install-android/x86-install/lib/libSDL3.so runtimes/android-x86/native
cp ../../../eng/submodules/sdl/install-android/x86_64-install/lib/libSDL3.so runtimes/android-x64/native
jars=( ../../../eng/submodules/sdl/install-android/armeabi-v7a-install/share/java/SDL3/SDL3-*.jar )
cp "${jars[1]}" android/SDL3.jar

0 comments on commit 1071026

Please sign in to comment.