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 # 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 import("//build/config/ios/ios_sdk.gni") | |
| 10 | 11 |
| 11 assert(host_os == "mac") | 12 assert(host_os == "mac") |
| 12 | 13 |
| 13 import("//build/toolchain/clang.gni") | 14 import("//build/toolchain/clang.gni") |
| 14 import("//build/toolchain/goma.gni") | 15 import("//build/toolchain/goma.gni") |
| 16 import("//build/config/sysroot.gni") | |
| 15 | 17 |
| 16 if (use_goma) { | 18 if (use_goma) { |
| 17 goma_prefix = "$goma_dir/gomacc " | 19 goma_prefix = "$goma_dir/gomacc " |
| 18 } else { | 20 } else { |
| 19 goma_prefix = "" | 21 goma_prefix = "" |
| 20 } | 22 } |
| 21 | 23 |
| 22 # This will copy the gyp-mac-tool to the build directory. We pass in the source | 24 # This will copy the gyp-mac-tool to the build directory. We pass in the source |
| 23 # file of the win tool. | 25 # file of the win tool. |
| 24 gyp_mac_tool_source = | 26 gyp_mac_tool_source = |
| 25 rebase_path("//tools/gyp/pylib/gyp/mac_tool.py", root_build_dir) | 27 rebase_path("//tools/gyp/pylib/gyp/mac_tool.py", root_build_dir) |
| 26 exec_script("setup_toolchain.py", [ gyp_mac_tool_source ]) | 28 exec_script("setup_toolchain.py", [ gyp_mac_tool_source ]) |
| 27 | 29 |
| 28 # Shared toolchain definition. Invocations should set toolchain_os to set the | 30 # Shared toolchain definition. Invocations should set toolchain_os to set the |
| 29 # build args in this definition. | 31 # build args in this definition. |
| 30 template("mac_toolchain") { | 32 template("mac_toolchain") { |
| 31 toolchain(target_name) { | 33 toolchain(target_name) { |
| 32 assert(defined(invoker.cc), "mac_toolchain() must specify a \"cc\" value") | 34 assert(defined(invoker.cc), "mac_toolchain() must specify a \"cc\" value") |
| 33 assert(defined(invoker.cxx), "mac_toolchain() must specify a \"cxx\" value") | 35 assert(defined(invoker.cxx), "mac_toolchain() must specify a \"cxx\" value") |
| 34 assert(defined(invoker.ld), "mac_toolchain() must specify a \"ld\" value") | 36 assert(defined(invoker.ld), "mac_toolchain() must specify a \"ld\" value") |
| 35 assert(defined(invoker.toolchain_cpu), | 37 assert(defined(invoker.toolchain_cpu), |
| 36 "mac_toolchain() must specify a \"toolchain_cpu\"") | 38 "mac_toolchain() must specify a \"toolchain_cpu\"") |
| 37 assert(defined(invoker.toolchain_os), | 39 assert(defined(invoker.toolchain_os), |
| 38 "mac_toolchain() must specify a \"toolchain_os\"") | 40 "mac_toolchain() must specify a \"toolchain_os\"") |
| 41 assert(defined(invoker.switch_sysroot), | |
| 42 "mac_toolchain() must specify a \"switch_sysroot\"") | |
| 39 | 43 |
| 40 # We can't do string interpolation ($ in strings) on things with dots in | 44 # We can't do string interpolation ($ in strings) on things with dots in |
| 41 # them. To allow us to use $cc below, for example, we create copies of | 45 # them. To allow us to use $cc below, for example, we create copies of |
| 42 # these values in our scope. | 46 # these values in our scope. |
| 43 cc = invoker.cc | 47 cc = invoker.cc |
| 44 cxx = invoker.cxx | 48 cxx = invoker.cxx |
| 45 ld = invoker.ld | 49 ld = invoker.ld |
| 46 | 50 |
| 47 # Make these apply to all tools below. | 51 # Make these apply to all tools below. |
| 48 lib_switch = "-l" | 52 lib_switch = "-l" |
| 49 lib_dir_switch = "-L" | 53 lib_dir_switch = "-L" |
| 50 | 54 |
| 55 sysroot_flags = "" | |
| 56 | |
| 57 if (invoker.switch_sysroot) { | |
| 58 version_flags = "" | |
| 59 | |
| 60 if (use_ios_simulator) { | |
| 61 version_flags = "-mios-simulator-version-min=$ios_deployment_target" | |
| 62 } else { | |
| 63 version_flags = "-miphoneos-version-min=$ios_deployment_target" | |
| 64 } | |
| 65 | |
| 66 sysroot_flags = "-isysroot $sysroot $version_flags" | |
| 67 } | |
| 68 | |
| 51 tool("cc") { | 69 tool("cc") { |
| 52 depfile = "{{output}}.d" | 70 depfile = "{{output}}.d" |
| 53 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}" | 71 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} $sysroot_fla gs {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" |
| 54 depsformat = "gcc" | 72 depsformat = "gcc" |
| 55 description = "CC {{output}}" | 73 description = "CC {{output}}" |
| 56 outputs = [ | 74 outputs = [ |
| 57 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", | 75 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", |
| 58 ] | 76 ] |
| 59 } | 77 } |
| 60 | 78 |
| 61 tool("cxx") { | 79 tool("cxx") { |
| 62 depfile = "{{output}}.d" | 80 depfile = "{{output}}.d" |
| 63 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" | 81 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} $sysroot_fl ags {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" |
| 64 depsformat = "gcc" | 82 depsformat = "gcc" |
| 65 description = "CXX {{output}}" | 83 description = "CXX {{output}}" |
| 66 outputs = [ | 84 outputs = [ |
| 67 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", | 85 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", |
| 68 ] | 86 ] |
| 69 } | 87 } |
| 70 | 88 |
| 71 tool("asm") { | 89 tool("asm") { |
| 72 # For GCC we can just use the C compiler to compile assembly. | 90 # For GCC we can just use the C compiler to compile assembly. |
| 73 depfile = "{{output}}.d" | 91 depfile = "{{output}}.d" |
| 74 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}" | 92 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}" |
| 75 depsformat = "gcc" | 93 depsformat = "gcc" |
| 76 description = "ASM {{output}}" | 94 description = "ASM {{output}}" |
| 77 outputs = [ | 95 outputs = [ |
| 78 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", | 96 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", |
| 79 ] | 97 ] |
| 80 } | 98 } |
| 81 | 99 |
| 82 tool("objc") { | 100 tool("objc") { |
| 83 depfile = "{{output}}.d" | 101 depfile = "{{output}}.d" |
| 84 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}" | 102 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}" |
| 85 depsformat = "gcc" | 103 depsformat = "gcc" |
| 86 description = "OBJC {{output}}" | 104 description = "OBJC {{output}}" |
| 87 outputs = [ | 105 outputs = [ |
| 88 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", | 106 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", |
| 89 ] | 107 ] |
| 90 } | 108 } |
| 91 | 109 |
| 92 tool("objcxx") { | 110 tool("objcxx") { |
| 93 depfile = "{{output}}.d" | 111 depfile = "{{output}}.d" |
| 94 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_objcc}} -c {{source}} -o {{output}}" | 112 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}" |
| 95 depsformat = "gcc" | 113 depsformat = "gcc" |
| 96 description = "OBJCXX {{output}}" | 114 description = "OBJCXX {{output}}" |
| 97 outputs = [ | 115 outputs = [ |
| 98 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", | 116 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", |
| 99 ] | 117 ] |
| 100 } | 118 } |
| 101 | 119 |
| 102 tool("alink") { | 120 tool("alink") { |
| 103 command = "rm -f {{output}} && ./gyp-mac-tool filter-libtool libtool -stat ic -o {{output}} {{inputs}}" | 121 command = "rm -f {{output}} && ./gyp-mac-tool filter-libtool libtool -stat ic -o {{output}} {{inputs}}" |
| 104 description = "LIBTOOL-STATIC {{output}}" | 122 description = "LIBTOOL-STATIC {{output}}" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 118 # to a temporary file, (3) if the temporary file has differences from the | 136 # to a temporary file, (3) if the temporary file has differences from the |
| 119 # existing .TOC file, overwrite it, oterwise, don't change it. | 137 # existing .TOC file, overwrite it, oterwise, don't change it. |
| 120 # | 138 # |
| 121 # As a special case, if the library reexports symbols from other dynamic | 139 # As a special case, if the library reexports symbols from other dynamic |
| 122 # libraries, we always update the .TOC and skip the temporary file and | 140 # libraries, we always update the .TOC and skip the temporary file and |
| 123 # diffing steps, since that library always needs to be re-linked. | 141 # diffing steps, since that library always needs to be re-linked. |
| 124 tocname = dylib + ".TOC" | 142 tocname = dylib + ".TOC" |
| 125 temporary_tocname = dylib + ".tmp" | 143 temporary_tocname = dylib + ".tmp" |
| 126 | 144 |
| 127 does_reexport_command = "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dyl ib | grep -q LC_REEXPORT_DYLIB" | 145 does_reexport_command = "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dyl ib | grep -q LC_REEXPORT_DYLIB" |
| 128 link_command = "$ld -shared {{ldflags}} -o $dylib -Wl,-filelist,$rspfile { {solibs}} {{libs}}" | 146 link_command = "$ld -shared $sysroot_flags {{ldflags}} -o $dylib -Wl,-file list,$rspfile {{solibs}} {{libs}}" |
| 129 replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $tempo rary_tocname $tocname" | 147 replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $tempo rary_tocname $tocname" |
| 130 extract_toc_command = "{ otool -l $dylib | grep LC_ID_DYLIB -A 5; nm -gP $ dylib | cut -f1-2 -d' ' | grep -v U\$\$; true; }" | 148 extract_toc_command = "{ otool -l $dylib | grep LC_ID_DYLIB -A 5; nm -gP $ dylib | cut -f1-2 -d' ' | grep -v U\$\$; true; }" |
| 131 | 149 |
| 132 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" | 150 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" |
| 133 | 151 |
| 134 rspfile_content = "{{inputs_newline}}" | 152 rspfile_content = "{{inputs_newline}}" |
| 135 | 153 |
| 136 description = "SOLINK {{output}}" | 154 description = "SOLINK {{output}}" |
| 137 | 155 |
| 138 # Use this for {{output_extension}} expansions unless a target manually | 156 # Use this for {{output_extension}} expansions unless a target manually |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 153 dylib, | 171 dylib, |
| 154 tocname, | 172 tocname, |
| 155 ] | 173 ] |
| 156 link_output = dylib | 174 link_output = dylib |
| 157 depend_output = tocname | 175 depend_output = tocname |
| 158 } | 176 } |
| 159 | 177 |
| 160 tool("link") { | 178 tool("link") { |
| 161 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" | 179 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 162 rspfile = "$outfile.rsp" | 180 rspfile = "$outfile.rsp" |
| 163 command = "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} { {libs}}" | 181 command = "$ld $sysroot_flags {{ldflags}} -o $outfile -Wl,-filelist,$rspfi le {{solibs}} {{libs}}" |
| 164 description = "LINK $outfile" | 182 description = "LINK $outfile" |
| 165 rspfile_content = "{{inputs_newline}}" | 183 rspfile_content = "{{inputs_newline}}" |
| 166 outputs = [ | 184 outputs = [ |
| 167 outfile, | 185 outfile, |
| 168 ] | 186 ] |
| 169 } | 187 } |
| 170 | 188 |
| 171 tool("stamp") { | 189 tool("stamp") { |
| 172 command = "touch {{output}}" | 190 command = "touch {{output}}" |
| 173 description = "STAMP {{output}}" | 191 description = "STAMP {{output}}" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 195 | 213 |
| 196 mac_toolchain("clang_arm") { | 214 mac_toolchain("clang_arm") { |
| 197 toolchain_cpu = "arm" | 215 toolchain_cpu = "arm" |
| 198 toolchain_os = "mac" | 216 toolchain_os = "mac" |
| 199 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", | 217 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| 200 root_build_dir) | 218 root_build_dir) |
| 201 cc = "${goma_prefix}$prefix/clang" | 219 cc = "${goma_prefix}$prefix/clang" |
| 202 cxx = "${goma_prefix}$prefix/clang++" | 220 cxx = "${goma_prefix}$prefix/clang++" |
| 203 ld = cxx | 221 ld = cxx |
| 204 is_clang = true | 222 is_clang = true |
| 223 switch_sysroot = false | |
| 224 } | |
| 225 | |
| 226 mac_toolchain("ios_clang_arm") { | |
|
sdefresne
2015/07/25 19:15:30
do we need "ios_clang_armv7" and "ios_clang_arm64"
| |
| 227 toolchain_cpu = "arm" | |
| 228 toolchain_os = "mac" | |
| 229 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", | |
|
sdefresne
2015/07/25 19:15:30
Question: with gyp, at multiple occasion, on iOS w
Dirk Pranke
2015/07/31 21:27:41
We can definitely add it. I'll add a TODO here.
| |
| 230 root_build_dir) | |
| 231 cc = "${goma_prefix}$prefix/clang" | |
| 232 cxx = "${goma_prefix}$prefix/clang++" | |
| 233 ld = cxx | |
| 234 is_clang = true | |
| 235 switch_sysroot = true | |
| 205 } | 236 } |
| 206 | 237 |
| 207 mac_toolchain("arm") { | 238 mac_toolchain("arm") { |
| 208 toolchain_cpu = "arm" | 239 toolchain_cpu = "arm" |
| 209 toolchain_os = "mac" | 240 toolchain_os = "mac" |
| 210 cc = "${goma_prefix}/gcc" | 241 cc = "${goma_prefix}/gcc" |
| 211 cxx = "${goma_prefix}/g++" | 242 cxx = "${goma_prefix}/g++" |
| 212 ld = cxx | 243 ld = cxx |
| 213 is_clang = false | 244 is_clang = false |
| 245 switch_sysroot = false | |
| 214 } | 246 } |
| 215 | 247 |
| 216 mac_toolchain("clang_x64") { | 248 mac_toolchain("clang_x64") { |
| 217 toolchain_cpu = "x64" | 249 toolchain_cpu = "x64" |
| 218 toolchain_os = "mac" | 250 toolchain_os = "mac" |
| 219 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", | 251 prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", |
| 220 root_build_dir) | 252 root_build_dir) |
| 221 cc = "${goma_prefix}$prefix/clang" | 253 cc = "${goma_prefix}$prefix/clang" |
| 222 cxx = "${goma_prefix}$prefix/clang++" | 254 cxx = "${goma_prefix}$prefix/clang++" |
| 223 ld = cxx | 255 ld = cxx |
| 224 is_clang = true | 256 is_clang = true |
| 257 switch_sysroot = false | |
| 225 } | 258 } |
| 226 | 259 |
| 227 mac_toolchain("x64") { | 260 mac_toolchain("x64") { |
| 228 toolchain_cpu = "x64" | 261 toolchain_cpu = "x64" |
| 229 toolchain_os = "mac" | 262 toolchain_os = "mac" |
| 230 cc = "${goma_prefix}/gcc" | 263 cc = "${goma_prefix}/gcc" |
| 231 cxx = "${goma_prefix}/g++" | 264 cxx = "${goma_prefix}/g++" |
| 232 ld = cxx | 265 ld = cxx |
| 233 is_clang = false | 266 is_clang = false |
| 267 switch_sysroot = false | |
| 234 } | 268 } |
| OLD | NEW |