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+sysroot_chromeos-base_chromeos-chrome.tar.xz" 32 # cros_target_cc = "x86_64-cros-linux-gnu-gcc -B/g/.cros_cache/chrome-sdk/tarballs/auron_paine+7657.0.0+target_toolchain/usr/x86_64-pc-linux-gnu/x86_64-cros-linux-gnu/binutils-bin/2.25.51-gold" 33 # cros_target_cxx = "x86_64-cros-linux-gnu-g++ -B/g/.cros_cache/chrome-sdk/tarballs/auron_paine+7657.0.0+target_toolchain/usr/x86_64-pc-linux-gnu/x86_64-cros-linux-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_cc = "" 40 cros_target_cxx = "" 41 cros_target_ar = "" 42 } 43 44 clang_toolchain("clang_target") { 45 toolchain_cpu = target_cpu 46 toolchain_os = "linux" 47 } 48 49 gcc_toolchain("target") { 50 # These defaults permit building on a Linux host as described above. 51 cc = "gcc" 52 cxx = "g++" 53 ar = "ar" 54 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 } 65 ld = cxx 66 67 toolchain_cpu = target_cpu 68 toolchain_os = "linux" 69 is_clang = is_clang 70 cc_wrapper = "" 71 } 72