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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 """Writes the icudata.lst file icupkg needs based on the information the gyp/gn
2 generators can give it."""
3
4 from __future__ import print_function
5
6 import argparse
7 import os
8 import sys
9
10 def change_ext(path, new_ext):
11 return os.path.splitext(path)[0] + new_ext
12
13 def main():
14 parser = argparse.ArgumentParser(
15 description=('Generates an icudata.lst file to be compiled by icu.'))
16
17 parser.add_argument('--inroot',
18 required=True,
19 help='The root of the indata files.')
20
21 parser.add_argument('--infile',
22 help='File that should contain a raw list.')
23
24 parser.add_argument('--outfile',
25 required=True,
26 help='File that will contain an ICU formatted list.')
27
28 parser.add_argument('--PRODUCT_DIR',
29 help=('The value of the PRODUCT_DIR env var. ' +
30 'Either this or --gn-root needs to be set.'))
31
32 parser.add_argument('--gn-root',
33 help=('The root of the gn build dir. Either this '
34 ' or PRODUCT_DIR (for gyp) must be set'))
35
36 parser.add_argument('files',
37 nargs='*',
38 help=('Files that were processed. Will magically '
39 'be mapped to result files by this script.'))
40
41 args = parser.parse_args()
42
43 if args.gn_root is None and args.PRODUCT_DIR is None:
44 print('One of --gn-root and --PRODUCT_DIR must be set.')
45 sys.exit(1)
46
47 def map_to_result(filepath):
48 filepath = filepath.strip()
49 if args.PRODUCT_DIR is not None:
50 # gyp for Ninja.
51 filepath = filepath.replace('$!PRODUCT_DIR', args.PRODUCT_DIR)
52 # gyp for Make.
53 filepath = filepath.replace('$(obj)', args.PRODUCT_DIR + '/obj')
54 if args.gn_root is not None:
55 filepath = filepath.replace('//', args.gn_root + '/')
56 if len(filepath) > 1 and filepath[0] == filepath[-1] == '"':
57 # Strip quote.
58 filepath = filepath[1:-1]
59 short_path = os.path.relpath(filepath, args.inroot)
60 if short_path.startswith('..'):
61 short_path = filepath
62 return short_path
63
64 tmp_file = args.outfile + '.tmp'
65 with open(tmp_file, 'w') as icudata_lst:
66 if args.infile:
67 with open(args.infile, 'r') as infile:
68 for filename in infile:
69 icudata_lst.write('%s\n' % map_to_result(filename))
70 for filename in args.files:
71 icudata_lst.write('%s\n' % map_to_result(filename))
72 if os.path.isfile(args.outfile):
73 os.unlink(args.outfile)
74 os.rename(tmp_file, args.outfile)
75
76 if __name__ == '__main__':
77 main()
OLDNEW
« 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