OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 cc = "gcc" |
6 cxx = "g++" | 6 cxx = "g++" |
7 ar = "ar" | 7 ar = "ar" |
8 ld = cxx | 8 ld = cxx |
9 | 9 |
10 # Everything up to the toolchain args is an exact copy of the GCC version | 10 # The toolchains below all issue the same commands with some different flags. |
11 # below. Keep in sync! Only the compiler variable definitions have changed. | 11 # TODO(brettw) it would be nice to have a different way to express this without |
12 toolchain("host") { | 12 # so much duplication. |
| 13 cc_command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \
$in -o \$out" |
| 14 cxx_command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -
c \$in -o \$out" |
| 15 alink_command = "rm -f \$out && $ar rcs \$out \$in" |
| 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" |
| 17 link_command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end
-group \$libs" |
| 18 stamp_command = "\${postbuilds}touch \$out" |
| 19 copy_command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$o
ut)" |
| 20 |
| 21 # ARM -------------------------------------------------------------------------- |
| 22 |
| 23 cc = "arm-linux-gnueabi-gcc" |
| 24 cxx = "arm-linux-gnueabi-g++" |
| 25 ar = "arm-linux-gnueabi-ar" |
| 26 ld = cxx |
| 27 |
| 28 toolchain("arm") { |
13 # Make these apply to all tools below. | 29 # Make these apply to all tools below. |
14 lib_prefix = "-l" | 30 lib_prefix = "-l" |
15 lib_dir_prefix="-L" | 31 lib_dir_prefix="-L" |
16 | 32 |
17 tool("cc") { | 33 tool("cc") { |
18 # cflags_pch_c | 34 # cflags_pch_c |
19 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c
\$in -o \$out" | 35 command = cc_command |
20 description = "CC \$out" | 36 description = "CC \$out" |
21 depfile = "\$out.d" | 37 depfile = "\$out.d" |
22 deps = "gcc" | 38 deps = "gcc" |
23 } | 39 } |
24 tool("cxx") { | 40 tool("cxx") { |
25 # cflags_pch_cc | 41 # cflags_pch_cc |
26 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -
c \$in -o \$out" | 42 command = cxx_command |
27 description = "CXX \$out" | 43 description = "CXX \$out" |
28 depfile = "\$out.d" | 44 depfile = "\$out.d" |
29 deps = "gcc" | 45 deps = "gcc" |
30 } | 46 } |
31 tool("alink") { | 47 tool("alink") { |
32 command = "rm -f \$out && $ar rcs \$out \$in" | 48 command = alink_command |
33 description = "AR \$out" | 49 description = "AR \$out" |
34 } | 50 } |
35 tool("solink") { | 51 tool("solink") { |
36 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags
-o \$lib -Wl,-soname=\$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}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\
$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { rea
delf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${li
b}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ;
fi; fi" | 52 command = solink_command |
37 description = "SOLINK \$lib" | 53 description = "SOLINK \$lib" |
38 #pool = "link_pool" | 54 #pool = "link_pool" |
39 restat = "1" | 55 restat = "1" |
40 } | 56 } |
41 tool("link") { | 57 tool("link") { |
42 command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-
group \$libs" | 58 command = link_command |
43 description = "LINK \$out" | 59 description = "LINK \$out" |
44 #pool = "link_pool" | 60 #pool = "link_pool" |
45 } | 61 } |
46 tool("stamp") { | 62 tool("stamp") { |
47 command = "\${postbuilds}touch \$out" | 63 command = stamp_command |
48 description = "STAMP \$out" | 64 description = "STAMP \$out" |
49 } | 65 } |
50 tool("copy") { | 66 tool("copy") { |
51 command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$ou
t)" | 67 command = copy_command |
52 description = "COPY \$in \$out" | |
53 } | |
54 | |
55 # When invoking this toolchain not as the default one, these args will be | |
56 # passed to the build. They are ignored when this is the default toolchain. | |
57 toolchain_args() { | |
58 # Pass the current CPU architecture to the build as the toolchain to use. | |
59 # If the default toolchain is set to ARM and the local system is x86, this | |
60 # will make this secondary toolchain refer to the host GCC again. | |
61 cpu_arch = build_cpu_arch | |
62 } | |
63 } | |
64 | |
65 # ARM Cross-Compile ------------------------------------------------------------ | |
66 | |
67 cc = "arm-linux-gnueabi-gcc" | |
68 cxx = "arm-linux-gnueabi-g++" | |
69 ar = "arm-linux-gnueabi-ar" | |
70 ld = cxx | |
71 | |
72 # Everything up the the toolchain args is an exact copy of the GCC version | |
73 # below. Keep in sync! Only the compiler variable definitions have changed. | |
74 toolchain("arm-cross-compile") { | |
75 # Make these apply to all tools below. | |
76 lib_prefix = "-l" | |
77 lib_dir_prefix="-L" | |
78 | |
79 tool("cc") { | |
80 # cflags_pch_c | |
81 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c
\$in -o \$out" | |
82 description = "CC \$out" | |
83 depfile = "\$out.d" | |
84 deps = "gcc" | |
85 } | |
86 tool("cxx") { | |
87 # cflags_pch_cc | |
88 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -
c \$in -o \$out" | |
89 description = "CXX \$out" | |
90 depfile = "\$out.d" | |
91 deps = "gcc" | |
92 } | |
93 tool("alink") { | |
94 command = "rm -f \$out && $ar rcs \$out \$in" | |
95 description = "AR \$out" | |
96 } | |
97 tool("solink") { | |
98 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags
-o \$lib -Wl,-soname=\$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}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\
$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { rea
delf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${li
b}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ;
fi; fi" | |
99 description = "SOLINK \$lib" | |
100 #pool = "link_pool" | |
101 restat = "1" | |
102 } | |
103 tool("link") { | |
104 command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-
group \$libs" | |
105 description = "LINK \$out" | |
106 #pool = "link_pool" | |
107 } | |
108 tool("stamp") { | |
109 command = "\${postbuilds}touch \$out" | |
110 description = "STAMP \$out" | |
111 } | |
112 tool("copy") { | |
113 command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$ou
t)" | |
114 description = "COPY \$in \$out" | 68 description = "COPY \$in \$out" |
115 } | 69 } |
116 | 70 |
117 # When invoking this toolchain not as the default one, these args will be | 71 # When invoking this toolchain not as the default one, these args will be |
118 # passed to the build. They are ignored when this is the default toolchain. | 72 # passed to the build. They are ignored when this is the default toolchain. |
119 toolchain_args() { | 73 toolchain_args() { |
120 cpu_arch = "arm" | 74 cpu_arch = "arm" |
121 } | 75 } |
122 } | 76 } |
| 77 |
| 78 # 32-bit ----------------------------------------------------------------------- |
| 79 |
| 80 toolchain("32") { |
| 81 # Make these apply to all tools below. |
| 82 lib_prefix = "-l" |
| 83 lib_dir_prefix="-L" |
| 84 |
| 85 tool("cc") { |
| 86 # cflags_pch_c |
| 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 = "x32" |
| 127 } |
| 128 } |
| 129 |
| 130 # 64-bit ----------------------------------------------------------------------- |
| 131 |
| 132 toolchain("64") { |
| 133 # Make these apply to all tools below. |
| 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 } |
OLD | NEW |