Skip to content

Commit c03f619

Browse files
committed
android build stuff
1 parent 3c11445 commit c03f619

File tree

6 files changed

+168
-0
lines changed

6 files changed

+168
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.build/
9+
.buildlog/
10+
.history
11+
.svn/
12+
.swiftpm/
13+
migrate_working_dir/
14+
15+
# IntelliJ related
16+
*.iml
17+
*.ipr
18+
*.iws
19+
.idea/
20+
21+
# The .vscode folder contains launch configuration and tasks you configure in
22+
# VS Code which you may wish to be included in version control, so this line
23+
# is commented out by default.
24+
#.vscode/
25+
26+
# Flutter/Dart/Pub related
27+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
28+
/pubspec.lock
29+
**/doc/api/
30+
.dart_tool/
31+
.flutter-plugins-dependencies
32+
/build/
33+
/coverage/
34+
35+
# binaries
36+
*.so
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.cxx
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
set(PROJECT_NAME "nobodywho_flutter")
2+
3+
# Unlike the Windows & Linux CMakeLists.txt, this Android equivalent is just here
4+
# to download the Android binaries into src/main/jniLibs/ and does not build anything.
5+
# The binary download/extraction is difficult to do concisely in Groovy/Gradle,
6+
# at least across host platforms, so we are just reusing our Linux/Windows logic.
7+
8+
# The Flutter tooling requires that developers have CMake 3.10 or later
9+
# installed. You should not increase this version, as doing so will cause
10+
# the plugin to fail to compile for some customers of the plugin.
11+
cmake_minimum_required(VERSION 3.10)
12+
13+
project(PROJECT_NAME)
14+
15+
set(NOBODYWHO_FLUTTER_LOCAL_BUILD_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../target/aarch64-linux-android/release/libnobodywho_flutter.so")
16+
set(LibRoot "${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs")
17+
18+
# check local build
19+
if(EXISTS ${NOBODYWHO_FLUTTER_LOCAL_BUILD_LIB_PATH})
20+
message("Using locally built NobodyWho artifact")
21+
set(NOBODYWHO_FLUTTER_LIB_PATH ${NOBODYWHO_FLUTTER_LOCAL_BUILD_LIB_PATH})
22+
23+
else()
24+
# TODO: download
25+
# this won't actually work until we can make real releases
26+
# w/e
27+
message("Downloading NobodyWho from github...")
28+
set(NOBODYWHO_FLUTTER_LIB_PATH "./libnobodywho_flutter.so")
29+
file(DOWNLOAD
30+
"https://github.com/nobodywho-ooo/nobodywho/releases/download/${LibraryVersion}/nobodywho_flutter_bundled_libs.tar.gz"
31+
${NOBODYWHO_FLUTTER_LIB_PATH}
32+
TLS_VERIFY ON
33+
)
34+
endif()
35+
36+
# copy in the binary, overriding any already present.
37+
file(REMOVE_RECURSE ${LibRoot})
38+
file(MAKE_DIRECTORY ${LibRoot}/arm64-v8a)
39+
file(COPY ${NOBODYWHO_FLUTTER_LIB_PATH} DESTINATION ${LibRoot}/arm64-v8a)
40+
41+
# Copy libc++_shared.so from NDK
42+
# CMAKE_ANDROID_NDK is automatically set by the Android Gradle Plugin
43+
set(CXX_SHARED_LIB "${CMAKE_ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so")
44+
if(EXISTS ${CXX_SHARED_LIB})
45+
message("Copying libc++_shared.so to jniLibs")
46+
file(COPY ${CXX_SHARED_LIB} DESTINATION ${LibRoot}/arm64-v8a)
47+
else()
48+
# Try alternative location for Windows/Mac
49+
set(CXX_SHARED_LIB "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so")
50+
if(EXISTS ${CXX_SHARED_LIB})
51+
message("Copying libc++_shared.so to jniLibs (alternative path)")
52+
file(COPY ${CXX_SHARED_LIB} DESTINATION ${LibRoot}/arm64-v8a)
53+
else()
54+
message(WARNING "libc++_shared.so not found in NDK at ${CMAKE_ANDROID_NDK}")
55+
endif()
56+
endif()
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// The Android Gradle Plugin builds the native code with the Android NDK.
2+
3+
group = "ooo.nobodywho.nobodywho_flutter"
4+
version = "1.0"
5+
6+
buildscript {
7+
repositories {
8+
google()
9+
mavenCentral()
10+
}
11+
12+
dependencies {
13+
// The Android Gradle Plugin knows how to build native code with the NDK.
14+
classpath("com.android.tools.build:gradle:8.9.1")
15+
}
16+
}
17+
18+
rootProject.allprojects {
19+
repositories {
20+
google()
21+
mavenCentral()
22+
}
23+
}
24+
25+
apply plugin: "com.android.library"
26+
27+
android {
28+
namespace = "ooo.nobodywho.nobodywho_flutter"
29+
30+
// Bumping the plugin compileSdk version requires all clients of this plugin
31+
// to bump the version in their app.
32+
compileSdk = 36
33+
34+
// Use the NDK version
35+
// declared in /android/app/build.gradle file of the Flutter project.
36+
// Replace it with a version number if this plugin requires a specific NDK version.
37+
// (e.g. ndkVersion "23.1.7779620")
38+
ndkVersion = android.ndkVersion
39+
40+
// Invoke the shared CMake build with the Android Gradle Plugin.
41+
externalNativeBuild {
42+
cmake {
43+
path = "CMakeLists.txt"
44+
45+
// The default CMake version for the Android Gradle Plugin is 3.10.2.
46+
// https://developer.android.com/studio/projects/install-ndk#vanilla_cmake
47+
//
48+
// The Flutter tooling requires that developers have CMake 3.10 or later
49+
// installed. You should not increase this version, as doing so will cause
50+
// the plugin to fail to compile for some customers of the plugin.
51+
// version "3.10.2"
52+
}
53+
}
54+
55+
compileOptions {
56+
sourceCompatibility = JavaVersion.VERSION_11
57+
targetCompatibility = JavaVersion.VERSION_11
58+
}
59+
60+
defaultConfig {
61+
minSdk = 24
62+
}
63+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'nobodywho_flutter'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="ooo.nobodywho.nobodywho_flutter">
3+
</manifest>

0 commit comments

Comments
 (0)