Skip to content

Commit aadd126

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 147b208 commit aadd126

File tree

6 files changed

+103
-10
lines changed

6 files changed

+103
-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

@@ -277,7 +277,7 @@ release-only:
277277
@if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
278278
exit 0 ; \
279279
else \
280-
echo "" >&2 ; \
280+
echo "" >&2 ; \
281281
echo "The git repository is not clean." >&2 ; \
282282
echo "Please commit changes before building release tarball." >&2 ; \
283283
echo "" >&2 ; \
@@ -288,17 +288,21 @@ release-only:
288288
@if [ "$(DISTTYPE)" != "release" -o "$(RELEASE)" = "1" ]; then \
289289
exit 0; \
290290
else \
291-
echo "" >&2 ; \
291+
echo "" >&2 ; \
292292
echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
293-
echo "Did you remember to update src/node_version.h?" >&2 ; \
294-
echo "" >&2 ; \
293+
echo "Did you remember to update src/node_version.h?" >&2 ; \
294+
echo "" >&2 ; \
295295
exit 1 ; \
296296
fi
297297

298298
$(PKG): release-only
299299
rm -rf $(PKGDIR)
300300
rm -rf out/deps out/Release
301-
$(PYTHON) ./configure --dest-cpu=x64 --tag=$(TAG)
301+
$(PYTHON) ./configure \
302+
--dest-cpu=x64 \
303+
--tag=$(TAG) \
304+
--release-urlbase=$(RELEASE_URLBASE) \
305+
$(CONFIG_FLAGS)
302306
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
303307
SIGN="$(CODESIGN_CERT)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
304308
cat tools/osx-pkg.pmdoc/index.xml.tmpl \
@@ -354,8 +358,13 @@ doc-upload: tar
354358
ssh $(STAGINGSERVER) "touch staging/$(DISTTYPEDIR)/$(FULLVERSION)/doc.done"
355359

356360
$(TARBALL)-headers: config.gypi release-only
357-
$(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
358-
HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '$(PREFIX)'
361+
$(PYTHON) ./configure \
362+
--prefix=/ \
363+
--dest-cpu=$(DESTCPU) \
364+
--tag=$(TAG) \
365+
--release-urlbase=$(RELEASE_URLBASE) \
366+
$(CONFIG_FLAGS)
367+
HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
359368
find $(TARNAME)/ -type l | xargs rm # annoying on windows
360369
tar -cf $(TARNAME)-headers.tar $(TARNAME)
361370
rm -rf $(TARNAME)
@@ -379,7 +388,12 @@ endif
379388
$(BINARYTAR): release-only
380389
rm -rf $(BINARYNAME)
381390
rm -rf out/deps out/Release
382-
$(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
391+
$(PYTHON) ./configure \
392+
--prefix=/ \
393+
--dest-cpu=$(DESTCPU) \
394+
--tag=$(TAG) \
395+
--release-urlbase=$(RELEASE_URLBASE) \
396+
$(CONFIG_FLAGS)
383397
$(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
384398
cp README.md $(BINARYNAME)
385399
cp LICENSE $(BINARYNAME)
@@ -446,7 +460,7 @@ bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events
446460
bench: bench-net bench-http bench-fs bench-tls
447461

448462
bench-http-simple:
449-
benchmark/http_simple_bench.sh
463+
benchmark/http_simple_bench.sh
450464

451465
bench-idle:
452466
$(NODE) benchmark/idle_server.js &

configure

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

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

689+
o['variables']['node_release_urlbase'] = options.release_urlbase or ''
690+
682691
if options.v8_options:
683692
o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')
684693

doc/api/process.markdown

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,36 @@ 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.
679+
680+
`process.release` contains the following properties:
681+
682+
* `name`: a string with a value that will always be `"io.js"` for io.js.
683+
* `sourceUrl`: a complete URL pointing to a _.tar.gz_ file containing the
684+
source of the current release.
685+
* `headersUrl`: a complete URL pointing to a _.tar.gz_ file containing only
686+
the header files for the current release. This file is significantly smaller
687+
than the full source file and can be used for compiling add-ons against
688+
io.js.
689+
* `libUrl`: a complete URL pointing to an _iojs.lib_ file matching the
690+
architecture and version of the current release. This file is used for
691+
compiling add-ons against io.js. _This property is only present on Windows
692+
builds of io.js and will be missing on all other platforms._
693+
694+
e.g.
695+
696+
{ name: 'io.js',
697+
sourceUrl: 'https://iojs.org/download/release/v2.3.5/iojs-v2.3.5.tar.gz',
698+
headersUrl: 'https://iojs.org/download/release/v2.3.5/iojs-v2.3.5-headers.tar.gz',
699+
libUrl: 'https://iojs.org/download/release/v2.3.5/win-x64/iojs.lib' }
700+
701+
In custom builds from non-release versions of the source tree, only the
702+
`name` property may be present. The additional properties should not be
703+
relied upon to exist.
704+
675705
## process.kill(pid[, signal])
676706

677707
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
@@ -2761,6 +2761,39 @@ void SetupProcessObject(Environment* env,
27612761
"platform",
27622762
OneByteString(env->isolate(), NODE_PLATFORM));
27632763

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