| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 cc = "gcc" | 5 import("../clang.gni") |
| 6 cxx = "g++" | 6 import("../goma.gni") |
| 7 ar = "ar" | 7 import("../gcc_toolchain.gni") |
| 8 ld = cxx | |
| 9 | 8 |
| 10 # The toolchains below all issue the same commands with some different flags. | 9 if (is_gyp) { |
| 11 # TODO(brettw) it would be nice to have a different way to express this without | 10 # Set the compilers for GYP to use. This logic is only relevant to GYP where |
| 12 # so much duplication. | 11 # there is "a" target compiler. In native GN builds, we have separate |
| 13 cc_command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \
$in -o \$out" | 12 # compilers for the toolchains below, any or all of which could be active in |
| 14 cxx_command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -
c \$in -o \$out" | 13 # any given build. |
| 15 alink_command = "rm -f \$out && $ar rcs \$out \$in" | 14 if (is_clang) { |
| 16 solink_command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldfl
ags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-who
le-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} |
cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-sonam
e=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && {
readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \$
{lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TO
C ; fi; fi" | 15 # Set the GYP header for all toolchains when running under Clang. |
| 17 link_command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end
-group \$libs" | 16 gyp_header = make_clang_global_settings |
| 18 stamp_command = "\${postbuilds}touch \$out" | 17 } else { |
| 19 copy_command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$o
ut)" | 18 gyp_header = "" |
| 19 } |
| 20 |
| 21 if (use_goma) { |
| 22 # There is a TODO(yyanagisawa) in common.gypi about the make generator not |
| 23 # supporting CC_wrapper without CC. As a result, we must add a condition |
| 24 # when on the generator when we're not explicitly setting the variables |
| 25 # above (which happens when gyp_header is empty at this point). |
| 26 # |
| 27 # GYP will interpret the file once for each generator, so we have to write |
| 28 # this condition into the GYP file since the user could have more than one |
| 29 # generator set. |
| 30 if (gyp_header == "") { |
| 31 gyp_header += |
| 32 "'conditions':" + |
| 33 "['\"<(GENERATOR)\"==\"ninja\"', {" + |
| 34 make_goma_global_settings + |
| 35 "}]," |
| 36 } else { |
| 37 gyp_header += make_goma_global_settings |
| 38 } |
| 39 } |
| 40 } |
| 20 | 41 |
| 21 # ARM -------------------------------------------------------------------------- | 42 # ARM -------------------------------------------------------------------------- |
| 22 | 43 |
| 23 cc = "arm-linux-gnueabi-gcc" | 44 gcc_toolchain("arm") { |
| 24 cxx = "arm-linux-gnueabi-g++" | 45 cc = "arm-linux-gnueabi-gcc" |
| 25 ar = "arm-linux-gnueabi-ar" | 46 cxx = "arm-linux-gnueabi-g++" |
| 26 ld = cxx | 47 ar = "arm-linux-gnueabi-ar" |
| 48 ld = cxx |
| 27 | 49 |
| 28 toolchain("arm") { | 50 toolchain_cpu_arch = "arm" |
| 29 # Make these apply to all tools below. | 51 toolchain_os = "linux" |
| 30 lib_prefix = "-l" | |
| 31 lib_dir_prefix="-L" | |
| 32 | |
| 33 tool("cc") { | |
| 34 # cflags_pch_c | |
| 35 command = cc_command | |
| 36 description = "CC \$out" | |
| 37 depfile = "\$out.d" | |
| 38 deps = "gcc" | |
| 39 } | |
| 40 tool("cxx") { | |
| 41 # cflags_pch_cc | |
| 42 command = cxx_command | |
| 43 description = "CXX \$out" | |
| 44 depfile = "\$out.d" | |
| 45 deps = "gcc" | |
| 46 } | |
| 47 tool("alink") { | |
| 48 command = alink_command | |
| 49 description = "AR \$out" | |
| 50 } | |
| 51 tool("solink") { | |
| 52 command = solink_command | |
| 53 description = "SOLINK \$lib" | |
| 54 #pool = "link_pool" | |
| 55 restat = "1" | |
| 56 } | |
| 57 tool("link") { | |
| 58 command = link_command | |
| 59 description = "LINK \$out" | |
| 60 #pool = "link_pool" | |
| 61 } | |
| 62 tool("stamp") { | |
| 63 command = stamp_command | |
| 64 description = "STAMP \$out" | |
| 65 } | |
| 66 tool("copy") { | |
| 67 command = copy_command | |
| 68 description = "COPY \$in \$out" | |
| 69 } | |
| 70 | |
| 71 # When invoking this toolchain not as the default one, these args will be | |
| 72 # passed to the build. They are ignored when this is the default toolchain. | |
| 73 toolchain_args() { | |
| 74 cpu_arch = "arm" | |
| 75 } | |
| 76 } | 52 } |
| 77 | 53 |
| 78 # 32-bit ----------------------------------------------------------------------- | 54 # 32-bit ----------------------------------------------------------------------- |
| 79 | 55 |
| 80 toolchain("32") { | 56 gcc_toolchain("x86") { |
| 81 # Make these apply to all tools below. | 57 cc = "gcc" |
| 82 lib_prefix = "-l" | 58 cxx = "g++" |
| 83 lib_dir_prefix="-L" | 59 ar = "ar" |
| 60 ld = cxx |
| 84 | 61 |
| 85 tool("cc") { | 62 toolchain_cpu_arch = "x86" |
| 86 # cflags_pch_c | 63 toolchain_os = "linux" |
| 87 command = cc_command | |
| 88 description = "CC \$out" | |
| 89 depfile = "\$out.d" | |
| 90 deps = "gcc" | |
| 91 } | |
| 92 tool("cxx") { | |
| 93 # cflags_pch_cc | |
| 94 command = cxx_command | |
| 95 description = "CXX \$out" | |
| 96 depfile = "\$out.d" | |
| 97 deps = "gcc" | |
| 98 } | |
| 99 tool("alink") { | |
| 100 command = alink_command | |
| 101 description = "AR \$out" | |
| 102 } | |
| 103 tool("solink") { | |
| 104 command = solink_command | |
| 105 description = "SOLINK \$lib" | |
| 106 #pool = "link_pool" | |
| 107 restat = "1" | |
| 108 } | |
| 109 tool("link") { | |
| 110 command = link_command | |
| 111 description = "LINK \$out" | |
| 112 #pool = "link_pool" | |
| 113 } | |
| 114 tool("stamp") { | |
| 115 command = stamp_command | |
| 116 description = "STAMP \$out" | |
| 117 } | |
| 118 tool("copy") { | |
| 119 command = copy_command | |
| 120 description = "COPY \$in \$out" | |
| 121 } | |
| 122 | |
| 123 # When invoking this toolchain not as the default one, these args will be | |
| 124 # passed to the build. They are ignored when this is the default toolchain. | |
| 125 toolchain_args() { | |
| 126 cpu_arch = "x86" | |
| 127 } | |
| 128 } | 64 } |
| 129 | 65 |
| 130 # 64-bit ----------------------------------------------------------------------- | 66 gcc_toolchain("x64") { |
| 67 cc = "gcc" |
| 68 cxx = "g++" |
| 69 ar = "ar" |
| 70 ld = cxx |
| 131 | 71 |
| 132 toolchain("64") { | 72 toolchain_cpu_arch = "x64" |
| 133 # Make these apply to all tools below. | 73 toolchain_os = "linux" |
| 134 lib_prefix = "-l" | |
| 135 lib_dir_prefix="-L" | |
| 136 | |
| 137 tool("cc") { | |
| 138 # cflags_pch_c | |
| 139 command = cc_command | |
| 140 description = "CC \$out" | |
| 141 depfile = "\$out.d" | |
| 142 deps = "gcc" | |
| 143 } | |
| 144 tool("cxx") { | |
| 145 # cflags_pch_cc | |
| 146 command = cxx_command | |
| 147 description = "CXX \$out" | |
| 148 depfile = "\$out.d" | |
| 149 deps = "gcc" | |
| 150 } | |
| 151 tool("alink") { | |
| 152 command = alink_command | |
| 153 description = "AR \$out" | |
| 154 } | |
| 155 tool("solink") { | |
| 156 command = solink_command | |
| 157 description = "SOLINK \$lib" | |
| 158 #pool = "link_pool" | |
| 159 restat = "1" | |
| 160 } | |
| 161 tool("link") { | |
| 162 command = link_command | |
| 163 description = "LINK \$out" | |
| 164 #pool = "link_pool" | |
| 165 } | |
| 166 tool("stamp") { | |
| 167 command = stamp_command | |
| 168 description = "STAMP \$out" | |
| 169 } | |
| 170 tool("copy") { | |
| 171 command = copy_command | |
| 172 description = "COPY \$in \$out" | |
| 173 } | |
| 174 | |
| 175 # When invoking this toolchain not as the default one, these args will be | |
| 176 # passed to the build. They are ignored when this is the default toolchain. | |
| 177 toolchain_args() { | |
| 178 cpu_arch = "x64" | |
| 179 } | |
| 180 } | 74 } |
| OLD | NEW |