Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: build/android/gyp/locale_pak_resources.py

Issue 2336173003: Fix android depfiles to always list GN's outputs[0] (Closed)
Patch Set: fix cronet_package Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/gyp/jinja_template.py ('k') | build/android/gyp/pack_relocations.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved. 3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 """Creates a resources.zip for locale .pak files. 6 """Creates a resources.zip for locale .pak files.
7 7
8 Places the locale.pak files into appropriate resource configs 8 Places the locale.pak files into appropriate resource configs
9 (e.g. en-GB.pak -> res/raw-en/en_gb.lpak). Also generates a locale_paks 9 (e.g. en-GB.pak -> res/raw-en/en_gb.lpak). Also generates a locale_paks
10 TypedArray so that resource files can be enumerated at runtime. 10 TypedArray so that resource files can be enumerated at runtime.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 help='Print out the list of languages that cover the given locale paks ' 89 help='Print out the list of languages that cover the given locale paks '
90 '(using Android\'s language codes)') 90 '(using Android\'s language codes)')
91 91
92 options, _ = parser.parse_args() 92 options, _ = parser.parse_args()
93 build_utils.CheckOptions(options, parser, 93 build_utils.CheckOptions(options, parser,
94 required=['locale_paks']) 94 required=['locale_paks'])
95 95
96 sources = build_utils.ParseGnList(options.locale_paks) 96 sources = build_utils.ParseGnList(options.locale_paks)
97 97
98 if options.depfile: 98 if options.depfile:
99 deps = sources + build_utils.GetPythonDependencies() 99 assert options.resources_zip
100 build_utils.WriteDepfile(options.depfile, deps) 100 build_utils.WriteDepfile(options.depfile, options.resources_zip, sources)
101 101
102 mappings, lang_to_locale_map = ComputeMappings(sources) 102 mappings, lang_to_locale_map = ComputeMappings(sources)
103 if options.print_languages: 103 if options.print_languages:
104 print '\n'.join(sorted(lang_to_locale_map)) 104 print '\n'.join(sorted(lang_to_locale_map))
105 105
106 if options.resources_zip: 106 if options.resources_zip:
107 with zipfile.ZipFile(options.resources_zip, 'w', zipfile.ZIP_STORED) as out: 107 with zipfile.ZipFile(options.resources_zip, 'w', zipfile.ZIP_STORED) as out:
108 for mapping in mappings: 108 for mapping in mappings:
109 out.write(mapping[0], mapping[1]) 109 out.write(mapping[0], mapping[1])
110 110
111 # Create TypedArray resources so ResourceExtractor can enumerate files. 111 # Create TypedArray resources so ResourceExtractor can enumerate files.
112 def WriteValuesFile(lang, names): 112 def WriteValuesFile(lang, names):
113 dest_dir = 'values' 113 dest_dir = 'values'
114 if lang: 114 if lang:
115 dest_dir += '-' + lang 115 dest_dir += '-' + lang
116 # Always extract en-US.lpak since it's the fallback. 116 # Always extract en-US.lpak since it's the fallback.
117 xml = CreateLocalePaksXml(names + ['en_us.lpak']) 117 xml = CreateLocalePaksXml(names + ['en_us.lpak'])
118 out.writestr(os.path.join(dest_dir, 'locale-paks.xml'), xml) 118 out.writestr(os.path.join(dest_dir, 'locale-paks.xml'), xml)
119 119
120 for lang, names in lang_to_locale_map.iteritems(): 120 for lang, names in lang_to_locale_map.iteritems():
121 WriteValuesFile(lang, names) 121 WriteValuesFile(lang, names)
122 WriteValuesFile(None, []) 122 WriteValuesFile(None, [])
123 123
124 124
125 if __name__ == '__main__': 125 if __name__ == '__main__':
126 sys.exit(main()) 126 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/gyp/jinja_template.py ('k') | build/android/gyp/pack_relocations.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698