File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232 - name : Install .NET Android workload
3333 run : dotnet workload install android
3434
35+ - name : Ensure Android NDK and CMake are available
36+ run : |
37+ # The ubuntu-latest runner has $ANDROID_HOME pre-installed.
38+ # Install a known NDK + CMake version if not already present.
39+ yes | sdkmanager --licenses > /dev/null 2>&1 || true
40+ sdkmanager --install "ndk;27.0.12077973" "cmake;3.22.1" > /dev/null 2>&1
41+
42+ - name : Build native library (libosu_native.so)
43+ run : |
44+ NDK_HOME="$ANDROID_HOME/ndk/27.0.12077973"
45+ CMAKE_BIN="$ANDROID_HOME/cmake/3.22.1/bin/cmake"
46+
47+ for ABI in arm64-v8a armeabi-v7a x86; do
48+ echo "::group::Building osu_native for $ABI"
49+ "$CMAKE_BIN" -B "build-native/$ABI" -S osu.Android/Native \
50+ -DCMAKE_TOOLCHAIN_FILE="$NDK_HOME/build/cmake/android.toolchain.cmake" \
51+ -DANDROID_ABI="$ABI" \
52+ -DANDROID_PLATFORM=android-30 \
53+ -DCMAKE_BUILD_TYPE=Release
54+ "$CMAKE_BIN" --build "build-native/$ABI" --config Release -j "$(nproc)"
55+ mkdir -p "osu.Android/libs/$ABI"
56+ cp "build-native/$ABI/libosu_native.so" "osu.Android/libs/$ABI/"
57+ echo "::endgroup::"
58+ done
59+
60+ echo "Native libraries built successfully:"
61+ find osu.Android/libs -name "*.so" -exec ls -lh {} \;
62+
3563 - name : Decode keystore
3664 id : keystore
3765 run : |
Original file line number Diff line number Diff line change @@ -344,3 +344,7 @@ FodyWeavers.xsd
344344
345345.idea /.idea.osu.Desktop /.idea /misc.xml
346346.idea /.idea.osu.Android /.idea /deploymentTargetDropDown.xml
347+
348+ # Native library build artifacts (built by CMake/NDK in CI or locally)
349+ osu.Android /libs /
350+ build-native /
Original file line number Diff line number Diff line change @@ -7,7 +7,22 @@ set(CMAKE_CXX_STANDARD 17)
77set (CMAKE_CXX_FLAGS_RELEASE "-O2 -flto -fvisibility=hidden -DNDEBUG" )
88set (CMAKE_C_FLAGS_RELEASE "-O2 -flto -fvisibility=hidden -DNDEBUG" )
99
10- find_package (oboe REQUIRED CONFIG )
10+ # Try pre-installed Oboe first (e.g. via Android NDK prefab or local install).
11+ # If not found, download and build from source for CI/hermetic builds.
12+ find_package (oboe QUIET CONFIG )
13+
14+ if (oboe_FOUND)
15+ set (OBOE_LIB oboe::oboe)
16+ else ()
17+ include (FetchContent )
18+ FetchContent_Declare (oboe
19+ URL https://github.com/google/oboe/archive/refs/tags/1.9.0.tar.gz
20+ URL_HASH SHA256=e030276d25b8bdfaeb04f66646821b1ba4a2b6a580a7e84fb144a478eaecd663
21+ )
22+ FetchContent_MakeAvailable (oboe)
23+ set (OBOE_LIB oboe)
24+ endif ()
25+
1126find_library (vulkan-lib vulkan )
1227find_library (log -lib log )
1328find_library (android -lib android )
@@ -18,7 +33,7 @@ add_library(osu_native SHARED
1833)
1934
2035target_link_libraries (osu_native
21- oboe::oboe
36+ ${OBOE_LIB}
2237 ${vulkan-lib}
2338 ${log-lib}
2439 ${android -lib}
Original file line number Diff line number Diff line change 1919 <ItemGroup >
2020 <PackageReference Include =" Microsoft.Maui.Essentials" Version =" 8.0.3" />
2121 </ItemGroup >
22- <!-- Exclude native C++ source files from the build. They are compiled separately via CMake/NDK. -->
22+ <!-- Exclude native C++ source files from the managed build. They are compiled separately via CMake/NDK. -->
2323 <ItemGroup >
2424 <None Remove =" Native\*.cpp" />
2525 <None Remove =" Native\*.h" />
2626 <None Remove =" Native\CMakeLists.txt" />
2727 </ItemGroup >
28+ <!-- Include pre-built native libraries when present (built by the release workflow or local NDK build).
29+ When absent, native features (Oboe audio, Vulkan probe) are gracefully disabled at runtime. -->
30+ <ItemGroup >
31+ <AndroidNativeLibrary Include =" libs\arm64-v8a\libosu_native.so" Condition =" Exists('libs\arm64-v8a\libosu_native.so')" Abi =" arm64-v8a" />
32+ <AndroidNativeLibrary Include =" libs\armeabi-v7a\libosu_native.so" Condition =" Exists('libs\armeabi-v7a\libosu_native.so')" Abi =" armeabi-v7a" />
33+ <AndroidNativeLibrary Include =" libs\x86\libosu_native.so" Condition =" Exists('libs\x86\libosu_native.so')" Abi =" x86" />
34+ </ItemGroup >
2835</Project >
You can’t perform that action at this time.
0 commit comments