11
11
import shlex
12
12
import subprocess
13
13
import shutil
14
+ import bz2
15
+
14
16
from distutils .spawn import find_executable as which
15
17
16
18
# If not run from node/, cd to node/.
409
411
intl_optgroup .add_option ('--with-intl' ,
410
412
action = 'store' ,
411
413
dest = 'with_intl' ,
412
- default = 'small -icu' ,
414
+ default = 'full -icu' ,
413
415
choices = valid_intl_modes ,
414
416
help = 'Intl mode (valid choices: {0}) [default: %default]' .format (
415
417
', ' .join (valid_intl_modes )))
@@ -1399,38 +1401,35 @@ def write_config(data, name):
1399
1401
icu_parent_path = 'deps'
1400
1402
1401
1403
# The full path to the ICU source directory. Should not include './'.
1402
- icu_full_path = 'deps/icu'
1404
+ icu_deps_path = 'deps/icu'
1405
+ icu_full_path = icu_deps_path
1403
1406
1404
1407
# icu-tmp is used to download and unpack the ICU tarball.
1405
1408
icu_tmp_path = os .path .join (icu_parent_path , 'icu-tmp' )
1406
1409
1407
1410
# canned ICU. see tools/icu/README.md to update.
1408
1411
canned_icu_dir = 'deps/icu-small'
1409
1412
1413
+ # use the README to verify what the canned ICU is
1414
+ canned_is_full = os .path .isfile (os .path .join (canned_icu_dir , 'README-FULL-ICU.txt' ))
1415
+ canned_is_small = os .path .isfile (os .path .join (canned_icu_dir , 'README-SMALL-ICU.txt' ))
1416
+ if canned_is_small :
1417
+ warn ('Ignoring %s - in-repo small icu is no longer supported.' % canned_icu_dir )
1418
+
1410
1419
# We can use 'deps/icu-small' - pre-canned ICU *iff*
1411
- # - with_intl == small-icu (the default!)
1412
- # - with_icu_locales == 'root,en' (the default!)
1413
- # - deps/icu-small exists!
1420
+ # - canned_is_full AND
1414
1421
# - with_icu_source is unset (i.e. no other ICU was specified)
1415
- # (Note that this is the *DEFAULT CASE*.)
1416
1422
#
1417
1423
# This is *roughly* equivalent to
1418
- # $ configure --with-intl=small -icu --with-icu-source=deps/icu-small
1424
+ # $ configure --with-intl=full -icu --with-icu-source=deps/icu-small
1419
1425
# .. Except that we avoid copying icu-small over to deps/icu.
1420
1426
# In this default case, deps/icu is ignored, although make clean will
1421
1427
# still harmlessly remove deps/icu.
1422
1428
1423
- # are we using default locales?
1424
- using_default_locales = ( options .with_icu_locales == icu_default_locales )
1425
-
1426
- # make sure the canned ICU really exists
1427
- canned_icu_available = os .path .isdir (canned_icu_dir )
1428
-
1429
- if (o ['variables' ]['icu_small' ] == b (True )) and using_default_locales and (not with_icu_source ) and canned_icu_available :
1429
+ if (not with_icu_source ) and canned_is_full :
1430
1430
# OK- we can use the canned ICU.
1431
- icu_config ['variables' ]['icu_small_canned' ] = 1
1432
1431
icu_full_path = canned_icu_dir
1433
-
1432
+ icu_config [ 'variables' ][ 'icu_full_canned' ] = 1
1434
1433
# --with-icu-source processing
1435
1434
# now, check that they didn't pass --with-icu-source=deps/icu
1436
1435
elif with_icu_source and os .path .abspath (icu_full_path ) == os .path .abspath (with_icu_source ):
@@ -1508,29 +1507,40 @@ def write_config(data, name):
1508
1507
icu_endianness = sys .byteorder [0 ]
1509
1508
o ['variables' ]['icu_ver_major' ] = icu_ver_major
1510
1509
o ['variables' ]['icu_endianness' ] = icu_endianness
1511
- icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major , 'l' )
1510
+ icu_data_file_l = 'icudt%s%s.dat' % (icu_ver_major , 'l' ) # LE filename
1512
1511
icu_data_file = 'icudt%s%s.dat' % (icu_ver_major , icu_endianness )
1513
1512
# relative to configure
1514
1513
icu_data_path = os .path .join (icu_full_path ,
1515
1514
'source/data/in' ,
1516
- icu_data_file_l )
1515
+ icu_data_file_l ) # LE
1516
+ compressed_data = '%s.bz2' % (icu_data_path )
1517
+ if not os .path .isfile (icu_data_path ) and os .path .isfile (compressed_data ):
1518
+ # unpack. deps/icu is a temporary path
1519
+ if os .path .isdir (icu_tmp_path ):
1520
+ shutil .rmtree (icu_tmp_path )
1521
+ os .mkdir (icu_tmp_path )
1522
+ icu_data_path = os .path .join (icu_tmp_path , icu_data_file_l )
1523
+ with open (icu_data_path , 'wb' ) as outf :
1524
+ with bz2 .BZ2File (compressed_data , 'rb' ) as inf :
1525
+ shutil .copyfileobj (inf , outf )
1526
+ # Now, proceed..
1527
+
1517
1528
# relative to dep..
1518
- icu_data_in = os .path .join ('..' ,'..' , icu_full_path , 'source/data/in' , icu_data_file_l )
1529
+ icu_data_in = os .path .join ('..' ,'..' , icu_data_path )
1519
1530
if not os .path .isfile (icu_data_path ) and icu_endianness != 'l' :
1520
1531
# use host endianness
1521
1532
icu_data_path = os .path .join (icu_full_path ,
1522
1533
'source/data/in' ,
1523
- icu_data_file )
1524
- # relative to dep..
1525
- icu_data_in = os .path .join ('..' , icu_full_path , 'source/data/in' ,
1526
- icu_data_file )
1527
- # this is the input '.dat' file to use .. icudt*.dat
1528
- # may be little-endian if from a icu-project.org tarball
1529
- o ['variables' ]['icu_data_in' ] = icu_data_in
1534
+ icu_data_file ) # will be generated
1530
1535
if not os .path .isfile (icu_data_path ):
1531
1536
# .. and we're not about to build it from .gyp!
1532
1537
error ('''ICU prebuilt data file %s does not exist.
1533
1538
See the README.md.''' % icu_data_path )
1539
+
1540
+ # this is the input '.dat' file to use .. icudt*.dat
1541
+ # may be little-endian if from a icu-project.org tarball
1542
+ o ['variables' ]['icu_data_in' ] = icu_data_in
1543
+
1534
1544
# map from variable name to subdirs
1535
1545
icu_src = {
1536
1546
'stubdata' : 'stubdata' ,
@@ -1547,6 +1557,31 @@ def write_config(data, name):
1547
1557
var = 'icu_src_%s' % i
1548
1558
path = '../../%s/source/%s' % (icu_full_path , icu_src [i ])
1549
1559
icu_config ['variables' ][var ] = glob_to_var ('tools/icu' , path , 'patches/%s/source/%s' % (icu_ver_major , icu_src [i ]) )
1560
+ # calculate platform-specific genccode args
1561
+ # print("platform %s, flavor %s" % (sys.platform, flavor))
1562
+ # if sys.platform == 'darwin':
1563
+ # shlib_suffix = '%s.dylib'
1564
+ # elif sys.platform.startswith('aix'):
1565
+ # shlib_suffix = '%s.a'
1566
+ # else:
1567
+ # shlib_suffix = 'so.%s'
1568
+ if flavor == 'win' :
1569
+ icu_config ['variables' ]['icu_asm_ext' ] = 'obj'
1570
+ icu_config ['variables' ]['icu_asm_opts' ] = [ '-o ' ]
1571
+ elif with_intl == 'small-icu' or options .cross_compiling :
1572
+ icu_config ['variables' ]['icu_asm_ext' ] = 'c'
1573
+ icu_config ['variables' ]['icu_asm_opts' ] = []
1574
+ elif flavor == 'mac' :
1575
+ icu_config ['variables' ]['icu_asm_ext' ] = 'S'
1576
+ icu_config ['variables' ]['icu_asm_opts' ] = [ '-a' , 'gcc-darwin' ]
1577
+ elif sys .platform .startswith ('aix' ):
1578
+ icu_config ['variables' ]['icu_asm_ext' ] = 'S'
1579
+ icu_config ['variables' ]['icu_asm_opts' ] = [ '-a' , 'xlc' ]
1580
+ else :
1581
+ # assume GCC-compatible asm is OK
1582
+ icu_config ['variables' ]['icu_asm_ext' ] = 'S'
1583
+ icu_config ['variables' ]['icu_asm_opts' ] = [ '-a' , 'gcc' ]
1584
+
1550
1585
# write updated icu_config.gypi with a bunch of paths
1551
1586
write (icu_config_name , do_not_edit +
1552
1587
pprint .pformat (icu_config , indent = 2 ) + '\n ' )
0 commit comments