diff --git a/README.md b/README.md index 8899e7e1..c27236d1 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/app/build.gradle b/app/build.gradle index bdfe8853..36822d85 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 diff --git a/build.gradle b/build.gradle index add0fad2..7b7e91dd 100644 --- a/build.gradle +++ b/build.gradle @@ -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() diff --git a/docker/Dockerfile b/docker/Dockerfile index 202bf82f..c44303e3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 diff --git a/syncthing/build-syncthing.py b/syncthing/build-syncthing.py index 31ad2cc7..83f0cb56 100644 --- a/syncthing/build-syncthing.py +++ b/syncthing/build-syncthing.py @@ -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())) diff --git a/syncthing/build.gradle b/syncthing/build.gradle index be363cd0..d71df7c7 100644 --- a/syncthing/build.gradle +++ b/syncthing/build.gradle @@ -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'