Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(531)

Side by Side Diff: build/toolchain/gcc_toolchain.gni

Issue 766573003: gn format //build (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/toolchain/android/BUILD.gn ('k') | build/toolchain/mac/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}" 87 command =
88 "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflag s_c}} -c {{source}} -o {{output}}"
88 depsformat = "gcc" 89 depsformat = "gcc"
89 description = "CC {{output}}" 90 description = "CC {{output}}"
90 outputs = [ 91 outputs =
91 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", 92 [ "{{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 = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" 97 command =
98 "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cfla gs_cc}} -c {{source}} -o {{output}}"
98 depsformat = "gcc" 99 depsformat = "gcc"
99 description = "CXX {{output}}" 100 description = "CXX {{output}}"
100 outputs = [ 101 outputs =
101 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", 102 [ "{{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 = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}" 108 command =
109 "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflag s_c}} -c {{source}} -o {{output}}"
109 depsformat = "gcc" 110 depsformat = "gcc"
110 description = "ASM {{output}}" 111 description = "ASM {{output}}"
111 outputs = [ 112 outputs =
112 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", 113 [ "{{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 ]
124 default_output_extension = ".a" 123 default_output_extension = ".a"
125 output_prefix = "lib" 124 output_prefix = "lib"
126 } 125 }
127 126
128 tool("solink") { 127 tool("solink") {
129 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". 128 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
130 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir. 129 sofile = "{{root_out_dir}}/$soname" # Possibly including toolchain dir.
131 rspfile = sofile + ".rsp" 130 rspfile = sofile + ".rsp"
132 131
133 # These variables are not built into GN but are helpers that implement 132 # These variables are not built into GN but are helpers that implement
134 # (1) linking to produce a .so, (2) extracting the symbols from that file 133 # (1) linking to produce a .so, (2) extracting the symbols from that file
135 # to a temporary file, (3) if the temporary file has differences from the 134 # to a temporary file, (3) if the temporary file has differences from the
136 # existing .TOC file, overwrite it, otherwise, don't change it. 135 # existing .TOC file, overwrite it, otherwise, don't change it.
137 tocfile = sofile + ".TOC" 136 tocfile = sofile + ".TOC"
138 temporary_tocname = sofile + ".tmp" 137 temporary_tocname = sofile + ".tmp"
139 link_command = "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$r spfile" 138 link_command =
140 toc_command = "{ readelf -d $sofile | grep SONAME ; nm -gD -f p $soname | cut -f1-2 -d' '; } > $temporary_tocname" 139 "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile"
141 replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $tempo rary_tocname $tocfile; fi" 140 toc_command =
141 "{ readelf -d $sofile | grep SONAME ; nm -gD -f p $soname | cut -f1-2 -d' '; } > $temporary_tocname"
142 replace_command =
143 "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $ tocfile; fi"
142 144
143 command = "$link_command && $toc_command && $replace_command" 145 command = "$link_command && $toc_command && $replace_command"
144 if (defined(invoker.postsolink)) { 146 if (defined(invoker.postsolink)) {
145 command += " && " + invoker.postsolink 147 command += " && " + invoker.postsolink
146 } 148 }
147 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" 149 rspfile_content =
150 "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive $sol ink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
148 151
149 description = "SOLINK $sofile" 152 description = "SOLINK $sofile"
150 153
151 # Use this for {{output_extension}} expansions unless a target manually 154 # Use this for {{output_extension}} expansions unless a target manually
152 # overrides it (in which case {{output_extension}} will be what the target 155 # overrides it (in which case {{output_extension}} will be what the target
153 # specifies). 156 # specifies).
154 default_output_extension = ".so" 157 default_output_extension = ".so"
155 158
156 output_prefix = "lib" 159 output_prefix = "lib"
157 160
(...skipping 11 matching lines...) Expand all
169 if (defined(invoker.solink_outputs)) { 172 if (defined(invoker.solink_outputs)) {
170 outputs += invoker.solink_outputs 173 outputs += invoker.solink_outputs
171 } 174 }
172 link_output = sofile 175 link_output = sofile
173 depend_output = tocfile 176 depend_output = tocfile
174 } 177 }
175 178
176 tool("link") { 179 tool("link") {
177 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" 180 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}"
178 rspfile = "$outfile.rsp" 181 rspfile = "$outfile.rsp"
179 command = "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solib s}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postfix" 182 command =
183 "$ld {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -W l,--end-group $libs_section_prefix {{libs}} $libs_section_postfix"
180 if (defined(invoker.postlink)) { 184 if (defined(invoker.postlink)) {
181 command += " && " + invoker.postlink 185 command += " && " + invoker.postlink
182 } 186 }
183 description = "LINK $outfile" 187 description = "LINK $outfile"
184 rspfile_content = "{{inputs}}" 188 rspfile_content = "{{inputs}}"
185 outputs = [ outfile ] 189 outputs = [ outfile ]
186 if (defined(invoker.link_outputs)) { 190 if (defined(invoker.link_outputs)) {
187 outputs += invoker.link_outputs 191 outputs += invoker.link_outputs
188 } 192 }
189 } 193 }
190 194
191 tool("stamp") { 195 tool("stamp") {
192 command = "touch {{output}}" 196 command = "touch {{output}}"
193 description = "STAMP {{output}}" 197 description = "STAMP {{output}}"
194 } 198 }
195 199
196 tool("copy") { 200 tool("copy") {
197 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} & & cp -af {{source}} {{output}})" 201 command =
202 "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp - af {{source}} {{output}})"
198 description = "COPY {{source}} {{output}}" 203 description = "COPY {{source}} {{output}}"
199 } 204 }
200 205
201 # When invoking this toolchain not as the default one, these args will be 206 # When invoking this toolchain not as the default one, these args will be
202 # passed to the build. They are ignored when this is the default toolchain. 207 # passed to the build. They are ignored when this is the default toolchain.
203 toolchain_args() { 208 toolchain_args() {
204 cpu_arch = invoker.toolchain_cpu_arch 209 cpu_arch = invoker.toolchain_cpu_arch
205 os = invoker.toolchain_os 210 os = invoker.toolchain_os
206 if (defined(invoker.is_clang)) { 211 if (defined(invoker.is_clang)) {
207 is_clang = invoker.is_clang 212 is_clang = invoker.is_clang
208 } 213 }
209 } 214 }
210 215
211 if (defined(invoker.deps)) { 216 if (defined(invoker.deps)) {
212 deps = invoker.deps 217 deps = invoker.deps
213 } 218 }
214 } 219 }
215 } 220 }
OLDNEW
« no previous file with comments | « build/toolchain/android/BUILD.gn ('k') | build/toolchain/mac/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698