| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # Rules to generate python packaged applications for Dart | 5 # Rules to generate python packaged applications for Dart |
| 6 | 6 |
| 7 import("../mojo_sdk.gni") | 7 import("../mojo_sdk.gni") |
| 8 | 8 |
| 9 template("dart_package") { | 9 template("dart_package") { |
| 10 action(target_name) { | 10 action(target_name) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 # Use this template to generate a .mojo dart application. One of the source | 50 # Use this template to generate a .mojo dart application. One of the source |
| 51 # files should be named main.dart and contain a main function as the | 51 # files should be named main.dart and contain a main function as the |
| 52 # entry point. Dependencies of dart_packaged_application targets should be | 52 # entry point. Dependencies of dart_packaged_application targets should be |
| 53 # either mojom targets (and specified using the mojom_deps variable) or | 53 # either mojom targets (and specified using the mojom_deps variable) or |
| 54 # dart_package targets. | 54 # dart_package targets. |
| 55 template("dart_packaged_application") { | 55 template("dart_packaged_application") { |
| 56 package_name = "${target_name}_package" | 56 package_name = "${target_name}_package" |
| 57 package_analyze_sources = "${target_name}_analyze" |
| 57 package_output = "$target_out_dir/$package_name.dartzip" | 58 package_output = "$target_out_dir/$package_name.dartzip" |
| 58 | 59 |
| 59 if (defined(invoker.output_name)) { | 60 if (defined(invoker.output_name)) { |
| 60 mojo_output = "$root_out_dir/" + invoker.output_name + ".mojo" | 61 mojo_output = "$root_out_dir/" + invoker.output_name + ".mojo" |
| 61 } else { | 62 } else { |
| 62 mojo_output = "$root_out_dir/" + target_name + ".mojo" | 63 mojo_output = "$root_out_dir/" + target_name + ".mojo" |
| 63 } | 64 } |
| 64 | 65 |
| 66 action_foreach(package_analyze_sources) { |
| 67 sources = invoker.sources |
| 68 |
| 69 script = rebase_path("mojo/public/tools/dart_analyze.py", ".", mojo_root) |
| 70 |
| 71 args = [ |
| 72 rebase_path(root_gen_dir), |
| 73 rebase_path("$target_gen_dir/{{source_name_part}}.stamp"), |
| 74 "{{source}}", |
| 75 "--no-hints", |
| 76 "--url-mapping=mojo:application,/" + |
| 77 rebase_path("mojo/public/dart/application.dart", "/", mojo_root), |
| 78 "--url-mapping=mojo:bindings,/" + |
| 79 rebase_path("mojo/public/dart/bindings.dart", "/", mojo_root), |
| 80 "--url-mapping=mojo:builtin,/" + |
| 81 rebase_path("mojo/dart/embedder/builtin.dart", "/", mojo_root), |
| 82 "--url-mapping=mojo:core,/" + |
| 83 rebase_path("mojo/public/dart/core.dart", "/", mojo_root), |
| 84 ] |
| 85 |
| 86 if (defined(invoker.deps)) { |
| 87 deps = invoker.deps |
| 88 } |
| 89 |
| 90 if (defined(invoker.datadeps)) { |
| 91 datadeps = invoker.datadeps |
| 92 } |
| 93 |
| 94 outputs = [ |
| 95 "$target_gen_dir/{{source_name_part}}.stamp", |
| 96 ] |
| 97 } |
| 98 |
| 65 dart_package(package_name) { | 99 dart_package(package_name) { |
| 66 sources = invoker.sources | 100 sources = invoker.sources |
| 67 if (defined(invoker.deps)) { | 101 if (defined(invoker.deps)) { |
| 68 deps = invoker.deps | 102 deps = invoker.deps |
| 69 } | 103 } |
| 70 if (defined(invoker.mojom_deps)) { | 104 if (defined(invoker.mojom_deps)) { |
| 71 mojom_deps = invoker.mojom_deps | 105 mojom_deps = invoker.mojom_deps |
| 72 } | 106 } |
| 73 if (defined(invoker.datadeps)) { | 107 if (defined(invoker.datadeps)) { |
| 74 datadeps = invoker.datadeps | 108 datadeps = invoker.datadeps |
| 75 } | 109 } |
| 76 } | 110 } |
| 77 | 111 |
| 78 action(target_name) { | 112 action(target_name) { |
| 79 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) | 113 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) |
| 80 | 114 |
| 81 input = package_output | 115 input = package_output |
| 82 inputs = [ | 116 inputs = [ |
| 83 input, | 117 input, |
| 84 ] | 118 ] |
| 85 | 119 |
| 86 output = mojo_output | 120 output = mojo_output |
| 87 outputs = [ | 121 outputs = [ |
| 88 output, | 122 output, |
| 89 ] | 123 ] |
| 90 | 124 |
| 91 deps = [ | 125 deps = [ |
| 126 # TODO(erg): When dartanalyze runs at an acceptable speed, add |
| 127 # ":$package_analyze_sources" as a dependency here and remove the |
| 128 # manual group("check") in the toplevel build file. |
| 92 ":$package_name", | 129 ":$package_name", |
| 93 ] | 130 ] |
| 94 if (defined(invoker.deps)) { | 131 if (defined(invoker.deps)) { |
| 95 deps += invoker.deps | 132 deps += invoker.deps |
| 96 } | 133 } |
| 97 if (defined(invoker.mojom_deps)) { | 134 if (defined(invoker.mojom_deps)) { |
| 98 deps += invoker.mojom_deps | 135 deps += invoker.mojom_deps |
| 99 } | 136 } |
| 100 if (defined(invoker.datadeps)) { | 137 if (defined(invoker.datadeps)) { |
| 101 datadeps = invoker.datadeps | 138 datadeps = invoker.datadeps |
| 102 } | 139 } |
| 103 | 140 |
| 104 line = "#!mojo mojo:dart_content_handler" | 141 line = "#!mojo mojo:dart_content_handler" |
| 105 if (defined(invoker.strict) && invoker.strict == true) { | 142 if (defined(invoker.strict) && invoker.strict == true) { |
| 106 line = "#!mojo mojo:dart_content_handler?strict=true" | 143 line = "#!mojo mojo:dart_content_handler?strict=true" |
| 107 } | 144 } |
| 108 | 145 |
| 109 rebase_input = rebase_path(input, root_build_dir) | 146 rebase_input = rebase_path(input, root_build_dir) |
| 110 rebase_output = rebase_path(output, root_build_dir) | 147 rebase_output = rebase_path(output, root_build_dir) |
| 111 args = [ | 148 args = [ |
| 112 "--input=$rebase_input", | 149 "--input=$rebase_input", |
| 113 "--output=$rebase_output", | 150 "--output=$rebase_output", |
| 114 "--line=$line", | 151 "--line=$line", |
| 115 ] | 152 ] |
| 116 } | 153 } |
| 117 } | 154 } |
| OLD | NEW |