Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: i18n: Don't auto-download ICU unless --download=all #21

Merged
merged 1 commit into from
Dec 18, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ enabled by default.
#### "small" (English only) support

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

Unix/Macintosh:

```sh
./configure --with-intl=small-icu
./configure --with-intl=small-icu --download=all
```

Windows:

```sh
vcbuild small-icu
vcbuild small-icu download-all
```

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

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

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

Unix/Macintosh:

```sh
./configure --with-intl=full-icu
./configure --with-intl=full-icu --download=all
```

Windows:

```sh
vcbuild full-icu
vcbuild full-icu download-all
```

#### Build with no Intl support `:-(`
Expand Down
10 changes: 9 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ parser.add_option('--with-etw',
dest='with_etw',
help='build with ETW (default is true on Windows)')

parser.add_option('--download',
action='store',
dest='download_list',
help=nodedownload.help())

parser.add_option('--with-icu-path',
action='store',
dest='with_icu_path',
Expand Down Expand Up @@ -310,6 +315,8 @@ parser.add_option('--xcode',

(options, args) = parser.parse_args()

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

def b(value):
"""Returns the string 'true' if value is truthy, 'false' otherwise."""
Expand Down Expand Up @@ -743,7 +750,8 @@ def configure_intl(o):
local = url.split('/')[-1]
targetfile = os.path.join(root_dir, 'deps', local)
if not os.path.isfile(targetfile):
nodedownload.retrievefile(url, targetfile)
if nodedownload.candownload(auto_downloads, "icu"):
nodedownload.retrievefile(url, targetfile)
else:
print ' Re-using existing %s' % targetfile
if os.path.isfile(targetfile):
Expand Down
58 changes: 58 additions & 0 deletions tools/configure.d/nodedownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,61 @@ def unpack(packedfile, parent_path):
else:
packedsuffix = packedfile.lower().split('.')[-1] # .zip, .tgz etc
raise Exception('Error: Don\'t know how to unpack %s with extension %s' % (packedfile, packedsuffix))

# List of possible "--download=" types.
download_types = set(['icu'])

# Default options for --download.
download_default = "none"

def help():
"""This function calculates the '--help' text for '--download'."""
return """Select which packages may be auto-downloaded.
valid values are: none, all, %s. (default is "%s").""" % (", ".join(download_types), download_default)

def set2dict(keys, value=None):
"""Convert some keys (iterable) to a dict."""
return dict((key, value) for (key) in keys)

def parse(opt):
"""This function parses the options to --download and returns a set such as { icu: true }, etc. """
if not opt:
opt = download_default

theOpts = set(opt.split(','))

if 'all' in theOpts:
# all on
return set2dict(download_types, True)
elif 'none' in theOpts:
# all off
return set2dict(download_types, False)

# OK. Now, process each of the opts.
theRet = set2dict(download_types, False)
for anOpt in opt.split(','):
if not anOpt or anOpt == "":
# ignore stray commas, etc.
continue
elif anOpt is 'all':
# all on
theRet = dict((key, True) for (key) in download_types)
else:
# turn this one on
if anOpt in download_types:
theRet[anOpt] = True
else:
# future proof: ignore unknown types
print 'Warning: ignoring unknown --download= type "%s"' % anOpt
# all done
return theRet

def candownload(auto_downloads, package):
if not (package in auto_downloads.keys()):
raise Exception('Internal error: "%s" is not in the --downloads list. Check nodedownload.py' % package)
if auto_downloads[package]:
return True
else:
print """Warning: Not downloading package "%s". You could pass "--download=all"
(Windows: "download-all") to try auto-downloading it.""" % package
return False
6 changes: 4 additions & 2 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set noperfctr=
set noperfctr_arg=
set noperfctr_msi_arg=
set i18n_arg=
set download_arg=

:next-arg
if "%1"=="" goto args-done
Expand Down Expand Up @@ -66,6 +67,7 @@ if /i "%1"=="jslint" set jslint=1&goto arg-ok
if /i "%1"=="small-icu" set i18n_arg=%1&goto arg-ok
if /i "%1"=="full-icu" set i18n_arg=%1&goto arg-ok
if /i "%1"=="intl-none" set i18n_arg=%1&goto arg-ok
if /i "%1"=="download-all" set download_arg="--download=all"&goto arg-ok

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

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

:help
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]
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]
echo Examples:
echo vcbuild.bat : builds release build
echo vcbuild.bat debug : builds debug build
Expand Down