| Index: build/toolchain/mac/BUILD.gn
|
| diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn
|
| index c43049cd88ad6dd63a46f46d6b9128fd67959f86..65fb7c661b198b6eeda1b55f1fde59f51be6e202 100644
|
| --- a/build/toolchain/mac/BUILD.gn
|
| +++ b/build/toolchain/mac/BUILD.gn
|
| @@ -52,71 +52,135 @@ template("mac_clang_toolchain") {
|
| ld = invoker.ld
|
|
|
| # Make these apply to all tools below.
|
| - lib_prefix = "-l"
|
| - lib_dir_prefix="-L"
|
| + lib_switch = "-l"
|
| + lib_dir_switch = "-L"
|
|
|
| tool("cc") {
|
| - command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c \$cflags_pch_c -c \$in -o \$out"
|
| - description = "CC \$out"
|
| - depfile = "\$out.d"
|
| + depfile = "{{output}}.d"
|
| + command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
|
| depsformat = "gcc"
|
| + description = "CC {{output}}"
|
| + outputs = [
|
| + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
| + ]
|
| }
|
| +
|
| tool("cxx") {
|
| - command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc \$cflags_pch_cc -c \$in -o \$out"
|
| - description = "CXX \$out"
|
| - depfile = "\$out.d"
|
| + depfile = "{{output}}.d"
|
| + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
|
| depsformat = "gcc"
|
| + description = "CXX {{output}}"
|
| + outputs = [
|
| + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
| + ]
|
| }
|
| +
|
| + tool("asm") {
|
| + # For GCC we can just use the C compiler to compile assembly.
|
| + depfile = "{{output}}.d"
|
| + command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
|
| + depsformat = "gcc"
|
| + description = "ASM {{output}}"
|
| + outputs = [
|
| + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
| + ]
|
| + }
|
| +
|
| tool("objc") {
|
| - command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c \$cflags_objc \$cflags_pch_objc -c \$in -o \$out"
|
| - description = "OBJC \$out"
|
| - depfile = "\$out.d"
|
| + depfile = "{{output}}.d"
|
| + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}"
|
| depsformat = "gcc"
|
| + description = "OBJC {{output}}"
|
| + outputs = [
|
| + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
| + ]
|
| }
|
| +
|
| tool("objcxx") {
|
| - command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc \$cflags_objcc \$cflags_pch_objcc -c \$in -o \$out"
|
| - description = "OBJCXX \$out"
|
| - depfile = "\$out.d"
|
| + depfile = "{{output}}.d"
|
| + command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} -c {{source}} -o {{output}}"
|
| depsformat = "gcc"
|
| + description = "OBJCXX {{output}}"
|
| + outputs = [
|
| + "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
|
| + ]
|
| }
|
| +
|
| tool("alink") {
|
| - command = "rm -f \$out && ./gyp-mac-tool filter-libtool libtool \$libtool_flags -static -o \$out \$in \$postbuilds"
|
| - description = "LIBTOOL-STATIC \$out"
|
| + command = "rm -f {{output}} && ./gyp-mac-tool filter-libtool libtool -static -o {{output}} {{inputs}}"
|
| + description = "LIBTOOL-STATIC {{output}}"
|
| + outputs = [
|
| + "{{target_out_dir}}/{{target_output_name}}{{output_extension}}"
|
| + ]
|
| + default_output_extension = ".a"
|
| + output_prefix = "lib"
|
| }
|
| +
|
| tool("solink") {
|
| - command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ] || otool -l \$lib | grep -q LC_REEXPORT_DYLIB ; then $ld -shared \$ldflags -o \$lib -Wl,-filelist,\$rspfile \$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 -shared \$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"
|
| - description = "SOLINK \$lib"
|
| - rspfile = "\$out.rsp"
|
| - rspfile_content = "\$in_newline"
|
| - #pool = "link_pool"
|
| - restat = "1"
|
| + dylib = "{{target_output_name}}{{output_extension}}" # eg "libfoo.dylib"
|
| + rspfile = dylib + ".rsp"
|
| +
|
| + # These variables are not build into GN but are helpers that implement
|
| + # (1) linking to produce a .so, (2) extracting the symbols from that file
|
| + # to a temporary file, (3) if the temporary file has differences from the
|
| + # existing .TOC file, overwrite it, oterwise, don't change it.
|
| + #
|
| + # As a special case, if the library reexports symbols from other dynamic
|
| + # libraries, we always update the .TOC and skip the temporary file and
|
| + # diffing steps, since that library always needs to be re-linked.
|
| + tocname = dylib + ".TOC"
|
| + temporary_tocname = dylib + ".tmp"
|
| +
|
| + does_reexport_command = "[ ! -e $dylib -o ! -e $tocname ] || otool -l $dylib | grep -q LC_REEXPORT_DYLIB"
|
| + link_command = "$ld -shared {{ldflags}} -o $dylib -Wl,-filelist,$rspfile {{solibs}} {{libs}}"
|
| + replace_command = "if ! cmp -s $temporary_tocname $tocname; then mv $temporary_tocname $tocname"
|
| + extract_toc_command = "{ otool -l $dylib | grep LC_ID_DYLIB -A 5; nm -gP $dylib | cut -f1-2 -d' ' | grep -v U\$\$; true; }"
|
| +
|
| + command = "if $does_reexport_command ; then $link_command && $extract_toc_command > $tocname; else $link_command && $extract_toc_command > $temporary_tocname && $replace_command ; fi; fi"
|
| +
|
| + rspfile_content = "{{inputs_newline}}"
|
| +
|
| + description = "SOLINK {{output}}"
|
| +
|
| + # Use this for {{output_extension}} expansions unless a target manually
|
| + # overrides it (in which case {{output_extension}} will be what the target
|
| + # specifies).
|
| + default_output_extension = ".dylib"
|
| +
|
| + output_prefix = "lib"
|
| +
|
| + # Since the above commands only updates the .TOC file when it changes, ask
|
| + # Ninja to check if the timestamp actually changed to know if downstream
|
| + # dependencies should be recompiled.
|
| + restat = true
|
| +
|
| + # Tell GN about the output files. It will link to the dylib but use the
|
| + # tocname for dependency management.
|
| + outputs = [
|
| + dylib,
|
| + tocname,
|
| + ]
|
| + link_output = dylib
|
| + depend_output = tocname
|
| }
|
| +
|
| tool("link") {
|
| - command = "$ld \$ldflags -o \$out -Wl,-filelist,\$rspfile \$solibs \$libs \$postbuilds"
|
| - description = "LINK \$out"
|
| - rspfile = "\$out.rsp"
|
| - rspfile_content = "\$in_newline"
|
| - #pool = "link_pool"
|
| + outfile = "{{target_output_name}}{{output_extension}}"
|
| + rspfile = "$outfile.rsp"
|
| + command = "$ld {{ldflags}} -o $outfile -Wl,-filelist,$rspfile {{solibs}} {{libs}}"
|
| + description = "LINK $outfile"
|
| + rspfile_content = "{{inputs_newline}}"
|
| + outputs = [ outfile ]
|
| }
|
| - #tool("infoplist") {
|
| - # command = "$cc -E -P -Wno-trigraphs -x c \$defines \$in -o \$out && plutil -convert xml1 \$out \$out"
|
| - # description = "INFOPLIST \$out"
|
| - #}
|
| - #tool("mac_tool") {
|
| - # command = "\$env ./gyp-mac-tool \$mactool_cmd \$in \$out"
|
| - # description = "MACTOOL \$mactool_cmd \$in"
|
| - #}
|
| - #tool("package_framework") {
|
| - # command = "./gyp-mac-tool package-framework \$out \$version \$postbuilds && touch \$out"
|
| - # description = "PACKAGE FRAMEWORK \$out, POSTBUILDS"
|
| - #}
|
| +
|
| tool("stamp") {
|
| - command = "\${postbuilds}touch \$out"
|
| - description = "STAMP \$out"
|
| + command = "touch {{output}}"
|
| + description = "STAMP {{output}}"
|
| }
|
| +
|
| tool("copy") {
|
| - command = "ln -f \$in \$out 2>/dev/null || (rm -rf \$out && cp -af \$in \$out)"
|
| - description = "COPY \$in \$out"
|
| + command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
|
| + description = "COPY {{source}} {{output}}"
|
| }
|
|
|
| toolchain_args() {
|
|
|