OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 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 import("//build/toolchain/gcc_toolchain.gni") |
| 6 |
| 7 # CrOS builds must cross-compile on a Linux host for the actual CrOS |
| 8 # device target. There are many different CrOS devices so the build |
| 9 # system provides configuration variables that permit a CrOS build to |
| 10 # control the cross-compilation tool chain. However, requiring such |
| 11 # fine-grain specification is tedious for build-bots and developers. |
| 12 # Consequently, the CrOS build system defaults to a convenience |
| 13 # compilation mode where the compilation host is also the build target. |
| 14 # |
| 15 # Chrome can be compiled in this way with the gn variable: |
| 16 # |
| 17 # target_os = "chromeos" |
| 18 # |
| 19 # To perform a board-specific build, first obtain the correct system |
| 20 # root (http://goo.gl/aFB4XH) for the board. Then configure GN to use it |
| 21 # by setting appropriate cross-compilation variables. |
| 22 # |
| 23 # For example, to compile a Chrome source tree in /g/src for an |
| 24 # auron_paine CrOS device with the system root cached in /g/.cros_cache, |
| 25 # the following GN arguments must be provided to configure |
| 26 # cross-compilation with Goma acceleration. (NB: additional variables |
| 27 # will be necessary to successfully compile a working CrOS Chrome. See |
| 28 # the definition of GYP_DEFINES inside a sysroot shell.) |
| 29 # |
| 30 # goma_dir = "/g/.cros_cache/common/goma+2" |
| 31 # target_sysroot= /g/.cros_cache/chrome-sdk/tarballs/auron_paine+7644.0.0+sysroo
t_chromeos-base_chromeos-chrome.tar.xz" |
| 32 # cros_target_cc = "x86_64-cros-linux-gnu-gcc -B/g/.cros_cache/chrome-sdk/tarbal
ls/auron_paine+7657.0.0+target_toolchain/usr/x86_64-pc-linux-gnu/x86_64-cros-lin
ux-gnu/binutils-bin/2.25.51-gold" |
| 33 # cros_target_cxx = "x86_64-cros-linux-gnu-g++ -B/g/.cros_cache/chrome-sdk/tarba
lls/auron_paine+7657.0.0+target_toolchain/usr/x86_64-pc-linux-gnu/x86_64-cros-li
nux-gnu/binutils-bin/2.25.51-gold" |
| 34 # cros_target_ar = "x86_64-cros-linux-gnu-gcc-ar" |
| 35 # target_cpu = "x64" |
| 36 |
| 37 declare_args() { |
| 38 # These must be specified for a board-specific build. |
| 39 cros_target_ar = "ar" |
| 40 cros_target_cc = "gcc" |
| 41 cros_target_cxx = "g++" |
| 42 cros_target_ld = "" |
| 43 cros_target_nm = "" |
| 44 cros_target_readelf = "" |
| 45 |
| 46 # These can be optionally set. The "_cppflags" will be applied to *both* |
| 47 # C and C++ files; use "_cxxflags" for C++-only flags. |
| 48 cros_target_extra_cflags = "" |
| 49 cros_target_extra_cppflags = "" |
| 50 cros_target_extra_cxxflags = "" |
| 51 cros_target_extra_ldflags = "" |
| 52 |
| 53 # is_clang is used instead of cros_target_is_clang |
| 54 |
| 55 cros_host_ar = "ar" |
| 56 cros_host_cc = "gcc" |
| 57 cros_host_cxx = "g++" |
| 58 cros_host_ld = "" |
| 59 cros_host_nm = "" |
| 60 cros_host_readelf = "" |
| 61 cros_host_extra_cflags = "" |
| 62 cros_host_extra_cppflags = "" |
| 63 cros_host_extra_cxxflags = "" |
| 64 cros_host_extra_ldflags = "" |
| 65 cros_host_is_clang = false |
| 66 |
| 67 cros_v8_snapshot_ar = "ar" |
| 68 cros_v8_snapshot_cc = "gcc" |
| 69 cros_v8_snapshot_cxx = "g++" |
| 70 cros_v8_snapshot_ld = "" |
| 71 cros_v8_snapshot_nm = "" |
| 72 cros_v8_snapshot_readelf = "" |
| 73 cros_v8_snapshot_extra_cflags = "" |
| 74 cros_v8_snapshot_extra_cppflags = "" |
| 75 cros_v8_snapshot_extra_cxxflags = "" |
| 76 cros_v8_snapshot_extra_ldflags = "" |
| 77 cros_v8_snapshot_is_clang = false |
| 78 } |
| 79 |
| 80 # TODO(dpranke): Delete this after we get rid of the reference to |
| 81 # build/toolchain/cros:clang_target in BUILDCONFIG.gn |
| 82 clang_toolchain("clang_target") { |
| 83 toolchain_cpu = target_cpu |
| 84 toolchain_os = "linux" |
| 85 } |
| 86 |
| 87 gcc_toolchain("target") { |
| 88 # These are args for the template. |
| 89 ar = cros_target_ar |
| 90 cc = cros_target_cc |
| 91 cxx = cros_target_cxx |
| 92 ld = cxx |
| 93 if (cros_target_ld != "") { |
| 94 ld = cros_target_ld |
| 95 } |
| 96 if (cros_target_nm != "") { |
| 97 nm = cros_target_nm |
| 98 } |
| 99 if (cros_target_readelf != "") { |
| 100 readelf = cros_target_readelf |
| 101 } |
| 102 extra_cflags = cros_target_extra_cflags |
| 103 extra_cppflags = cros_target_extra_cppflags |
| 104 extra_cxxflags = cros_target_extra_cxxflags |
| 105 extra_ldflags = cros_target_extra_ldflags |
| 106 |
| 107 # These are passed through as toolchain_args. |
| 108 cc_wrapper = "" |
| 109 is_clang = is_clang |
| 110 toolchain_cpu = target_cpu |
| 111 toolchain_os = "linux" |
| 112 } |
| 113 |
| 114 gcc_toolchain("host") { |
| 115 # These are args for the template. |
| 116 ar = cros_host_ar |
| 117 cc = cros_host_cc |
| 118 cxx = cros_host_cxx |
| 119 ld = cxx |
| 120 if (cros_host_ld != "") { |
| 121 ld = cros_host_ld |
| 122 } |
| 123 if (cros_host_nm != "") { |
| 124 nm = cros_host_nm |
| 125 } |
| 126 if (cros_host_readelf != "") { |
| 127 readelf = cros_host_readelf |
| 128 } |
| 129 extra_cflags = cros_host_extra_cflags |
| 130 extra_cppflags = cros_host_extra_cppflags |
| 131 extra_cxxflags = cros_host_extra_cxxflags |
| 132 extra_ldflags = cros_host_extra_ldflags |
| 133 |
| 134 # These are passed through as toolchain_args. |
| 135 cc_wrapper = "" |
| 136 is_clang = cros_host_is_clang |
| 137 toolchain_cpu = host_cpu |
| 138 toolchain_os = "linux" |
| 139 use_sysroot = false |
| 140 } |
| 141 |
| 142 gcc_toolchain("v8_snapshot") { |
| 143 # These are args for the template. |
| 144 ar = cros_v8_snapshot_ar |
| 145 cc = cros_v8_snapshot_cc |
| 146 cxx = cros_v8_snapshot_cxx |
| 147 ld = cxx |
| 148 if (cros_v8_snapshot_ld != "") { |
| 149 ld = cros_v8_snapshot_ld |
| 150 } |
| 151 if (cros_v8_snapshot_nm != "") { |
| 152 nm = cros_v8_snapshot_nm |
| 153 } |
| 154 if (cros_v8_snapshot_readelf != "") { |
| 155 readelf = cros_v8_snapshot_readelf |
| 156 } |
| 157 extra_cflags = cros_v8_snapshot_extra_cflags |
| 158 extra_cppflags = cros_v8_snapshot_extra_cppflags |
| 159 extra_cxxflags = cros_v8_snapshot_extra_cxxflags |
| 160 extra_ldflags = cros_v8_snapshot_extra_ldflags |
| 161 |
| 162 # These are passed through as toolchain_args. |
| 163 cc_wrapper = "" |
| 164 is_clang = cros_v8_snapshot_is_clang |
| 165 if (target_cpu == "x86" || target_cpu == "arm" || target_cpu == "mipsel") { |
| 166 toolchain_cpu = "x86" |
| 167 } else { |
| 168 toolchain_cpu = "x64" |
| 169 } |
| 170 toolchain_os = "linux" |
| 171 use_sysroot = false |
| 172 } |
OLD | NEW |