mirror of
https://github.com/syncthing/syncthing-android.git
synced 2025-01-09 19:53:33 +00:00
Build with Android NDK 19c (#384)
* Update NDK from r18 to r19c * Add syncthing/quick_clean.cmd * Fix typo * Update syncthing/quick_clean.cmd * Remove make_standalone_toolchain for NDK 19c
This commit is contained in:
parent
304cf72c42
commit
999b7d8626
2 changed files with 34 additions and 40 deletions
|
@ -16,27 +16,30 @@ GO_VERSION = '1.12.1'
|
||||||
GO_EXPECTED_SHASUM_LINUX = '2a3fdabf665496a0db5f41ec6af7a9b15a49fbe71a85a50ca38b1f13a103aeec'
|
GO_EXPECTED_SHASUM_LINUX = '2a3fdabf665496a0db5f41ec6af7a9b15a49fbe71a85a50ca38b1f13a103aeec'
|
||||||
GO_EXPECTED_SHASUM_WINDOWS = '2f4849b512fffb2cf2028608aa066cc1b79e730fd146c7b89015797162f08ec5'
|
GO_EXPECTED_SHASUM_WINDOWS = '2f4849b512fffb2cf2028608aa066cc1b79e730fd146c7b89015797162f08ec5'
|
||||||
|
|
||||||
|
NDK_VERSION = 'r19c'
|
||||||
|
NDK_EXPECTED_SHASUM_LINUX = 'fd94d0be6017c6acbd193eb95e09cf4b6f61b834'
|
||||||
|
NDK_EXPECTED_SHASUM_WINDOWS = 'c4cd8c0b6e7618ca0a871a5f24102e40c239f6a3'
|
||||||
|
|
||||||
BUILD_TARGETS = [
|
BUILD_TARGETS = [
|
||||||
{
|
{
|
||||||
'arch': 'arm',
|
'arch': 'arm',
|
||||||
'goarch': 'arm',
|
'goarch': 'arm',
|
||||||
'jni_dir': 'armeabi',
|
'jni_dir': 'armeabi',
|
||||||
'cc': 'arm-linux-androideabi-clang',
|
'clang': 'armv7a-linux-androideabi16-clang',
|
||||||
'patch_underaligned_tls': 'yes',
|
'patch_underaligned_tls': 'yes',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'arch': 'arm64',
|
'arch': 'arm64',
|
||||||
'goarch': 'arm64',
|
'goarch': 'arm64',
|
||||||
'jni_dir': 'arm64-v8a',
|
'jni_dir': 'arm64-v8a',
|
||||||
'cc': 'aarch64-linux-android-clang',
|
'clang': 'aarch64-linux-android21-clang',
|
||||||
'patch_underaligned_tls': 'yes',
|
'patch_underaligned_tls': 'yes',
|
||||||
'min_sdk': 21,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'arch': 'x86',
|
'arch': 'x86',
|
||||||
'goarch': '386',
|
'goarch': '386',
|
||||||
'jni_dir': 'x86',
|
'jni_dir': 'x86',
|
||||||
'cc': 'i686-linux-android-clang',
|
'clang': 'i686-linux-android16-clang',
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -205,12 +208,12 @@ def install_ndk():
|
||||||
# Consts.
|
# Consts.
|
||||||
pwd_path = os.path.dirname(os.path.realpath(__file__))
|
pwd_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
url = 'https://dl.google.com/android/repository/android-ndk-r18-windows-x86_64.zip'
|
url = 'https://dl.google.com/android/repository/android-ndk-' + NDK_VERSION + '-windows-x86_64.zip'
|
||||||
expected_shasum = '7fc0e0f94d86ea389bd18761abdc1bae2c005587'
|
expected_shasum = NDK_EXPECTED_SHASUM_WINDOWS
|
||||||
|
|
||||||
else:
|
else:
|
||||||
url = 'https://dl.google.com/android/repository/android-ndk-r18-linux-x86_64.zip'
|
url = 'https://dl.google.com/android/repository/android-ndk-' + NDK_VERSION + '-linux-x86_64.zip'
|
||||||
expected_shasum = '2ac2e8e1ef73ed551cac3a1479bb28bd49369212'
|
expected_shasum = NDK_EXPECTED_SHASUM_LINUX
|
||||||
|
|
||||||
zip_fullfn = pwd_path + os.path.sep + 'ndk.zip';
|
zip_fullfn = pwd_path + os.path.sep + 'ndk.zip';
|
||||||
# Download NDK.
|
# Download NDK.
|
||||||
|
@ -230,7 +233,7 @@ def install_ndk():
|
||||||
print("[ok] Checksum of", zip_fullfn, "matches expected value.")
|
print("[ok] Checksum of", zip_fullfn, "matches expected value.")
|
||||||
|
|
||||||
# Proceed with extraction of the NDK if necessary.
|
# Proceed with extraction of the NDK if necessary.
|
||||||
ndk_home_path = pwd_path + os.path.sep + 'android-ndk-r18'
|
ndk_home_path = pwd_path + os.path.sep + 'android-ndk-' + NDK_VERSION
|
||||||
if not os.path.isfile(ndk_home_path + os.path.sep + "sysroot" + os.path.sep + "NOTICE"):
|
if not os.path.isfile(ndk_home_path + os.path.sep + "sysroot" + os.path.sep + "NOTICE"):
|
||||||
print("Extracting NDK ...")
|
print("Extracting NDK ...")
|
||||||
# This will go to a subfolder "android-ndk-r18" in the current path.
|
# This will go to a subfolder "android-ndk-r18" in the current path.
|
||||||
|
@ -308,11 +311,7 @@ if platform.system() not in SUPPORTED_PYTHON_PLATFORMS:
|
||||||
|
|
||||||
module_dir = os.path.dirname(os.path.realpath(__file__))
|
module_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
project_dir = os.path.realpath(os.path.join(module_dir, '..'))
|
project_dir = os.path.realpath(os.path.join(module_dir, '..'))
|
||||||
# Use seperate build dir so standalone ndk isn't deleted by `gradle clean`
|
|
||||||
build_dir = os.path.join(module_dir, 'gobuild')
|
|
||||||
go_build_dir = os.path.join(build_dir, 'go-packages')
|
|
||||||
syncthing_dir = os.path.join(module_dir, 'src', 'github.com', 'syncthing', 'syncthing')
|
syncthing_dir = os.path.join(module_dir, 'src', 'github.com', 'syncthing', 'syncthing')
|
||||||
min_sdk = get_min_sdk(project_dir)
|
|
||||||
|
|
||||||
# Check if git is available.
|
# Check if git is available.
|
||||||
git_bin = which("git");
|
git_bin = which("git");
|
||||||
|
@ -364,35 +363,23 @@ syncthingVersion = subprocess.check_output([
|
||||||
'--always'
|
'--always'
|
||||||
]).strip();
|
]).strip();
|
||||||
syncthingVersion = syncthingVersion.decode().replace("rc", "preview");
|
syncthingVersion = syncthingVersion.decode().replace("rc", "preview");
|
||||||
print('Building syncthing version', syncthingVersion);
|
|
||||||
|
|
||||||
|
print('Cleaning go-build cache')
|
||||||
|
subprocess.check_call([go_bin, 'clean', '-cache'], cwd=syncthing_dir)
|
||||||
|
|
||||||
|
print('Building syncthing version', syncthingVersion);
|
||||||
for target in BUILD_TARGETS:
|
for target in BUILD_TARGETS:
|
||||||
target_min_sdk = str(target.get('min_sdk', min_sdk))
|
|
||||||
print('Building for', target['arch'])
|
print('Building for', target['arch'])
|
||||||
|
|
||||||
if os.environ.get('SYNCTHING_ANDROID_PREBUILT', ''):
|
ndk_clang_fullfn = os.path.join(
|
||||||
# The environment variable indicates the SDK and stdlib was prebuilt, set a custom paths.
|
os.environ['ANDROID_NDK_HOME'],
|
||||||
standalone_ndk_dir = os.environ['ANDROID_NDK_HOME'] + os.path.sep + 'standalone-ndk' + os.path.sep + 'android-' + target_min_sdk + '-' + target['goarch']
|
'toolchains',
|
||||||
pkg_argument = []
|
'llvm',
|
||||||
else:
|
'prebuilt',
|
||||||
# Build standalone NDK toolchain if it doesn't exist.
|
'windows-x86_64' if sys.platform == 'win32' else 'linux-x86_64',
|
||||||
# https://developer.android.com/ndk/guides/standalone_toolchain.html
|
'bin',
|
||||||
standalone_ndk_dir = build_dir + os.path.sep + 'standalone-ndk' + os.path.sep + 'android-' + target_min_sdk + '-' + target['goarch']
|
target['clang'],
|
||||||
pkg_argument = ['-pkgdir', os.path.join(go_build_dir, target['goarch'])]
|
)
|
||||||
|
|
||||||
if not os.path.isdir(standalone_ndk_dir):
|
|
||||||
print('Building standalone NDK for', target['arch'], 'API level', target_min_sdk, 'to', standalone_ndk_dir)
|
|
||||||
subprocess.check_call([
|
|
||||||
sys.executable,
|
|
||||||
os.path.join(os.environ['ANDROID_NDK_HOME'], 'build', 'tools', 'make_standalone_toolchain.py'),
|
|
||||||
'--arch',
|
|
||||||
target['arch'],
|
|
||||||
'--api',
|
|
||||||
target_min_sdk,
|
|
||||||
'--install-dir',
|
|
||||||
standalone_ndk_dir,
|
|
||||||
'-v'
|
|
||||||
])
|
|
||||||
|
|
||||||
environ = os.environ.copy()
|
environ = os.environ.copy()
|
||||||
environ.update({
|
environ.update({
|
||||||
|
@ -404,9 +391,9 @@ for target in BUILD_TARGETS:
|
||||||
subprocess.check_call([go_bin, 'mod', 'download'], cwd=syncthing_dir)
|
subprocess.check_call([go_bin, 'mod', 'download'], cwd=syncthing_dir)
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
go_bin, 'run', 'build.go', '-goos', 'android', '-goarch', target['goarch'],
|
go_bin, 'run', 'build.go', '-goos', 'android', '-goarch', target['goarch'],
|
||||||
'-cc', os.path.join(standalone_ndk_dir, 'bin', target['cc']),
|
'-cc', ndk_clang_fullfn,
|
||||||
'-version', syncthingVersion
|
'-version', syncthingVersion
|
||||||
] + pkg_argument + ['-no-upgrade', 'build'], env=environ, cwd=syncthing_dir)
|
] + ['-no-upgrade', 'build'], env=environ, cwd=syncthing_dir)
|
||||||
|
|
||||||
# Determine path of source artifact
|
# Determine path of source artifact
|
||||||
source_artifact = os.path.join(syncthing_dir, 'syncthing')
|
source_artifact = os.path.join(syncthing_dir, 'syncthing')
|
||||||
|
|
7
syncthing/quick_clean.cmd
Normal file
7
syncthing/quick_clean.cmd
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
@echo off
|
||||||
|
cls
|
||||||
|
REM
|
||||||
|
RD /S /Q "%~dps0..\app\src\main\jniLibs"
|
||||||
|
REM
|
||||||
|
echo Done.
|
||||||
|
timeout 2
|
Loading…
Reference in a new issue