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/config/compiler/compiler.gni") |
| 6 import("//build/config/sysroot.gni") |
5 import("//build/toolchain/gcc_toolchain.gni") | 7 import("//build/toolchain/gcc_toolchain.gni") |
6 | 8 import("//build/toolchain/cros_toolchain.gni") |
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 | 9 |
80 # TODO(dpranke): Delete this after we get rid of the reference to | 10 # TODO(dpranke): Delete this after we get rid of the reference to |
81 # build/toolchain/cros:clang_target in BUILDCONFIG.gn | 11 # build/toolchain/cros:clang_target in BUILDCONFIG.gn |
82 clang_toolchain("clang_target") { | 12 clang_toolchain("clang_target") { |
83 toolchain_cpu = target_cpu | 13 toolchain_cpu = target_cpu |
84 toolchain_os = "linux" | 14 toolchain_os = "linux" |
85 } | 15 } |
86 | 16 |
87 gcc_toolchain("target") { | 17 template("cros_target_toolchain") { |
88 # These are args for the template. | 18 if (defined(invoker.use_debug_fission)) { |
89 ar = cros_target_ar | 19 use_debug_fission = invoker.use_debug_fission |
90 cc = cros_target_cc | |
91 cxx = cros_target_cxx | |
92 ld = cxx | |
93 if (cros_target_ld != "") { | |
94 ld = cros_target_ld | |
95 } | 20 } |
96 if (cros_target_nm != "") { | 21 if (defined(invoker.use_gold)) { |
97 nm = cros_target_nm | 22 use_gold = invoker.use_gold |
98 } | 23 } |
99 if (cros_target_readelf != "") { | 24 if (defined(invoker.use_sysroot)) { |
100 readelf = cros_target_readelf | 25 use_sysroot = invoker.use_sysroot |
101 } | 26 } |
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 | 27 |
107 # These are passed through as toolchain_args. | 28 gcc_toolchain(target_name) { |
108 cc_wrapper = "" | 29 # These are args for the template. |
109 is_clang = is_clang | 30 ar = cros_target_ar |
110 toolchain_cpu = target_cpu | 31 cc = cros_target_cc |
111 toolchain_os = "linux" | 32 cxx = cros_target_cxx |
| 33 ld = cxx |
| 34 if (cros_target_ld != "") { |
| 35 ld = cros_target_ld |
| 36 } |
| 37 if (cros_target_nm != "") { |
| 38 nm = cros_target_nm |
| 39 } |
| 40 if (cros_target_readelf != "") { |
| 41 readelf = cros_target_readelf |
| 42 } |
| 43 extra_cflags = cros_target_extra_cflags |
| 44 extra_cppflags = cros_target_extra_cppflags |
| 45 extra_cxxflags = cros_target_extra_cxxflags |
| 46 extra_ldflags = cros_target_extra_ldflags |
| 47 |
| 48 # These are passed through as toolchain_args. |
| 49 cc_wrapper = "" |
| 50 is_clang = is_clang |
| 51 toolchain_cpu = target_cpu |
| 52 toolchain_os = "chromeos" |
| 53 |
| 54 use_debug_fission = use_debug_fission |
| 55 use_gold = use_gold |
| 56 use_sysroot = use_sysroot |
| 57 } |
| 58 } |
| 59 |
| 60 # This is the normal toolchain for most targets. |
| 61 cros_target_toolchain("target") { |
| 62 } |
| 63 |
| 64 # This is a special toolchain needed just for the nacl_bootstrap target in |
| 65 # //native_client/src/trusted/service_runtime/linux. It is identical |
| 66 # to ":target" except that it forces use_debug_fission, use_gold, and |
| 67 # use_sysroot off. |
| 68 cros_target_toolchain("nacl_bootstrap") { |
| 69 use_debug_fission = false |
| 70 use_gold = false |
| 71 use_sysroot = false |
112 } | 72 } |
113 | 73 |
114 gcc_toolchain("host") { | 74 gcc_toolchain("host") { |
115 # These are args for the template. | 75 # These are args for the template. |
116 ar = cros_host_ar | 76 ar = cros_host_ar |
117 cc = cros_host_cc | 77 cc = cros_host_cc |
118 cxx = cros_host_cxx | 78 cxx = cros_host_cxx |
119 ld = cxx | 79 ld = cxx |
120 if (cros_host_ld != "") { | 80 if (cros_host_ld != "") { |
121 ld = cros_host_ld | 81 ld = cros_host_ld |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 cc_wrapper = "" | 123 cc_wrapper = "" |
164 is_clang = cros_v8_snapshot_is_clang | 124 is_clang = cros_v8_snapshot_is_clang |
165 if (target_cpu == "x86" || target_cpu == "arm" || target_cpu == "mipsel") { | 125 if (target_cpu == "x86" || target_cpu == "arm" || target_cpu == "mipsel") { |
166 toolchain_cpu = "x86" | 126 toolchain_cpu = "x86" |
167 } else { | 127 } else { |
168 toolchain_cpu = "x64" | 128 toolchain_cpu = "x64" |
169 } | 129 } |
170 toolchain_os = "linux" | 130 toolchain_os = "linux" |
171 use_sysroot = false | 131 use_sysroot = false |
172 } | 132 } |
OLD | NEW |