1# Copyright 2015 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5# Creates a symlink. 6# Args: 7# source: Path to link to. 8# output: Where to create the symlink. 9template("symlink") { 10 action(target_name) { 11 forward_variables_from(invoker, 12 [ 13 "data_deps", 14 "deps", 15 "testonly", 16 "visibility", 17 ]) 18 outputs = [ invoker.output ] 19 script = "//build/symlink.py" 20 args = [ 21 "-f", 22 rebase_path(invoker.source, get_path_info(invoker.output, "dir")), 23 rebase_path(invoker.output, root_build_dir), 24 ] 25 } 26} 27 28# Creates a symlink from root_build_dir/target_name to |binary_label|. This rule 29# is meant to be used within if (current_toolchain == default_toolchain) blocks 30# and point to targets in the non-default toolchain. 31# Note that for executables, using a copy (as opposed to a symlink) does not 32# work when is_component_build=true, since dependent libraries are found via 33# relative location. 34# 35# Args: 36# binary_label: Target that builds the file to symlink to. e.g.: 37# ":$target_name($host_toolchain)". 38# binary_output_name: The output_name set by the binary_label target 39# (if applicable). 40# output_name: Where to create the symlink 41# (default="$root_out_dir/$binary_output_name"). 42# 43# Example: 44# if (current_toolchain == host_toolchain) { 45# executable("foo") { ... } 46# } else if (current_toolchain == default_toolchain) { 47# binary_symlink("foo") { 48# binary_label = ":foo($host_toolchain)" 49# } 50# } 51template("binary_symlink") { 52 symlink(target_name) { 53 forward_variables_from(invoker, 54 [ 55 "output", 56 "testonly", 57 "visibility", 58 ]) 59 deps = [ invoker.binary_label ] 60 data_deps = [ invoker.binary_label ] 61 if (defined(invoker.data_deps)) { 62 data_deps += invoker.data_deps 63 } 64 65 _out_dir = get_label_info(invoker.binary_label, "root_out_dir") 66 if (defined(invoker.binary_output_name)) { 67 _name = invoker.binary_output_name 68 } else { 69 _name = get_label_info(invoker.binary_label, "name") 70 } 71 source = "$_out_dir/$_name" 72 73 _output_name = _name 74 if (defined(invoker.output_name)) { 75 _output_name = invoker.output_name 76 } 77 output = "$root_out_dir/$_output_name" 78 } 79} 80