Skip to content

Commit d1c4872

Browse files
committed
Merge pull request #21 from srl295/srl-v0.12-downloadopt
build: i18n: Don't auto-download ICU unless --download=all Thanks @trevnorris for taking a look.
2 parents f758028 + c4a22f0 commit d1c4872

File tree

4 files changed

+79
-10
lines changed

4 files changed

+79
-10
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,19 @@ enabled by default.
9191
#### "small" (English only) support
9292

9393
This option will build with "small" (English only) support, but
94-
the full `Intl` (ECMA-402) APIs. It will download the ICU library
95-
as needed.
94+
the full `Intl` (ECMA-402) APIs. With `--download=all` it will
95+
download the ICU library as needed.
9696

9797
Unix/Macintosh:
9898

9999
```sh
100-
./configure --with-intl=small-icu
100+
./configure --with-intl=small-icu --download=all
101101
```
102102

103103
Windows:
104104

105105
```sh
106-
vcbuild small-icu
106+
vcbuild small-icu download-all
107107
```
108108

109109
The `small-icu` mode builds
@@ -114,18 +114,19 @@ with English-only data. You can add full data at runtime.
114114

115115
#### Build with full ICU support (all locales supported by ICU):
116116

117-
*Note*, this may download ICU if you don't have an ICU in `deps/icu`
117+
With the `--download=all`, this may download ICU if you don't
118+
have an ICU in `deps/icu`.
118119

119120
Unix/Macintosh:
120121

121122
```sh
122-
./configure --with-intl=full-icu
123+
./configure --with-intl=full-icu --download=all
123124
```
124125

125126
Windows:
126127

127128
```sh
128-
vcbuild full-icu
129+
vcbuild full-icu download-all
129130
```
130131

131132
#### Build with no Intl support `:-(`

configure

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ parser.add_option('--with-etw',
242242
dest='with_etw',
243243
help='build with ETW (default is true on Windows)')
244244

245+
parser.add_option('--download',
246+
action='store',
247+
dest='download_list',
248+
help=nodedownload.help())
249+
245250
parser.add_option('--with-icu-path',
246251
action='store',
247252
dest='with_icu_path',
@@ -310,6 +315,8 @@ parser.add_option('--xcode',
310315

311316
(options, args) = parser.parse_args()
312317

318+
# set up auto-download list
319+
auto_downloads = nodedownload.parse(options.download_list)
313320

314321
def b(value):
315322
"""Returns the string 'true' if value is truthy, 'false' otherwise."""
@@ -743,7 +750,8 @@ def configure_intl(o):
743750
local = url.split('/')[-1]
744751
targetfile = os.path.join(root_dir, 'deps', local)
745752
if not os.path.isfile(targetfile):
746-
nodedownload.retrievefile(url, targetfile)
753+
if nodedownload.candownload(auto_downloads, "icu"):
754+
nodedownload.retrievefile(url, targetfile)
747755
else:
748756
print ' Re-using existing %s' % targetfile
749757
if os.path.isfile(targetfile):

tools/configure.d/nodedownload.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,61 @@ def unpack(packedfile, parent_path):
6767
else:
6868
packedsuffix = packedfile.lower().split('.')[-1] # .zip, .tgz etc
6969
raise Exception('Error: Don\'t know how to unpack %s with extension %s' % (packedfile, packedsuffix))
70+
71+
# List of possible "--download=" types.
72+
download_types = set(['icu'])
73+
74+
# Default options for --download.
75+
download_default = "none"
76+
77+
def help():
78+
"""This function calculates the '--help' text for '--download'."""
79+
return """Select which packages may be auto-downloaded.
80+
valid values are: none, all, %s. (default is "%s").""" % (", ".join(download_types), download_default)
81+
82+
def set2dict(keys, value=None):
83+
"""Convert some keys (iterable) to a dict."""
84+
return dict((key, value) for (key) in keys)
85+
86+
def parse(opt):
87+
"""This function parses the options to --download and returns a set such as { icu: true }, etc. """
88+
if not opt:
89+
opt = download_default
90+
91+
theOpts = set(opt.split(','))
92+
93+
if 'all' in theOpts:
94+
# all on
95+
return set2dict(download_types, True)
96+
elif 'none' in theOpts:
97+
# all off
98+
return set2dict(download_types, False)
99+
100+
# OK. Now, process each of the opts.
101+
theRet = set2dict(download_types, False)
102+
for anOpt in opt.split(','):
103+
if not anOpt or anOpt == "":
104+
# ignore stray commas, etc.
105+
continue
106+
elif anOpt is 'all':
107+
# all on
108+
theRet = dict((key, True) for (key) in download_types)
109+
else:
110+
# turn this one on
111+
if anOpt in download_types:
112+
theRet[anOpt] = True
113+
else:
114+
# future proof: ignore unknown types
115+
print 'Warning: ignoring unknown --download= type "%s"' % anOpt
116+
# all done
117+
return theRet
118+
119+
def candownload(auto_downloads, package):
120+
if not (package in auto_downloads.keys()):
121+
raise Exception('Internal error: "%s" is not in the --downloads list. Check nodedownload.py' % package)
122+
if auto_downloads[package]:
123+
return True
124+
else:
125+
print """Warning: Not downloading package "%s". You could pass "--download=all"
126+
(Windows: "download-all") to try auto-downloading it.""" % package
127+
return False

vcbuild.bat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ set noperfctr=
3636
set noperfctr_arg=
3737
set noperfctr_msi_arg=
3838
set i18n_arg=
39+
set download_arg=
3940

4041
:next-arg
4142
if "%1"=="" goto args-done
@@ -66,6 +67,7 @@ if /i "%1"=="jslint" set jslint=1&goto arg-ok
6667
if /i "%1"=="small-icu" set i18n_arg=%1&goto arg-ok
6768
if /i "%1"=="full-icu" set i18n_arg=%1&goto arg-ok
6869
if /i "%1"=="intl-none" set i18n_arg=%1&goto arg-ok
70+
if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok
6971

7072
echo Warning: ignoring invalid command line option `%1`.
7173

@@ -97,7 +99,7 @@ if defined NIGHTLY set TAG=nightly-%NIGHTLY%
9799
@rem Generate the VS project.
98100
SETLOCAL
99101
if defined VS100COMNTOOLS call "%VS100COMNTOOLS%\VCVarsQueryRegistry.bat"
100-
python configure %i18n_arg% %debug_arg% %nosnapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG%
102+
python configure %download_arg% %i18n_arg% %debug_arg% %nosnapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG%
101103
if errorlevel 1 goto create-msvs-files-failed
102104
if not exist node.sln goto create-msvs-files-failed
103105
echo Project files generated.
@@ -234,7 +236,7 @@ python tools/closure_linter/closure_linter/gjslint.py --unix_mode --strict --noj
234236
goto exit
235237

236238
:help
237-
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64]
239+
echo vcbuild.bat [debug/release] [msi] [test-all/test-uv/test-internet/test-pummel/test-simple/test-message] [clean] [noprojgen] [small-icu/full-icu/intl-none] [nobuild] [nosign] [x86/x64] [download-all]
238240
echo Examples:
239241
echo vcbuild.bat : builds release build
240242
echo vcbuild.bat debug : builds debug build

0 commit comments

Comments
 (0)