| 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 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_switch = "-l" | 55 lib_switch = "-l" |
| 56 lib_dir_switch = "-L" | 56 lib_dir_switch = "-L" |
| 57 | 57 |
| 58 tool("cc") { | 58 tool("cc") { |
| 59 depfile = "{{output}}.d" | 59 depfile = "{{output}}.d" |
| 60 command = | 60 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {
{cflags_c}} -c {{source}} -o {{output}}" |
| 61 "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflag
s_c}} -c {{source}} -o {{output}}" | |
| 62 depsformat = "gcc" | 61 depsformat = "gcc" |
| 63 description = "CC {{output}}" | 62 description = "CC {{output}}" |
| 64 outputs = | 63 outputs = [ |
| 65 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] | 64 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 65 ] |
| 66 } | 66 } |
| 67 | 67 |
| 68 tool("cxx") { | 68 tool("cxx") { |
| 69 depfile = "{{output}}.d" | 69 depfile = "{{output}}.d" |
| 70 command = | 70 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}}
{{cflags_cc}} -c {{source}} -o {{output}}" |
| 71 "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cfla
gs_cc}} -c {{source}} -o {{output}}" | |
| 72 depsformat = "gcc" | 71 depsformat = "gcc" |
| 73 description = "CXX {{output}}" | 72 description = "CXX {{output}}" |
| 74 outputs = | 73 outputs = [ |
| 75 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] | 74 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 75 ] |
| 76 } | 76 } |
| 77 | 77 |
| 78 tool("asm") { | 78 tool("asm") { |
| 79 # For GCC we can just use the C compiler to compile assembly. | 79 # For GCC we can just use the C compiler to compile assembly. |
| 80 depfile = "{{output}}.d" | 80 depfile = "{{output}}.d" |
| 81 command = | 81 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {
{cflags_c}} -c {{source}} -o {{output}}" |
| 82 "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflag
s_c}} -c {{source}} -o {{output}}" | |
| 83 depsformat = "gcc" | 82 depsformat = "gcc" |
| 84 description = "ASM {{output}}" | 83 description = "ASM {{output}}" |
| 85 outputs = | 84 outputs = [ |
| 86 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] | 85 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 86 ] |
| 87 } | 87 } |
| 88 | 88 |
| 89 tool("objc") { | 89 tool("objc") { |
| 90 depfile = "{{output}}.d" | 90 depfile = "{{output}}.d" |
| 91 command = | 91 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}}
{{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}" |
| 92 "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cfla
gs_c}} {{cflags_objc}} -c {{source}} -o {{output}}" | |
| 93 depsformat = "gcc" | 92 depsformat = "gcc" |
| 94 description = "OBJC {{output}}" | 93 description = "OBJC {{output}}" |
| 95 outputs = | 94 outputs = [ |
| 96 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] | 95 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 96 ] |
| 97 } | 97 } |
| 98 | 98 |
| 99 tool("objcxx") { | 99 tool("objcxx") { |
| 100 depfile = "{{output}}.d" | 100 depfile = "{{output}}.d" |
| 101 command = | 101 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}}
{{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}" |
| 102 "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cfla
gs_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}" | |
| 103 depsformat = "gcc" | 102 depsformat = "gcc" |
| 104 description = "OBJCXX {{output}}" | 103 description = "OBJCXX {{output}}" |
| 105 outputs = | 104 outputs = [ |
| 106 [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ] | 105 "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o", |
| 106 ] |
| 107 } | 107 } |
| 108 | 108 |
| 109 tool("alink") { | 109 tool("alink") { |
| 110 command = | 110 command = "rm -f {{output}} && ./gyp-mac-tool filter-libtool libtool -stat
ic -o {{output}} {{inputs}}" |
| 111 "rm -f {{output}} && ./gyp-mac-tool filter-libtool libtool -static -o
{{output}} {{inputs}}" | |
| 112 description = "LIBTOOL-STATIC {{output}}" | 111 description = "LIBTOOL-STATIC {{output}}" |
| 113 outputs = | 112 outputs = [ |
| 114 [ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ] | 113 "{{target_out_dir}}/{{target_output_name}}{{output_extension}}", |
| 114 ] |
| 115 default_output_extension = ".a" | 115 default_output_extension = ".a" |
| 116 output_prefix = "lib" | 116 output_prefix = "lib" |
| 117 } | 117 } |
| 118 | 118 |
| 119 tool("solink") { | 119 tool("solink") { |
| 120 dylib = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # e
g "./libfoo.dylib" | 120 dylib = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" # e
g "./libfoo.dylib" |
| 121 rspfile = dylib + ".rsp" | 121 rspfile = dylib + ".rsp" |
| 122 | 122 |
| 123 # These variables are not build into GN but are helpers that implement | 123 # These variables are not build into GN but are helpers that implement |
| 124 # (1) linking to produce a .so, (2) extracting the symbols from that file | 124 # (1) linking to produce a .so, (2) extracting the symbols from that file |
| 125 # to a temporary file, (3) if the temporary file has differences from the | 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. | 126 # existing .TOC file, overwrite it, oterwise, don't change it. |
| 127 # | 127 # |
| 128 # As a special case, if the library reexports symbols from other dynamic | 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 | 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. | 130 # diffing steps, since that library always needs to be re-linked. |
| 131 tocname = dylib + ".TOC" | 131 tocname = dylib + ".TOC" |
| 132 temporary_tocname = dylib + ".tmp" | 132 temporary_tocname = dylib + ".tmp" |
| 133 | 133 |
| 134 does_reexport_command = | 134 does_reexport_command = "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dyl
ib | grep -q LC_REEXPORT_DYLIB" |
| 135 "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dylib | grep -q LC_REEX
PORT_DYLIB" | 135 link_command = "$ld -shared {{ldflags}} -o $dylib -Wl,-filelist,$rspfile {
{solibs}} {{libs}}" |
| 136 link_command = | 136 replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $tempo
rary_tocname $tocname" |
| 137 "$ld -shared {{ldflags}} -o $dylib -Wl,-filelist,$rspfile {{solibs}} {
{libs}}" | 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 replace_command = | |
| 139 "if ! cmp -s $temporary_tocname $tocname; then mv $temporary_tocname $
tocname" | |
| 140 extract_toc_command = | |
| 141 "{ otool -l $dylib | grep LC_ID_DYLIB -A 5; nm -gP $dylib | cut -f1-2
-d' ' | grep -v U\$\$; true; }" | |
| 142 | 138 |
| 143 command = | 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" |
| 144 "if $does_reexport_command ; then $link_command && $extract_toc_comman
d > $tocname; else $link_command && $extract_toc_command > $temporary_tocname &&
$replace_command ; fi; fi" | |
| 145 | 140 |
| 146 rspfile_content = "{{inputs_newline}}" | 141 rspfile_content = "{{inputs_newline}}" |
| 147 | 142 |
| 148 description = "SOLINK {{output}}" | 143 description = "SOLINK {{output}}" |
| 149 | 144 |
| 150 # Use this for {{output_extension}} expansions unless a target manually | 145 # Use this for {{output_extension}} expansions unless a target manually |
| 151 # overrides it (in which case {{output_extension}} will be what the target | 146 # overrides it (in which case {{output_extension}} will be what the target |
| 152 # specifies). | 147 # specifies). |
| 153 default_output_extension = ".dylib" | 148 default_output_extension = ".dylib" |
| 154 | 149 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 165 dylib, | 160 dylib, |
| 166 tocname, | 161 tocname, |
| 167 ] | 162 ] |
| 168 link_output = dylib | 163 link_output = dylib |
| 169 depend_output = tocname | 164 depend_output = tocname |
| 170 } | 165 } |
| 171 | 166 |
| 172 tool("link") { | 167 tool("link") { |
| 173 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" | 168 outfile = "{{root_out_dir}}/{{target_output_name}}{{output_extension}}" |
| 174 rspfile = "$outfile.rsp" | 169 rspfile = "$outfile.rsp" |
| 175 command = | 170 command = "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} {
{libs}}" |
| 176 "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} {{libs}
}" | |
| 177 description = "LINK $outfile" | 171 description = "LINK $outfile" |
| 178 rspfile_content = "{{inputs_newline}}" | 172 rspfile_content = "{{inputs_newline}}" |
| 179 outputs = [ outfile ] | 173 outputs = [ |
| 174 outfile, |
| 175 ] |
| 180 } | 176 } |
| 181 | 177 |
| 182 tool("stamp") { | 178 tool("stamp") { |
| 183 command = "touch {{output}}" | 179 command = "touch {{output}}" |
| 184 description = "STAMP {{output}}" | 180 description = "STAMP {{output}}" |
| 185 } | 181 } |
| 186 | 182 |
| 187 tool("copy") { | 183 tool("copy") { |
| 188 command = | 184 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} &
& cp -af {{source}} {{output}})" |
| 189 "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -
af {{source}} {{output}})" | |
| 190 description = "COPY {{source}} {{output}}" | 185 description = "COPY {{source}} {{output}}" |
| 191 } | 186 } |
| 192 | 187 |
| 193 toolchain_args() { | 188 toolchain_args() { |
| 194 os = invoker.toolchain_os | 189 os = invoker.toolchain_os |
| 195 } | 190 } |
| 196 } | 191 } |
| 197 } | 192 } |
| 198 | 193 |
| 199 # Toolchain representing the target build (either mac or iOS). | 194 # Toolchain representing the target build (either mac or iOS). |
| 200 mac_clang_toolchain("clang") { | 195 mac_clang_toolchain("clang") { |
| 201 toolchain_os = os | 196 toolchain_os = os |
| 202 } | 197 } |
| 203 | 198 |
| 204 # This toolchain provides a way for iOS target compiles to reference targets | 199 # This toolchain provides a way for iOS target compiles to reference targets |
| 205 # compiled for the host system. It just overrides the OS back to "mac". | 200 # compiled for the host system. It just overrides the OS back to "mac". |
| 206 mac_clang_toolchain("host_clang") { | 201 mac_clang_toolchain("host_clang") { |
| 207 toolchain_os = "mac" | 202 toolchain_os = "mac" |
| 208 } | 203 } |
| OLD | NEW |