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=dart:mojo_application,/" + |
| 77 rebase_path("mojo/public/dart/application.dart", "/", mojo_root), |
| 78 "--url-mapping=dart:mojo_bindings,/" + |
| 79 rebase_path("mojo/public/dart/bindings.dart", "/", mojo_root), |
| 80 "--url-mapping=dart:mojo_builtin,/" + |
| 81 rebase_path("mojo/dart/embedder/builtin.dart", "/", mojo_root), |
| 82 "--url-mapping=dart:mojo_core,/" + |
| 83 rebase_path("mojo/public/dart/core.dart", "/", mojo_root), |
| 84 ] |
| 85 |
| 86 deps = [] |
| 87 if (defined(invoker.deps)) { |
| 88 deps += invoker.deps |
| 89 } |
| 90 |
| 91 outputs = [ |
| 92 "$target_gen_dir/{{source_name_part}}.stamp", |
| 93 ] |
| 94 } |
| 95 |
65 dart_package(package_name) { | 96 dart_package(package_name) { |
66 sources = invoker.sources | 97 sources = invoker.sources |
67 if (defined(invoker.deps)) { | 98 if (defined(invoker.deps)) { |
68 deps = invoker.deps | 99 deps = invoker.deps |
69 } | 100 } |
70 if (defined(invoker.mojom_deps)) { | 101 if (defined(invoker.mojom_deps)) { |
71 mojom_deps = invoker.mojom_deps | 102 mojom_deps = invoker.mojom_deps |
72 } | 103 } |
73 if (defined(invoker.datadeps)) { | 104 if (defined(invoker.datadeps)) { |
74 datadeps = invoker.datadeps | 105 datadeps = invoker.datadeps |
75 } | 106 } |
76 } | 107 } |
77 | 108 |
78 action(target_name) { | 109 action(target_name) { |
79 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) | 110 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) |
80 | 111 |
81 input = package_output | 112 input = package_output |
82 inputs = [ | 113 inputs = [ |
83 input, | 114 input, |
84 ] | 115 ] |
85 | 116 |
86 output = mojo_output | 117 output = mojo_output |
87 outputs = [ | 118 outputs = [ |
88 output, | 119 output, |
89 ] | 120 ] |
90 | 121 |
91 deps = [ | 122 deps = [ |
| 123 ":$package_analyze_sources", |
92 ":$package_name", | 124 ":$package_name", |
93 ] | 125 ] |
94 if (defined(invoker.deps)) { | 126 if (defined(invoker.deps)) { |
95 deps += invoker.deps | 127 deps += invoker.deps |
96 } | 128 } |
97 if (defined(invoker.mojom_deps)) { | 129 if (defined(invoker.mojom_deps)) { |
98 deps += invoker.mojom_deps | 130 deps += invoker.mojom_deps |
99 } | 131 } |
100 if (defined(invoker.datadeps)) { | 132 if (defined(invoker.datadeps)) { |
101 datadeps = invoker.datadeps | 133 datadeps = invoker.datadeps |
102 } | 134 } |
103 | 135 |
104 line = "#!mojo mojo:dart_content_handler" | 136 line = "#!mojo mojo:dart_content_handler" |
105 if (defined(invoker.strict) && invoker.strict == true) { | 137 if (defined(invoker.strict) && invoker.strict == true) { |
106 line = "#!mojo mojo:dart_content_handler?strict=true" | 138 line = "#!mojo mojo:dart_content_handler?strict=true" |
107 } | 139 } |
108 | 140 |
109 rebase_input = rebase_path(input, root_build_dir) | 141 rebase_input = rebase_path(input, root_build_dir) |
110 rebase_output = rebase_path(output, root_build_dir) | 142 rebase_output = rebase_path(output, root_build_dir) |
111 args = [ | 143 args = [ |
112 "--input=$rebase_input", | 144 "--input=$rebase_input", |
113 "--output=$rebase_output", | 145 "--output=$rebase_output", |
114 "--line=$line", | 146 "--line=$line", |
115 ] | 147 ] |
116 } | 148 } |
117 } | 149 } |
OLD | NEW |