OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 # Instantiate grit. This will produce a script target to run grit, and a | 5 # Instantiate grit. This will produce a script target to run grit, and a |
6 # static library that compiles the .cc files. | 6 # static library that compiles the .cc files. |
7 # | 7 # |
8 # Example: | 8 # Example: |
9 # grit("my_resources") { | 9 # grit("my_resources") { |
10 # source = "myfile.grd" # source is required. | 10 # source = "myfile.grd" # source is required. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 # the current one. | 48 # the current one. |
49 grit_outputs = rebase_path(grit_outputs_build_rel, root_build_dir) | 49 grit_outputs = rebase_path(grit_outputs_build_rel, root_build_dir) |
50 | 50 |
51 # The current grit setup makes an file in $target_gen_dir/grit/foo.h that | 51 # The current grit setup makes an file in $target_gen_dir/grit/foo.h that |
52 # the source code expects to include via "grit/foo.h". It would be nice to | 52 # the source code expects to include via "grit/foo.h". It would be nice to |
53 # change this to including absolute paths relative to the root gen directory | 53 # change this to including absolute paths relative to the root gen directory |
54 # (like "mycomponent/foo.h"). This config sets up the include path. | 54 # (like "mycomponent/foo.h"). This config sets up the include path. |
55 grit_config = target_name + "_grit_config" | 55 grit_config = target_name + "_grit_config" |
56 config(grit_config) { | 56 config(grit_config) { |
57 include_dirs = [ target_gen_dir ] | 57 include_dirs = [ target_gen_dir ] |
| 58 |
| 59 # Only our generated static library can depend on this. |
| 60 visibility = ":" + target_name |
58 } | 61 } |
59 | 62 |
60 grit_custom_target = target_name + "_grit" | 63 grit_custom_target = target_name + "_grit" |
61 action(grit_custom_target) { | 64 action(grit_custom_target) { |
62 script = "//tools/grit/grit.py" | 65 script = "//tools/grit/grit.py" |
63 source_prereqs = grit_inputs | 66 source_prereqs = grit_inputs |
64 outputs = grit_outputs | 67 outputs = grit_outputs |
65 | 68 |
66 # TODO(brettw) grit_defines. | 69 # TODO(brettw) grit_defines. |
67 args = [ | 70 args = [ |
68 "-i", source_path, "build", | 71 "-i", source_path, "build", |
69 "-f", resource_ids, | 72 "-f", resource_ids, |
70 "-o", output_dir, | 73 "-o", output_dir, |
71 ] + grit_flags | 74 ] + grit_flags |
72 | 75 |
73 # Inherit deps from template invocation if any. | 76 # Only our generated static library can depend on this. |
| 77 visibility = ":" + target_name |
74 } | 78 } |
75 | 79 |
76 # This is the thing that people actually link with, it must be named the | 80 # This is the thing that people actually link with, it must be named the |
77 # same as the argument the template was invoked with. | 81 # same as the argument the template was invoked with. |
78 static_library(target_name) { | 82 static_library(target_name) { |
79 # Since we generate a file, we need to be run before the targets that | 83 # Since we generate a file, we need to be run before the targets that |
80 # depend on us. | 84 # depend on us. |
81 hard_dep = true | 85 hard_dep = true |
82 sources = grit_outputs | 86 sources = grit_outputs |
83 | 87 |
84 # Deps set on the template invocation will go on the grit script running | 88 # Deps set on the template invocation will go on the grit script running |
85 # target rather than this library. | 89 # target rather than this library. |
86 deps = [] | 90 deps = [] |
87 deps = [ ":$grit_custom_target" ] | 91 deps = [ ":$grit_custom_target" ] |
88 direct_dependent_configs = [ ":$grit_config" ] | 92 direct_dependent_configs = [ ":$grit_config" ] |
| 93 |
| 94 if (defined(invoker.visibility)) { |
| 95 visibility = invoker.visibility |
| 96 } |
89 } | 97 } |
90 } | 98 } |
OLD | NEW |