| OLD | NEW |
| 1 # Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
| 3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 _dart_root = rebase_path("..") | 5 _dart_root = rebase_path("..") |
| 6 | 6 |
| 7 # copy_tree() copies a directory tree rooted at `source` to `dest`, which should | 7 # copy_tree() copies a directory tree rooted at `source` to `dest`, which should |
| 8 # be somewhere under $root_out_dir. | 8 # be somewhere under $root_out_dir. |
| 9 # | 9 # |
| 10 # Optional parameters: | 10 # Optional parameters: |
| 11 # exclude - A comma separated list that is passed to shutil.ignore_patterns() | 11 # exclude - A comma separated list that is passed to shutil.ignore_patterns() |
| 12 # in tools/copy_tree.py. | 12 # in tools/copy_tree.py. |
| 13 template("copy_tree") { | 13 template("copy_tree") { |
| 14 assert(defined(invoker.source), "copy_tree must define 'source'") | 14 assert(defined(invoker.source), "copy_tree must define 'source'") |
| 15 assert(defined(invoker.dest), "copy_tree must define 'dest'") | 15 assert(defined(invoker.dest), "copy_tree must define 'dest'") |
| 16 assert(defined(invoker.inputs), "copy_tree must define 'inputs'") |
| 16 source = invoker.source | 17 source = invoker.source |
| 17 dest = invoker.dest | 18 dest = invoker.dest |
| 19 inputs = invoker.inputs |
| 18 action(target_name) { | 20 action(target_name) { |
| 19 if (defined(invoker.visibility)) { | 21 if (defined(invoker.visibility)) { |
| 20 visibility = invoker.visibility | 22 visibility = invoker.visibility |
| 21 } | 23 } |
| 22 | 24 |
| 23 deps = [] | 25 deps = [] |
| 24 if (defined(invoker.deps)) { | 26 if (defined(invoker.deps)) { |
| 25 deps += invoker.deps | 27 deps += invoker.deps |
| 26 } | 28 } |
| 27 | 29 |
| 28 common_args = [ | 30 common_args = [ |
| 29 "--from", | 31 "--from", |
| 30 rebase_path(source), | 32 rebase_path(source), |
| 31 "--to", | 33 "--to", |
| 32 rebase_path(dest), | 34 rebase_path(dest), |
| 33 ] | 35 ] |
| 34 if (defined(invoker.exclude)) { | 36 if (defined(invoker.exclude)) { |
| 35 common_args += [ | 37 common_args += [ |
| 36 "--exclude", | 38 "--exclude", |
| 37 invoker.exclude, | 39 invoker.exclude, |
| 38 ] | 40 ] |
| 39 } | 41 } |
| 40 | 42 |
| 41 dry_run_args = common_args + [ "--dry-run" ] | 43 relative_files = rebase_path(inputs, rebase_path(source)) |
| 42 input_files = exec_script("$_dart_root/tools/copy_tree.py", | |
| 43 dry_run_args, | |
| 44 "list lines") | |
| 45 inputs = input_files | |
| 46 relative_files = rebase_path(input_files, rebase_path(source)) | |
| 47 | 44 |
| 48 output_files = [] | 45 output_files = [] |
| 49 foreach(input, relative_files) { | 46 foreach(input, relative_files) { |
| 50 output_files += [ "$dest/$input" ] | 47 output_files += [ "$dest/$input" ] |
| 51 } | 48 } |
| 52 | 49 |
| 53 outputs = output_files | 50 outputs = output_files |
| 54 script = "$_dart_root/tools/copy_tree.py" | 51 script = "$_dart_root/tools/copy_tree.py" |
| 55 args = common_args | 52 args = common_args |
| 56 } | 53 } |
| 57 } | 54 } |
| OLD | NEW |