1# Copyright 2019 The Chromium Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5template("mac_toolchain") { 6 toolchain(target_name) { 7 assert(defined(invoker.toolchain_args), 8 "Toolchains must declare toolchain_args") 9 10 toolchain_args = { 11 forward_variables_from(invoker.toolchain_args, "*") 12 } 13 14 cc = "clang" 15 cxx = "clang++" 16 17 tool("link") { 18 output = "{{output_dir}}/{{target_output_name}}{{output_extension}}" 19 rspfile = output + ".rsp" 20 rspfile_content = "{{inputs_newline}}" 21 22 outputs = [ output ] 23 command = "$cxx {{ldflags}} -o $output -Wl,-filelist,$rspfile {{libs}} {{solibs}} {{frameworks}}" 24 description = "LINK {{output}}" 25 26 default_output_dir = "{{root_out_dir}}" 27 default_output_extension = "" 28 output_prefix = "" 29 } 30 31 tool("solink") { 32 dylib = "{{output_dir}}/{{target_output_name}}{{output_extension}}" 33 rspfile = dylib + ".rsp" 34 rspfile_content = "{{inputs_newline}}" 35 36 outputs = [ dylib ] 37 command = "$cxx -dynamiclib {{ldflags}} -o $dylib -Wl,-filelist,$rspfile {{libs}} {{solibs}} {{frameworks}}" 38 description = "SOLINK {{output}}" 39 40 default_output_dir = "{{root_out_dir}}" 41 default_output_extension = ".dylib" 42 output_prefix = "lib" 43 } 44 45 tool("cc") { 46 depfile = "{{output}}.d" 47 precompiled_header_type = "gcc" 48 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}" 49 depsformat = "gcc" 50 description = "CC {{output}}" 51 outputs = [ "{{target_out_dir}}/{{label_name}}/{{source_name_part}}.o" ] 52 } 53 54 tool("cxx") { 55 depfile = "{{output}}.d" 56 precompiled_header_type = "gcc" 57 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" 58 depsformat = "gcc" 59 description = "CXX {{output}}" 60 outputs = [ "{{target_out_dir}}/{{label_name}}/{{source_name_part}}.o" ] 61 } 62 63 tool("objc") { 64 depfile = "{{output}}.d" 65 precompiled_header_type = "gcc" 66 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{framework_dirs}} {{cflags}} {{cflags_objc}} -c {{source}} -o {{output}}" 67 depsformat = "gcc" 68 description = "OBJC {{output}}" 69 outputs = [ "{{target_out_dir}}/{{label_name}}/{{source_name_part}}.o" ] 70 } 71 72 tool("objcxx") { 73 depfile = "{{output}}.d" 74 precompiled_header_type = "gcc" 75 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{framework_dirs}} {{cflags}} {{cflags_objcc}} -c {{source}} -o {{output}}" 76 depsformat = "gcc" 77 description = "OBJCXX {{output}}" 78 outputs = [ "{{target_out_dir}}/{{label_name}}/{{source_name_part}}.o" ] 79 } 80 81 tool("stamp") { 82 command = "touch {{output}}" 83 description = "STAMP {{output}}" 84 } 85 86 tool("copy_bundle_data") { 87 command = "rm -rf {{output}} && cp -a {{source}} {{output}}" 88 description = "COPY_BUNDLE_DATA {{output}}" 89 } 90 } 91} 92 93mac_toolchain("clang_x86") { 94 toolchain_args = { 95 current_cpu = "x86" 96 current_os = "mac" 97 } 98} 99 100mac_toolchain("clang_x64") { 101 toolchain_args = { 102 current_cpu = "x64" 103 current_os = "mac" 104 } 105} 106 107mac_toolchain("clang_arm") { 108 toolchain_args = { 109 current_cpu = "arm" 110 current_os = "mac" 111 } 112} 113 114mac_toolchain("clang_arm64") { 115 toolchain_args = { 116 current_cpu = "arm64" 117 current_os = "mac" 118 } 119} 120