• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5# This header file defines the "sysroot" variable which is the absolute path
6# of the sysroot. If no sysroot applies, the variable will be an empty string.
7
8import("//build/config/chrome_build.gni")
9
10declare_args() {
11  # The absolute path of the sysroot that is applied when compiling using
12  # the target toolchain.
13  target_sysroot = ""
14  use_sysroot = true
15}
16
17if (current_os == target_os && current_cpu == target_cpu &&
18    target_sysroot != "") {
19  sysroot = target_sysroot
20} else if (is_android) {
21  import("//build/config/android/config.gni")
22  if (current_cpu == "x86") {
23    sysroot = "$android_ndk_root/$x86_android_sysroot_subdir"
24  } else if (current_cpu == "arm") {
25    sysroot = "$android_ndk_root/$arm_android_sysroot_subdir"
26  } else if (current_cpu == "mipsel") {
27    sysroot = "$android_ndk_root/$mips_android_sysroot_subdir"
28  } else if (current_cpu == "x64") {
29    sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir"
30  } else if (current_cpu == "arm64") {
31    sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir"
32  } else if (current_cpu == "mips64") {
33    sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir"
34  } else {
35    sysroot = ""
36  }
37} else if (is_linux && !is_chromeos && use_sysroot) {
38  # By default build against a sysroot image downloaded from Cloud Storage
39  # during gclient runhooks.
40  if (current_cpu == "x64") {
41    sysroot = "//build/linux/debian_wheezy_amd64-sysroot"
42  } else if (current_cpu == "x86") {
43    sysroot = "//build/linux/debian_wheezy_i386-sysroot"
44  } else if (current_cpu == "mipsel") {
45    sysroot = "//build/linux/debian_wheezy_mips-sysroot"
46  } else if (current_cpu == "arm") {
47    sysroot = "//build/linux/debian_wheezy_arm-sysroot"
48  } else {
49    # Any other builds don't use a sysroot.
50    sysroot = ""
51  }
52
53  if (sysroot != "") {
54    # Our sysroot images only contains gcc 4.6 headers, but chromium requires
55    # gcc 4.9. Clang is able to detect and work with the 4.6 headers while
56    # gcc is not. This check can be removed if we ever update to a more modern
57    # sysroot.
58    assert(is_clang, "sysroot images require clang (try use_sysroot=false)")
59
60    _script_arch = current_cpu
61    if (_script_arch == "x86") {
62      _script_arch = "i386"
63    } else if (_script_arch == "x64") {
64      _script_arch = "amd64"
65    }
66    assert(
67        exec_script("//build/dir_exists.py",
68                    [ rebase_path(sysroot) ],
69                    "string") == "True",
70        "Missing sysroot ($sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=$_script_arch")
71  }
72} else if (is_mac) {
73  import("//build/config/mac/mac_sdk.gni")
74  sysroot = mac_sdk_path
75} else if (is_ios) {
76  import("//build/config/ios/ios_sdk.gni")
77  sysroot = ios_sdk_path
78} else {
79  sysroot = ""
80}
81