| 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 value will be inherited in the toolchain below. | 5 # This value will be inherited in the toolchain below. |
| 6 concurrent_links = exec_script("get_concurrent_links.py", [], "value") | 6 concurrent_links = exec_script("get_concurrent_links.py", [], "value") |
| 7 | 7 |
| 8 # This template defines a toolchain for something that works like gcc | 8 # This template defines a toolchain for something that works like gcc |
| 9 # (including clang). | 9 # (including clang). |
| 10 # | 10 # |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } else { | 77 } else { |
| 78 solink_libs_section_postfix = "" | 78 solink_libs_section_postfix = "" |
| 79 } | 79 } |
| 80 | 80 |
| 81 # These library switches can apply to all tools below. | 81 # These library switches can apply to all tools below. |
| 82 lib_switch = "-l" | 82 lib_switch = "-l" |
| 83 lib_dir_switch = "-L" | 83 lib_dir_switch = "-L" |
| 84 | 84 |
| 85 tool("cc") { | 85 tool("cc") { |
| 86 depfile = "{{output}}.d" | 86 depfile = "{{output}}.d" |
| 87 command = | 87 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {
{cflags_c}} -c {{source}} -o {{output}}" |
| 88 "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflag
s_c}} -c {{source}} -o {{output}}" | |
| 89 depsformat = "gcc" | 88 depsformat = "gcc" |
| 90 description = "CC {{output}}" | 89 description = "CC {{output}}" |
| 91 outputs = | 90 outputs = [ |
| 92 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] | 91 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 92 ] |
| 93 } | 93 } |
| 94 | 94 |
| 95 tool("cxx") { | 95 tool("cxx") { |
| 96 depfile = "{{output}}.d" | 96 depfile = "{{output}}.d" |
| 97 command = | 97 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}}
{{cflags_cc}} -c {{source}} -o {{output}}" |
| 98 "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cfla
gs_cc}} -c {{source}} -o {{output}}" | |
| 99 depsformat = "gcc" | 98 depsformat = "gcc" |
| 100 description = "CXX {{output}}" | 99 description = "CXX {{output}}" |
| 101 outputs = | 100 outputs = [ |
| 102 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] | 101 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 102 ] |
| 103 } | 103 } |
| 104 | 104 |
| 105 tool("asm") { | 105 tool("asm") { |
| 106 # For GCC we can just use the C compiler to compile assembly. | 106 # For GCC we can just use the C compiler to compile assembly. |
| 107 depfile = "{{output}}.d" | 107 depfile = "{{output}}.d" |
| 108 command = | 108 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {
{cflags_c}} -c {{source}} -o {{output}}" |
| 109 "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflag
s_c}} -c {{source}} -o {{output}}" | |
| 110 depsformat = "gcc" | 109 depsformat = "gcc" |
| 111 description = "ASM {{output}}" | 110 description = "ASM {{output}}" |
| 112 outputs = | 111 outputs = [ |
| 113 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] | 112 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 113 ] |
| 114 } | 114 } |
| 115 | 115 |
| 116 tool("alink") { | 116 tool("alink") { |
| 117 rspfile = "{{output}}.rsp" | 117 rspfile = "{{output}}.rsp" |
| 118 command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" | 118 command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" |
| 119 description = "AR {{output}}" | 119 description = "AR {{output}}" |
| 120 rspfile_content = "{{inputs}}" | 120 rspfile_content = "{{inputs}}" |
| 121 outputs = | 121 outputs = [ |
| 122 [ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ] | 122 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 123 ] |
| 123 default_output_extension = ".a" | 124 default_output_extension = ".a" |
| 124 output_prefix = "lib" | 125 output_prefix = "lib" |
| 125 } | 126 } |
| 126 | 127 |
| 127 tool("solink") { | 128 tool("solink") { |
| 128 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". | 129 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". |
| 129 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. | 130 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. |
| 130 rspfile = sofile + ".rsp" | 131 rspfile = sofile + ".rsp" |
| 131 | 132 |
| 132 # These variables are not built into GN but are helpers that implement | 133 # These variables are not built into GN but are helpers that implement |
| 133 # (1) linking to produce a .so, (2) extracting the symbols from that file | 134 # (1) linking to produce a .so, (2) extracting the symbols from that file |
| 134 # to a temporary file, (3) if the temporary file has differences from the | 135 # to a temporary file, (3) if the temporary file has differences from the |
| 135 # existing .TOC file, overwrite it, otherwise, don't change it. | 136 # existing .TOC file, overwrite it, otherwise, don't change it. |
| 136 tocfile = sofile + ".TOC" | 137 tocfile = sofile + ".TOC" |
| 137 temporary_tocname = sofile + ".tmp" | 138 temporary_tocname = sofile + ".tmp" |
| 138 link_command = | 139 link_command = |
| 139 "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile" | 140 "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile" |
| 140 toc_command = | 141 toc_command = "{ readelf -d $sofile | grep SONAME ; nm -gD -f p $soname |
cut -f1-2 -d' '; } > $temporary_tocname" |
| 141 "{ readelf -d $sofile | grep SONAME ; nm -gD -f p $soname | cut -f1-2
-d' '; } > $temporary_tocname" | 142 replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $tempo
rary_tocname $tocfile; fi" |
| 142 replace_command = | |
| 143 "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $
tocfile; fi" | |
| 144 | 143 |
| 145 command = "$link_command && $toc_command && $replace_command" | 144 command = "$link_command && $toc_command && $replace_command" |
| 146 if (defined(invoker.postsolink)) { | 145 if (defined(invoker.postsolink)) { |
| 147 command += " && " + invoker.postsolink | 146 command += " && " + invoker.postsolink |
| 148 } | 147 } |
| 149 rspfile_content = | 148 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol
e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" |
| 150 "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $sol
ink_libs_section_prefix {{libs}} $solink_libs_section_postfix" | |
| 151 | 149 |
| 152 description = "SOLINK $sofile" | 150 description = "SOLINK $sofile" |
| 153 | 151 |
| 154 # Use this for {{output_extension}} expansions unless a target manually | 152 # Use this for {{output_extension}} expansions unless a target manually |
| 155 # overrides it (in which case {{output_extension}} will be what the target | 153 # overrides it (in which case {{output_extension}} will be what the target |
| 156 # specifies). | 154 # specifies). |
| 157 default_output_extension = ".so" | 155 default_output_extension = ".so" |
| 158 | 156 |
| 159 output_prefix = "lib" | 157 output_prefix = "lib" |
| 160 | 158 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 172 if (defined(invoker.solink_outputs)) { | 170 if (defined(invoker.solink_outputs)) { |
| 173 outputs += invoker.solink_outputs | 171 outputs += invoker.solink_outputs |
| 174 } | 172 } |
| 175 link_output = sofile | 173 link_output = sofile |
| 176 depend_output = tocfile | 174 depend_output = tocfile |
| 177 } | 175 } |
| 178 | 176 |
| 179 tool("link") { | 177 tool("link") { |
| 180 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" | 178 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 181 rspfile = "$outfile.rsp" | 179 rspfile = "$outfile.rsp" |
| 182 command = | 180 command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solib
s}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" |
| 183 "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -W
l,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" | |
| 184 if (defined(invoker.postlink)) { | 181 if (defined(invoker.postlink)) { |
| 185 command += " && " + invoker.postlink | 182 command += " && " + invoker.postlink |
| 186 } | 183 } |
| 187 description = "LINK $outfile" | 184 description = "LINK $outfile" |
| 188 rspfile_content = "{{inputs}}" | 185 rspfile_content = "{{inputs}}" |
| 189 outputs = [ outfile ] | 186 outputs = [ |
| 187 outfile, |
| 188 ] |
| 190 if (defined(invoker.link_outputs)) { | 189 if (defined(invoker.link_outputs)) { |
| 191 outputs += invoker.link_outputs | 190 outputs += invoker.link_outputs |
| 192 } | 191 } |
| 193 } | 192 } |
| 194 | 193 |
| 195 tool("stamp") { | 194 tool("stamp") { |
| 196 command = "touch {{output}}" | 195 command = "touch {{output}}" |
| 197 description = "STAMP {{output}}" | 196 description = "STAMP {{output}}" |
| 198 } | 197 } |
| 199 | 198 |
| 200 tool("copy") { | 199 tool("copy") { |
| 201 command = | 200 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} &
& cp -af {{source}} {{output}})" |
| 202 "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -
af {{source}} {{output}})" | |
| 203 description = "COPY {{source}} {{output}}" | 201 description = "COPY {{source}} {{output}}" |
| 204 } | 202 } |
| 205 | 203 |
| 206 # When invoking this toolchain not as the default one, these args will be | 204 # When invoking this toolchain not as the default one, these args will be |
| 207 # passed to the build. They are ignored when this is the default toolchain. | 205 # passed to the build. They are ignored when this is the default toolchain. |
| 208 toolchain_args() { | 206 toolchain_args() { |
| 209 cpu_arch = invoker.toolchain_cpu_arch | 207 cpu_arch = invoker.toolchain_cpu_arch |
| 210 os = invoker.toolchain_os | 208 os = invoker.toolchain_os |
| 211 if (defined(invoker.is_clang)) { | 209 if (defined(invoker.is_clang)) { |
| 212 is_clang = invoker.is_clang | 210 is_clang = invoker.is_clang |
| 213 } | 211 } |
| 214 } | 212 } |
| 215 | 213 |
| 216 if (defined(invoker.deps)) { | 214 if (defined(invoker.deps)) { |
| 217 deps = invoker.deps | 215 deps = invoker.deps |
| 218 } | 216 } |
| 219 } | 217 } |
| 220 } | 218 } |
| OLD | NEW |