2017-05-21 06:30:06 +00:00
|
|
|
# Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
|
|
|
|
# for details. All rights reserved. Use of this source code is governed by a
|
|
|
|
# BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
_dart_root = rebase_path("..")
|
|
|
|
|
|
|
|
# copy_tree() copies a directory tree rooted at `source` to `dest`, which should
|
|
|
|
# be somewhere under $root_out_dir.
|
|
|
|
#
|
|
|
|
# Optional parameters:
|
|
|
|
# exclude - A comma separated list that is passed to shutil.ignore_patterns()
|
|
|
|
# in tools/copy_tree.py.
|
2017-08-09 18:13:59 +00:00
|
|
|
template("_copy_tree") {
|
2017-05-21 06:30:06 +00:00
|
|
|
assert(defined(invoker.source), "copy_tree must define 'source'")
|
|
|
|
assert(defined(invoker.dest), "copy_tree must define 'dest'")
|
2017-08-09 18:13:59 +00:00
|
|
|
assert(defined(invoker.inputs), "copy_tree must define 'inputs'")
|
2017-05-21 06:30:06 +00:00
|
|
|
source = invoker.source
|
|
|
|
dest = invoker.dest
|
2017-08-09 18:13:59 +00:00
|
|
|
inputs = invoker.inputs
|
2017-05-21 06:30:06 +00:00
|
|
|
action(target_name) {
|
|
|
|
if (defined(invoker.visibility)) {
|
|
|
|
visibility = invoker.visibility
|
|
|
|
}
|
|
|
|
|
|
|
|
deps = []
|
|
|
|
if (defined(invoker.deps)) {
|
|
|
|
deps += invoker.deps
|
|
|
|
}
|
|
|
|
|
|
|
|
common_args = [
|
|
|
|
"--from",
|
|
|
|
rebase_path(source),
|
|
|
|
"--to",
|
|
|
|
rebase_path(dest),
|
|
|
|
]
|
|
|
|
if (defined(invoker.exclude)) {
|
|
|
|
common_args += [
|
|
|
|
"--exclude",
|
|
|
|
invoker.exclude,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2017-08-09 18:13:59 +00:00
|
|
|
relative_files = rebase_path(inputs, rebase_path(source))
|
2017-05-21 06:30:06 +00:00
|
|
|
|
|
|
|
output_files = []
|
|
|
|
foreach(input, relative_files) {
|
|
|
|
output_files += [ "$dest/$input" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
outputs = output_files
|
|
|
|
script = "$_dart_root/tools/copy_tree.py"
|
|
|
|
args = common_args
|
|
|
|
}
|
|
|
|
}
|
2017-08-09 18:13:59 +00:00
|
|
|
|
|
|
|
# copy_trees() arranges to invoke copy_tree.py only once to gather the list of
|
|
|
|
# input source files for every _copy_tree() target. It takes a list of scopes as
|
|
|
|
# a parameter. The scopes should contain the following mappings.
|
|
|
|
#
|
|
|
|
# target: The target name for the _copy_tree() target.
|
|
|
|
# visibility: The visibility for the _copy_tree() target.
|
|
|
|
# source: The source directory relative to this directory.
|
|
|
|
# dest: The destination directory for the _copy_tree() target.
|
|
|
|
# deps: Any deps needed for the _copy_tree() target.
|
|
|
|
# ignore_patterns: Patterns to ignore when walking the directory tree.
|
|
|
|
# This should be '{}' if nothing should be ignored.
|
|
|
|
#
|
|
|
|
# copy_trees() will then make sure each invocation of _copy_tree() has the
|
|
|
|
# correct 'inputs' parameter
|
|
|
|
template("copy_trees") {
|
|
|
|
assert(defined(invoker.sources), "$target_name must define 'source'")
|
|
|
|
sources = invoker.sources
|
|
|
|
copy_tree_source_paths = []
|
|
|
|
foreach(copy_tree_spec, sources) {
|
|
|
|
copy_tree_source_paths += [
|
|
|
|
rebase_path(copy_tree_spec.source),
|
|
|
|
copy_tree_spec.ignore_patterns
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Evaluate script output as GN, producing a scope containing a single value
|
|
|
|
# "sources"
|
|
|
|
copy_tree_inputs_scope = exec_script("$_dart_root/tools/copy_tree.py",
|
|
|
|
["--gn"] + copy_tree_source_paths,
|
|
|
|
"scope")
|
|
|
|
|
|
|
|
# A list of lists of input source files for copy_tree.
|
|
|
|
copy_tree_inputs = copy_tree_inputs_scope.sources
|
|
|
|
copy_tree_inputs_index = 0
|
|
|
|
foreach(copy_tree_spec, sources) {
|
|
|
|
_copy_tree(copy_tree_spec.target) {
|
|
|
|
visibility = copy_tree_spec.visibility
|
|
|
|
source = copy_tree_spec.source
|
|
|
|
dest = copy_tree_spec.dest
|
|
|
|
inputs = copy_tree_inputs[copy_tree_inputs_index]
|
|
|
|
if (defined(copy_tree_spec.deps)) {
|
|
|
|
deps = copy_tree_spec.deps
|
|
|
|
}
|
|
|
|
if (copy_tree_spec.ignore_patterns != "{}") {
|
|
|
|
exclude = copy_tree_spec.ignore_patterns
|
|
|
|
}
|
|
|
|
}
|
|
|
|
copy_tree_inputs_index = copy_tree_inputs_index + 1
|
|
|
|
}
|
|
|
|
}
|