From fb20471401a85b5523148e88f00b763079ae370c Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Thu, 9 Jun 2016 08:35:32 -0700 Subject: [PATCH] Speedup canned small-icu build When: * using canned, small-icu (the default for configure && make) * .. on little endian systems we can avoid building some things we're currently building. Namely, on the host toolchain side in this scenario, only genccode needs to be compiled, and it doesn't need the i18n or io libraries Fixes: https://github.com/nodejs/node/issues/7253 --- configure | 10 ++++++++-- tools/icu/icu-generic.gyp | 42 +++++++++++++++++++++++++++++++++++---- tools/icu/icutrim.py | 15 ++++++++++++-- 3 files changed, 59 insertions(+), 8 deletions(-) diff --git a/configure b/configure index f7a3f41ae02821..7e4a85b8c22d87 100755 --- a/configure +++ b/configure @@ -952,7 +952,10 @@ def configure_intl(o): print '\n ** Corrupted ZIP? Delete %s to retry download.\n' % targetfile return None icu_config = { - 'variables': {} + 'variables': { + 'icu_small_canned': b(False), + 'icu_need_swap': b(True), + } } icu_config_name = 'icu_config.gypi' def write_config(data, name): @@ -1046,7 +1049,7 @@ def configure_intl(o): if (o['variables']['icu_small'] == b(True)) and using_default_locales and (not with_icu_source) and canned_icu_available: # OK- we can use the canned ICU. - icu_config['variables']['icu_small_canned'] = 1 + icu_config['variables']['icu_small_canned'] = b(True) icu_full_path = canned_icu_dir # --with-icu-source processing @@ -1144,6 +1147,9 @@ def configure_intl(o): # this is the input '.dat' file to use .. icudt*.dat # may be little-endian if from a icu-project.org tarball o['variables']['icu_data_in'] = icu_data_in + if icu_data_in.endswith('%s.dat' % icu_endianness): + # we may still swap, but mark that we can skip it if need be + icu_config['variables']['icu_need_swap'] = b(False) # this is the icudt*.dat file which node will be using (platform endianness) o['variables']['icu_data_file'] = icu_data_file if not os.path.isfile(icu_data_path): diff --git a/tools/icu/icu-generic.gyp b/tools/icu/icu-generic.gyp index a61b294141fc21..0b357116e92c31 100644 --- a/tools/icu/icu-generic.gyp +++ b/tools/icu/icu-generic.gyp @@ -261,7 +261,8 @@ '-F', 'icu_small.json', '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat', '-v', - '-L', '<(icu_locales)'], + '-L', '<(icu_locales)', + '-K', '<(icu_small_canned)'], }, { # build final .dat -> .obj @@ -325,7 +326,17 @@ # link against stub data (as primary data) # then, use icupkg and genccode to rebuild small data 'dependencies': [ 'icustubdata', 'genccode#host', 'icupkg#host', 'genrb#host', 'iculslocs#host', - 'icu_implementation', 'icu_uconfig' ], + 'icu_implementation', 'icu_uconfig' ], + 'conditions': [ + ['icu_small_canned == "true"', { + # with canned data, don’t need genrb or iculslocs + 'dependencies!': [ 'genrb#host', 'iculslocs#host' ], + }], + ['icu_need_swap == "false" and icu_small_canned == "true"', { + # canned data, so don’t need to swap + 'dependencies!': [ 'icupkg#host' ], + }], + ], 'export_dependent_settings': [ 'icustubdata' ], 'actions': [ { @@ -342,7 +353,8 @@ '-F', 'icu_small.json', '-O', 'icudt<(icu_ver_major)<(icu_endianness).dat', '-v', - '-L', '<(icu_locales)'], + '-L', '<(icu_locales)', + '-K', '<(icu_small_canned)'], }, { # rename to get the final entrypoint name right 'action_name': 'rename', @@ -512,7 +524,25 @@ 'conditions': [ ['OS == "solaris"', { 'defines': [ '_XOPEN_SOURCE_EXTENDED=0' ] - }] + }], + ['OS != "win" and icu_need_swap == "false" and icu_small_canned == "true"', { + # we are ONLY building genccode. + # pare down the dependencies dramatically. + 'sources!': [ '<@(icu_src_i18n)', + '<@(icu_src_io)', ], + 'defines!': [ 'UCONFIG_NO_BREAK_ITERATION=0' ], + 'defines': [ + #disables the 'year' stuff + 'UCONFIG_NO_FORMATTING=1', + 'UCONFIG_NO_REGULAR_EXPRESSIONS=1', + 'UCONFIG_NO_NORMALIZATION=1', + 'UCONFIG_NO_SERVICE=1', + 'UCONFIG_NO_IDNA=1', + # should be ok to disable conversion in this case + # .. but http://bugs.icu-project.org/trac/ticket/11046 + #'UCONFIG_NO_CONVERSION=1', + ] + }], ], 'direct_dependent_settings': { 'include_dirs': [ @@ -581,6 +611,10 @@ '<@(icu_src_genccode)', 'no-op.cc', ], + 'defines': [ + #disables the 'current year' stuff + 'UCONFIG_NO_FORMATTING=1', + ] }, ], } diff --git a/tools/icu/icutrim.py b/tools/icu/icutrim.py index 517bf39bad323d..c53281f62bc86f 100755 --- a/tools/icu/icutrim.py +++ b/tools/icu/icutrim.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Copyright (C) 2014 IBM Corporation and Others. All Rights Reserved. +# Copyright (C) 2014,2016 IBM Corporation and Others. All Rights Reserved. # # @author Steven R. Loomis # @@ -65,6 +65,10 @@ action="count", default=0) +parser.add_option("-K","--canned", + action="count", + default=0) + parser.add_option('-L',"--locales", action="store", dest="locales", @@ -170,7 +174,14 @@ def runcmd(tool, cmd, doContinue=False): ## The first letter of endian_letter will be 'b' or 'l' for big or little endian_letter = options.endian[0] -runcmd("icupkg", "-t%s %s %s""" % (endian_letter, options.datfile, outfile)) +if ( options.datfile.endswith("%s.dat" % endian_letter) ): + shutil.copyfile(options.datfile, outfile) +else: + runcmd("icupkg", "-t%s %s %s""" % (endian_letter, options.datfile, outfile)) + +if ( options.canned > 0 ): + print "Canned small ICU - no need to actually trim." + sys.exit(0) ## STEP 2 - get listing listfile = os.path.join(options.tmpdir,"icudata.lst")