Skip to content

Commit d1ecc81

Browse files
committed
build: Add the option to generate compile_commands.json on Windows via vcbuild.bat
This also needs nodejs/gyp-next#238
1 parent 021cf91 commit d1ecc81

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

configure.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,8 +2164,9 @@ def make_bin_override():
21642164

21652165
if options.compile_commands_json:
21662166
gyp_args += ['-f', 'compile_commands_json']
2167-
os.path.islink('./compile_commands.json') and os.unlink('./compile_commands.json')
2168-
os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
2167+
if sys.platform != 'win32':
2168+
os.path.islink('./compile_commands.json') and os.unlink('./compile_commands.json')
2169+
os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
21692170

21702171
# pass the leftover non-whitespace positional arguments to GYP
21712172
gyp_args += [arg for arg in args if not str.isspace(arg)]
@@ -2175,4 +2176,7 @@ def make_bin_override():
21752176

21762177
print_verbose("running: \n " + " ".join(['python', 'tools/gyp_node.py'] + gyp_args))
21772178
run_gyp(gyp_args)
2179+
if sys.platform == 'win32':
2180+
os.path.isfile('./compile_commands.json') and os.unlink('./compile_commands.json')
2181+
shutil.copy2('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json')
21782182
info('configure completed successfully')

vcbuild.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ set openssl_no_asm=
7171
set no_shared_roheap=
7272
set doc=
7373
set extra_msbuild_args=
74+
set compile_commands=
7475
set exit_code=0
7576

7677
:next-arg
@@ -144,6 +145,7 @@ if /i "%1"=="openssl-no-asm" set openssl_no_asm=1&goto arg-ok
144145
if /i "%1"=="no-shared-roheap" set no_shared_roheap=1&goto arg-ok
145146
if /i "%1"=="doc" set doc=1&goto arg-ok
146147
if /i "%1"=="binlog" set extra_msbuild_args=/binaryLogger:%config%\node.binlog&goto arg-ok
148+
if /i "%1"=="compile-commands" set compile_commands=1&goto arg-ok
147149

148150
echo Error: invalid command line option `%1`.
149151
exit /b 1
@@ -199,6 +201,7 @@ if defined debug_nghttp2 set configure_flags=%configure_flags% --debug-nghttp
199201
if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm
200202
if defined no_shared_roheap set configure_flags=%configure_flags% --disable-shared-readonly-heap
201203
if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose
204+
if defined compile_commands set configure_flags=%configure_flags% -C
202205
if "%target_arch%"=="x86" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set configure_flags=%configure_flags% --no-cross-compiling
203206

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

0 commit comments

Comments
 (0)