Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: mojo/public/dart/rules.gni

Issue 1063233004: Teach dart_package to understand the packages/ subdirectory (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Remove dart-packages Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/dart/rules.gni
diff --git a/mojo/public/dart/rules.gni b/mojo/public/dart/rules.gni
index 036c0733ec77ec9cb49b1b6116220cb093c5f011..94b50efa93d71202ef9430dd413bac468c7a0971 100644
--- a/mojo/public/dart/rules.gni
+++ b/mojo/public/dart/rules.gni
@@ -4,23 +4,64 @@
# Rules to generate python packaged applications for Dart
-import("../mojo_sdk.gni")
+import("//build/module_args/mojo.gni")
template("dart_package") {
package_target_name = "$target_name"
package_output = "$target_out_dir/$target_name.dartzip"
+ if (defined(invoker.uses_pub) && invoker.uses_pub) {
+ # Pull in any dependencies specified via pubspec.yaml and repackage them in
+ # a dartzip file.
+ action("${package_target_name}_pub_get") {
+ target_dir = get_label_info(":$target_name", "dir")
+ script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_sdk_root)
+
+ # Run pub get and get a list of the pulled-in files as inputs.
+ pub_get_script =
+ rebase_path("mojo/public/tools/dart_pub_get.py", ".", mojo_sdk_root)
+ rebase_dart_sdk_root = rebase_path(mojo_dart_sdk_root, root_build_dir)
+ rebase_target_dir = rebase_path(target_dir, root_build_dir)
+ inputs = exec_script(pub_get_script,
tonyg 2015/04/08 13:52:38 Curious about a couple of things: 1. Does pub get
blundell 2015/04/09 11:53:41 The inputs to the inner script are (1) the script
+ [
+ rebase_dart_sdk_root,
+ rebase_target_dir,
+ ],
+ "list lines",
+ [ target_dir + "/pubspec.lock" ])
+
+ # Zip up all the pulled-in files relative to their location in the
+ # packages dir.
+ output = "$target_out_dir/$target_name.dartzip"
+ outputs = [
+ output,
+ ]
+ rebase_base_dir = rebase_target_dir + "/packages"
+ rebase_inputs = rebase_path(inputs, root_build_dir)
+ rebase_output = rebase_path(output, root_build_dir)
+ args = [
+ "--base-dir=$rebase_base_dir",
+ "--inputs=$rebase_inputs",
+ "--output=$rebase_output",
+ ]
+ }
+ }
+
action("${package_target_name}_package") {
- script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_root)
+ script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_sdk_root)
inputs = invoker.sources
deps = []
zip_inputs = []
+ if (defined(invoker.uses_pub) && invoker.uses_pub) {
+ deps += [ ":${package_target_name}_pub_get" ]
+ }
+
if (defined(invoker.deps)) {
deps += invoker.deps
- foreach(d, invoker.deps) {
+ foreach(d, deps) {
dep_name = get_label_info(d, "name")
dep_target_out_dir = get_label_info(d, "target_out_dir")
zip_inputs += [ "$dep_target_out_dir/$dep_name.dartzip" ]
@@ -54,7 +95,8 @@ template("dart_package") {
}
action(target_name) {
- script = rebase_path("mojo/public/tools/dart_analyze.py", ".", mojo_root)
+ script =
+ rebase_path("mojo/public/tools/dart_analyze.py", ".", mojo_sdk_root)
sources = [
package_output,
@@ -103,6 +145,9 @@ template("dart_packaged_application") {
if (defined(invoker.deps)) {
deps = invoker.deps
}
+ if (defined(invoker.uses_pub)) {
+ uses_pub = invoker.uses_pub
+ }
if (defined(invoker.mojom_deps)) {
mojom_deps = invoker.mojom_deps
}
@@ -112,7 +157,7 @@ template("dart_packaged_application") {
}
action(target_name) {
- script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root)
+ script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_sdk_root)
input = package_output
inputs = [

Powered by Google App Engine
This is Rietveld 408576698