From 2334d5cda8f07cb0800351cd7d12c599888d5730 Mon Sep 17 00:00:00 2001 From: Vladimir Morozov Date: Fri, 26 Apr 2024 04:36:13 -0700 Subject: [PATCH] build,tools,node-api: fix building node-api tests for Windows Debug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/52632 Reviewed-By: Luigi Pinca Reviewed-By: Cheng Zhao Reviewed-By: Michaël Zasso Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Gerhard Stöbich Reviewed-By: Chengzhong Wu Reviewed-By: Michael Dawson --- tools/build_addons.py | 14 ++++++++------ vcbuild.bat | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/build_addons.py b/tools/build_addons.py index 8e445be5116c62..db948ba7b908e8 100755 --- a/tools/build_addons.py +++ b/tools/build_addons.py @@ -38,7 +38,7 @@ def rebuild_addons(args): # Copy node.lib. if args.is_win: - node_lib_dir = os.path.join(headers_dir, 'Release') + node_lib_dir = os.path.join(headers_dir, args.config) os.makedirs(node_lib_dir) shutil.copy2(os.path.join(args.out_dir, 'node.lib'), os.path.join(node_lib_dir, 'node.lib')) @@ -89,17 +89,17 @@ def node_gyp_rebuild(test_dir): executor.map(node_gyp_rebuild, test_dirs) def get_default_out_dir(args): - default_out_dir = os.path.join('out', 'Release') + default_out_dir = os.path.join('out', args.config) if not args.is_win: # POSIX platforms only have one out dir. return default_out_dir # On Windows depending on the args of GYP and configure script, the out dir - # could be 'out/Release' or just 'Release'. + # could be 'out/Release', 'out/Debug' or just 'Release' or 'Debug'. if os.path.exists(default_out_dir): return default_out_dir - if os.path.exists('Release'): - return 'Release' - raise RuntimeError('Can not find out dir, did you run configure?') + if os.path.exists(args.config): + return args.config + raise RuntimeError('Cannot find out dir, did you run build?') def main(): if sys.platform == 'cygwin': @@ -124,6 +124,8 @@ def main(): default='deps/npm/node_modules/node-gyp/bin/node-gyp.js') parser.add_argument('--is-win', help='build for Windows target', action='store_true', default=(sys.platform == 'win32')) + parser.add_argument('--config', help='build config (Release or Debug)', + default='Release') args, unknown_args = parser.parse_known_args() if not args.out_dir: diff --git a/vcbuild.bat b/vcbuild.bat index 7b117aa2f9ba40..6ec27b88b21578 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -583,7 +583,7 @@ for /d %%F in (test\addons\??_*) do ( if %errorlevel% neq 0 exit /b %errorlevel% :: building addons setlocal -python "%~dp0tools\build_addons.py" "%~dp0test\addons" +python "%~dp0tools\build_addons.py" "%~dp0test\addons" --config %config% if errorlevel 1 exit /b 1 endlocal @@ -600,7 +600,7 @@ for /d %%F in (test\js-native-api\??_*) do ( ) :: building js-native-api setlocal -python "%~dp0tools\build_addons.py" "%~dp0test\js-native-api" +python "%~dp0tools\build_addons.py" "%~dp0test\js-native-api" --config %config% if errorlevel 1 exit /b 1 endlocal goto build-node-api-tests @@ -618,7 +618,7 @@ for /d %%F in (test\node-api\??_*) do ( ) :: building node-api setlocal -python "%~dp0tools\build_addons.py" "%~dp0test\node-api" +python "%~dp0tools\build_addons.py" "%~dp0test\node-api" --config %config% if errorlevel 1 exit /b 1 endlocal goto run-tests