Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/toolchain/gcc_toolchain.gni") | 5 import("//build/toolchain/gcc_toolchain.gni") |
| 6 | 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 | |
| 7 declare_args() { | 37 declare_args() { |
| 8 # The CrOS build system supports many different kinds of targets across | 38 # These must be specified for a board-specific build. |
| 9 # many different architectures. Bringing your own toolchain is also supported, | |
| 10 # so it's actually impossible to enumerate all toolchains for all targets | |
| 11 # as GN toolchain specifications. | |
| 12 # These arguments provide a mechanism for specifying your CC, CXX and AR at | |
| 13 # buildfile-generation time, allowing the CrOS build system to always use | |
| 14 # the right tools for the current target. | |
| 15 cros_target_cc = "" | 39 cros_target_cc = "" |
| 16 cros_target_cxx = "" | 40 cros_target_cxx = "" |
| 17 cros_target_ar = "" | 41 cros_target_ar = "" |
| 18 } | 42 } |
| 19 | 43 |
| 20 gcc_toolchain("target") { | 44 clang_toolchain("clang_x64") { |
|
Dirk Pranke
2015/12/01 20:13:48
is there really a reason to support both the _x64
rjkroege
2015/12/02 00:22:39
Probably not? I have simplified the file.
| |
| 21 assert(cros_target_cc != "", "Must provide target CC.") | 45 toolchain_cpu = "x64" |
| 22 assert(cros_target_cxx != "", "Must provide target CXX.") | 46 toolchain_os = "linux" |
| 23 assert(cros_target_ar != "", "Must provide target AR.") | 47 } |
| 24 | 48 |
| 25 cc = "${cros_target_cc}" | 49 gcc_toolchain("x64") { |
| 26 cxx = "${cros_target_cxx}" | 50 # These defaults permit building on a Linux host as described above. |
| 51 cc = "gcc" | |
| 52 cxx = "g++" | |
| 53 ar = "ar" | |
| 27 | 54 |
| 28 ar = "${cros_target_ar}" | 55 # But to build for a specific board, the cros_* args will need to be defined. |
| 56 if (cros_target_cc != "") { | |
| 57 cc = "${cros_target_cc}" | |
| 58 } | |
| 59 if (cros_target_cxx != "") { | |
| 60 cxx = "${cros_target_cxx}" | |
| 61 } | |
| 62 if (cros_target_ar != "") { | |
| 63 ar = "${cros_target_ar}" | |
| 64 } | |
| 29 ld = cxx | 65 ld = cxx |
| 30 | 66 |
| 31 toolchain_cpu = "${target_cpu}" | 67 toolchain_cpu = "x64" |
| 32 toolchain_os = "linux" | 68 toolchain_os = "linux" |
| 33 is_clang = is_clang | 69 is_clang = is_clang |
| 34 use_ccache = false | 70 use_ccache = false |
| 35 use_goma = false | |
| 36 } | 71 } |
| 72 | |
| 73 clang_toolchain("clang_x86") { | |
| 74 toolchain_cpu = "x86" | |
| 75 toolchain_os = "linux" | |
| 76 } | |
| 77 | |
| 78 gcc_toolchain("x86") { | |
| 79 cc = "gcc" | |
| 80 cxx = "g++" | |
| 81 | |
| 82 readelf = "readelf" | |
| 83 nm = "nm" | |
| 84 ar = "ar" | |
| 85 ld = cxx | |
| 86 | |
| 87 # To build for a specific board, the cros_* args will need to be defined. | |
| 88 if (cros_target_cc != "") { | |
| 89 cc = "${cros_target_cc}" | |
| 90 } | |
| 91 if (cros_target_cxx != "") { | |
| 92 cxx = "${cros_target_cxx}" | |
| 93 } | |
| 94 if (cros_target_ar != "") { | |
| 95 ar = "${cros_target_ar}" | |
| 96 } | |
| 97 | |
| 98 toolchain_cpu = "x86" | |
| 99 toolchain_os = "linux" | |
| 100 is_clang = false | |
| 101 } | |
| OLD | NEW |