Skip to content

Commit 62eeeb0

Browse files
committed
src: introduce process.release object
PR-URL: #2154 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]>
1 parent 8be6060 commit 62eeeb0

File tree

6 files changed

+100
-10
lines changed

6 files changed

+100
-10
lines changed

Makefile

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ test-timers-clean:
156156

157157
apidoc_sources = $(wildcard doc/api/*.markdown)
158158
apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
159-
$(addprefix out/,$(apidoc_sources:.markdown=.json))
159+
$(addprefix out/,$(apidoc_sources:.markdown=.json))
160160

161161
apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
162162

@@ -269,7 +269,7 @@ release-only:
269269
@if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
270270
exit 0 ; \
271271
else \
272-
echo "" >&2 ; \
272+
echo "" >&2 ; \
273273
echo "The git repository is not clean." >&2 ; \
274274
echo "Please commit changes before building release tarball." >&2 ; \
275275
echo "" >&2 ; \
@@ -280,17 +280,21 @@ release-only:
280280
@if [ "$(DISTTYPE)" != "release" -o "$(RELEASE)" = "1" ]; then \
281281
exit 0; \
282282
else \
283-
echo "" >&2 ; \
283+
echo "" >&2 ; \
284284
echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
285-
echo "Did you remember to update src/node_version.h?" >&2 ; \
286-
echo "" >&2 ; \
285+
echo "Did you remember to update src/node_version.h?" >&2 ; \
286+
echo "" >&2 ; \
287287
exit 1 ; \
288288
fi
289289

290290
$(PKG): release-only
291291
rm -rf $(PKGDIR)
292292
rm -rf out/deps out/Release
293-
$(PYTHON) ./configure --dest-cpu=x64 --tag=$(TAG)
293+
$(PYTHON) ./configure \
294+
--dest-cpu=x64 \
295+
--tag=$(TAG) \
296+
--release-urlbase=$(RELEASE_URLBASE) \
297+
$(CONFIG_FLAGS)
294298
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
295299
SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
296300
cat tools/osx-pkg.pmdoc/index.xml.tmpl \
@@ -346,8 +350,13 @@ doc-upload: tar
346350
ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/doc.done"
347351

348352
$(TARBALL)-headers: config.gypi release-only
349-
$(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
350-
HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
353+
$(PYTHON) ./configure \
354+
--prefix=/ \
355+
--dest-cpu=$(DESTCPU) \
356+
--tag=$(TAG) \
357+
--release-urlbase=$(RELEASE_URLBASE) \
358+
$(CONFIG_FLAGS)
359+
HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '$(PREFIX)'
351360
find $(TARNAME)/ -type l | xargs rm # annoying on windows
352361
tar -cf $(TARNAME)-headers.tar $(TARNAME)
353362
rm -rf $(TARNAME)
@@ -371,7 +380,12 @@ endif
371380
$(BINARYTAR): release-only
372381
rm -rf $(BINARYNAME)
373382
rm -rf out/deps out/Release
374-
$(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
383+
$(PYTHON) ./configure \
384+
--prefix=/ \
385+
--dest-cpu=$(DESTCPU) \
386+
--tag=$(TAG) \
387+
--release-urlbase=$(RELEASE_URLBASE) \
388+
$(CONFIG_FLAGS)
375389
$(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
376390
cp README.md $(BINARYNAME)
377391
cp LICENSE $(BINARYNAME)
@@ -438,7 +452,7 @@ bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events
438452
bench: bench-net bench-http bench-fs bench-tls
439453

440454
bench-http-simple:
441-
benchmark/http_simple_bench.sh
455+
benchmark/http_simple_bench.sh
442456

443457
bench-idle:
444458
$(NODE) benchmark/idle_server.js &

configure

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ parser.add_option('--tag',
191191
dest='tag',
192192
help='custom build tag')
193193

194+
parser.add_option('--release-urlbase',
195+
action='store',
196+
dest='release_urlbase',
197+
help='Provide a custom URL prefix for the `process.release` properties '
198+
'`sourceUrl` and `headersUrl`. When compiling a release build, this '
199+
'will default to https://iojs.org/download/release/')
200+
194201
parser.add_option('--v8-options',
195202
action='store',
196203
dest='v8_options',
@@ -675,6 +682,8 @@ def configure_node(o):
675682
else:
676683
o['variables']['node_tag'] = ''
677684

685+
o['variables']['node_release_urlbase'] = options.release_urlbase or ''
686+
678687
if options.v8_options:
679688
o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')
680689

doc/api/process.markdown

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,33 @@ An example of the possible output looks like:
672672
target_arch: 'x64',
673673
v8_use_snapshot: 'true' } }
674674

675+
## process.release
676+
677+
An Object containing metadata related to the current release, including URLs
678+
for the source tarball and headers-only tarball. This property may not exist in
679+
custom builds from non-release versions of the source tree.
680+
681+
`process.release` contains the following properties:
682+
683+
* `name`: a string with a value that will always be `"io.js"` for io.js.
684+
* `sourceUrl`: a complete URL pointing to a _.tar.gz_ file containing the
685+
source of the current release.
686+
* `headersUrl`: a complete URL pointing to a _.tar.gz_ file containing only
687+
the header files for the current release. This file is significantly smaller
688+
than the full source file and can be used for compiling add-ons against
689+
io.js.
690+
* `libUrl`: a complete URL pointing to an _iojs.lib_ file matching the
691+
architecture and version of the current release. This file is used for
692+
compiling add-ons against io.js. _This property is only present on Windows
693+
builds of io.js and will be missing on all other platforms._
694+
695+
e.g.
696+
697+
{ name: 'io.js',
698+
sourceUrl: 'https://iojs.org/download/release/v2.3.5/iojs-v2.3.5.tar.gz',
699+
headersUrl: 'https://iojs.org/download/release/v2.3.5/iojs-v2.3.5-headers.tar.gz',
700+
libUrl: 'https://iojs.org/download/release/v2.3.5/win-x64/iojs.lib' }
701+
675702
## process.kill(pid[, signal])
676703

677704
Send a signal to a process. `pid` is the process id and `signal` is the

node.gyp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@
194194
'src/node_main.cc',
195195
],
196196
}],
197+
[ 'node_release_urlbase!=""', {
198+
'defines': [
199+
'NODE_RELEASE_URLBASE="<(node_release_urlbase)"',
200+
]
201+
}],
197202
[ 'v8_enable_i18n_support==1', {
198203
'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ],
199204
'dependencies': [

src/node.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,39 @@ void SetupProcessObject(Environment* env,
27622762
"platform",
27632763
OneByteString(env->isolate(), NODE_PLATFORM));
27642764

2765+
// process.release
2766+
Local<Object> release = Object::New(env->isolate());
2767+
READONLY_PROPERTY(process, "release", release);
2768+
READONLY_PROPERTY(release, "name", OneByteString(env->isolate(), "io.js"));
2769+
2770+
// if this is a release build and no explicit base has been set
2771+
// substitute the standard release download URL
2772+
#ifndef NODE_RELEASE_URLBASE
2773+
# if NODE_VERSION_IS_RELEASE
2774+
# define NODE_RELEASE_URLBASE "https://iojs.org/download/release/"
2775+
# endif
2776+
#endif
2777+
2778+
#if defined(NODE_RELEASE_URLBASE)
2779+
# define _RELEASE_URLPFX NODE_RELEASE_URLBASE "v" NODE_VERSION_STRING "/"
2780+
# define _RELEASE_URLFPFX _RELEASE_URLPFX "iojs-v" NODE_VERSION_STRING
2781+
2782+
READONLY_PROPERTY(release,
2783+
"sourceUrl",
2784+
OneByteString(env->isolate(),
2785+
_RELEASE_URLFPFX ".tar.gz"));
2786+
READONLY_PROPERTY(release,
2787+
"headersUrl",
2788+
OneByteString(env->isolate(),
2789+
_RELEASE_URLFPFX "-headers.tar.gz"));
2790+
# ifdef _WIN32
2791+
READONLY_PROPERTY(release,
2792+
"libUrl",
2793+
OneByteString(env->isolate(),
2794+
_RELEASE_URLPFX "win-" NODE_ARCH "/iojs.lib"));
2795+
# endif
2796+
#endif
2797+
27652798
// process.argv
27662799
Local<Array> arguments = Array::New(env->isolate(), argc);
27672800
for (int i = 0; i < argc; ++i) {

vcbuild.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ set noperfctr_arg=
3535
set noperfctr_msi_arg=
3636
set i18n_arg=
3737
set download_arg=
38+
set release_urls_arg=
3839

3940
:next-arg
4041
if "%1"=="" goto args-done
@@ -79,6 +80,7 @@ if "%config%"=="Debug" set debug_arg=--debug
7980
if defined nosnapshot set snapshot_arg=--without-snapshot
8081
if defined noetw set noetw_arg=--without-etw& set noetw_msi_arg=/p:NoETW=1
8182
if defined noperfctr set noperfctr_arg=--without-perfctr& set noperfctr_msi_arg=/p:NoPerfCtr=1
83+
if defined RELEASE_URLBASE set release_urlbase_arg=--release-urlbase=%RELEASE_URLBASE%
8284

8385
if "%i18n_arg%"=="full-icu" set i18n_arg=--with-intl=full-icu
8486
if "%i18n_arg%"=="small-icu" set i18n_arg=--with-intl=small-icu

0 commit comments

Comments
 (0)