From beb1892036f2bc6165cac4ed6ee3d0f61d27cf4c Mon Sep 17 00:00:00 2001 From: Segev Finer Date: Sat, 30 Mar 2024 22:17:13 +0300 Subject: [PATCH] build: add the option to generate compile_commands.json in vcbuild.bat Refs: https://github.com/nodejs/gyp-next/pull/238 PR-URL: https://github.com/nodejs/node/pull/52279 Reviewed-By: Yagiz Nizipli Reviewed-By: Stefan Stojanovic Reviewed-By: James M Snell --- configure.py | 8 ++++++-- vcbuild.bat | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index 073cc0c390f..12faf7abaa8 100755 --- a/configure.py +++ b/configure.py @@ -2310,8 +2310,9 @@ else: if options.compile_commands_json: gyp_args += ['-f', 'compile_commands_json'] - os.path.islink('./compile_commands.json') and os.unlink('./compile_commands.json') - os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json') + if sys.platform != 'win32': + os.path.lexists('./compile_commands.json') and os.unlink('./compile_commands.json') + os.symlink('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json') # pass the leftover non-whitespace positional arguments to GYP gyp_args += [arg for arg in args if not str.isspace(arg)] @@ -2321,4 +2322,7 @@ if warn.warned and not options.verbose: print_verbose("running: \n " + " ".join(['python', 'tools/gyp_node.py'] + gyp_args)) run_gyp(gyp_args) +if options.compile_commands_json and sys.platform == 'win32': + os.path.isfile('./compile_commands.json') and os.unlink('./compile_commands.json') + shutil.copy2('./out/' + config['BUILDTYPE'] + '/compile_commands.json', './compile_commands.json') info('configure completed successfully') diff --git a/vcbuild.bat b/vcbuild.bat index 1f73851d6ea..6bd6b6a2e98 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -70,6 +70,7 @@ set openssl_no_asm= set no_shared_roheap= set doc= set extra_msbuild_args= +set compile_commands= set exit_code=0 :next-arg @@ -147,6 +148,7 @@ if /i "%1"=="openssl-no-asm" set openssl_no_asm=1&goto arg-ok if /i "%1"=="no-shared-roheap" set no_shared_roheap=1&goto arg-ok if /i "%1"=="doc" set doc=1&goto arg-ok if /i "%1"=="binlog" set extra_msbuild_args=/binaryLogger:out\%config%\node.binlog&goto arg-ok +if /i "%1"=="compile-commands" set compile_commands=1&goto arg-ok echo Error: invalid command line option `%1`. exit /b 1 @@ -205,6 +207,7 @@ if defined debug_nghttp2 set configure_flags=%configure_flags% --debug-nghttp if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm if defined no_shared_roheap set configure_flags=%configure_flags% --disable-shared-readonly-heap if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose +if defined compile_commands set configure_flags=%configure_flags% -C if "%target_arch%"=="x86" ( echo "32-bit Windows builds are not supported anymore."