Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | |
|
brettw
2015/12/10 00:12:21
This file should go with the script, so build/syml
agrieve
2015/12/10 11:07:38
Done.
| |
| 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 # to: Path to link to. | |
| 8 # from: Path to link from (default=root_out_dir/target_name) | |
| 9 template("symlink") { | |
|
brettw
2015/12/10 00:12:21
I think it would be nice if this mirrored the "cop
agrieve
2015/12/10 11:07:38
Done.
| |
| 10 action(target_name) { | |
| 11 forward_variables_from(invoker, | |
| 12 [ | |
| 13 "deps", | |
| 14 "public_deps", | |
| 15 "data_deps", | |
| 16 "testonly", | |
| 17 "visibility", | |
| 18 ]) | |
| 19 _to = invoker.to | |
|
brettw
2015/12/10 00:12:21
I find the underscores weird to read and they don'
agrieve
2015/12/10 11:07:38
This pattern is actually fairly common, at least w
| |
| 20 | |
| 21 if (defined(invoker.from)) { | |
| 22 _from = invoker.from | |
| 23 } else { | |
| 24 _from = "$root_out_dir/${invoker.target_name}" | |
| 25 } | |
| 26 | |
| 27 # TODO(agrieve): Declaring the output as _from triggers a | |
|
brettw
2015/12/10 00:12:21
Fix: https://codereview.chromium.org/1506343003
W
agrieve
2015/12/10 11:07:38
Great! I cherry-picked this change into a test bra
| |
| 28 # "multiple rules generate foo" warning in ninja when there is a target with | |
| 29 # the same name in a different toolchain | |
| 30 _stamp = "$target_gen_dir/$target_name.stamp" | |
| 31 outputs = [ | |
| 32 _stamp, | |
| 33 ] | |
| 34 script = "//build/symlink.py" | |
| 35 args = [ | |
| 36 "-f", | |
| 37 "--touch", | |
| 38 rebase_path(_stamp, root_build_dir), | |
| 39 rebase_path(_to, get_path_info(_from, "dir")), | |
| 40 rebase_path(_from, root_build_dir), | |
| 41 ] | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 # Creates a convenience symlink from root_build_dir/target_name to | |
| 46 # host_tool_chain/target_name. | |
| 47 # Note that for executables, using a copy (as opposed to a symlink) does not | |
| 48 # work when is_component_build=true, since dependent libraries are found via | |
| 49 # relative location. | |
| 50 # Args: | |
| 51 # target_dep: Target that builds the file to symlink to | |
| 52 # (default=":${invoker.target_name}($host_toolchain)"). | |
| 53 # to: File to symlink to (default="target_dep's out_dir/target_name") | |
| 54 template("host_symlink") { | |
|
brettw
2015/12/10 00:12:21
I find this:
host_sym_link("foo") {
}
really w
agrieve
2015/12/10 11:07:38
Made binary_label mandatory, but left output optio
| |
| 55 symlink(target_name) { | |
| 56 _target_dep = ":${invoker.target_name}($host_toolchain)" | |
| 57 if (defined(invoker.target_dep)) { | |
| 58 _target_dep = invoker.target_dep | |
| 59 } | |
| 60 | |
| 61 forward_variables_from(invoker, | |
| 62 [ | |
| 63 "testonly", | |
| 64 "visibility", | |
| 65 ]) | |
| 66 | |
| 67 # The target doesn't need to be built before creating a symlink to it. | |
| 68 data_deps = [ | |
|
brettw
2015/12/10 00:12:21
I don't think you want to use data deps here. Data
agrieve
2015/12/10 11:07:38
Done.
| |
| 69 _target_dep, | |
| 70 ] | |
| 71 | |
| 72 if (defined(invoker.to)) { | |
| 73 to = invoker.to | |
| 74 } else { | |
| 75 _out_dir = get_label_info(_target_dep, "root_out_dir") | |
| 76 to = "$_out_dir/" + get_label_info(_target_dep, "name") | |
| 77 } | |
| 78 } | |
| 79 } | |
| OLD | NEW |