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

Side by Side Diff: build/toolchain/mac/BUILD.gn

Issue 485833003: Pull new GN, update toolchain definitions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Android Created 6 years, 4 months 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 | Annotate | Revision Log
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 # TODO(brettw) Use "gcc_toolchain.gni" like the Linux toolchains. This requires 5 # TODO(brettw) Use "gcc_toolchain.gni" like the Linux toolchains. This requires
6 # some enhancements since the commands on Mac are slightly different than on 6 # some enhancements since the commands on Mac are slightly different than on
7 # Linux. 7 # Linux.
8 8
9 import("../goma.gni") 9 import("../goma.gni")
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 "mac_clang_toolchain() must specify a \"toolchain_os\"") 45 "mac_clang_toolchain() must specify a \"toolchain_os\"")
46 46
47 # We can't do string interpolation ($ in strings) on things with dots in 47 # We can't do string interpolation ($ in strings) on things with dots in
48 # them. To allow us to use $cc below, for example, we create copies of 48 # them. To allow us to use $cc below, for example, we create copies of
49 # these values in our scope. 49 # these values in our scope.
50 cc = invoker.cc 50 cc = invoker.cc
51 cxx = invoker.cxx 51 cxx = invoker.cxx
52 ld = invoker.ld 52 ld = invoker.ld
53 53
54 # Make these apply to all tools below. 54 # Make these apply to all tools below.
55 lib_prefix = "-l" 55 lib_switch = "-l"
56 lib_dir_prefix="-L" 56 lib_dir_switch = "-L"
57 57
58 tool("cc") { 58 tool("cc") {
59 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c \ $cflags_pch_c -c \$in -o \$out" 59 depfile = "{{output}}.d"
60 description = "CC \$out" 60 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}"
61 depfile = "\$out.d"
62 depsformat = "gcc" 61 depsformat = "gcc"
62 description = "CC {{output}}"
63 outputs = [
64 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
65 ]
63 } 66 }
67
64 tool("cxx") { 68 tool("cxx") {
65 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc \$cflags_pch_cc -c \$in -o \$out" 69 depfile = "{{output}}.d"
66 description = "CXX \$out" 70 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
67 depfile = "\$out.d"
68 depsformat = "gcc" 71 depsformat = "gcc"
72 description = "CXX {{output}}"
73 outputs = [
74 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
75 ]
69 } 76 }
77
78 tool("asm") {
79 # For GCC we can just use the C compiler to compile assembly.
80 depfile = "{{output}}.d"
81 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}"
82 depsformat = "gcc"
83 description = "ASM {{output}}"
84 outputs = [
85 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
86 ]
87 }
88
70 tool("objc") { 89 tool("objc") {
71 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c \ $cflags_objc \$cflags_pch_objc -c \$in -o \$out" 90 depfile = "{{output}}.d"
72 description = "OBJC \$out" 91 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}"
73 depfile = "\$out.d"
74 depsformat = "gcc" 92 depsformat = "gcc"
93 description = "OBJC {{output}}"
94 outputs = [
95 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
96 ]
75 } 97 }
98
76 tool("objcxx") { 99 tool("objcxx") {
77 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc \$cflags_objcc \$cflags_pch_objcc -c \$in -o \$out" 100 depfile = "{{output}}.d"
78 description = "OBJCXX \$out" 101 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}"
79 depfile = "\$out.d"
80 depsformat = "gcc" 102 depsformat = "gcc"
103 description = "OBJCXX {{output}}"
104 outputs = [
105 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
106 ]
81 } 107 }
108
82 tool("alink") { 109 tool("alink") {
83 command = "rm -f \$out && ./gyp-mac-tool filter-libtool libtool \$libtool_ flags -static -o \$out \$in \$postbuilds" 110 command = "rm -f {{output}} && ./gyp-mac-tool filter-libtool libtool -stat ic -o {{output}} {{inputs}}"
84 description = "LIBTOOL-STATIC \$out" 111 description = "LIBTOOL-STATIC {{output}}"
112 outputs = [
113 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}"
114 ]
115 default_output_extension = ".a"
116 output_prefix = "lib"
85 } 117 }
118
86 tool("solink") { 119 tool("solink") {
87 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ] || otool -l \$lib | grep -q LC_REEXPORT_DYLIB ; then $ld -shared \$ldflags -o \$lib -Wl,-filelist,\$rspfi le \$solibs \$libs \$postbuilds && { otool -l \$lib | grep LC_ID_DYLIB -A 5; nm -gP \$lib | cut -f1-2 -d' ' | grep -v U\$\$; true; } > \${lib}.TOC; else $ld -sh ared \$ldflags -o \$lib \$in \$solibs \$libs \$postbuilds && { otool -l \$lib | grep LC_ID_DYLIB -A 5; nm -gP \$lib | cut -f1-2 -d' ' | grep -v U\$\$; true; } > \${lib}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib} .TOC ; fi; fi" 120 dylib = "{{target_output_name}}{{output_extension}}" # eg "libfoo.dylib"
88 description = "SOLINK \$lib" 121 rspfile = dylib + ".rsp"
89 rspfile = "\$out.rsp" 122
90 rspfile_content = "\$in_newline" 123 # These variables are not build into GN but are helpers that implement
91 #pool = "link_pool" 124 # (1) linking to produce a .so, (2) extracting the symbols from that file
92 restat = "1" 125 # to a temporary file, (3) if the temporary file has differences from the
126 # existing .TOC file, overwrite it, oterwise, don't change it.
127 #
128 # As a special case, if the library reexports symbols from other dynamic
129 # libraries, we always update the .TOC and skip the temporary file and
130 # diffing steps, since that library always needs to be re-linked.
131 tocname = dylib + ".TOC"
132 temporary_tocname = dylib + ".tmp"
133
134 does_reexport_command = "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dyl ib | grep -q LC_REEXPORT_DYLIB"
135 link_command = "$ld -shared {{ldflags}} -o $dylib -Wl,-filelist,$rspfile { {solibs}} {{libs}}"
136 replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $tempo rary_tocname $tocname"
137 extract_toc_command = "{ otool -l $dylib | grep LC_ID_DYLIB -A 5; nm -gP $ dylib | cut -f1-2 -d' ' | grep -v U\$\$; true; }"
138
139 command = "if $does_reexport_command ; then $link_command && $extract_toc_ command > $tocname; else $link_command && $extract_toc_command > $temporary_tocn ame && $replace_command ; fi; fi"
140
141 rspfile_content = "{{inputs_newline}}"
142
143 description = "SOLINK {{output}}"
144
145 # Use this for {{output_extension}} expansions unless a target manually
146 # overrides it (in which case {{output_extension}} will be what the target
147 # specifies).
148 default_output_extension = ".dylib"
149
150 output_prefix = "lib"
151
152 # Since the above commands only updates the .TOC file when it changes, ask
153 # Ninja to check if the timestamp actually changed to know if downstream
154 # dependencies should be recompiled.
155 restat = true
156
157 # Tell GN about the output files. It will link to the dylib but use the
158 # tocname for dependency management.
159 outputs = [
160 dylib,
161 tocname,
162 ]
163 link_output = dylib
164 depend_output = tocname
93 } 165 }
166
94 tool("link") { 167 tool("link") {
95 command = "$ld \$ldflags -o \$out -Wl,-filelist,\$rspfile \$solibs \$libs \$postbuilds" 168 outfile = "{{target_output_name}}{{output_extension}}"
96 description = "LINK \$out" 169 rspfile = "$outfile.rsp"
97 rspfile = "\$out.rsp" 170 command = "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} { {libs}}"
98 rspfile_content = "\$in_newline" 171 description = "LINK $outfile"
99 #pool = "link_pool" 172 rspfile_content = "{{inputs_newline}}"
173 outputs = [ outfile ]
100 } 174 }
101 #tool("infoplist") { 175
102 # command = "$cc -E -P -Wno-trigraphs -x c \$defines \$in -o \$out && pluti l -convert xml1 \$out \$out"
103 # description = "INFOPLIST \$out"
104 #}
105 #tool("mac_tool") {
106 # command = "\$env ./gyp-mac-tool \$mactool_cmd \$in \$out"
107 # description = "MACTOOL \$mactool_cmd \$in"
108 #}
109 #tool("package_framework") {
110 # command = "./gyp-mac-tool package-framework \$out \$version \$postbuilds && touch \$out"
111 # description = "PACKAGE FRAMEWORK \$out, POSTBUILDS"
112 #}
113 tool("stamp") { 176 tool("stamp") {
114 command = "\${postbuilds}touch \$out" 177 command = "touch {{output}}"
115 description = "STAMP \$out" 178 description = "STAMP {{output}}"
116 } 179 }
180
117 tool("copy") { 181 tool("copy") {
118 command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$ out)" 182 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} & & cp -af {{source}} {{output}})"
119 description = "COPY \$in \$out" 183 description = "COPY {{source}} {{output}}"
120 } 184 }
121 185
122 toolchain_args() { 186 toolchain_args() {
123 os = invoker.toolchain_os 187 os = invoker.toolchain_os
124 } 188 }
125 } 189 }
126 } 190 }
127 191
128 # Toolchain representing the target build (either mac or iOS). 192 # Toolchain representing the target build (either mac or iOS).
129 mac_clang_toolchain("clang") { 193 mac_clang_toolchain("clang") {
130 toolchain_os = os 194 toolchain_os = os
131 } 195 }
132 196
133 # This toolchain provides a way for iOS target compiles to reference targets 197 # This toolchain provides a way for iOS target compiles to reference targets
134 # compiled for the host system. It just overrides the OS back to "mac". 198 # compiled for the host system. It just overrides the OS back to "mac".
135 mac_clang_toolchain("host_clang") { 199 mac_clang_toolchain("host_clang") {
136 toolchain_os = "mac" 200 toolchain_os = "mac"
137 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698