Skip to content

Commit

Permalink
build,tools,node-api: fix building node-api tests for Windows Debug
Browse files Browse the repository at this point in the history
PR-URL: #52632
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Cheng Zhao <zcbenz@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
vmoroz authored and marco-ippolito committed May 3, 2024
1 parent 7e6d923 commit 20bb165
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions tools/build_addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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':
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions vcbuild.bat
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,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

Expand All @@ -624,7 +624,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
Expand All @@ -642,7 +642,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
Expand Down

0 comments on commit 20bb165

Please sign in to comment.