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 toolchain for something that works like gcc | 5 # This template defines a toolchain for something that works like gcc |
| 6 # (including clang). | 6 # (including clang). |
| 7 # | 7 # |
| 8 # It requires the following variables specifying the executables to run: | 8 # It requires the following variables specifying the executables to run: |
| 9 # - cc | 9 # - cc |
| 10 # - cxx | 10 # - cxx |
| 11 # - ar | 11 # - ar |
| 12 # - ld | 12 # - ld |
| 13 # and the following which is used in the toolchain_args | 13 # and the following which is used in the toolchain_args |
| 14 # - toolchain_cpu_arch (What "cpu_arch" should be set to when invoking a | 14 # - toolchain_cpu_arch (What "cpu_arch" should be set to when invoking a |
| 15 # build using this toolchain.) | 15 # build using this toolchain.) |
| 16 # - toolchain_os (What "os" should be set to when invoking a build using this | 16 # - toolchain_os (What "os" should be set to when invoking a build using this |
| 17 # toolchain.) | 17 # toolchain.) |
| 18 # | 18 # |
| 19 # Optional parameters: | 19 # Optional parameters: |
| 20 # - libs_section_prefix | 20 # - libs_section_prefix |
| 21 # - libs_section_postfix | 21 # - libs_section_postfix |
| 22 # The contents of these strings, if specified, will be placed around | 22 # The contents of these strings, if specified, will be placed around |
| 23 # the libs section of the linker line. It allows one to inject libraries | 23 # the libs section of the linker line. It allows one to inject libraries |
| 24 # at the beginning and end for all targets in a toolchain. | 24 # at the beginning and end for all targets in a toolchain. |
| 25 # - solink_libs_section_prefix | |
| 26 # - solink_libs_section_postfix | |
| 27 # Same as libs_section_{pre,post}fix except used for solink instead of link . | |
| 25 # - deps | 28 # - deps |
| 26 # Just fowarded to the toolchain definition. | 29 # Just fowarded to the toolchain definition. |
| 27 # - is_clang | 30 # - is_clang |
| 28 template("gcc_toolchain") { | 31 template("gcc_toolchain") { |
| 29 toolchain(target_name) { | 32 toolchain(target_name) { |
| 30 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") | 33 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") |
| 31 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") | 34 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") |
| 32 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") | 35 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") |
| 33 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") | 36 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") |
| 34 assert(defined(invoker.toolchain_cpu_arch), | 37 assert(defined(invoker.toolchain_cpu_arch), |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 50 } else { | 53 } else { |
| 51 libs_section_prefix = "" | 54 libs_section_prefix = "" |
| 52 } | 55 } |
| 53 | 56 |
| 54 if (defined(invoker.libs_section_postfix)) { | 57 if (defined(invoker.libs_section_postfix)) { |
| 55 libs_section_postfix = invoker.libs_section_postfix | 58 libs_section_postfix = invoker.libs_section_postfix |
| 56 } else { | 59 } else { |
| 57 libs_section_postfix = "" | 60 libs_section_postfix = "" |
| 58 } | 61 } |
| 59 | 62 |
| 63 if (defined(invoker.solink_libs_section_prefix)) { | |
| 64 solink_libs_section_prefix = invoker.solink_libs_section_prefix | |
| 65 } else { | |
| 66 solink_libs_section_prefix = "" | |
| 67 } | |
| 68 | |
| 69 if (defined(invoker.solink_libs_section_postfix)) { | |
| 70 solink_libs_section_postfix = invoker.solink_libs_section_postfix | |
| 71 } else { | |
| 72 solink_libs_section_postfix = "" | |
| 73 } | |
| 74 | |
| 60 # Make these apply to all tools below. | 75 # Make these apply to all tools below. |
| 61 lib_prefix = "-l" | 76 lib_prefix = "-l" |
| 62 lib_dir_prefix="-L" | 77 lib_dir_prefix="-L" |
| 63 | 78 |
| 64 tool("cc") { | 79 tool("cc") { |
| 65 # cflags_pch_c | 80 # cflags_pch_c |
| 66 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c - c \$in -o \$out" | 81 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c - c \$in -o \$out" |
| 67 description = "CC \$out" | 82 description = "CC \$out" |
| 68 depfile = "\$out.d" | 83 depfile = "\$out.d" |
| 69 depsformat = "gcc" | 84 depsformat = "gcc" |
| 70 } | 85 } |
| 71 tool("cxx") { | 86 tool("cxx") { |
| 72 # cflags_pch_cc | 87 # cflags_pch_cc |
| 73 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" | 88 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -c \$in -o \$out" |
| 74 description = "CXX \$out" | 89 description = "CXX \$out" |
| 75 depfile = "\$out.d" | 90 depfile = "\$out.d" |
| 76 depsformat = "gcc" | 91 depsformat = "gcc" |
| 77 } | 92 } |
| 78 tool("alink") { | 93 tool("alink") { |
| 79 command = "rm -f \$out && $ar rcs \$out @\$rspfile" | 94 command = "rm -f \$out && $ar rcs \$out @\$rspfile" |
| 80 description = "AR \$out" | 95 description = "AR \$out" |
| 81 rspfile = "\$out.rsp" | 96 rspfile = "\$out.rsp" |
| 82 rspfile_content = "\$in" | 97 rspfile_content = "\$in" |
| 83 } | 98 } |
| 84 tool("solink") { | 99 tool("solink") { |
| 85 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldfla gs -o \$lib -Wl,-soname=\$soname @\$rspfile && { readelf -d \${lib} | grep SONAM E ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$l dflags -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" | 100 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldfla gs -o \$lib -Wl,-soname=\$soname @\$rspfile && { readelf -d \${lib} | grep SONAM E ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$l dflags -o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no- whole-archive $solink_libs_section_prefix \$libs $solink_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" |
|
jamesr
2014/07/28 19:34:45
i'm not sure i understand the difference between t
| |
| 86 description = "SOLINK \$lib" | 101 description = "SOLINK \$lib" |
| 87 rspfile = "\$out.rsp" | 102 rspfile = "\$out.rsp" |
| 88 rspfile_content = "-Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archiv e \$libs" | 103 rspfile_content = "-Wl,--whole-archive \$in $solink_libs_section_prefix \$ solibs $solink_libs_section_postfix -Wl,--no-whole-archive \$libs" |
| 89 #pool = "link_pool" | 104 #pool = "link_pool" |
| 90 restat = "1" | 105 restat = "1" |
| 91 } | 106 } |
| 92 tool("link") { | 107 tool("link") { |
| 93 command = "$ld \$ldflags -o \$out -Wl,--start-group @\$rspfile \$solibs -W l,--end-group $libs_section_prefix \$libs $libs_section_postfix" | 108 command = "$ld \$ldflags -o \$out -Wl,--start-group @\$rspfile \$solibs -W l,--end-group $libs_section_prefix \$libs $libs_section_postfix" |
| 94 description = "LINK \$out" | 109 description = "LINK \$out" |
| 95 rspfile = "\$out.rsp" | 110 rspfile = "\$out.rsp" |
| 96 rspfile_content = "\$in" | 111 rspfile_content = "\$in" |
| 97 #pool = "link_pool" | 112 #pool = "link_pool" |
| 98 } | 113 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 113 if (defined(invoker.is_clang)) { | 128 if (defined(invoker.is_clang)) { |
| 114 is_clang = invoker.is_clang | 129 is_clang = invoker.is_clang |
| 115 } | 130 } |
| 116 } | 131 } |
| 117 | 132 |
| 118 if (defined(invoker.deps)) { | 133 if (defined(invoker.deps)) { |
| 119 deps = invoker.deps | 134 deps = invoker.deps |
| 120 } | 135 } |
| 121 } | 136 } |
| 122 } | 137 } |
| OLD | NEW |