Skip to content

Commit 1071026

Browse files
committed
Add Android build for SDL
1 parent dde8e23 commit 1071026

File tree

6 files changed

+45
-21
lines changed

6 files changed

+45
-21
lines changed

.github/workflows/native.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ jobs:
7676
name: natives-${{ matrix.flat.target }}-${{ matrix.flat.runtime }}
7777
path: |
7878
./.workaround-*.txt
79-
./${{ matrix.flat.dir }}/runtimes/${{ matrix.flat.runtime }}/**/*
80-
./${{ matrix.flat.dir}}/lib/*${{ matrix.flat.runtime }}*/**/*
79+
./${{ matrix.flat.dir }}/runtimes/${{ format('{0}{1}', matrix.flat.runtime, !contains(matrix.flat.runtime, '-') && '*' || '') }}/**/*
80+
./${{ matrix.flat.dir }}/lib/*${{ matrix.flat.runtime }}*/**/*
81+
./${{ matrix.flat.dir }}/*${{ matrix.flat.runtime }}*/**/*
8182
commit:
8283
name: Commit Binaries
8384
needs: [prerequisites, build]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,3 +497,4 @@ src/Website/Silk.NET.Statiq/cache
497497
!**/lib/**/*.aar
498498
build/
499499
!eng/build/
500+
.workaround*

Directory.Build.props

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,4 @@
6565
<VersionDependsOn>SilkShippingControl;$(VersionDependsOn)</VersionDependsOn>
6666
<PackageVersionDependsOn>SilkShippingControl;$(PackageVersionDependsOn)</PackageVersionDependsOn>
6767
</PropertyGroup>
68-
69-
<!-- SourceLink -->
70-
<PropertyGroup Condition="'$(SilkSourceLinkExempt)' == ''">
71-
<DebugType>portable</DebugType>
72-
<EmbedAllSources>true</EmbedAllSources>
73-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
74-
<IncludeSymbols>true</IncludeSymbols>
75-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
76-
</PropertyGroup>
7768
</Project>

Directory.Build.targets

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,28 @@
139139
</UsingTask>
140140

141141
<Target Name="SilkShippingControl" BeforeTargets="BeforeBuild">
142+
<!-- SourceLink -->
143+
<PropertyGroup Condition="'$(SilkSourceLinkExempt)' == '' and '$(SilkNativePackage)' != 'true' and '$(SilkMetapackage)' != 'true'">
144+
<DebugType>portable</DebugType>
145+
<EmbedAllSources>true</EmbedAllSources>
146+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
147+
<IncludeSymbols>true</IncludeSymbols>
148+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
149+
</PropertyGroup>
150+
<!-- Non-C# packages (i.e. metapackages, natives) -->
151+
<PropertyGroup Condition="'$(SilkNativePackage)' == 'true' or '$(SilkMetapackage)' == 'true'">
152+
<IncludeBuildOutput>false</IncludeBuildOutput>
153+
<NoWarn>NU5128</NoWarn>
154+
</PropertyGroup>
142155
<!-- Public API -->
143156
<PropertyGroup Condition="'$(SilkTrackPublicAPI)' != 'true' or '$(TargetFramework)' == ''">
144157
<SilkTrackPublicAPI>false</SilkTrackPublicAPI>
145158
</PropertyGroup>
146159
<ItemGroup Condition="'$(SilkTrackPublicAPI)' == 'true'">
147160
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" PrivateAssets="All" />
148161
</ItemGroup>
149-
<ItemGroup Condition="'$(SilkSourceLinkExempt)' == ''">
162+
<!-- SourceLink -->
163+
<ItemGroup Condition="'$(SilkSourceLinkExempt)' == '' and '$(SilkNativePackage)' != 'true' and '$(SilkMetapackage)' != 'true'">
150164
<PackageReference Include="DotNet.ReproducibleBuilds" PrivateAssets="All"/>
151165
<PackageReference Include="DotNet.ReproducibleBuilds.Isolated" PrivateAssets="All"/>
152166
</ItemGroup>
@@ -178,12 +192,12 @@
178192
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(SilkVersion)-$(VersionSuffix)</PackageVersion>
179193
</PropertyGroup>
180194
<!-- Trimming -->
181-
<PropertyGroup>
182-
<IsTrimmable Condition="'$(SilkTrimmingExempt)' == ''">true</IsTrimmable>
183-
<EnableTrimAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableTrimAnalyzer>
184-
<EnableAotAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableAotAnalyzer>
185-
<EnableSingleFileAnalyzer Condition="'$(SilkTrimmingExempt)' == ''">true</EnableSingleFileAnalyzer>
186-
<TrimMode Condition="'$(SilkTrimmingExempt)' == ''">full</TrimMode>
195+
<PropertyGroup Condition="'$(SilkTrimmingExempt)' == ''">
196+
<IsTrimmable>true</IsTrimmable>
197+
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
198+
<EnableAotAnalyzer>true</EnableAotAnalyzer>
199+
<EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
200+
<TrimMode>full</TrimMode>
187201
</PropertyGroup>
188202
</Target>
189203
</Project>

sources/Core/Silk.NET/Silk.NET.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
<Nullable>enable</Nullable>
77
<SilkDescription>A package that will pull in all non-extension Silk.NET packages for every API.</SilkDescription>
88
<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>
9-
<IncludeBuildOutput>false</IncludeBuildOutput>
10-
<SilkSourceLinkExempt>true</SilkSourceLinkExempt>
11-
<NoWarn>NU5128</NoWarn>
9+
<SilkMetapackage>true</SilkMetapackage>
1210
</PropertyGroup>
1311

1412
<ItemGroup>

sources/SDL/Native/build-android.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env -S bash -eu
2+
3+
if [ ! -e ../../../eng/submodules/sdl/CMakeLists.txt ]; then
4+
git submodule update --init --recursive --depth 1 ../../../eng/submodules/sdl
5+
fi
6+
7+
if [ ! -z "$GITHUB_ACTIONS" ]; then
8+
# NDK already installed: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md
9+
sdkmanager --install "platforms;android-19"
10+
fi
11+
12+
../../../eng/submodules/sdl/build-scripts/build-release.py --actions android --root ../../../eng/submodules/sdl
13+
mkdir -p runtimes/android-x86/native runtimes/android-x64/native runtimes/android-arm/native runtimes/android-arm64/native android
14+
cp ../../../eng/submodules/sdl/install-android/arm64-v8a-install/lib/libSDL3.so runtimes/android-arm64/native
15+
cp ../../../eng/submodules/sdl/install-android/armeabi-v7a-install/lib/libSDL3.so runtimes/android-arm/native
16+
cp ../../../eng/submodules/sdl/install-android/x86-install/lib/libSDL3.so runtimes/android-x86/native
17+
cp ../../../eng/submodules/sdl/install-android/x86_64-install/lib/libSDL3.so runtimes/android-x64/native
18+
jars=( ../../../eng/submodules/sdl/install-android/armeabi-v7a-install/share/java/SDL3/SDL3-*.jar )
19+
cp "${jars[1]}" android/SDL3.jar

0 commit comments

Comments
 (0)