Skip to content

Commit a929c71

Browse files
segevfinertargos
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 <yagiz@nizipli.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 295f684 commit a929c71

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
@@ -2307,8 +2307,9 @@ def make_bin_override():
23072307

23082308
if options.compile_commands_json:
23092309
gyp_args += ['-f', 'compile_commands_json']
2310-
os.path.islink('./compile_commands.json') and os.unlink('./compile_commands.json')
2311-
os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
2310+
if sys.platform != 'win32':
2311+
os.path.lexists('./compile_commands.json') and os.unlink('./compile_commands.json')
2312+
os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
23122313

23132314
# pass the leftover non-whitespace positional arguments to GYP
23142315
gyp_args += [arg for arg in args if not str.isspace(arg)]
@@ -2318,4 +2319,7 @@ def make_bin_override():
23182319

23192320
print_verbose("running: \n " + " ".join(['python', 'tools/gyp_node.py'] + gyp_args))
23202321
run_gyp(gyp_args)
2322+
if options.compile_commands_json and sys.platform == 'win32':
2323+
os.path.isfile('./compile_commands.json') and os.unlink('./compile_commands.json')
2324+
shutil.copy2('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
23212325
info('configure completed successfully')

vcbuild.bat

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ set openssl_no_asm=
7070
set no_shared_roheap=
7171
set doc=
7272
set extra_msbuild_args=
73+
set compile_commands=
7374
set exit_code=0
7475

7576
:next-arg
@@ -147,6 +148,7 @@ if /i "%1"=="openssl-no-asm" set openssl_no_asm=1&goto arg-ok
147148
if /i "%1"=="no-shared-roheap" set no_shared_roheap=1&goto arg-ok
148149
if /i "%1"=="doc" set doc=1&goto arg-ok
149150
if /i "%1"=="binlog" set extra_msbuild_args=/binaryLogger:out\%config%\node.binlog&goto arg-ok
151+
if /i "%1"=="compile-commands" set compile_commands=1&goto arg-ok
150152

151153
echo Error: invalid command line option `%1`.
152154
exit /b 1
@@ -205,6 +207,7 @@ if defined debug_nghttp2 set configure_flags=%configure_flags% --debug-nghttp
205207
if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm
206208
if defined no_shared_roheap set configure_flags=%configure_flags% --disable-shared-readonly-heap
207209
if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose
210+
if defined compile_commands set configure_flags=%configure_flags% -C
208211
if "%target_arch%"=="x86" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set configure_flags=%configure_flags% --no-cross-compiling
209212

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

0 commit comments

Comments
 (0)