From 19a30f3b7e8d4291ce8dafe46b9206baba85a412 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 31 Mar 2019 10:50:44 +0200 Subject: [PATCH] build: fix inspector dependency resolution It was reported that parallel builds on Windows sometimes error because of missing intermediate files. On closer inspection I noticed that some files are copied from src/ to the intermediate build directory in a way where they don't participate in dependency resolution. Put another way, the build system doesn't know to wait for the copy to complete because we don't tell it to. Fix that by not copying around files but instead making the script that processes them a little smarter about where to find them and where to store the results. PR-URL: https://github.com/nodejs/node/pull/27026 Fixes: https://github.com/nodejs/node/issues/27025 Reviewed-By: Eugene Ostroukhov Reviewed-By: Richard Lau Signed-off-by: Beth Griggs --- src/inspector/node_inspector.gypi | 20 +++++--------------- tools/inspector_protocol/code_generator.py | 7 +++---- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/inspector/node_inspector.gypi b/src/inspector/node_inspector.gypi index 5191543ab73450..f6f07a8b8830da 100644 --- a/src/inspector/node_inspector.gypi +++ b/src/inspector/node_inspector.gypi @@ -1,7 +1,6 @@ { 'variables': { 'protocol_tool_path': '../../tools/inspector_protocol', - 'node_inspector_path': '../../src/inspector', 'node_inspector_generated_sources': [ '<(SHARED_INTERMEDIATE_DIR)/src/node/inspector/protocol/Forward.h', '<(SHARED_INTERMEDIATE_DIR)/src/node/inspector/protocol/Protocol.cpp', @@ -67,23 +66,14 @@ '<(SHARED_INTERMEDIATE_DIR)', '<(SHARED_INTERMEDIATE_DIR)/src', # for inspector ], - 'copies': [ - { - 'files': [ - '<(node_inspector_path)/node_protocol_config.json', - '<(node_inspector_path)/node_protocol.pdl' - ], - 'destination': '<(SHARED_INTERMEDIATE_DIR)', - } - ], 'actions': [ { 'action_name': 'convert_node_protocol_to_json', 'inputs': [ - '<(SHARED_INTERMEDIATE_DIR)/node_protocol.pdl', + 'node_protocol.pdl', ], 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/node_protocol.json', + '<(SHARED_INTERMEDIATE_DIR)/src/node_protocol.json', ], 'action': [ 'python', @@ -95,8 +85,8 @@ { 'action_name': 'node_protocol_generated_sources', 'inputs': [ - '<(SHARED_INTERMEDIATE_DIR)/node_protocol_config.json', - '<(SHARED_INTERMEDIATE_DIR)/node_protocol.json', + 'node_protocol_config.json', + '<(SHARED_INTERMEDIATE_DIR)/src/node_protocol.json', '<@(node_protocol_files)', ], 'outputs': [ @@ -108,7 +98,7 @@ 'tools/inspector_protocol/code_generator.py', '--jinja_dir', '<@(protocol_tool_path)/..', '--output_base', '<(SHARED_INTERMEDIATE_DIR)/src/', - '--config', '<(SHARED_INTERMEDIATE_DIR)/node_protocol_config.json', + '--config', 'src/inspector/node_protocol_config.json', ], 'message': 'Generating node protocol sources from protocol json', }, diff --git a/tools/inspector_protocol/code_generator.py b/tools/inspector_protocol/code_generator.py index fb9959d6082a7b..9200022413303a 100755 --- a/tools/inspector_protocol/code_generator.py +++ b/tools/inspector_protocol/code_generator.py @@ -29,9 +29,9 @@ def read_config(): # pylint: disable=W0703 - def json_to_object(data, output_base, config_base): + def json_to_object(data, output_base): def json_object_hook(object_dict): - items = [(k, os.path.join(config_base, v) if k == "path" else v) for (k, v) in object_dict.items()] + items = [(k, os.path.join(output_base, v) if k == "path" else v) for (k, v) in object_dict.items()] items = [(k, os.path.join(output_base, v) if k == "output" else v) for (k, v) in items] keys, values = list(zip(*items)) return collections.namedtuple('X', keys)(*values) @@ -71,7 +71,6 @@ def init_defaults(config_tuple, path, defaults): if not config_file: raise Exception("Config file name must be specified") config_file = config_file.decode('utf8') - config_base = os.path.dirname(config_file) config_values = arg_options.config_value if not config_values: config_values = [] @@ -84,7 +83,7 @@ def init_defaults(config_tuple, path, defaults): try: config_json_file = open(config_file, "r") config_json_string = config_json_file.read() - config_partial = json_to_object(config_json_string, output_base, config_base) + config_partial = json_to_object(config_json_string, output_base) config_json_file.close() defaults = { ".use_snake_file_names": False,