Skip to content

Commit

Permalink
build: run mkcodecache as an action
Browse files Browse the repository at this point in the history
* fix test-code-cache (for the common cases)
* deprecate `configure --code-cache-path`

PR-URL: #27161
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
refack committed Apr 16, 2019
1 parent 5ac0308 commit 14df42f
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 147 deletions.
14 changes: 3 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,17 @@ $(NODE_G_EXE): config.gypi out/Makefile
$(MAKE) -C out BUILDTYPE=Debug V=$(V)
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi

CODE_CACHE_DIR ?= out/$(BUILDTYPE)/obj/gen
CODE_CACHE_FILE ?= $(CODE_CACHE_DIR)/node_code_cache.cc

ifeq ($(BUILDTYPE),Debug)
CONFIG_FLAGS += --debug
endif

.PHONY: with-code-cache
with-code-cache:
@echo $(CONFIG_FLAGS)
$(PYTHON) ./configure $(CONFIG_FLAGS)
$(MAKE)
mkdir -p $(CODE_CACHE_DIR)
out/$(BUILDTYPE)/mkcodecache $(CODE_CACHE_FILE)
$(PYTHON) ./configure --code-cache-path $(CODE_CACHE_FILE) $(CONFIG_FLAGS)
$(MAKE)
echo "'with-code-cache' target is a noop"

.PHONY: test-code-cache
test-code-cache: with-code-cache
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) code-cache
echo "'test-code-cache' target is a noop"

out/Makefile: config.gypi common.gypi node.gyp \
deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp \
Expand Down
8 changes: 4 additions & 4 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,9 @@
parser.add_option('--code-cache-path',
action='store',
dest='code_cache_path',
help='Use a file generated by tools/generate_code_cache.js to compile the'
' code cache for builtin modules into the binary')
help='optparse.SUPPRESS_HELP')

# End dummy list.

parser.add_option('--without-ssl',
action='store_true',
Expand Down Expand Up @@ -1050,8 +1051,7 @@ def configure_node(o):
o['variables']['debug_nghttp2'] = 'false'

o['variables']['node_no_browser_globals'] = b(options.no_browser_globals)
if options.code_cache_path:
o['variables']['node_code_cache_path'] = options.code_cache_path
o['variables']['node_code_cache_path'] = 'yes'
o['variables']['node_shared'] = b(options.shared)
node_module_version = getmoduleversion.get_version()

Expand Down
70 changes: 52 additions & 18 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
'node_use_dtrace%': 'false',
'node_use_etw%': 'false',
'node_no_browser_globals%': 'false',
'node_code_cache_path%': '',
'node_use_v8_platform%': 'true',
'node_use_bundled_v8%': 'true',
'node_shared%': 'false',
Expand Down Expand Up @@ -224,6 +223,7 @@
'deps/acorn/acorn/dist/acorn.js',
'deps/acorn/acorn-walk/dist/walk.js',
],
'mkcodecache_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mkcodecache<(EXECUTABLE_SUFFIX)',
'conditions': [
[ 'node_shared=="true"', {
'node_target_type%': 'shared_library',
Expand Down Expand Up @@ -280,16 +280,24 @@
{
'target_name': '<(node_core_target_name)',
'type': 'executable',
'sources': [
'src/node_main.cc'

'defines': [
'NODE_WANT_INTERNALS=1',
],

'includes': [
'node.gypi'
],

'include_dirs': [
'src',
'deps/v8/include'
],

'sources': [
'src/node_main.cc'
],

'dependencies': [ 'deps/histogram/histogram.gyp:histogram' ],

'msvs_settings': {
Expand Down Expand Up @@ -402,7 +410,32 @@
'LinkIncremental': 2 # enable incremental linking
},
},
}]
}],
['want_separate_host_toolset==0', {
'dependencies': [
'mkcodecache',
],
'actions': [
{
'action_name': 'run_mkcodecache',
'process_outputs_as_sources': 1,
'inputs': [
'<(mkcodecache_exec)',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/node_code_cache.cc',
],
'action': [
'<@(_inputs)',
'<@(_outputs)',
],
},
],
}, {
'sources': [
'src/node_code_cache_stub.cc'
],
}],
],
}, # node_core_target_name
{
Expand Down Expand Up @@ -615,11 +648,6 @@
'msvs_disabled_warnings!': [4244],

'conditions': [
[ 'node_code_cache_path!=""', {
'sources': [ '<(node_code_cache_path)' ]
}, {
'sources': [ 'src/node_code_cache_stub.cc' ]
}],
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
'product_extension': '<(shlib_suffix)',
'xcode_settings': {
Expand Down Expand Up @@ -1047,6 +1075,7 @@
'defines': [ 'NODE_WANT_INTERNALS=1' ],

'sources': [
'src/node_code_cache_stub.cc',
'test/cctest/node_test_fixture.cc',
'test/cctest/test_aliased_buffer.cc',
'test/cctest/test_base64.cc',
Expand Down Expand Up @@ -1075,7 +1104,9 @@
'HAVE_INSPECTOR=1',
],
}, {
'defines': [ 'HAVE_INSPECTOR=0' ]
'defines': [
'HAVE_INSPECTOR=0',
]
}],
['OS=="solaris"', {
'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
Expand Down Expand Up @@ -1130,11 +1161,14 @@
'deps/uv/include',
],

'defines': [ 'NODE_WANT_INTERNALS=1' ],

'defines': [
'NODE_WANT_INTERNALS=1'
],
'sources': [
'src/node_code_cache_stub.cc',
'tools/code_cache/mkcodecache.cc',
'tools/code_cache/cache_builder.cc'
'tools/code_cache/cache_builder.cc',
'tools/code_cache/cache_builder.h',
],

'conditions': [
Expand All @@ -1155,22 +1189,22 @@
],
}],
],
}, # cache_builder
], # end targets
}, # mkcodecache
], # end targets

'conditions': [
[ 'OS=="aix" and node_shared=="true"', {
['OS=="aix" and node_shared=="true"', {
'targets': [
{
'target_name': 'node_aix_shared',
'type': 'shared_library',
'product_name': '<(node_core_target_name)',
'ldflags': [ '--shared' ],
'ldflags': ['--shared'],
'product_extension': '<(shlib_suffix)',
'includes': [
'node.gypi'
],
'dependencies': [ '<(node_lib_target_name)' ],
'dependencies': ['<(node_lib_target_name)'],
'include_dirs': [
'src',
'deps/v8/include',
Expand Down
26 changes: 16 additions & 10 deletions node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
'conditions': [
['OS!="aix" and node_shared=="false"', {
'ldflags': [
'-Wl,--whole-archive,<(obj_dir)/deps/zlib/<(STATIC_LIB_PREFIX)'
'zlib<(STATIC_LIB_SUFFIX)',
'-Wl,--whole-archive,'
'<(obj_dir)/deps/zlib/<(STATIC_LIB_PREFIX)zlib<(STATIC_LIB_SUFFIX)',
'-Wl,--no-whole-archive',
],
}],
Expand Down Expand Up @@ -184,8 +184,8 @@
'conditions': [
['OS!="aix" and node_shared=="false"', {
'ldflags': [
'-Wl,--whole-archive,<(obj_dir)/deps/uv/<(STATIC_LIB_PREFIX)'
'uv<(STATIC_LIB_SUFFIX)',
'-Wl,--whole-archive,'
'<(obj_dir)/deps/uv/<(STATIC_LIB_PREFIX)uv<(STATIC_LIB_SUFFIX)',
'-Wl,--no-whole-archive',
],
}],
Expand Down Expand Up @@ -223,27 +223,33 @@
[ 'OS=="aix"', {
'defines': [
'_LINUX_SOURCE_COMPAT',
'__STDC_FORMAT_MACROS'
'__STDC_FORMAT_MACROS',
],
'conditions': [
[ 'force_load=="true"', {

'variables': {
'exp_filename': '<(PRODUCT_DIR)/<(_target_name).exp',
},
'actions': [
{
'action_name': 'expfile',
'inputs': [
'<(obj_dir)'
'<(obj_dir)',
],
'outputs': [
'<(PRODUCT_DIR)/node.exp'
'<(exp_filename)',
],
'action': [
'sh', 'tools/create_expfile.sh',
'<@(_inputs)', '<@(_outputs)'
'<@(_inputs)',
'<@(_outputs)',
],
}
],
'ldflags': ['-Wl,-bE:<(PRODUCT_DIR)/node.exp', '-Wl,-brtl'],
'ldflags': [
'-Wl,-bE:<(exp_filename)',
'-Wl,-brtl',
],
}],
],
}],
Expand Down
21 changes: 0 additions & 21 deletions test/code-cache/code-cache.status

This file was deleted.

64 changes: 0 additions & 64 deletions test/code-cache/test-code-cache-generator.js

This file was deleted.

6 changes: 0 additions & 6 deletions test/code-cache/testcfg.py

This file was deleted.

Loading

0 comments on commit 14df42f

Please sign in to comment.