Support Big Endian part 2
Follow-up CL to https://codereview.chromium.org/2162393003
1. make_data_assembly now accepts '--mac' to generate assembly source
for Mac
2. Fix icu.gyp to support all platforms
BUG=v8:4828
TEST='d8' is built correct with icu_use_data_file set to either 0 or 1 on Mac/Linux
TEST=run `GYP_DEFINES="target_arch=mips" ./gypfiles/gyp_v8` and make sure
that ninja files use 'b' data/assembly file for Big Endian on Mac/Linux
R=machenbach@chromium.org
Review URL: https://codereview.chromium.org/2165403003 .
diff --git a/icu.gyp b/icu.gyp
index 9806c9b..e334044 100644
--- a/icu.gyp
+++ b/icu.gyp
@@ -118,44 +118,52 @@
'target_name': 'data_assembly',
'type': 'none',
'conditions': [
- [ 'target_arch=="mips" or target_arch=="mips64"', {
- 'data_assembly_sources': [
- 'common/icudtb.dat',
- ],
+ [ 'target_arch=="mips" or target_arch=="mips64"', { # Big Endian
'data_assembly_inputs': [
- 'scripts/make_data_assembly.py',
'common/icudtb.dat',
],
'data_assembly_outputs': [
'<(SHARED_INTERMEDIATE_DIR)/third_party/icu/icudtb_dat.S',
],
- }],
- [ 'target_arch!="mips" and target_arch!="mips64"', {
- 'data_assembly_sources': [
- 'common/icudtl.dat',
- ],
- 'data_assembly_inputs': [
- 'scripts/make_data_assembly.py',
- 'common/icudtl.dat',
- ],
+ }, { # Little Endian
'data_assembly_outputs': [
'<(SHARED_INTERMEDIATE_DIR)/third_party/icu/icudtl_dat.S',
],
+ 'conditions': [
+ ['OS == "android"', {
+ 'data_assembly_inputs': [
+ 'android/icudtl.dat',
+ ],
+ } , { # else: OS!="android"
+ 'data_assembly_inputs': [
+ 'common/icudtl.dat',
+ ],
+ }], # OS==android
+ ],
}],
],
'sources': [
- '<@(_data_assembly_sources)',
+ '<@(_data_assembly_inputs)',
],
'actions': [
{
'action_name': 'make_data_assembly',
'inputs': [
+ 'scripts/make_data_assembly.py',
'<@(_data_assembly_inputs)',
],
'outputs': [
'<@(_data_assembly_outputs)',
],
- 'action': ['python', '<@(_inputs)', '<@(_outputs)'],
+ 'target_conditions': [
+ [ 'OS == "mac" or OS == "ios" or '
+ '((OS == "android" or OS == "qnx") and '
+ '_toolset == "host" and host_os == "mac")', {
+ 'action': ['python', '<@(_inputs)', '<@(_outputs)', '--mac'],
+ } , {
+ 'action': ['python', '<@(_inputs)', '<@(_outputs)'],
+ }],
+ ],
},
],
},
@@ -169,20 +177,13 @@
'data_assembly#target',
],
'sources': [
- # These are hand-generated, but will do for now. The linux
- # version is an identical copy of the (mac) icudtl_dat.S file,
- # modulo removal of the .private_extern and .const directives and
- # with no leading underscore on the icudt52_dat symbol.
- 'android/icudtl_dat.S',
'<(SHARED_INTERMEDIATE_DIR)/third_party/icu/icudtl_dat.S',
'<(SHARED_INTERMEDIATE_DIR)/third_party/icu/icudtb_dat.S',
- 'mac/icudtl_dat.S',
],
'conditions': [
[ 'target_arch=="mips" or target_arch=="mips64"', {
'sources!': ['<(SHARED_INTERMEDIATE_DIR)/third_party/icu/icudtl_dat.S'],
- }],
- [ 'target_arch!="mips" and target_arch!="mips64"', {
+ }, {
'sources!': ['<(SHARED_INTERMEDIATE_DIR)/third_party/icu/icudtb_dat.S'],
}],
[ 'use_system_icu==1 and want_separate_host_toolset==1', {
@@ -208,12 +209,6 @@
},
],
}],
- [ '(OS == "mac" or OS == "ios") and icu_use_data_file_flag==0', {
- 'type': 'none',
- 'dependencies!': [
- 'data_assembly#target',
- ],
- }],
[ 'icu_use_data_file_flag==1', {
'type': 'none',
'dependencies!': [
@@ -239,22 +234,12 @@
}], # icu_use_data_file_flag
], # conditions
'target_conditions': [
- [ 'OS == "win" or OS == "mac" or OS == "ios" or '
- '(OS == "android" and (_toolset != "host" or host_os != "linux")) or '
- '(OS == "qnx" and (_toolset == "host" and host_os != "linux"))', {
+ [ 'OS == "win"', {
'sources!': [
'<(SHARED_INTERMEDIATE_DIR)/third_party/icu/icudtl_dat.S',
'<(SHARED_INTERMEDIATE_DIR)/third_party/icu/icudtb_dat.S'
],
}],
- [ 'OS != "android" or _toolset == "host"', {
- 'sources!': ['android/icudtl_dat.S'],
- }],
- [ 'OS != "mac" and OS != "ios" and '
- '((OS != "android" and OS != "qnx") or '
- '_toolset != "host" or host_os != "mac")', {
- 'sources!': ['mac/icudtl_dat.S'],
- }],
], # target_conditions
},
{
diff --git a/scripts/make_data_assembly.py b/scripts/make_data_assembly.py
index f69a3af..250c132 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 @@
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"
+ "#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)]