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 filecmp | 10 import filecmp |
(...skipping 21 matching lines...) Expand all Loading... |
32 'rc_translateable': 'rc', | 32 'rc_translateable': 'rc', |
33 'rc_nontranslateable': 'rc', | 33 'rc_nontranslateable': 'rc', |
34 'rc_header': 'rc_header', | 34 'rc_header': 'rc_header', |
35 'resource_map_header': 'resource_map', | 35 'resource_map_header': 'resource_map', |
36 'resource_map_source': 'resource_map', | 36 'resource_map_source': 'resource_map', |
37 'resource_file_map_source': 'resource_map', | 37 'resource_file_map_source': 'resource_map', |
38 } | 38 } |
39 _format_modules.update( | 39 _format_modules.update( |
40 (type, 'policy_templates.template_formatter') for type in | 40 (type, 'policy_templates.template_formatter') for type in |
41 [ 'adm', 'admx', 'adml', 'reg', 'doc', 'json', | 41 [ 'adm', 'admx', 'adml', 'reg', 'doc', 'json', |
42 'plist', 'plist_strings', 'ios_plist' ]) | 42 'plist', 'plist_strings', 'ios_plist', 'android_policy' ]) |
43 | 43 |
44 | 44 |
45 def GetFormatter(type): | 45 def GetFormatter(type): |
46 modulename = 'grit.format.' + _format_modules[type] | 46 modulename = 'grit.format.' + _format_modules[type] |
47 __import__(modulename) | 47 __import__(modulename) |
48 module = sys.modules[modulename] | 48 module = sys.modules[modulename] |
49 try: | 49 try: |
50 return module.Format | 50 return module.Format |
51 except AttributeError: | 51 except AttributeError: |
52 return module.GetFormatter(type) | 52 return module.GetFormatter(type) |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 for output in self.res.GetOutputFiles(): | 313 for output in self.res.GetOutputFiles(): |
314 self.VerboseOut('Creating %s...' % output.GetFilename()) | 314 self.VerboseOut('Creating %s...' % output.GetFilename()) |
315 | 315 |
316 # Microsoft's RC compiler can only deal with single-byte or double-byte | 316 # Microsoft's RC compiler can only deal with single-byte or double-byte |
317 # files (no UTF-8), so we make all RC files UTF-16 to support all | 317 # files (no UTF-8), so we make all RC files UTF-16 to support all |
318 # character sets. | 318 # character sets. |
319 if output.GetType() in ('rc_header', 'resource_map_header', | 319 if output.GetType() in ('rc_header', 'resource_map_header', |
320 'resource_map_source', 'resource_file_map_source'): | 320 'resource_map_source', 'resource_file_map_source'): |
321 encoding = 'cp1252' | 321 encoding = 'cp1252' |
322 elif output.GetType() in ('android', 'c_format', 'js_map_format', 'plist', | 322 elif output.GetType() in ('android', 'c_format', 'js_map_format', 'plist', |
323 'plist_strings', 'doc', 'json'): | 323 'plist_strings', 'doc', 'json', 'android_policy'
): |
324 encoding = 'utf_8' | 324 encoding = 'utf_8' |
325 elif output.GetType() in ('chrome_messages_json'): | 325 elif output.GetType() in ('chrome_messages_json'): |
326 # Chrome Web Store currently expects BOM for UTF-8 files :-( | 326 # Chrome Web Store currently expects BOM for UTF-8 files :-( |
327 encoding = 'utf-8-sig' | 327 encoding = 'utf-8-sig' |
328 else: | 328 else: |
329 # TODO(gfeher) modify here to set utf-8 encoding for admx/adml | 329 # TODO(gfeher) modify here to set utf-8 encoding for admx/adml |
330 encoding = 'utf_16' | 330 encoding = 'utf_16' |
331 | 331 |
332 # Set the context, for conditional inclusion of resources | 332 # Set the context, for conditional inclusion of resources |
333 self.res.SetOutputLanguage(output.GetLanguage()) | 333 self.res.SetOutputLanguage(output.GetLanguage()) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 self.MakeDirectoriesTo(depfile) | 471 self.MakeDirectoriesTo(depfile) |
472 outfile = self.fo_create(depfile, 'wb') | 472 outfile = self.fo_create(depfile, 'wb') |
473 outfile.writelines(depfile_contents) | 473 outfile.writelines(depfile_contents) |
474 | 474 |
475 @staticmethod | 475 @staticmethod |
476 def MakeDirectoriesTo(file): | 476 def MakeDirectoriesTo(file): |
477 '''Creates directories necessary to contain |file|.''' | 477 '''Creates directories necessary to contain |file|.''' |
478 dir = os.path.split(file)[0] | 478 dir = os.path.split(file)[0] |
479 if not os.path.exists(dir): | 479 if not os.path.exists(dir): |
480 os.makedirs(dir) | 480 os.makedirs(dir) |
OLD | NEW |