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

Unified Diff: build_tools/write_icudata_lst.py

Issue 1000163003: Generate the icu data binaries at compile time instead of checking in binaries Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: Fixed warnings in cross compiling Created 5 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
« no previous file with comments | « build_tools/run_without_cygwin.py ('k') | build_tools/write_icupkg_inc.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build_tools/write_icudata_lst.py
diff --git a/build_tools/write_icudata_lst.py b/build_tools/write_icudata_lst.py
new file mode 100644
index 0000000000000000000000000000000000000000..40e9ff34cffb4338fec71511928c339c5a2551d7
--- /dev/null
+++ b/build_tools/write_icudata_lst.py
@@ -0,0 +1,77 @@
+"""Writes the icudata.lst file icupkg needs based on the information the gyp/gn
+generators can give it."""
+
+from __future__ import print_function
+
+import argparse
+import os
+import sys
+
+def change_ext(path, new_ext):
+ return os.path.splitext(path)[0] + new_ext
+
+def main():
+ parser = argparse.ArgumentParser(
+ description=('Generates an icudata.lst file to be compiled by icu.'))
+
+ parser.add_argument('--inroot',
+ required=True,
+ help='The root of the indata files.')
+
+ parser.add_argument('--infile',
+ help='File that should contain a raw list.')
+
+ parser.add_argument('--outfile',
+ required=True,
+ help='File that will contain an ICU formatted list.')
+
+ parser.add_argument('--PRODUCT_DIR',
+ help=('The value of the PRODUCT_DIR env var. ' +
+ 'Either this or --gn-root needs to be set.'))
+
+ parser.add_argument('--gn-root',
+ help=('The root of the gn build dir. Either this '
+ ' or PRODUCT_DIR (for gyp) must be set'))
+
+ parser.add_argument('files',
+ nargs='*',
+ help=('Files that were processed. Will magically '
+ 'be mapped to result files by this script.'))
+
+ args = parser.parse_args()
+
+ if args.gn_root is None and args.PRODUCT_DIR is None:
+ print('One of --gn-root and --PRODUCT_DIR must be set.')
+ sys.exit(1)
+
+ def map_to_result(filepath):
+ filepath = filepath.strip()
+ if args.PRODUCT_DIR is not None:
+ # gyp for Ninja.
+ filepath = filepath.replace('$!PRODUCT_DIR', args.PRODUCT_DIR)
+ # gyp for Make.
+ filepath = filepath.replace('$(obj)', args.PRODUCT_DIR + '/obj')
+ if args.gn_root is not None:
+ filepath = filepath.replace('//', args.gn_root + '/')
+ if len(filepath) > 1 and filepath[0] == filepath[-1] == '"':
+ # Strip quote.
+ filepath = filepath[1:-1]
+ short_path = os.path.relpath(filepath, args.inroot)
+ if short_path.startswith('..'):
+ short_path = filepath
+ return short_path
+
+ tmp_file = args.outfile + '.tmp'
+ with open(tmp_file, 'w') as icudata_lst:
+ if args.infile:
+ with open(args.infile, 'r') as infile:
+ for filename in infile:
+ icudata_lst.write('%s\n' % map_to_result(filename))
+ for filename in args.files:
+ icudata_lst.write('%s\n' % map_to_result(filename))
+ if os.path.isfile(args.outfile):
+ os.unlink(args.outfile)
+ os.rename(tmp_file, args.outfile)
+
+if __name__ == '__main__':
+ main()
« no previous file with comments | « build_tools/run_without_cygwin.py ('k') | build_tools/write_icupkg_inc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698