Chromium Code Reviews| 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 # This template defines a GCC toolchain. | 5 # This template defines a GCC toolchain. |
| 6 # | 6 # |
| 7 # It requires the following variables specifying the executables to run: | 7 # It requires the following variables specifying the executables to run: |
| 8 # - cc | 8 # - cc |
| 9 # - cxx | 9 # - cxx |
| 10 # - ar | 10 # - ar |
| 11 # - ld | 11 # - ld |
| 12 # and the following which is used in the toolchain_args | 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 | 13 # - toolchain_cpu_arch (What "cpu_arch" should be set to when invoking a |
| 14 # build using this toolchain.) | 14 # build using this toolchain.) |
| 15 # - toolchain_os (What "os" should be set to when invoking a build using this | 15 # - toolchain_os (What "os" should be set to when invoking a build using this |
| 16 # toolchain.) | 16 # toolchain.) |
| 17 # | |
| 18 # Optional parameters: | |
| 19 # - libs_section_prefix | |
| 20 # - libs_section_postfix | |
| 21 # The contents of these strings, if specified, will be placed around | |
| 22 # the libs section of the linker line. It allows one to inject libraries | |
| 23 # at the beginning and end for all targets in a toolchain. | |
| 17 template("gcc_toolchain") { | 24 template("gcc_toolchain") { |
| 18 toolchain(target_name) { | 25 toolchain(target_name) { |
| 19 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") | 26 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") |
| 20 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") | 27 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") |
| 21 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") | 28 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") |
| 22 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") | 29 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") |
| 23 assert(defined(invoker.toolchain_cpu_arch), | 30 assert(defined(invoker.toolchain_cpu_arch), |
| 24 "gcc_toolchain() must specify a \"toolchain_cpu_arch\"") | 31 "gcc_toolchain() must specify a \"toolchain_cpu_arch\"") |
| 25 assert(defined(invoker.toolchain_os), | 32 assert(defined(invoker.toolchain_os), |
| 26 "gcc_toolchain() must specify a \"toolchain_os\"") | 33 "gcc_toolchain() must specify a \"toolchain_os\"") |
| 27 | 34 |
| 28 # We can't do string interpolation ($ in strings) on things with dots in | 35 # 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 | 36 # them. To allow us to use $cc below, for example, we create copies of |
| 30 # these values in our scope. | 37 # these values in our scope. |
| 31 cc = invoker.cc | 38 cc = invoker.cc |
| 32 cxx = invoker.cxx | 39 cxx = invoker.cxx |
| 33 ar = invoker.ar | 40 ar = invoker.ar |
| 34 ld = invoker.ld | 41 ld = invoker.ld |
| 35 | 42 |
| 43 # Bring these into our scope for string interpolation with default values. | |
|
awong
2014/05/12 19:23:02
I think we should experiment with default libs. W
brettw
2014/05/12 21:00:08
Sorry, but I am totally not touching this with a 1
cjhopman
2014/05/12 21:04:19
Maybe we should try to do this with the gyp build
awong
2014/05/12 21:34:23
Okay. I'll take this.
| |
| 44 if (defined(invoker.libs_section_prefix)) { | |
| 45 libs_section_prefix = invoker.libs_section_prefix | |
| 46 } else { | |
| 47 libs_section_prefix = "" | |
| 48 } | |
| 49 | |
| 50 if (defined(invoker.libs_section_postfix)) { | |
| 51 libs_section_postfix = invoker.libs_section_postfix | |
| 52 } else { | |
| 53 libs_section_postfix = "" | |
| 54 } | |
| 55 | |
| 36 # Make these apply to all tools below. | 56 # Make these apply to all tools below. |
| 37 lib_prefix = "-l" | 57 lib_prefix = "-l" |
| 38 lib_dir_prefix="-L" | 58 lib_dir_prefix="-L" |
| 39 | 59 |
| 40 tool("cc") { | 60 tool("cc") { |
| 41 # cflags_pch_c | 61 # cflags_pch_c |
| 42 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c - c \$in -o \$out" | 62 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c - c \$in -o \$out" |
| 43 description = "CC \$out" | 63 description = "CC \$out" |
| 44 depfile = "\$out.d" | 64 depfile = "\$out.d" |
| 45 deps = "gcc" | 65 deps = "gcc" |
| 46 } | 66 } |
| 47 tool("cxx") { | 67 tool("cxx") { |
| 48 # cflags_pch_cc | 68 # cflags_pch_cc |
| 49 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" | 69 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" |
| 50 description = "CXX \$out" | 70 description = "CXX \$out" |
| 51 depfile = "\$out.d" | 71 depfile = "\$out.d" |
| 52 deps = "gcc" | 72 deps = "gcc" |
| 53 } | 73 } |
| 54 tool("alink") { | 74 tool("alink") { |
| 55 command = "rm -f \$out && $ar rcs \$out \$in" | 75 command = "rm -f \$out && $ar rcs \$out \$in" |
| 56 description = "AR \$out" | 76 description = "AR \$out" |
| 57 } | 77 } |
| 58 tool("solink") { | 78 tool("solink") { |
| 59 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldfla gs -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whol e-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | c ut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname =\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { r eadelf -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" | 79 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldfla gs -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whol e-archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | c ut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname =\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive $libs_section _prefix \$libs $libs_section_postfix && { 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" | 80 description = "SOLINK \$lib" |
| 61 #pool = "link_pool" | 81 #pool = "link_pool" |
| 62 restat = "1" | 82 restat = "1" |
| 63 } | 83 } |
| 64 tool("link") { | 84 tool("link") { |
| 65 command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--en d-group \$libs" | 85 command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--en d-group $libs_section_prefix \$libs $libs_section_postfix" |
| 66 description = "LINK \$out" | 86 description = "LINK \$out" |
| 67 #pool = "link_pool" | 87 #pool = "link_pool" |
| 68 } | 88 } |
| 69 tool("stamp") { | 89 tool("stamp") { |
| 70 command = "\${postbuilds}touch \$out" | 90 command = "\${postbuilds}touch \$out" |
| 71 description = "STAMP \$out" | 91 description = "STAMP \$out" |
| 72 } | 92 } |
| 73 tool("copy") { | 93 tool("copy") { |
| 74 command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$ out)" | 94 command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$ out)" |
| 75 description = "COPY \$in \$out" | 95 description = "COPY \$in \$out" |
| 76 } | 96 } |
| 77 | 97 |
| 78 # When invoking this toolchain not as the default one, these args will be | 98 # 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. | 99 # passed to the build. They are ignored when this is the default toolchain. |
| 80 toolchain_args() { | 100 toolchain_args() { |
| 81 cpu_arch = invoker.toolchain_cpu_arch | 101 cpu_arch = invoker.toolchain_cpu_arch |
| 82 os = invoker.toolchain_os | 102 os = invoker.toolchain_os |
| 83 } | 103 } |
| 84 } | 104 } |
| 85 } | 105 } |
| OLD | NEW |