1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-22 10:51:28 +00:00

Set ndk path automatically in gradle (#1741)

This commit is contained in:
Simon Frei 2021-12-08 10:55:50 +01:00 committed by GitHub
parent 72cc528888
commit abbe8afd2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 13 additions and 9 deletions

View file

@ -21,8 +21,8 @@ Language mappings are defined in `.tx/config`, with the second code being the on
# Building
### Dependencies
- Android SDK (you can skip this if you are using Android Studio)
- Android NDK (`$ANDROID_NDK_HOME` should point at the root directory of your NDK)
- Android SDK, with `$ANDROID_HOME` pointing to it (you can skip this if you are using Android Studio)
- Android NDK (you should install the required version (`ext.ndkVersionShared` in `./build.gradle`) with the usual tools, such that it's located within `$ANDROID_HOME/ndk/`).
- Go (see [here](https://docs.syncthing.net/dev/building.html#prerequisites) for the required version)
- Java Version 11 (you scan skip this if you are using Android Studio, otherwise you might need to set `$JAVA_HOME` accordingly)

View file

@ -24,10 +24,10 @@ dependencies {
}
android {
// Changes to these values need to be reflected in `.travis.yml`
// Changes to these values need to be reflected in `../docker/Dockerfile`
compileSdkVersion 29
buildToolsVersion '29.0.3'
ndkVersion = '23.0.7599858'
ndkVersion = "${ndkVersionShared}"
buildTypes.debug.applicationIdSuffix ".debug"
dataBinding.enabled = true

View file

@ -1,6 +1,11 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
// Cannot be called "ndkVersion" as that leads to naming collision
// Changes to this value must be reflected in `./docker/Dockerfile`
ndkVersionShared = '23.0.7599858'
}
repositories {
google()
jcenter()

View file

@ -35,9 +35,6 @@ RUN $SDKMANAGER tools platform-tools "build-tools;29.0.3" "platforms;android-29"
# Accept licenses of newly installed packages
RUN yes | $SDKMANAGER --licenses
# Setup the NDK path
ENV ANDROID_NDK_HOME ${ANDROID_HOME}/ndk/${NDK_VERSION}
# Enable prebuild mode
ENV SYNCTHING_ANDROID_PREBUILT 1

View file

@ -60,10 +60,11 @@ def get_min_sdk(project_dir):
def get_ndk_home():
if not os.environ.get('ANDROID_NDK_HOME', ''):
fail('ANDROID_NDK_HOME environment variable not defined')
if not os.environ.get('NDK_VERSION', '') or not os.environ.get('ANDROID_HOME', ''):
fail('ANDROID_NDK_HOME or NDK_VERSION and ANDROID_HOME environment variable must be defined')
return os.path.join(os.environ['ANDROID_HOME'], 'ndk', os.environ['NDK_VERSION'])
return os.environ['ANDROID_NDK_HOME']
if platform.system() not in PLATFORM_DIRS:
fail('Unsupported python platform %s. Supported platforms: %s', platform.system(),
', '.join(PLATFORM_DIRS.keys()))

View file

@ -1,4 +1,5 @@
task buildNative(type: Exec) {
environment "NDK_VERSION", "$ndkVersionShared"
inputs.dir("$projectDir/src/")
outputs.dir("$projectDir/../app/src/main/jniLibs/")
executable = 'python3'