Skip to content

Commit

Permalink
build: reduce chance of unneeded rebuild
Browse files Browse the repository at this point in the history
Run `node_js2c` and `mkssldef` as actions and not as targets makes sure
they are run only once, just before processing the rest of `node_lib`.
This helps `make` based dependency change detection be more accurate.

Add comments with tagrget names for readability.

Use `process_outputs_as_sources` for automatic inclution of outputs.

PR-URL: #23156
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
refack authored and targos committed Oct 3, 2018
1 parent aae0ece commit 7d21cc2
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 71 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ available-node = \
# BUILDTYPE=Debug builds both release and debug builds. If you want to compile
# just the debug build, run `make -C out BUILDTYPE=Debug` instead.
ifeq ($(BUILDTYPE),Release)
all: out/Makefile $(NODE_EXE) ## Default target, builds node in out/Release/node.
all: $(NODE_EXE) ## Default target, builds node in out/Release/node.
else
all: out/Makefile $(NODE_EXE) $(NODE_G_EXE)
all: $(NODE_EXE) $(NODE_G_EXE)
endif

.PHONY: help
Expand Down
4 changes: 2 additions & 2 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'node_tag%': '',
'uv_library%': 'static_library',

'clang%': 0,

'openssl_fips%': '',

# Default to -O0 for debug builds.
Expand Down Expand Up @@ -91,8 +93,6 @@
}],
['OS=="mac"', {
'clang%': 1,
}, {
'clang%': 0,
}],
],
},
Expand Down
115 changes: 48 additions & 67 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
'sources': [
'tools/msvs/genfiles/node_perfctr_provider.rc',
],
}]
}],
],
}],
],
Expand All @@ -308,16 +308,11 @@
'product_name': '<(node_core_target_name)-win',
}],
],
},
}, # node_core_target_name
{
'target_name': '<(node_lib_target_name)',
'type': '<(node_intermediate_lib_type)',
'product_name': '<(node_core_target_name)',

'dependencies': [
'node_js2c#host',
],

'includes': [
'node.gypi'
],
Expand Down Expand Up @@ -463,7 +458,6 @@
'<@(library_files)',
# node.gyp is added to the project by default.
'common.gypi',
'<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc',
],

'variables': {
Expand Down Expand Up @@ -610,15 +604,9 @@
'src/tls_wrap.h'
],
}],
],
},
{
'target_name': 'mkssldef',
'type': 'none',
# TODO(bnoordhuis) Make all platforms export the same list of symbols.
# Teach mkssldef.py to generate linker maps that UNIX linkers understand.
'conditions': [
[ 'use_openssl_def==1', {
# TODO(bnoordhuis) Make all platforms export the same list of symbols.
# Teach mkssldef.py to generate linker maps that UNIX linkers understand.
'variables': {
'mkssldef_flags': [
# Categories to export.
Expand Down Expand Up @@ -648,6 +636,7 @@
'deps/openssl/openssl/util/libssl.num',
],
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
'process_outputs_as_sources': 1,
'action': [
'python',
'tools/mkssldef.py',
Expand All @@ -660,9 +649,41 @@
],
}],
],
},
# generate ETW header and resource files
'actions': [
{
'action_name': 'node_js2c',
'process_outputs_as_sources': 1,
'inputs': [
'<@(library_files)',
'tools/check_macros.py'
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc',
],
'conditions': [
[ 'node_use_dtrace=="false" and node_use_etw=="false"', {
'inputs': [ 'src/notrace_macros.py' ]
}],
[ 'node_use_perfctr=="false"', {
'inputs': [ 'src/noperfctr_macros.py' ]
}],
[ 'node_debug_lib=="false"', {
'inputs': [ 'tools/nodcheck_macros.py' ]
}],
[ 'node_debug_lib=="true"', {
'inputs': [ 'tools/dcheck_macros.py' ]
}]
],
'action': [
'python', 'tools/js2c.py',
'<@(_outputs)',
'<@(_inputs)', 'config.gypi',
],
},
],
}, # node_lib_target_name
{
# generate ETW header and resource files
'target_name': 'node_etw',
'type': 'none',
'conditions': [
Expand All @@ -681,9 +702,9 @@
]
} ]
]
},
# generate perf counter header and resource files
}, # node_etw
{
# generate perf counter header and resource files
'target_name': 'node_perfctr',
'type': 'none',
'conditions': [
Expand All @@ -705,46 +726,7 @@
],
} ]
]
},
{
'target_name': 'node_js2c',
'type': 'none',
'toolsets': ['host'],
'actions': [
{
'action_name': 'node_js2c',
'process_outputs_as_sources': 1,
'inputs': [
'<@(library_files)',
'./config.gypi',
'tools/check_macros.py'
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc',
],
'conditions': [
[ 'node_use_dtrace=="false" and node_use_etw=="false"', {
'inputs': [ 'src/notrace_macros.py' ]
}],
[ 'node_use_perfctr=="false"', {
'inputs': [ 'src/noperfctr_macros.py' ]
}],
[ 'node_debug_lib=="false"', {
'inputs': [ 'tools/nodcheck_macros.py' ]
}],
[ 'node_debug_lib=="true"', {
'inputs': [ 'tools/dcheck_macros.py' ]
}]
],
'action': [
'python',
'tools/js2c.py',
'<@(_outputs)',
'<@(_inputs)',
],
},
],
}, # end node_js2c
}, # node_perfctr
{
'target_name': 'node_dtrace_header',
'type': 'none',
Expand Down Expand Up @@ -772,7 +754,7 @@
]
} ],
]
},
}, # node_dtrace_header
{
'target_name': 'node_dtrace_provider',
'type': 'none',
Expand Down Expand Up @@ -807,7 +789,7 @@
],
}],
]
},
}, # node_dtrace_provider
{
'target_name': 'node_dtrace_ustack',
'type': 'none',
Expand Down Expand Up @@ -855,7 +837,7 @@
]
} ],
]
},
}, # node_dtrace_ustack
{
'target_name': 'specialize_node_d',
'type': 'none',
Expand All @@ -881,7 +863,7 @@
],
} ],
]
},
}, # specialize_node_d
{
# When using shared lib to build executable in Windows, in order to avoid
# filename collision, the executable name is node-win.exe. Need to rename
Expand Down Expand Up @@ -909,7 +891,7 @@
],
} ],
]
},
}, # rename_node_bin_win
{
'target_name': 'cctest',
'type': 'executable',
Expand All @@ -918,7 +900,6 @@
'<(node_lib_target_name)',
'rename_node_bin_win',
'deps/gtest/gtest.gyp:gtest',
'node_js2c#host',
'node_dtrace_header',
'node_dtrace_ustack',
'node_dtrace_provider',
Expand Down Expand Up @@ -979,7 +960,7 @@
'type': 'none',
}],
],
}
}, # cctest
], # end targets

'conditions': [
Expand Down
10 changes: 10 additions & 0 deletions node.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
},
'force_load%': '<(force_load)',
},
# Putting these explicitly here so not to be dependant on common.gypi.
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
'xcode_settings': {
'WARNING_CFLAGS': [
'-Wall',
'-Wendif-labels',
'-W',
'-Wno-unused-parameter',
],
},
'conditions': [
[ 'node_shared=="false"', {
'msvs_settings': {
Expand Down

0 comments on commit 7d21cc2

Please sign in to comment.