Chromium Code Reviews| Index: scripts/make_data_assembly.py |
| diff --git a/scripts/make_data_assembly.py b/scripts/make_data_assembly.py |
| index f69a3af6773d32a52bc6d1f0e01583fbefae3563..250c1325955f6fbc2568f7b46711fd8483c7e923 100755 |
| --- a/scripts/make_data_assembly.py |
| +++ b/scripts/make_data_assembly.py |
| @@ -5,20 +5,30 @@ |
| # found in the LICENSE file. |
| import binascii |
| +import optparse |
| import sys |
| -if len(sys.argv) < 2: |
| - sys.exit("Usage: %s icu_data_file [output_assembly_file]" % sys.argv[0]) |
| +parser = optparse.OptionParser() |
| +parser.add_option("--mac", |
| + help="generate assembly file for Mac/iOS (default: False)", |
| + action="store_true", default=False) |
| +parser.set_usage("""make_data_assembly icu_data [assembly_file] [--mac] |
| + icu_data: ICU data file to generate assembly from. |
| + assembly_file: Output file converted from icu_data file.""") |
| +(options, args) = parser.parse_args() |
| -input_file = sys.argv[1] |
| +if len(args) < 1: |
| + parser.error("ICU data file is not given.") |
| + |
| +input_file = args[0] |
| n = input_file.find(".dat") |
| if n == -1: |
| sys.exit("%s is not an ICU .dat file." % input_file) |
| -if len(sys.argv) < 3: |
| +if len(args) < 2: |
| output_file = input_file[0:n] + "_dat.S" |
| else: |
| - output_file = sys.argv[2] |
| + output_file = args[1] |
| if input_file.find("l.dat") == -1: |
| if input_file.find("b.dat") == -1: |
| @@ -36,15 +46,26 @@ if n == -1: |
| version_number = input_data[n + 5:n + 7] |
| output = open(output_file, 'w') |
| -output.write(".globl icudt" + version_number + "_dat\n" |
| - "\t.section .note.GNU-stack,\"\",%progbits\n" |
| - "\t.section .rodata\n" |
| - "\t.balign 16\n" |
| - "#ifdef U_HIDE_DATA_SYMBOL\n" |
| - "\t.hidden icudt" + version_number + "_dat\n" |
| - "#endif\n" |
| - "\t.type icudt" + version_number + "_dat,%object\n" |
| - "icudt" + version_number + "_dat:\n") |
| + |
| +if options.mac: |
| + output.write(".globl _icudt%s_dat\n" |
|
Michael Achenbach
2016/07/22 07:34:08
I have no idea about this and can only rubber stam
jungshik at Google
2016/07/22 20:31:13
Thanks. Don't worry. It comes from scripts/make_ma
|
| + "#ifdef U_HIDE_DATA_SYMBOL\n" |
| + "\t.private_extern _icudt%s_dat\n" |
| + "#endif\n" |
| + "\t.data\n" |
| + "\t.const\n" |
| + "\t.align 4\n" |
| + "_icudt%s_dat:\n" %tuple([version_number] * 3)) |
| +else: |
| + output.write(".globl icudt%s_dat\n" |
| + "\t.section .note.GNU-stack,\"\",%%progbits\n" |
| + "\t.section .rodata\n" |
| + "\t.balign 16\n" |
| + "#ifdef U_HIDE_DATA_SYMBOL\n" |
| + "\t.hidden icudt%s_dat\n" |
| + "#endif\n" |
| + "\t.type icudt%s_dat,%%object\n" |
| + "icudt%s_dat:\n" % tuple([version_number] * 4)) |
| split = [binascii.hexlify(input_data[i:i + 4][::step]).upper().lstrip('0') |
| for i in range(0, len(input_data), 4)] |