Index: build_tools/write_res_index.py |
diff --git a/build_tools/write_res_index.py b/build_tools/write_res_index.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c20ad6fb30fe8c34383ca4f9625f5043e756f682 |
--- /dev/null |
+++ b/build_tools/write_res_index.py |
@@ -0,0 +1,44 @@ |
+"""Writes a res_index.txt file listing all locales (resources) that |
+are included. This matches a half dozen "echo" blocks in the |
+Makefiles.""" |
+ |
+from __future__ import print_function |
+ |
+import argparse |
+import os |
+ |
+def change_ext(path, new_ext): |
+ return os.path.splitext(path)[0] + new_ext |
+ |
+def main(): |
+ parser = argparse.ArgumentParser( |
+ description=("Generates a resindex.txt file to be compiled by icu.")) |
+ |
+ parser.add_argument("--outfile", |
+ required=True, |
+ help="File that will contain the ICU resource text.") |
+ |
+ parser.add_argument("--cldr-version", |
+ help="The CLDR version. Optional") |
+ |
+ parser.add_argument("files", |
+ nargs='*', |
+ help=("Files to be included in the list. " + |
+ "Can include paths (that will be ignored)")) |
+ |
+ args = parser.parse_args() |
+ |
+ with open(args.outfile, "w") as out: |
+ out.write("// Warning this file is automatically generated\n") |
+ out.write("res_index:table(nofallback) {\n") |
+ if args.cldr_version: |
+ out.write(" CLDRVersion { \"%s\" }\n" % args.cldr_version) |
+ out.write(" InstalledLocales {\n") |
+ for filename in args.files: |
+ out.write(" %s {\"\"}\n" % |
+ change_ext(os.path.basename(filename), "")) |
+ out.write(" }\n") |
+ out.write("}\n") |
+ |
+if __name__ == "__main__": |
+ main() |