Skip to content

Commit f25760c

Browse files
segevfinermarco-ippolito
authored andcommitted
build: add the option to generate compile_commands.json in vcbuild.bat
Refs: nodejs/gyp-next#238 PR-URL: #52279 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Stefan Stojanovic <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ae4b2ae commit f25760c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

configure.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -2249,8 +2249,9 @@ def make_bin_override():
22492249

22502250
if options.compile_commands_json:
22512251
gyp_args += ['-f', 'compile_commands_json']
2252-
os.path.islink('./compile_commands.json') and os.unlink('./compile_commands.json')
2253-
os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
2252+
if sys.platform != 'win32':
2253+
os.path.lexists('./compile_commands.json') and os.unlink('./compile_commands.json')
2254+
os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
22542255

22552256
# pass the leftover non-whitespace positional arguments to GYP
22562257
gyp_args += [arg for arg in args if not str.isspace(arg)]
@@ -2260,4 +2261,7 @@ def make_bin_override():
22602261

22612262
print_verbose("running: \n " + " ".join(['python', 'tools/gyp_node.py'] + gyp_args))
22622263
run_gyp(gyp_args)
2264+
if options.compile_commands_json and sys.platform == 'win32':
2265+
os.path.isfile('./compile_commands.json') and os.unlink('./compile_commands.json')
2266+
shutil.copy2('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
22632267
info('configure completed successfully')

vcbuild.bat

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ set openssl_no_asm=
6666
set no_shared_roheap=
6767
set doc=
6868
set extra_msbuild_args=
69+
set compile_commands=
6970
set exit_code=0
7071

7172
:next-arg
@@ -140,6 +141,7 @@ if /i "%1"=="openssl-no-asm" set openssl_no_asm=1&goto arg-ok
140141
if /i "%1"=="no-shared-roheap" set no_shared_roheap=1&goto arg-ok
141142
if /i "%1"=="doc" set doc=1&goto arg-ok
142143
if /i "%1"=="binlog" set extra_msbuild_args=/binaryLogger:out\%config%\node.binlog&goto arg-ok
144+
if /i "%1"=="compile-commands" set compile_commands=1&goto arg-ok
143145

144146
echo Error: invalid command line option `%1`.
145147
exit /b 1
@@ -196,6 +198,7 @@ if defined debug_nghttp2 set configure_flags=%configure_flags% --debug-nghttp
196198
if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm
197199
if defined no_shared_roheap set configure_flags=%configure_flags% --disable-shared-readonly-heap
198200
if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose
201+
if defined compile_commands set configure_flags=%configure_flags% -C
199202
if "%target_arch%"=="x86" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set configure_flags=%configure_flags% --no-cross-compiling
200203

201204
if not exist "%~dp0deps\icu" goto no-depsicu

0 commit comments

Comments
 (0)