From bb88caec0680d098f4de936e1b2d09756344fca1 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 18 Apr 2017 02:20:56 -0400 Subject: [PATCH] build: fix ninja build failure When working on commit 6a09a69ec9d36b705e9bde2ac1a193566a702d96 ("build: enable cctest to use generated objects") I did not take into account building with ninja: $ ./configure $ tools/gyp_node.py -f ninja $ ninja -C out/Release $ ln -fs out/Release/node node When ninja generated the ninja build files, src files that are relative to the src directory will be named with a dot instead of a path separator, for example: out/Release/obj/src/node/node.o would instead become: out/Release/obj/src/node.node.o This commit adds an additional variable for the type of object separator used for this case. Currently the check for if ninja is being used is a normal if statement as are the following os checks (win and aix). But the win and aix ones should only be evaluated if the build is not generated by ninja. This commit turns this logic into an if ninja else statement. PR-URL: https://github.com/nodejs/node/pull/12484 Fixes: https://github.com/nodejs/node/issues/12448 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Refael Ackermann Reviewed-By: Gibson Fahnestock --- common.gypi | 19 ++++++-------- node.gyp | 72 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/common.gypi b/common.gypi index a97e12ae38c7f1..ea08e80365b5c6 100644 --- a/common.gypi +++ b/common.gypi @@ -35,6 +35,13 @@ 'icu_use_data_file_flag%': 0, 'conditions': [ + ['GENERATOR=="ninja"', { + 'OBJ_DIR': '<(PRODUCT_DIR)/obj', + 'V8_BASE': '<(PRODUCT_DIR)/obj/deps/v8/src/libv8_base.a', + }, { + 'OBJ_DIR%': '<(PRODUCT_DIR)/obj.target', + 'V8_BASE%': '<(PRODUCT_DIR)/obj.target/deps/v8/src/libv8_base.a', + }], ['OS == "win"', { 'os_posix': 0, 'v8_postmortem_support%': 'false', @@ -45,18 +52,8 @@ 'v8_postmortem_support%': 'true', }], ['OS== "mac"', { - 'OBJ_DIR': '<(PRODUCT_DIR)/obj.target', + 'OBJ_DIR%': '<(PRODUCT_DIR)/obj.target', 'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a', - }, { - 'conditions': [ - ['GENERATOR=="ninja"', { - 'OBJ_DIR': '<(PRODUCT_DIR)/obj', - 'V8_BASE': '<(PRODUCT_DIR)/obj/deps/v8/src/libv8_base.a', - }, { - 'OBJ_DIR%': '<(PRODUCT_DIR)/obj.target', - 'V8_BASE%': '<(PRODUCT_DIR)/obj.target/deps/v8/src/libv8_base.a', - }], - ], }], ['openssl_fips != ""', { 'OPENSSL_PRODUCT': 'libcrypto.a', diff --git a/node.gyp b/node.gyp index d7a282134ee286..f50aea3475598d 100644 --- a/node.gyp +++ b/node.gyp @@ -574,19 +574,31 @@ 'OBJ_GEN_PATH': '<(OBJ_DIR)/node/gen', 'OBJ_TRACING_PATH': '<(OBJ_DIR)/node/src/tracing', 'OBJ_SUFFIX': 'o', + 'OBJ_SEPARATOR': '/', 'conditions': [ ['OS=="win"', { - 'OBJ_PATH': '<(OBJ_DIR)/node', - 'OBJ_GEN_PATH': '<(OBJ_DIR)/node', - 'OBJ_TRACING_PATH': '<(OBJ_DIR)/node', 'OBJ_SUFFIX': 'obj', }], - ['OS=="aix"', { - 'OBJ_PATH': '<(OBJ_DIR)/node_base/src', - 'OBJ_GEN_PATH': '<(OBJ_DIR)/node_base/gen', - 'OBJ_TRACING_PATH': '<(OBJ_DIR)/node_base/src/tracing', - }], - ], + ['GENERATOR=="ninja"', { + 'OBJ_PATH': '<(OBJ_DIR)/src', + 'OBJ_GEN_PATH': '<(OBJ_DIR)/gen', + 'OBJ_TRACING_PATH': '<(OBJ_DIR)/src/tracing', + 'OBJ_SEPARATOR': '/node.', + }, { + 'conditions': [ + ['OS=="win"', { + 'OBJ_PATH': '<(OBJ_DIR)/node', + 'OBJ_GEN_PATH': '<(OBJ_DIR)/node', + 'OBJ_TRACING_PATH': '<(OBJ_DIR)/node', + }], + ['OS=="aix"', { + 'OBJ_PATH': '<(OBJ_DIR)/node_base/src', + 'OBJ_GEN_PATH': '<(OBJ_DIR)/node_base/gen', + 'OBJ_TRACING_PATH': '<(OBJ_DIR)/node_base/src/tracing', + }], + ]} + ] + ], }, 'includes': [ @@ -603,24 +615,24 @@ ], 'libraries': [ - '<(OBJ_GEN_PATH)/node_javascript.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node_debug_options.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/async-wrap.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/env.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node_buffer.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node_i18n.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node_url.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/util.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/string_bytes.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/string_search.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/stream_base.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node_constants.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node_revert.<(OBJ_SUFFIX)', - '<(OBJ_TRACING_PATH)/agent.<(OBJ_SUFFIX)', - '<(OBJ_TRACING_PATH)/node_trace_buffer.<(OBJ_SUFFIX)', - '<(OBJ_TRACING_PATH)/node_trace_writer.<(OBJ_SUFFIX)', - '<(OBJ_TRACING_PATH)/trace_event.<(OBJ_SUFFIX)', + '<(OBJ_GEN_PATH)<(OBJ_SEPARATOR)node_javascript.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_debug_options.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)async-wrap.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)env.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_buffer.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_i18n.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_url.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)util.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)string_bytes.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)string_search.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)stream_base.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_constants.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_revert.<(OBJ_SUFFIX)', + '<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)agent.<(OBJ_SUFFIX)', + '<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)node_trace_buffer.<(OBJ_SUFFIX)', + '<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)node_trace_writer.<(OBJ_SUFFIX)', + '<(OBJ_TRACING_PATH)<(OBJ_SEPARATOR)trace_event.<(OBJ_SUFFIX)', ], 'defines': [ @@ -683,9 +695,9 @@ 'copies': [{ 'destination': '<(OBJ_DIR)/cctest/src', 'files': [ - '<(OBJ_PATH)/node_dtrace_ustack.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node_dtrace_provider.<(OBJ_SUFFIX)', - '<(OBJ_PATH)/node_dtrace.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_dtrace_ustack.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_dtrace_provider.<(OBJ_SUFFIX)', + '<(OBJ_PATH)<(OBJ_SEPARATOR)node_dtrace.<(OBJ_SUFFIX)', ]}, ], }],