Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 '''The 'grit build' tool along with integration for this tool with the | 6 '''The 'grit build' tool along with integration for this tool with the |
| 7 SCons build system. | 7 SCons build system. |
| 8 ''' | 8 ''' |
| 9 | 9 |
| 10 import codecs | 10 import codecs |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 | 78 |
| 79 --assert-file-list Provide a file listing multiple asserted output files. | 79 --assert-file-list Provide a file listing multiple asserted output files. |
| 80 There is one file name per line. This acts like specifying | 80 There is one file name per line. This acts like specifying |
| 81 each file with "-a" on the command line, but without the | 81 each file with "-a" on the command line, but without the |
| 82 possibility of running into OS line-length limits for very | 82 possibility of running into OS line-length limits for very |
| 83 long lists. | 83 long lists. |
| 84 | 84 |
| 85 -o OUTPUTDIR Specify what directory output paths are relative to. | 85 -o OUTPUTDIR Specify what directory output paths are relative to. |
| 86 Defaults to the current directory. | 86 Defaults to the current directory. |
| 87 | 87 |
| 88 -p FILE Specify a file containing a pre-determined mapping from | |
| 89 resource names to resource ids which will be used to assign | |
| 90 resource ids to those resources. Resources not found in this | |
| 91 file will assigned ids normally. The file is of the format: | |
|
Nico
2017/02/17 21:44:08
s/will/will be/
Have you considered if missing ID
Alexei Svitkine (slow)
2017/02/17 22:07:51
Done.
| |
| 92 RESOURCE_ONE_NAME 123 | |
| 93 RESOURCE_TWO_NAME 124 | |
| 94 | |
| 88 -D NAME[=VAL] Specify a C-preprocessor-like define NAME with optional | 95 -D NAME[=VAL] Specify a C-preprocessor-like define NAME with optional |
| 89 value VAL (defaults to 1) which will be used to control | 96 value VAL (defaults to 1) which will be used to control |
| 90 conditional inclusion of resources. | 97 conditional inclusion of resources. |
| 91 | 98 |
| 92 -E NAME=VALUE Set environment variable NAME to VALUE (within grit). | 99 -E NAME=VALUE Set environment variable NAME to VALUE (within grit). |
| 93 | 100 |
| 94 -f FIRSTIDSFILE Path to a python file that specifies the first id of | 101 -f FIRSTIDSFILE Path to a python file that specifies the first id of |
| 95 value to use for resources. A non-empty value here will | 102 value to use for resources. A non-empty value here will |
| 96 override the value specified in the <grit> node's | 103 override the value specified in the <grit> node's |
| 97 first_ids_file. | 104 first_ids_file. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 IDs). This helps ensure that values of IDs stay the same, that all messages | 146 IDs). This helps ensure that values of IDs stay the same, that all messages |
| 140 are exported to translation interchange files (e.g. XMB files), etc. | 147 are exported to translation interchange files (e.g. XMB files), etc. |
| 141 ''' | 148 ''' |
| 142 | 149 |
| 143 def ShortDescription(self): | 150 def ShortDescription(self): |
| 144 return 'A tool that builds RC files for compilation.' | 151 return 'A tool that builds RC files for compilation.' |
| 145 | 152 |
| 146 def Run(self, opts, args): | 153 def Run(self, opts, args): |
| 147 self.output_directory = '.' | 154 self.output_directory = '.' |
| 148 first_ids_file = None | 155 first_ids_file = None |
| 156 predetermined_ids_file = None | |
| 149 whitelist_filenames = [] | 157 whitelist_filenames = [] |
| 150 assert_output_files = [] | 158 assert_output_files = [] |
| 151 target_platform = None | 159 target_platform = None |
| 152 depfile = None | 160 depfile = None |
| 153 depdir = None | 161 depdir = None |
| 154 rc_header_format = None | 162 rc_header_format = None |
| 155 output_all_resource_defines = None | 163 output_all_resource_defines = None |
| 156 write_only_new = False | 164 write_only_new = False |
| 157 depend_on_stamp = False | 165 depend_on_stamp = False |
| 158 js_minifier = None | 166 js_minifier = None |
| 159 replace_ellipsis = True | 167 replace_ellipsis = True |
| 160 (own_opts, args) = getopt.getopt(args, 'a:o:D:E:f:w:t:h:', | 168 (own_opts, args) = getopt.getopt(args, 'a:p:o:D:E:f:w:t:h:', |
| 161 ('depdir=','depfile=','assert-file-list=', | 169 ('depdir=','depfile=','assert-file-list=', |
| 162 'output-all-resource-defines', | 170 'output-all-resource-defines', |
| 163 'no-output-all-resource-defines', | 171 'no-output-all-resource-defines', |
| 164 'no-replace-ellipsis', | 172 'no-replace-ellipsis', |
| 165 'depend-on-stamp', | 173 'depend-on-stamp', |
| 166 'js-minifier=', | 174 'js-minifier=', |
| 167 'write-only-new=')) | 175 'write-only-new=')) |
| 168 for (key, val) in own_opts: | 176 for (key, val) in own_opts: |
| 169 if key == '-a': | 177 if key == '-a': |
| 170 assert_output_files.append(val) | 178 assert_output_files.append(val) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 185 # .grd itself. | 193 # .grd itself. |
| 186 first_ids_file = val | 194 first_ids_file = val |
| 187 elif key == '-w': | 195 elif key == '-w': |
| 188 whitelist_filenames.append(val) | 196 whitelist_filenames.append(val) |
| 189 elif key == '--output-all-resource-defines': | 197 elif key == '--output-all-resource-defines': |
| 190 output_all_resource_defines = True | 198 output_all_resource_defines = True |
| 191 elif key == '--no-output-all-resource-defines': | 199 elif key == '--no-output-all-resource-defines': |
| 192 output_all_resource_defines = False | 200 output_all_resource_defines = False |
| 193 elif key == '--no-replace-ellipsis': | 201 elif key == '--no-replace-ellipsis': |
| 194 replace_ellipsis = False | 202 replace_ellipsis = False |
| 203 elif key == '-p': | |
| 204 predetermined_ids_file = val | |
| 195 elif key == '-t': | 205 elif key == '-t': |
| 196 target_platform = val | 206 target_platform = val |
| 197 elif key == '-h': | 207 elif key == '-h': |
| 198 rc_header_format = val | 208 rc_header_format = val |
| 199 elif key == '--depdir': | 209 elif key == '--depdir': |
| 200 depdir = val | 210 depdir = val |
| 201 elif key == '--depfile': | 211 elif key == '--depfile': |
| 202 depfile = val | 212 depfile = val |
| 203 elif key == '--write-only-new': | 213 elif key == '--write-only-new': |
| 204 write_only_new = val != '0' | 214 write_only_new = val != '0' |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 226 self.whitelist_names.update(whitelist_contents.strip().split('\n')) | 236 self.whitelist_names.update(whitelist_contents.strip().split('\n')) |
| 227 | 237 |
| 228 if js_minifier: | 238 if js_minifier: |
| 229 minifier.SetJsMinifier(js_minifier) | 239 minifier.SetJsMinifier(js_minifier) |
| 230 | 240 |
| 231 self.write_only_new = write_only_new | 241 self.write_only_new = write_only_new |
| 232 | 242 |
| 233 self.res = grd_reader.Parse(opts.input, | 243 self.res = grd_reader.Parse(opts.input, |
| 234 debug=opts.extra_verbose, | 244 debug=opts.extra_verbose, |
| 235 first_ids_file=first_ids_file, | 245 first_ids_file=first_ids_file, |
| 246 predetermined_ids_file=predetermined_ids_file, | |
| 236 defines=self.defines, | 247 defines=self.defines, |
| 237 target_platform=target_platform) | 248 target_platform=target_platform) |
| 238 | 249 |
| 239 # If the output_all_resource_defines option is specified, override the value | 250 # If the output_all_resource_defines option is specified, override the value |
| 240 # found in the grd file. | 251 # found in the grd file. |
| 241 if output_all_resource_defines is not None: | 252 if output_all_resource_defines is not None: |
| 242 self.res.SetShouldOutputAllResourceDefines(output_all_resource_defines) | 253 self.res.SetShouldOutputAllResourceDefines(output_all_resource_defines) |
| 243 | 254 |
| 244 # Set an output context so that conditionals can use defines during the | 255 # Set an output context so that conditionals can use defines during the |
| 245 # gathering stage; we use a dummy language here since we are not outputting | 256 # gathering stage; we use a dummy language here since we are not outputting |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 self.MakeDirectoriesTo(depfile) | 526 self.MakeDirectoriesTo(depfile) |
| 516 outfile = self.fo_create(depfile, 'w', encoding='utf-8') | 527 outfile = self.fo_create(depfile, 'w', encoding='utf-8') |
| 517 outfile.writelines(depfile_contents) | 528 outfile.writelines(depfile_contents) |
| 518 | 529 |
| 519 @staticmethod | 530 @staticmethod |
| 520 def MakeDirectoriesTo(file): | 531 def MakeDirectoriesTo(file): |
| 521 '''Creates directories necessary to contain |file|.''' | 532 '''Creates directories necessary to contain |file|.''' |
| 522 dir = os.path.split(file)[0] | 533 dir = os.path.split(file)[0] |
| 523 if not os.path.exists(dir): | 534 if not os.path.exists(dir): |
| 524 os.makedirs(dir) | 535 os.makedirs(dir) |
| OLD | NEW |