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

Unified Diff: build/android/gyp/copy_resources_v17.py

Issue 14476011: [Android] Auto-generate API 14 resources from the existing API 17 resources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed Newton's comment. Investigating warnings. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: build/android/gyp/copy_resources_v17.py
diff --git a/build/android/gyp/copy_resources_v17.py b/build/android/gyp/copy_resources_v17.py
new file mode 100644
index 0000000000000000000000000000000000000000..7f0d9de5f6d999cffce574b07e05f068cfcaeb40
--- /dev/null
+++ b/build/android/gyp/copy_resources_v17.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
newt (away) 2013/04/26 21:22:24 maybe name this copy_v17_resources.py for consiste
newt (away) 2013/04/26 22:50:47 p.s. if you rename it, do it as a separate patch s
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
+#
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import optparse
+import os
+import sys
+
+from util import build_utils
+
+
+def copy_resources_in_dir(input_dir, output_dir):
+ """Copy resources in the directory.
newt (away) 2013/04/26 21:22:24 "Copy all XML resources from input_dir to output_d
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
+ """
+
+ for name in os.listdir(options.res_dir):
+ if not os.path.isfile(name):
+ continue
+
+ if not name.lower().endswith('.xml'):
+ continue
+
+ input_filename = os.path.join(input_dir, name)
+ output_filename = os.path.join(output_dir, name)
+
+ build_utils.MakeDirectory(input_dir)
newt (away) 2013/04/26 21:22:24 it doesn't make sense to create the input director
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
+ build_utils.MakeDirectory(output_dir)
+ build_utils.CopyFile(input_filename, output_filename)
newt (away) 2013/04/26 21:22:24 Did you consider using symlinks here? I believe t
cjhopman 2013/04/26 21:48:47 Ah! please don't use symlinks -- it tends to break
newt (away) 2013/04/26 22:50:47 ok fine :) My preference is to minimize utility f
Kibeom Kim (inactive) 2013/04/27 00:05:07 ok..
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
+
+
+def ParseArgs():
+ """Parses command line options.
+
+ Returns:
+ An options object as from optparse.OptionsParser.parse_args()
+ """
+ parser = optparse.OptionParser()
+ parser.add_option('--res-dir',
+ help='directory containing resources to be copied')
+ parser.add_option('--res-v17-dir',
+ help='dest directory to be copied.')
newt (away) 2013/04/26 21:22:24 "output directory to which resources will be copie
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
+
+ (options, args) = parser.parse_args()
+
+ if args:
+ parser.error('No positional arguments should be given.')
+
+ # Check that required options have been provided.
+ required_options = ('res_dir', 'res_v17_dir')
+ build_utils.CheckOptions(options, parser, required=required_options)
+ return options
+
+
+def main(argv):
newt (away) 2013/04/26 21:22:24 we should probably delete the output directory bef
Kibeom Kim (inactive) 2013/04/27 00:05:07 Done.
+ """Copy resource files and add -v17 to the sub directory names.
+
+ This is coupled with generate_v14_resources.py. Please refer to
+ generate_v14_resources.py's comment for why we are doing this.
+ Or crbug.com/235118 .
+ """
+ options = ParseArgs()
+
+ build_utils.MakeDirectory(options.res_v17_dir)
+
+ for name in os.listdir(options.res_dir):
+ if not os.path.isdir(name):
+ continue
+
+ dir_pieces = name.split('-')
+ resource_type = dir_pieces[0]
+ qualifiers = dir_pieces[1:]
+
+ # We only copy resources under layout*/ and xml*/.
+ if resource_type not in ('layout', 'xml'):
+ continue
+
+ # Skip RTL resources because they are not supported by API 14.
+ if 'ldrtl' in qualifiers:
+ continue
+
+ # Copy all the resource files.
+ input_path = os.path.join(options.res_dir, name)
+ output_path = os.path.join(options.res_v17_dir, name + '-v17')
+ copy_resources_in_dir(input_path, output_path)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
+
« no previous file with comments | « no previous file | build/android/gyp/generate_v14_resources.py » ('j') | build/android/gyp/generate_v14_resources.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698