summaryrefslogtreecommitdiff
path: root/deps/v8/build/symlink.gni
blob: 4da5a57e43530743270c68f477dfb964c5805994 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Creates a symlink.
# Args:
#   source: Path to link to.
#   output: Where to create the symlink.
template("symlink") {
  action(target_name) {
    forward_variables_from(invoker,
                           [
                             "data_deps",
                             "deps",
                             "testonly",
                             "visibility",
                           ])
    outputs = [
      invoker.output,
    ]
    script = "//build/symlink.py"
    args = [
      "-f",
      rebase_path(invoker.source, get_path_info(invoker.output, "dir")),
      rebase_path(invoker.output, root_build_dir),
    ]
  }
}

# Creates a symlink from root_build_dir/target_name to |binary_label|. This rule
# is meant to be used within if (current_toolchain == default_toolchain) blocks
# and point to targets in the non-default toolchain.
# Note that for executables, using a copy (as opposed to a symlink) does not
# work when is_component_build=true, since dependent libraries are found via
# relative location.
#
# Args:
#   binary_label: Target that builds the file to symlink to. e.g.:
#       ":$target_name($host_toolchain)".
#   binary_output_name: The output_name set by the binary_label target
#       (if applicable).
#   output_name: Where to create the symlink
#       (default="$root_out_dir/$binary_output_name").
#
# Example:
#   if (current_toolchain == host_toolchain) {
#     executable("foo") { ... }
#   } else if (current_toolchain == default_toolchain) {
#     binary_symlink("foo") {
#       binary_label = ":foo($host_toolchain)"
#     }
#   }
template("binary_symlink") {
  symlink(target_name) {
    forward_variables_from(invoker,
                           [
                             "output",
                             "testonly",
                             "visibility",
                           ])
    deps = [
      invoker.binary_label,
    ]
    data_deps = [
      invoker.binary_label,
    ]
    if (defined(invoker.data_deps)) {
      data_deps += invoker.data_deps
    }

    _out_dir = get_label_info(invoker.binary_label, "root_out_dir")
    if (defined(invoker.binary_output_name)) {
      _name = invoker.binary_output_name
    } else {
      _name = get_label_info(invoker.binary_label, "name")
    }
    source = "$_out_dir/$_name"

    _output_name = _name
    if (defined(invoker.output_name)) {
      _output_name = invoker.output_name
    }
    output = "$root_out_dir/$_output_name"
  }
}