1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 # This file is meant to be included into an action to invoke grit in a
6 # consistent manner. To use this the following variables need to be
8 # grit_grd_file: string: grd file path
9 # grit_out_dir: string: the output directory path
11 # It would be really nice to do this with a rule instead of actions, but it
12 # would need to determine inputs and outputs via grit_info on a per-file
13 # basis. GYP rules don't currently support that. They could be extended to
14 # do this, but then every generator would need to be updated to handle this.
18 'grit_cmd': ['python', '<(DEPTH)/tools/grit/grit.py'],
19 'grit_resource_ids%': '<(DEPTH)/tools/gritsettings/resource_ids',
20 # This makes it possible to add more defines in specific targets,
21 # instead of build/common.gypi .
22 'grit_additional_defines%': [],
23 'grit_rc_header_format%': [],
24 'grit_whitelist%': '',
27 # These scripts can skip writing generated files if they are identical
28 # to the already existing files, which avoids further build steps, like
29 # recompilation. However, a dependency (earlier build step) having a
30 # newer timestamp than an output (later build step) confuses some build
31 # systems, so only use this on ninja, which explicitly supports this use
32 # case (gyp turns all actions into ninja restat rules).
33 ['"<(GENERATOR)"=="ninja"', {
34 'write_only_new': '1',
36 'write_only_new': '0',
41 ['"<(grit_whitelist)"==""', {
43 'grit_whitelist_flag': [],
47 'grit_whitelist_flag': ['-w', '<(grit_whitelist)'],
52 '<!@pymod_do_main(grit_info <@(grit_defines) <@(grit_additional_defines) '
53 '--inputs <(grit_grd_file) -f "<(grit_resource_ids)")',
56 '<!@pymod_do_main(grit_info <@(grit_defines) <@(grit_additional_defines) '
57 '--outputs \'<(grit_out_dir)\' '
58 '<(grit_grd_file) -f "<(grit_resource_ids)")',
60 'action': ['<@(grit_cmd)',
61 '-i', '<(grit_grd_file)', 'build',
62 '-f', '<(grit_resource_ids)',
63 '-o', '<(grit_out_dir)',
64 '--write-only-new=<(write_only_new)',
66 '<@(grit_whitelist_flag)',
67 '<@(grit_additional_defines)',
68 '<@(grit_rc_header_format)'],
69 'message': 'Generating resources from <(grit_grd_file)',