Index: build/toolchain/android/BUILD.gn |
diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn |
new file mode 100644 |
index 0000000000000000000000000000000000000000..7710cd0f9962b013efb5be10429ccdf1ccbd72e4 |
--- /dev/null |
+++ b/build/toolchain/android/BUILD.gn |
@@ -0,0 +1,101 @@ |
+# Copyright 2013 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import("../clang.gni") |
+import("../goma.gni") |
+import("../gcc_toolchain.gni") |
+ |
+# Get the location of the Android tools in our tree. |
+android_ndk_root = |
+ rebase_path("//third_party/android_tools/ndk", ".", "") |
+android_sdk_root = |
+ rebase_path("//third_party/android_tools/sdk", ".", "") |
+ |
+# Get the Android version of the name of the build host's architecture. |
+if (build_cpu_arch == "x64") { |
+ android_host_arch = "x86_64" |
+} else if (build_cpu_arch == "x86") { |
+ android_host_arch = "x86" |
+} else { |
+ assert(false, "Need Android toolchain support for your build OS.") |
+} |
+ |
+if (is_gyp) { |
+ # Set the compilers for GYP to use. This logic is only relevant to GYP where |
+ # there is "a" target compiler. In native GN builds, we have separate |
+ # compilers for the toolchains below, any or all of which could be active in |
+ # any given build. |
+ if (is_clang) { |
+ # Set the GYP header for all toolchains when running under Clang. |
+ gyp_header = make_clang_global_settings |
+ } else { |
+ # Find the compiler for GYP for non-Clang Android. |
+ if (cpu_arch == "x86") { |
+ android_toolchain_arch = "x86-4.6" |
+ } else if (cpu_arch == "arm") { |
+ android_toolchain_arch = "arm-linux-androideabi-4.6" |
+ } else { |
+ assert(false, "Need Android toolchain support for your platform.") |
+ } |
+ |
+ android_toolchain = |
+ "$android_ndk_root/toolchains/$android_toolchain_arch/prebuilt/$build_os-$android_host_arch/bin" |
+ |
+ # This script will find the compilers for the given Android toolchain |
+ # directory. |
+ # TODO(brettw) write this script which locates the Android compilers. |
+ #android_compilers = exec_script("find_android_compilers.py", |
+ # [android_toolchain], "value") |
+ android_compilers = ["gcc", "g++", "gcc", "g++"] |
+ gyp_header = |
+ "'make_global_settings': [" + |
+ "['CC', '" + android_compilers[0] + "']," + |
+ "['CXX', '" + android_compilers[1] + "']," + |
+ "['CC.host', '" + android_compilers[2] + "']," + |
+ "['CXX.host', '" + android_compilers[3] + "']," + |
+ "]," |
+ } |
+ |
+ if (use_goma) { |
+ # There is a TODO(yyanagisawa) in common.gypi about the make generator not |
+ # supporting CC_wrapper without CC. As a result, we must add a condition |
+ # when on the generator when we're not explicitly setting the variables |
+ # above (which happens when gyp_header is empty at this point). |
+ # |
+ # GYP will interpret the file once for each generator, so we have to write |
+ # this condition into the GYP file since the user could have more than one |
+ # generator set. |
+ if (gyp_header == "") { |
+ gyp_header += |
+ "'conditions':" + |
+ "['\"<(GENERATOR)\"==\"ninja\"', {" + |
+ make_goma_global_settings + |
+ "}]," |
+ } else { |
+ gyp_header += make_goma_global_settings |
+ } |
+ } |
+} |
+ |
+gcc_toolchain("x86") { |
+ prefix = "$android_ndk_root/toolchains/x86-4.6/prebuilt/$build_os-$android_host_arch/bin/i686-linux-android-" |
+ cc = prefix + "gcc" |
+ cxx = prefix + "g++" |
+ ar = prefix + "ar" |
+ ld = cxx |
+ |
+ toolchain_cpu_arch = "x86" |
+ toolchain_os = "android" |
+} |
+ |
+gcc_toolchain("arm") { |
+ prefix = "$android_ndk_root/toolchains/arm-linux-androideabi-4.6/prebuilt/$build_os-$android_host_arch/bin/arm-linux-androideabi-" |
+ cc = prefix + "gcc" |
+ cxx = prefix + "g++" |
+ ar = prefix + "ar" |
+ ld = cxx |
+ |
+ toolchain_cpu_arch = "arm" |
+ toolchain_os = "android" |
+} |