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

src: introduce process.release object (WIP) #493

Closed
wants to merge 1 commit into from
Closed
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
63 changes: 44 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ test-npm: $(NODE_EXE)
rm -rf npm-cache npm-tmp npm-prefix
mkdir npm-cache npm-tmp npm-prefix
cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \
npm_config_prefix="$(shell pwd)/npm-prefix" \
npm_config_tmp="$(shell pwd)/npm-tmp" \
../../$(NODE_EXE) cli.js install --ignore-scripts
npm_config_prefix="$(shell pwd)/npm-prefix" \
npm_config_tmp="$(shell pwd)/npm-tmp" \
../../$(NODE_EXE) cli.js install --ignore-scripts
cd deps/npm ; npm_config_cache="$(shell pwd)/npm-cache" \
npm_config_prefix="$(shell pwd)/npm-prefix" \
npm_config_tmp="$(shell pwd)/npm-tmp" \
../../$(NODE_EXE) cli.js run-script test-all && \
../../$(NODE_EXE) cli.js prune --prod && \
cd ../.. && \
rm -rf npm-cache npm-tmp npm-prefix
npm_config_prefix="$(shell pwd)/npm-prefix" \
npm_config_tmp="$(shell pwd)/npm-tmp" \
../../$(NODE_EXE) cli.js run-script test-all && \
../../$(NODE_EXE) cli.js prune --prod && \
cd ../.. && \
rm -rf npm-cache npm-tmp npm-prefix

test-npm-publish: $(NODE_EXE)
npm_package_config_publishtest=true ./$(NODE_EXE) deps/npm/test/run.js
Expand All @@ -160,7 +160,7 @@ test-timers-clean:

apidoc_sources = $(wildcard doc/api/*.markdown)
apidocs = $(addprefix out/,$(apidoc_sources:.markdown=.html)) \
$(addprefix out/,$(apidoc_sources:.markdown=.json))
$(addprefix out/,$(apidoc_sources:.markdown=.json))

apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets

Expand Down Expand Up @@ -244,7 +244,7 @@ release-only:
@if [ "$(shell git status --porcelain | egrep -v '^\?\? ')" = "" ]; then \
exit 0 ; \
else \
echo "" >&2 ; \
echo "" >&2 ; \
echo "The git repository is not clean." >&2 ; \
echo "Please commit changes before building release tarball." >&2 ; \
echo "" >&2 ; \
Expand All @@ -255,10 +255,26 @@ release-only:
@if [ "$(NIGHTLY)" != "" -o "$(RELEASE)" = "1" ]; then \
exit 0; \
else \
echo "" >&2 ; \
echo "" >&2 ; \
echo "#NODE_VERSION_IS_RELEASE is set to $(RELEASE)." >&2 ; \
echo "Did you remember to update src/node_version.cc?" >&2 ; \
echo "" >&2 ; \
echo "Did you remember to update src/node_version.h?" >&2 ; \
echo "" >&2 ; \
exit 1 ; \
fi
@if [ "$(RELEASE_SOURCE_URL)" != "" ]; then \
exit 0; \
else \
echo "" >&2 ; \
echo "#RELEASE_SOURCE_URL is not set." >&2 ; \
echo "" >&2 ; \
exit 1 ; \
fi
@if [ "$(RELEASE_HEADERS_URL)" != "" ]; then \
exit 0; \
else \
echo "" >&2 ; \
echo "#RELEASE_HEADERS_URL is not set." >&2 ; \
echo "" >&2 ; \
exit 1 ; \
fi

Expand All @@ -267,10 +283,14 @@ pkg: $(PKG)
$(PKG): release-only
rm -rf $(PKGDIR)
rm -rf out/deps out/Release
$(PYTHON) ./configure --dest-cpu=ia32 --tag=$(TAG)
$(PYTHON) ./configure --dest-cpu=ia32 --tag=$(TAG) \
--release-source-url=$(RELEASE_SOURCE_URL) \
--release-headers-url=$(RELEASE_HEADERS_URL)
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)/32
rm -rf out/deps out/Release
$(PYTHON) ./configure --dest-cpu=x64 --tag=$(TAG)
$(PYTHON) ./configure --dest-cpu=x64 --tag=$(TAG) \
--release-source-url=$(RELEASE_SOURCE_URL) \
--release-headers-url=$(RELEASE_HEADERS_URL)
$(MAKE) install V=$(V) DESTDIR=$(PKGDIR)
SIGN="$(APP_SIGN)" PKGDIR="$(PKGDIR)" bash tools/osx-codesign.sh
lipo $(PKGDIR)/32/usr/local/bin/iojs \
Expand Down Expand Up @@ -308,7 +328,10 @@ tar: $(TARBALL)
$(BINARYTAR): release-only
rm -rf $(BINARYNAME)
rm -rf out/deps out/Release
$(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
$(PYTHON) ./configure --prefix=/ --dest-cpu=$(DESTCPU) \
--tag=$(TAG) \
--release-source-url=$(RELEASE_SOURCE_URL) \
--release-headers-url=$(RELEASE_HEADERS_URL) $(CONFIG_FLAGS)
$(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1
cp README.md $(BINARYNAME)
cp LICENSE $(BINARYNAME)
Expand All @@ -326,7 +349,9 @@ binary: $(BINARYTAR)
$(PKGSRC): release-only
rm -rf dist out
$(PYTHON) configure --prefix=/ \
--dest-cpu=$(DESTCPU) --tag=$(TAG) $(CONFIG_FLAGS)
--dest-cpu=$(DESTCPU) --tag=$(TAG) \
--release-source-url=$(RELEASE_SOURCE_URL) \
--release-headers-url=$(RELEASE_HEADERS_URL) $(CONFIG_FLAGS)
$(MAKE) install DESTDIR=dist
(cd dist; find * -type f | sort) > packlist
pkg_info -X pkg_install | \
Expand Down Expand Up @@ -380,7 +405,7 @@ bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events
bench: bench-net bench-http bench-fs bench-tls

bench-http-simple:
benchmark/http_simple_bench.sh
benchmark/http_simple_bench.sh

bench-idle:
./$(NODE_EXE) benchmark/idle_server.js &
Expand Down
30 changes: 30 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ parser.add_option('--tag',
dest='tag',
help='custom build tag')

parser.add_option('--release-source-url',
action='store',
dest='release_source_url',
help='custom url for process.release.sourceUrl')

parser.add_option('--release-headers-url',
action='store',
dest='release_headers_url',
help='custom url for process.release.headersUrl')

parser.add_option('--release-lib-url',
action='store',
dest='release_lib_url',
help='custom url for process.release.libUrl. Only valid on Windows.')

parser.add_option('--v8-options',
action='store',
dest='v8_options',
Expand Down Expand Up @@ -555,6 +570,21 @@ def configure_node(o):
else:
o['variables']['node_tag'] = ''

if options.release_source_url:
o['variables']['node_release_source_url'] = options.release_source_url
else:
o['variables']['node_release_source_url'] = ''

if options.release_headers_url:
o['variables']['node_release_headers_url'] = options.release_headers_url
else:
o['variables']['node_release_headers_url'] = ''

if options.release_lib_url:
o['variables']['node_release_lib_url'] = '-' + options.release_lib_url
else:
o['variables']['node_release_lib_url'] = ''

if options.v8_options:
o['variables']['node_v8_options'] = options.v8_options.replace('"', '\\"')

Expand Down
15 changes: 15 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,21 @@
],

'conditions': [
[ 'node_release_source_url!=""', {
'defines': [
'NODE_RELEASE_SOURCE_URL="<(node_release_source_url)"',
]
}],
[ 'node_release_headers_url!=""', {
'defines': [
'NODE_RELEASE_HEADERS_URL="<(node_release_headers_url)"',
]
}],
[ 'node_release_lib_url!=""', {
'defines': [
'NODE_RELEASE_LIB_URL="<(node_release_lib_url)"',
]
}],
[ 'v8_enable_i18n_support==1', {
'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ],
'dependencies': [
Expand Down
24 changes: 24 additions & 0 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2613,6 +2613,30 @@ void SetupProcessObject(Environment* env,
"platform",
OneByteString(env->isolate(), NODE_PLATFORM));

// process.release
Local<Object> release = Object::New(env->isolate());
READONLY_PROPERTY(process, "release", release);

READONLY_PROPERTY(release, "name", OneByteString(env->isolate(), "iojs"));

#if defined(NODE_RELEASE_SOURCE_URL)
READONLY_PROPERTY(release,
"sourceUrl",
OneByteString(env->isolate(), NODE_RELEASE_SOURCE_URL));
#endif

#if defined(NODE_RELEASE_HEADERS_URL)
READONLY_PROPERTY(release,
"headersUrl",
OneByteString(env->isolate(), NODE_RELEASE_HEADERS_URL));
#endif

#if defined(NODE_RELEASE_LIB_URL)
READONLY_PROPERTY(release,
"libUrl",
OneByteString(env->isolate(), NODE_RELEASE_LIB_URL));
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it possible to reconstruct the download URL from the NODE_VERSION_* macros in src/node_version.h? The approach you've taken is not bad but it's considerably more complex than is strictly necessary, I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes ... this is an option but this gives us more flexibility for testing and baking in arbitrary urls to releases including nightlies, I can hardwire the host in here and handle the nightlies special case with macros if you think that's the best way to go. For now this is really helpful for testing this feature so I'll leave it asis.


// process.argv
Local<Array> arguments = Array::New(env->isolate(), argc);
for (int i = 0; i < argc; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/node_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define NODE_MINOR_VERSION 0
#define NODE_PATCH_VERSION 5

#define NODE_VERSION_IS_RELEASE 0
#define NODE_VERSION_IS_RELEASE 1

#ifndef NODE_STRINGIFY
#define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)
Expand Down
7 changes: 6 additions & 1 deletion vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ set noperfctr_arg=
set noperfctr_msi_arg=
set i18n_arg=
set download_arg=
set release_urls_arg=

:next-arg
if "%1"=="" goto args-done
Expand Down Expand Up @@ -87,6 +88,10 @@ if "%i18n_arg%"=="full-icu" set i18n_arg=--with-intl=full-icu
if "%i18n_arg%"=="small-icu" set i18n_arg=--with-intl=small-icu
if "%i18n_arg%"=="intl-none" set i18n_arg=--with-intl=none

if defined RELEASE_SOURCE_URL set release_urls_arg=--release-source-url=%RELEASE_SOURCE_URL%
if defined RELEASE_HEADERS_URL set release_urls_arg=%release_urls_arg% --release-headers-url=%RELEASE_HEADERS_URL%
if defined RELEASE_LIB_URL set release_urls_arg=%release_urls_arg% --release-lib-url=%RELEASE_LIB_URL%

:project-gen
@rem Skip project generation if requested.
if defined noprojgen goto msbuild
Expand All @@ -96,7 +101,7 @@ if defined NIGHTLY set TAG=nightly-%NIGHTLY%
@rem Generate the VS project.
SETLOCAL
if defined VS100COMNTOOLS call "%VS100COMNTOOLS%\VCVarsQueryRegistry.bat"
python configure %download_arg% %i18n_arg% %debug_arg% %snapshot_arg% %noetw_arg% %noperfctr_arg% --dest-cpu=%target_arch% --tag=%TAG%
python configure %download_arg% %i18n_arg% %debug_arg% %snapshot_arg% %noetw_arg% %noperfctr_arg% %release_urls% --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