Skip to content
Snippets Groups Projects
Commit 2fd941df authored by Yang Guo's avatar Yang Guo Committed by Jungshik Shin
Browse files

Introduce build target for bundled data on Windows

On non-Windows platforms, we generate assembly to bundle ICU data.
On Windows however, we previously use a checked in icudt.dll, which
is no longer maintained.

We could use the same assembly approach if we wrap in inline assembly.

Bug: chromium:938223
Change-Id: Ieced205ae2e082a5290bd45499216c6c86751ca1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/deps/icu/+/1503032


Reviewed-by: default avatarJungshik Shin <jshin@chromium.org>
parent 8c67416c
No related branches found
No related tags found
No related merge requests found
...@@ -49,11 +49,7 @@ config("icu_config") { ...@@ -49,11 +49,7 @@ config("icu_config") {
if (icu_use_data_file) { if (icu_use_data_file) {
defines += [ "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE" ] defines += [ "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE" ]
} else { } else {
if (is_win) { defines += [ "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC" ]
defines += [ "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_SHARED" ]
} else {
defines += [ "ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC" ]
}
} }
if (is_win) { if (is_win) {
...@@ -1106,37 +1102,47 @@ if (icu_use_data_file) { ...@@ -1106,37 +1102,47 @@ if (icu_use_data_file) {
} }
} }
} else { } else {
data_assembly = "$target_gen_dir/${data_bundle_prefix}_dat.S"
inline_data_assembly = "$target_gen_dir/${data_bundle_prefix}_dat.cc"
action("make_data_assembly") {
script = "scripts/make_data_assembly.py"
inputs = [ "$data_dir/$data_bundle" ]
outputs = [ data_assembly ]
args = [
rebase_path(inputs[0], root_build_dir),
rebase_path(data_assembly, root_build_dir),
]
# TODO(GYP): Gyp has considerations here for QNX and for the host
# toolchain that have not been ported over.
if (is_mac || is_ios) {
args += [ "--mac" ]
} else if (is_win) {
args += [ "--win" ]
}
}
if (is_win) { if (is_win) {
# On Windows the target DLL is pre-built so just use a copy rule. action("make_inline_data_assembly") {
# data_bundle and data_dir have to be used to avoid 'unused variable' deps = [ ":make_data_assembly" ]
# error. script = "scripts/asm_to_inline_asm.py"
data_bundle = "icudt.dll" inputs = [ data_assembly ]
data_dir = "windows" outputs = [ inline_data_assembly ]
copy("icudata") { args = rebase_path([
sources = [ "$data_dir/$data_bundle" ] data_assembly,
outputs = [ "$root_out_dir/$data_bundle" ] inline_data_assembly,
data = outputs ], root_build_dir)
} }
} else { } else {
data_assembly = "$target_gen_dir/${data_bundle_prefix}_dat.S" not_needed([ "inline_data_assembly" ])
action("make_data_assembly") { }
script = "scripts/make_data_assembly.py"
inputs = [ "$data_dir/$data_bundle" ]
outputs = [ "$data_assembly" ]
args = [
rebase_path(inputs[0], root_build_dir),
rebase_path(data_assembly, root_build_dir),
]
# TODO(GYP): Gyp has considerations here for QNX and for the host
# toolchain that have not been ported over.
if (is_mac || is_ios) {
args += [ "--mac" ]
}
}
source_set("icudata") { source_set("icudata") {
sources = [ "$data_assembly" ] defines = [ "U_HIDE_DATA_SYMBOL" ]
defines = [ "U_HIDE_DATA_SYMBOL" ] if (is_win) {
sources = [ inline_data_assembly ]
deps = [ ":make_inline_data_assembly", ]
} else {
sources = [ data_assembly ]
deps = [ ":make_data_assembly", ] deps = [ ":make_data_assembly", ]
} }
} }
......
#!/usr/bin/env python
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
'''
Converts a given file in clang assembly syntax to a corresponding
representation in inline assembly. Specifically, this is used for
Windows clang builds.
'''
import argparse
import sys
def asm_to_inl_asm(in_filename, out_filename):
with open(in_filename, 'r') as infile, open(out_filename, 'wb') as outfile:
outfile.write('__asm__(\n')
for line in infile:
# Escape " in .S file before outputing it to inline asm file.
line = line.replace('"', '\\"')
outfile.write(' "%s\\n"\n' % line.rstrip())
outfile.write(');\n')
return 0
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('input', help='Name of the input assembly file')
parser.add_argument('output', help='Name of the target CC file')
args = parser.parse_args()
sys.exit(asm_to_inl_asm(args.input, args.output))
...@@ -12,7 +12,10 @@ parser = optparse.OptionParser() ...@@ -12,7 +12,10 @@ parser = optparse.OptionParser()
parser.add_option("--mac", parser.add_option("--mac",
help="generate assembly file for Mac/iOS (default: False)", help="generate assembly file for Mac/iOS (default: False)",
action="store_true", default=False) action="store_true", default=False)
parser.set_usage("""make_data_assembly icu_data [assembly_file] [--mac] parser.add_option("--win",
help="generate assembly file for Windows (default: False)",
action="store_true", default=False)
parser.set_usage("""make_data_assembly icu_data [assembly_file] [--mac] [--win]
icu_data: ICU data file to generate assembly from. icu_data: ICU data file to generate assembly from.
assembly_file: Output file converted from icu_data file.""") assembly_file: Output file converted from icu_data file.""")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
...@@ -56,6 +59,11 @@ if options.mac: ...@@ -56,6 +59,11 @@ if options.mac:
"\t.const\n" "\t.const\n"
"\t.align 4\n" "\t.align 4\n"
"_icudt%s_dat:\n" %tuple([version_number] * 3)) "_icudt%s_dat:\n" %tuple([version_number] * 3))
elif options.win:
output.write(".globl icudt%s_dat\n"
"\t.section .rdata\n"
"\t.balign 16\n"
"icudt%s_dat:\n" % tuple([version_number] * 2))
else: else:
output.write(".globl icudt%s_dat\n" output.write(".globl icudt%s_dat\n"
"\t.section .note.GNU-stack,\"\",%%progbits\n" "\t.section .note.GNU-stack,\"\",%%progbits\n"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment