Skip to content

Commit 04fd4fa

Browse files
committed
src: introduce process.release object
PR-URL: #2154 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent 2d9456e commit 04fd4fa

File tree

6 files changed

+102
-9
lines changed

6 files changed

+102
-9
lines changed

Makefile

+23-9
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,7 +350,12 @@ 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)
353+
$(PYTHON) ./configure \
354+
--prefix=/ \
355+
--dest-cpu=$(DESTCPU) \
356+
--tag=$(TAG) \
357+
--release-urlbase=$(RELEASE_URLBASE) \
358+
$(CONFIG_FLAGS)
350359
HEADERS_ONLY=1 $(PYTHON) tools/install.py install '$(TARNAME)' '/'
351360
find $(TARNAME)/ -type l | xargs rm # annoying on windows
352361
tar -cf $(TARNAME)-headers.tar $(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

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

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

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

+33
Original file line numberDiff line numberDiff line change
@@ -2760,6 +2760,39 @@ void SetupProcessObject(Environment* env,
27602760
"platform",
27612761
OneByteString(env->isolate(), NODE_PLATFORM));
27622762

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

vcbuild.bat

+2
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)