diff options
author | Raphael Cotty <raphael.cotty@gmail.com> | 2021-03-29 22:03:36 +0200 |
---|---|---|
committer | Raphaƫl Cotty <raphael.cotty@gmail.com> | 2021-03-31 11:01:07 +0000 |
commit | e7f204c4b82475f39c3f5a3870a7393857b1a29a (patch) | |
tree | 071b5344faf0c8c5344f1be36fbfe00a5b72db01 /share/qbs | |
parent | 33cbe8a4ddc89696ae52df222cd959ba1e4d4b93 (diff) | |
download | qbs-e7f204c4b82475f39c3f5a3870a7393857b1a29a.tar.gz |
Android: Add support for ndk 22.1.7171670
Android ndk 19 introduced a new layout for the platforms and sysroot
directory. They are merged into the toolchain directory. Android ndk 22
removed the deprecated platforms and sysroot.
Since the minimum required version of Android.ndk is 19 this patch
switches Qbs to the new layout.
Fixes: QBS-1637
Change-Id: Ie69d305ba77ac1689205e2fb2fd3414a3bada2bd
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
Diffstat (limited to 'share/qbs')
-rw-r--r-- | share/qbs/modules/Android/ndk/utils.js | 4 | ||||
-rw-r--r-- | share/qbs/modules/cpp/android-gcc.qbs | 72 |
2 files changed, 35 insertions, 41 deletions
diff --git a/share/qbs/modules/Android/ndk/utils.js b/share/qbs/modules/Android/ndk/utils.js index 3605df314..e763ed9b6 100644 --- a/share/qbs/modules/Android/ndk/utils.js +++ b/share/qbs/modules/Android/ndk/utils.js @@ -100,6 +100,6 @@ function commonLinkerFlags(abi) { return ["-z", "noexecstack", "-z", "relro", "-z", "now", "--build-id=sha1", "--gc-sections" ]; } -function stlFilePath(path, ndk, suffix) { - return path + ndk.appStl.slice(0, ndk.appStl.indexOf('_')) + suffix + "." + ndk.platformVersion; +function stlFileName(prefix, ndk, suffix) { + return prefix + ndk.appStl.slice(0, ndk.appStl.indexOf('_')) + suffix; } diff --git a/share/qbs/modules/cpp/android-gcc.qbs b/share/qbs/modules/cpp/android-gcc.qbs index 5759606aa..e42601a23 100644 --- a/share/qbs/modules/cpp/android-gcc.qbs +++ b/share/qbs/modules/cpp/android-gcc.qbs @@ -43,21 +43,32 @@ LinuxGCC { priority: 2 rpaths: [] + // toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android cxxLanguageVersion: "c++14" - property string cxxStlBaseDir: FileInfo.joinPaths(Android.ndk.ndkDir, "sources", "cxx-stl") - property string stlBaseDir: FileInfo.joinPaths(cxxStlBaseDir, "llvm-libc++") - property string stlLibsDir: { - if (stlBaseDir) - return FileInfo.joinPaths(stlBaseDir, "libs", Android.ndk.abi); - return undefined; + property string archLibsDir: { + switch (qbs.architecture) { + case "arm64": + return "aarch64"; + case "armv7a": + return "arm"; + case "x86_64": + return qbs.architecture; + case "x86": + return "i686"; + } } + property string targetDir: "android" + (["armeabi", "armeabi-v7a"].contains(Android.ndk.abi) ? "eabi" : "") + property string triple: [archLibsDir, targetSystem, targetDir].join("-") + property string libsDir: FileInfo.joinPaths(sysroot, "usr", "lib", triple); - property string sharedStlFilePath: (stlLibsDir && Android.ndk.appStl.endsWith("_shared")) - ? FileInfo.joinPaths(stlLibsDir, dynamicLibraryPrefix + Android.ndk.appStl + dynamicLibrarySuffix) + property string sharedStlFilePath: (libsDir && Android.ndk.appStl.endsWith("_shared")) + ? FileInfo.joinPaths(libsDir, dynamicLibraryPrefix + Android.ndk.appStl + dynamicLibrarySuffix) : undefined - property string staticStlFilePath: (stlLibsDir && Android.ndk.appStl.endsWith("_static")) - ? FileInfo.joinPaths(stlLibsDir, NdkUtils.stlFilePath(staticLibraryPrefix, Android.ndk, staticLibrarySuffix)) + property string staticStlFilePath: (libsDir && Android.ndk.appStl.endsWith("_static")) + ? FileInfo.joinPaths(libsDir, Android.ndk.platformVersion, + NdkUtils.stlFileName(staticLibraryPrefix, Android.ndk, + staticLibrarySuffix)) : undefined Group { @@ -91,52 +102,35 @@ LinuxGCC { linkerFlags: NdkUtils.commonLinkerFlags(Android.ndk.abi); driverLinkerFlags: { - var flags = ["-fuse-ld=lld", "-Wl,--exclude-libs,libgcc.a", "-Wl,--exclude-libs,libatomic.a", "-nostdlib++"]; - if (Android.ndk.appStl.startsWith("c++") && Android.ndk.abi === "armeabi-v7a") - flags = flags.concat(["-Wl,--exclude-libs,libunwind.a"]); + var flags = ["-fuse-ld=lld", "-Wl,--exclude-libs,libgcc.a", "-nostdlib++"]; + // See https://android.googlesource.com/platform/ndk/+/ndk-release-r21/docs/BuildSystemMaintainers.md#Unwinding + if (Android.ndk.abi === "armeabi-v7a") { + flags = flags.concat(["-Wl,--exclude-libs,libgcc_real.a"]); + if (Android.ndk.appStl.startsWith("c++")) + flags = flags.concat(["-Wl,--exclude-libs,libunwind.a"]); + } return flags; } platformDriverFlags: ["-fdata-sections", "-ffunction-sections", "-funwind-tables", "-fstack-protector-strong", "-no-canonical-prefixes"] - libraryPaths: { - var prefix = FileInfo.joinPaths(sysroot, "usr"); - var paths = []; - if (Android.ndk.abi === "x86_64") // no lib64 for arm64-v8a - paths.push(FileInfo.joinPaths(prefix, "lib64")); - paths.push(FileInfo.joinPaths(prefix, "lib")); - paths.push(stlLibsDir); - return paths; - } - dynamicLibraries: { var libs = ["c", "m"]; if (sharedStlFilePath) - libs.push(FileInfo.joinPaths(stlLibsDir, NdkUtils.stlFilePath(dynamicLibraryPrefix, Android.ndk, dynamicLibrarySuffix))); + libs.push(FileInfo.joinPaths(libsDir, Android.ndk.platformVersion, + NdkUtils.stlFileName(dynamicLibraryPrefix, Android.ndk, + dynamicLibrarySuffix))); return libs; } - staticLibraries: staticStlFilePath - systemIncludePaths: { - var includes = [FileInfo.joinPaths(sysroot, "usr", "include", toolchainTriple)]; - if (Android.ndk.abi === "armeabi-v7a") { - includes.push(FileInfo.joinPaths(Android.ndk.ndkDir, "sources", "android", - "support", "include")); - } - includes.push(FileInfo.joinPaths(stlBaseDir, "include")); - includes.push(FileInfo.joinPaths(stlBaseDir + "abi", "include")); - return includes; - } defines: ["ANDROID", "__ANDROID__"] binutilsPath: FileInfo.joinPaths(Android.ndk.ndkDir, "toolchains", "llvm", "prebuilt", Android.ndk.hostArch, "bin"); binutilsPathPrefix: FileInfo.joinPaths(binutilsPath, "llvm-") - syslibroot: FileInfo.joinPaths(Android.ndk.ndkDir, "platforms", - Android.ndk.platform, "arch-" - + NdkUtils.abiNameToDirName(Android.ndk.abi)) - sysroot: FileInfo.joinPaths(Android.ndk.ndkDir, "sysroot") + sysroot: FileInfo.joinPaths(Android.ndk.ndkDir, "toolchains", "llvm", "prebuilt", + Android.ndk.hostArch, "sysroot") targetArch: { switch (qbs.architecture) { |