summaryrefslogtreecommitdiffstats
path: root/chrome/tools
diff options
context:
space:
mode:
authorgfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 20:34:17 +0000
committergfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-24 20:34:17 +0000
commite33bd5b260b1f40156a92d9eacaa62cabcde0eac (patch)
tree631ef6d09445caa65c3154e60a3dc2bed2b391f1 /chrome/tools
parent3f882613e62b9fbbfcdf8b8f4003bd66cd23d7ff (diff)
downloadchromium_src-e33bd5b260b1f40156a92d9eacaa62cabcde0eac.zip
chromium_src-e33bd5b260b1f40156a92d9eacaa62cabcde0eac.tar.gz
chromium_src-e33bd5b260b1f40156a92d9eacaa62cabcde0eac.tar.bz2
Start generating translated policy templates
-Add output nodes of translations into policy_templates.grd. -Copy translated string tables into the Mac bundle. -Work around the problem that the zip tool would get too long command-line arguments if all the translated templates were enumerated as arguments. -Fix importing of UTF-8 strings into the template generator BUG=61779 TEST=Check that there are translated adml, adm and html files in policy_templates.zip. Review URL: http://codereview.chromium.org/6969064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rw-r--r--chrome/tools/build/win/make_policy_zip.py78
-rw-r--r--chrome/tools/build/win/make_zip_with_relative_entries.py63
2 files changed, 78 insertions, 63 deletions
diff --git a/chrome/tools/build/win/make_policy_zip.py b/chrome/tools/build/win/make_policy_zip.py
new file mode 100644
index 0000000..60037c3
--- /dev/null
+++ b/chrome/tools/build/win/make_policy_zip.py
@@ -0,0 +1,78 @@
+# Copyright (c) 2011 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.
+
+"""Creates a zip archive with policy template files. The list of input files is
+extracted from a grd file with grit. This is to keep the length of input
+arguments below the limit on Windows.
+"""
+
+import optparse
+import os
+import sys
+import zipfile
+
+def add_files_to_zip(zip_file, base_dir, file_list):
+ """Pack a list of files into a zip archive, that is already
+ opened for writing.
+
+ Args:
+ zip_file: An object representing the zip archive.
+ base_dir: Base path of all the files in the real file system.
+ files: List of file paths to add, all relative to base_dir.
+ The zip entries will only contain this componenet of the path.
+ """
+ for file_path in file_list:
+ zip_file.write(base_dir + file_path, file_path)
+ return 0
+
+def get_grd_outputs(grit_cmd, grit_defines, grd_file, grd_strip_path_prefix):
+ grit_path = os.path.join(os.getcwd(), os.path.dirname(grit_cmd))
+ sys.path.append(grit_path)
+ import grit_info
+ outputs = grit_info.Outputs(grd_file, grit_defines)
+ result = []
+ for item in outputs:
+ assert item.startswith(grd_strip_path_prefix)
+ result.append(item[len(grd_strip_path_prefix):])
+ return result
+
+def main(argv):
+ """Pack a list of files into a zip archive.
+
+ Args:
+ zip_path: The file name of the zip archive.
+ base_dir: Base path of input files.
+ locales: The list of locales that are used to generate the list of file
+ names using INPUT_FILES.
+ """
+ parser = optparse.OptionParser()
+ parser.add_option("--output", dest="output")
+ parser.add_option("--basedir", dest="basedir")
+ parser.add_option("--grit_info", dest="grit_info")
+ parser.add_option("--grd_input", dest="grd_input")
+ parser.add_option("--grd_strip_path_prefix", dest="grd_strip_path_prefix")
+ parser.add_option("--extra_input", action="append", dest="extra_input",
+ default=[])
+ parser.add_option("-D", action="append", dest="grit_defines", default=[])
+ parser.add_option("-E", action="append", dest="grit_build_env", default=[])
+ options, args = parser.parse_args(argv[1:])
+
+ if (options.basedir[-1] != '/'):
+ options.basedir += '/'
+ grit_defines = {}
+ for define in options.grit_defines:
+ grit_defines[define] = 1
+
+ file_list = options.extra_input
+ file_list += get_grd_outputs(options.grit_info, grit_defines,
+ options.grd_input, options.grd_strip_path_prefix)
+ zip_file = zipfile.ZipFile(options.output, 'w', zipfile.ZIP_DEFLATED)
+ try:
+ return add_files_to_zip(zip_file, options.basedir, file_list)
+ finally:
+ zip_file.close()
+
+if '__main__' == __name__:
+ sys.exit(main(sys.argv))
+
diff --git a/chrome/tools/build/win/make_zip_with_relative_entries.py b/chrome/tools/build/win/make_zip_with_relative_entries.py
deleted file mode 100644
index 4df554e..0000000
--- a/chrome/tools/build/win/make_zip_with_relative_entries.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (c) 2010 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.
-
-"""Creates a zip archive with relative entry paths, from a list of files with
-absolute paths.
-"""
-
-import sys
-import zipfile
-
-def add_files_to_zip(zip_file, base_dir, files):
- """Pack a list of files into a zip archive, that is already
- opened for writing.
-
- Args:
- zip_file: An object representing the zip archive.
- base_dir: A path that will be stripped from the beginning of the paths of
- added files.
- files: The list of file paths to add.
- """
- prefix_len = len(base_dir)
-
- for file_path in files:
- if not file_path.startswith(base_dir):
- print "All the input files should be in the base directory."
- return 1
- entry_path = file_path[prefix_len:]
- zip_file.write(file_path, entry_path)
-
- return 0
-
-
-def main(zip_path, base_dir, files):
- """Pack a list of files into a zip archive.
-
- Args:
- zip_path: The file name of the zip archive.
- base_dir: A path that will be stripped from the beginning of the paths of
- added files.
- files: The list of file paths to add.
-
- Example:
- main('x.zip', '/a/b', ['/a/b/c/1.txt', '/a/b/d/2.txt'])
- Will put the following entries to x.zip:
- c/1.txt
- d/2.txt
- """
- if (base_dir[-1] != '/'):
- base_dir = base_dir + '/'
-
- zip_file = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
- try:
- return add_files_to_zip(zip_file, base_dir, files)
- finally:
- zip_file.close()
-
-if '__main__' == __name__:
- if len(sys.argv) < 4:
- print "usage: %s output.zip path/to/base/dir list of files" % sys.argv[0]
- sys.exit(1)
-
- sys.exit(main(sys.argv[1], sys.argv[2], sys.argv[3:]))