OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 declare_args() { | 5 declare_args() { |
6 # Absolute path to a resource whitelist (generated using | 6 # Absolute path to a resource whitelist (generated using |
7 # //tools/resources/find_used_resources.py). | 7 # //tools/resources/find_used_resources.py). |
8 repack_whitelist = "" | 8 repack_whitelist = "" |
9 } | 9 } |
10 | 10 |
11 # This file defines a template to invoke grit repack in a consistent manner. | 11 # This file defines a template to invoke grit repack in a consistent manner. |
12 # | 12 # |
13 # Parameters: | 13 # Parameters: |
14 # sources [required] | 14 # sources [required] |
15 # List of pak files that need to be combined. | 15 # List of pak files that need to be combined. |
16 # | 16 # |
17 # output [required] | 17 # output [required] |
18 # File name (single string) of the output file. | 18 # File name (single string) of the output file. |
19 # | 19 # |
20 # deps [optional] | 20 # deps [optional] |
21 # visibility [optional] | 21 # visibility [optional] |
22 # Normal meaning. | 22 # Normal meaning. |
23 template("repack") { | 23 template("repack") { |
24 action(target_name) { | 24 action(target_name) { |
| 25 forward_variables_from(invoker, |
| 26 [ |
| 27 "deps", |
| 28 "testonly", |
| 29 "visibility", |
| 30 ]) |
25 assert(defined(invoker.sources), "Need sources for $target_name") | 31 assert(defined(invoker.sources), "Need sources for $target_name") |
26 assert(defined(invoker.output), "Need output for $target_name") | 32 assert(defined(invoker.output), "Need output for $target_name") |
27 | 33 |
28 if (defined(invoker.visibility)) { | |
29 visibility = invoker.visibility | |
30 } | |
31 | |
32 script = "//tools/grit/grit/format/repack.py" | 34 script = "//tools/grit/grit/format/repack.py" |
33 | 35 |
34 inputs = invoker.sources | 36 inputs = invoker.sources |
35 outputs = [ | 37 outputs = [ |
36 invoker.output, | 38 invoker.output, |
37 ] | 39 ] |
38 | 40 |
39 args = [] | 41 args = [] |
40 if (repack_whitelist != "") { | 42 if (repack_whitelist != "") { |
41 assert( | 43 assert( |
42 repack_whitelist == rebase_path(repack_whitelist), | 44 repack_whitelist == rebase_path(repack_whitelist), |
43 "repack_whitelist must be an absolute path. Current value is $repack_w
hitelist") | 45 "repack_whitelist must be an absolute path. Current value is $repack_w
hitelist") |
44 args += [ "--whitelist=$repack_whitelist" ] | 46 args += [ "--whitelist=$repack_whitelist" ] |
45 } | 47 } |
46 args += [ rebase_path(invoker.output, root_build_dir) ] | 48 args += [ rebase_path(invoker.output, root_build_dir) ] |
47 args += rebase_path(invoker.sources, root_build_dir) | 49 args += rebase_path(invoker.sources, root_build_dir) |
48 | |
49 if (defined(invoker.deps)) { | |
50 deps = invoker.deps | |
51 } | |
52 } | 50 } |
53 } | 51 } |
54 | 52 |
55 # This template combines repacking resources and defining a bundle_data target | 53 # This template combines repacking resources and defining a bundle_data target |
56 # to move them to the application bundle. This is mostly useful on iOS. | 54 # to move them to the application bundle. This is mostly useful on iOS. |
57 # | 55 # |
58 # Parameters: | 56 # Parameters: |
59 # sources [required] | 57 # sources [required] |
60 # List of pak files that need to be combined. | 58 # List of pak files that need to be combined. |
61 # | 59 # |
(...skipping 13 matching lines...) Expand all Loading... |
75 _repack_target_name = target_name + "_repack" | 73 _repack_target_name = target_name + "_repack" |
76 _bundle_target_name = target_name | 74 _bundle_target_name = target_name |
77 | 75 |
78 repack(_repack_target_name) { | 76 repack(_repack_target_name) { |
79 visibility = [ ":$_bundle_target_name" ] | 77 visibility = [ ":$_bundle_target_name" ] |
80 forward_variables_from(invoker, | 78 forward_variables_from(invoker, |
81 [ | 79 [ |
82 "deps", | 80 "deps", |
83 "output", | 81 "output", |
84 "sources", | 82 "sources", |
| 83 "testonly", |
85 ]) | 84 ]) |
86 } | 85 } |
87 | 86 |
88 bundle_data(_bundle_target_name) { | 87 bundle_data(_bundle_target_name) { |
89 forward_variables_from(invoker, [ "visibility" ]) | 88 forward_variables_from(invoker, |
| 89 [ |
| 90 "testonly", |
| 91 "visibility", |
| 92 ]) |
90 | 93 |
91 public_deps = [ | 94 public_deps = [ |
92 ":$_repack_target_name", | 95 ":$_repack_target_name", |
93 ] | 96 ] |
94 sources = [ | 97 sources = [ |
95 invoker.output, | 98 invoker.output, |
96 ] | 99 ] |
97 if (defined(invoker.bundle_output)) { | 100 if (defined(invoker.bundle_output)) { |
98 outputs = [ | 101 outputs = [ |
99 invoker.bundle_output, | 102 invoker.bundle_output, |
100 ] | 103 ] |
101 } else { | 104 } else { |
102 outputs = [ | 105 outputs = [ |
103 "{{bundle_resources_dir}}/{{source_file_part}}", | 106 "{{bundle_resources_dir}}/{{source_file_part}}", |
104 ] | 107 ] |
105 } | 108 } |
106 } | 109 } |
107 } | 110 } |
OLD | NEW |