From 98348d4c244c7944339926c892a2a182db2f116b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Isager=20Dalsgar=C3=B0?= Date: Wed, 28 Aug 2024 11:54:58 +0200 Subject: [PATCH] Use addon prebuilds --- .github/workflows/test.yml | 2 +- .gitignore | 1 + app/CMakeLists.txt => CMakeLists.txt | 31 ++++++++++++------- app/build.gradle | 10 ++++-- .../holepunch/bare/android/MainActivity.java | 2 +- app/src/main/jniLibs/.gitignore | 2 ++ vendor/bare-kit | 2 +- 7 files changed, 32 insertions(+), 18 deletions(-) rename app/CMakeLists.txt => CMakeLists.txt (55%) create mode 100644 app/src/main/jniLibs/.gitignore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 377310f..29970b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,4 +39,4 @@ jobs: java-version: 21 - run: npm install -g bare-dev - run: bare-dev android sdk licenses accept - - run: bare-dev build + - run: bare-dev build --gradle diff --git a/.gitignore b/.gitignore index 9ce6496..ba8e137 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .cxx/ .idea/ build/ +prebuilds/ node_modules/ package-lock.json local.properties diff --git a/app/CMakeLists.txt b/CMakeLists.txt similarity index 55% rename from app/CMakeLists.txt rename to CMakeLists.txt index 7caa278..43e5e49 100644 --- a/app/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,34 +4,41 @@ project(bare_android C) include(bare) -set(BARE_USE_SYSTEM_LOG ON CACHE BOOL "Use system logging" FORCE) - -install_node_modules(WORKING_DIRECTORY ..) - -add_subdirectory(../vendor/bare-kit vendor/bare-kit EXCLUDE_FROM_ALL) +install_node_modules() add_bare_bundle( bare_android_bundle ENTRY app/src/main/js/app.js OUT app/src/main/assets/app.bundle - WORKING_DIRECTORY .. ) add_library(bare_android SHARED) +add_dependencies(bare_android bare_android_bundle) + set_target_properties( bare_android PROPERTIES - C_STANDARD 99 - POSITION_INDEPENDENT_CODE ON + LINKER_LANGUAGE C + OUTPUT_NAME app ) -add_dependencies(bare_android bare_android_bundle) +target_sources( + bare_android + PUBLIC + app/src/main/assets/app.bundle +) + +link_bare_modules( + bare_android + PREBUILDS + DESTINATION app/src/main/jniLibs/${ANDROID_ABI} +) + +find_package(bare-kit REQUIRED CONFIG) target_link_libraries( bare_android PUBLIC - bare_kit + bare-kit::bare_kit ) - -link_bare_modules(bare_android WORKING_DIRECTORY ..) diff --git a/app/build.gradle b/app/build.gradle index 0601c19..3d30af6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,7 +5,7 @@ plugins { android { namespace 'to.holepunch.bare.android' compileSdk 34 - ndkVersion '27.0.11718014' + ndkVersion '27.0.12077973' defaultConfig { applicationId 'to.holepunch.bare.android' @@ -17,11 +17,15 @@ android { externalNativeBuild { cmake { targets 'bare_android' - arguments "-DCMAKE_MODULE_PATH=$System.env.CMAKE_MODULE_PATH" + arguments "-DCMAKE_MODULE_PATH=" + "bare-dev paths cmake".execute().text, "-DANDROID_STL=none" } } } + buildFeatures { + prefab true + } + buildTypes { release { signingConfig signingConfigs.debug @@ -31,7 +35,7 @@ android { externalNativeBuild { cmake { version '3.25.0+' - path 'CMakeLists.txt' + path '../CMakeLists.txt' } } } diff --git a/app/src/main/java/to/holepunch/bare/android/MainActivity.java b/app/src/main/java/to/holepunch/bare/android/MainActivity.java index f532c6f..a4e5862 100644 --- a/app/src/main/java/to/holepunch/bare/android/MainActivity.java +++ b/app/src/main/java/to/holepunch/bare/android/MainActivity.java @@ -9,7 +9,7 @@ public class MainActivity extends Activity { static { - System.loadLibrary("bare_android"); + System.loadLibrary("app"); } Worklet worklet; diff --git a/app/src/main/jniLibs/.gitignore b/app/src/main/jniLibs/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/app/src/main/jniLibs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/vendor/bare-kit b/vendor/bare-kit index 728fe1a..4448271 160000 --- a/vendor/bare-kit +++ b/vendor/bare-kit @@ -1 +1 @@ -Subproject commit 728fe1a5b85ca2a10300b24c345bca43aa3e1b5b +Subproject commit 44482711fbafb81d24309ae0260b4ed3c4282193