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
3 # found in the LICENSE file.
5 # This template defines a GCC toolchain.
7 # It requires the following variables specifying the executables to run:
12 # and the following which is used in the toolchain_args
13 # - toolchain_cpu_arch (What "cpu_arch" should be set to when invoking a
14 # build using this toolchain.)
15 # - toolchain_os (What "os" should be set to when invoking a build using this
17 template("gcc_toolchain") {
18 toolchain(target_name) {
19 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
20 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value")
21 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value")
22 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value")
23 assert(defined(invoker.toolchain_cpu_arch),
24 "gcc_toolchain() must specify a \"toolchain_cpu_arch\"")
25 assert(defined(invoker.toolchain_os),
26 "gcc_toolchain() must specify a \"toolchain_os\"")
28 # We can't do string interpolation ($ in strings) on things with dots in
29 # them. To allow us to use $cc below, for example, we create copies of
30 # these values in our scope.
36 # Make these apply to all tools below.
42 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c \$in -o \$out"
43 description = "CC \$out"
49 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out"
50 description = "CXX \$out"
55 command = "rm -f \$out && $ar rcs \$out \$in"
56 description = "AR \$out"
59 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 && { 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}.TOC ; fi; fi"
60 description = "SOLINK \$lib"
65 command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-group \$libs"
66 description = "LINK \$out"
70 command = "\${postbuilds}touch \$out"
71 description = "STAMP \$out"
74 command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)"
75 description = "COPY \$in \$out"
78 # When invoking this toolchain not as the default one, these args will be
79 # passed to the build. They are ignored when this is the default toolchain.
81 cpu_arch = invoker.toolchain_cpu_arch
82 os = invoker.toolchain_os