Index: sdk/BUILD.gn |
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn |
index f0458053bb42a589eb986a7194cb2190cf9943b4..86c50e05863c1342e83b586324482771c4926454 100644 |
--- a/sdk/BUILD.gn |
+++ b/sdk/BUILD.gn |
@@ -215,6 +215,150 @@ _analyzer_source_dirs = [ |
"kernel", |
] |
+# 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") { |
zra
2017/08/09 18:05:01
I moved this to copy_tree.gni
|
+ 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 |
+ ] |
+ } |
+ # A scope containing a single value "sources" |
rmacnak
2017/08/07 22:20:19
Evaluate script output as GN, producing a scope...
zra
2017/08/09 18:05:01
Done.
|
+ copy_tree_inputs_scope = exec_script("../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 |
+ } |
+} |
+ |
+# From here down to the copy_trees() invocation, we collect all the information |
+# about trees that need to be copied in the list of scopes, copy_tree_specs. |
+copy_tree_specs = [] |
+ |
+# This loop generates rules for copying analyzer sources into lib/ |
+foreach(analyzer_source_dir, _analyzer_source_dirs) { |
+ copy_tree_specs += [{ |
+ target = "copy_${analyzer_source_dir}_source_dir" |
+ visibility = [ ":copy_analyzer_sources" ] |
+ source = "../pkg/$analyzer_source_dir" |
+ dest = "$root_out_dir/dart-sdk/lib/$analyzer_source_dir" |
+ ignore_patterns = "*.svn,doc,*.py,*.gypi,*.sh,.gitignore,packages,test,testcases" |
+ }] |
+} |
+ |
+# This rule copies dartdoc templates to |
+# bin/snapshots/resources/dartdoc/templates |
+copy_tree_specs += [{ |
+ target = "copy_dartdoc_templates" |
+ visibility = [ ":copy_dartdoc_files" ] |
+ source = "../third_party/pkg/dartdoc/lib/templates" |
+ dest = "$root_out_dir/dart-sdk/bin/snapshots/resources/dartdoc/templates" |
+ ignore_patterns = "{}" |
+}] |
+ |
+# This rule copies dartdoc resources to |
+# bin/snapshots/resources/dartdoc/resources |
+copy_tree_specs += [{ |
+ target = "copy_dartdoc_resources" |
+ visibility = [ ":copy_dartdoc_files" ] |
+ source = "../third_party/pkg/dartdoc/lib/resources" |
+ dest = "$root_out_dir/dart-sdk/bin/snapshots/resources/dartdoc/resources" |
+ ignore_patterns = "{}" |
+}] |
+ |
+# This rule copies js needed by ddc to lib/dev_compiler |
+copy_tree_specs += [{ |
+ target = "copy_dev_compiler_js" |
+ visibility = [ |
+ ":copy_dev_compiler_sdk", |
+ ":copy_dev_compiler_require_js", |
+ ":copy_dev_compiler_tools", |
+ ] |
+ source = "../pkg/dev_compiler/lib/js" |
+ dest = "$root_out_dir/dart-sdk/lib/dev_compiler" |
+ ignore_patterns = "{}" |
+}] |
+ |
+# This rule copies pub assets to lib/_internal/pub/asset |
+copy_tree_specs += [{ |
+ target = "copy_pub_assets" |
+ visibility = [ |
+ ":create_common_sdk", |
+ ":copy_7zip", |
+ ] |
+ deps = [ |
+ ":copy_libraries", |
+ ] |
+ source = "../third_party/pkg/pub/lib/src/asset" |
+ dest = "$root_out_dir/dart-sdk/lib/_internal/pub/asset" |
+ ignore_patterns = "{}" |
+}] |
+ |
+# This loop generates rules to copy libraries to lib/ |
+foreach(library, _full_sdk_libraries) { |
+ copy_tree_specs += [{ |
+ target = "copy_${library}_library" |
+ visibility = [ |
+ ":copy_platform_sdk_libraries", |
+ ":copy_full_sdk_libraries", |
+ ] |
+ source = "lib/$library" |
+ dest = "$root_out_dir/dart-sdk/lib/$library" |
+ ignore_patterns = "*.svn,doc,*.py,*.gypi,*.sh,.gitignore" |
+ }] |
+} |
+ |
+if (is_win) { |
+ copy_tree_specs += [{ |
+ target = "copy_7zip" |
+ visibility = [ ":create_common_sdk" ] |
+ deps = [ |
+ ":copy_libraries", |
+ ":copy_pub_assets", |
+ ] |
+ source = "../third_party/7zip" |
+ dest = "$root_out_dir/dart-sdk/lib/_internal/pub/asset/7zip" |
+ ignore_patterns = ".svn" |
+ }] |
+} |
+ |
+# This generates all of the copy_tree() targets. |
+copy_trees("copy_trees") { |
+ sources = copy_tree_specs |
+} |
+ |
# Copies the Dart VM binary into bin/ |
copy("copy_dart") { |
visibility = [ ":create_common_sdk" ] |
@@ -381,16 +525,6 @@ group("copy_full_sdk_snapshots") { |
} |
} |
-# This loop generates rules for copying analyzer sources into lib/ |
-foreach(analyzer_source_dir, _analyzer_source_dirs) { |
- copy_tree("copy_${analyzer_source_dir}_source_dir") { |
- visibility = [ ":copy_analyzer_sources" ] |
- source = "../pkg/$analyzer_source_dir" |
- dest = "$root_out_dir/dart-sdk/lib/$analyzer_source_dir" |
- exclude = "*.svn,doc,*.py,*.gypi,*.sh,.gitignore,packages,test,testcases" |
- } |
-} |
- |
# This is the main rule for copying analyzer sources to lib/ |
group("copy_analyzer_sources") { |
visibility = [ ":create_common_sdk" ] |
@@ -400,22 +534,6 @@ group("copy_analyzer_sources") { |
} |
} |
-# This rule copies dartdoc templates to |
-# bin/snapshots/resources/dartdoc/templates |
-copy_tree("copy_dartdoc_templates") { |
- visibility = [ ":copy_dartdoc_files" ] |
- source = "../third_party/pkg/dartdoc/lib/templates" |
- dest = "$root_out_dir/dart-sdk/bin/snapshots/resources/dartdoc/templates" |
-} |
- |
-# This rule copies dartdoc resources to |
-# bin/snapshots/resources/dartdoc/resources |
-copy_tree("copy_dartdoc_resources") { |
- visibility = [ ":copy_dartdoc_files" ] |
- source = "../third_party/pkg/dartdoc/lib/resources" |
- dest = "$root_out_dir/dart-sdk/bin/snapshots/resources/dartdoc/resources" |
-} |
- |
# This rule writes the .packages file for dartdoc resources. |
write_file("$root_out_dir/dart-sdk/bin/snapshots/resources/dartdoc/.packages", |
"dartdoc:.") |
@@ -490,17 +608,6 @@ copy("copy_dev_compiler_summary") { |
] |
} |
-# This rule copies js needed by ddc to lib/dev_compiler |
-copy_tree("copy_dev_compiler_js") { |
- visibility = [ |
- ":copy_dev_compiler_sdk", |
- ":copy_dev_compiler_require_js", |
- ":copy_dev_compiler_tools", |
- ] |
- source = "../pkg/dev_compiler/lib/js" |
- dest = "$root_out_dir/dart-sdk/lib/dev_compiler" |
-} |
- |
# This rule copies require.js to lib/dev_compiler/amd |
copy("copy_dev_compiler_require_js") { |
visibility = [ ":copy_dev_compiler_sdk" ] |
@@ -571,32 +678,6 @@ copy("copy_platform_files") { |
] |
} |
-# This rule copies pub assets to lib/_internal/pub/asset |
-copy_tree("copy_pub_assets") { |
- visibility = [ |
- ":create_common_sdk", |
- ":copy_7zip", |
- ] |
- deps = [ |
- ":copy_libraries", |
- ] |
- source = "../third_party/pkg/pub/lib/src/asset" |
- dest = "$root_out_dir/dart-sdk/lib/_internal/pub/asset" |
-} |
- |
-# This loop generates rules to copy libraries to lib/ |
-foreach(library, _full_sdk_libraries) { |
- copy_tree("copy_${library}_library") { |
- visibility = [ |
- ":copy_platform_sdk_libraries", |
- ":copy_full_sdk_libraries", |
- ] |
- source = "lib/$library" |
- dest = "$root_out_dir/dart-sdk/lib/$library" |
- exclude = "*.svn,doc,*.py,*.gypi,*.sh,.gitignore" |
- } |
-} |
- |
# This is the main rule to copy libraries in _platform_sdk_libraries to lib/ |
group("copy_platform_sdk_libraries") { |
visibility = [ |
@@ -633,19 +714,6 @@ group("copy_libraries") { |
} |
} |
-if (is_win) { |
- copy_tree("copy_7zip") { |
- visibility = [ ":create_common_sdk" ] |
- deps = [ |
- ":copy_libraries", |
- ":copy_pub_assets", |
- ] |
- source = "../third_party/7zip" |
- dest = "$root_out_dir/dart-sdk/lib/_internal/pub/asset/7zip" |
- exclude = ".svn" |
- } |
-} |
- |
# This rule writes the version file. |
action("write_version_file") { |
visibility = [ ":create_common_sdk" ] |