mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
build: find version of Clang installed on Windows
PR-URL: https://github.com/nodejs/node/pull/53228 Refs: https://github.com/nodejs/node/issues/52809 Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
committed by
GitHub
parent
521c9c6df7
commit
0758c9b6d0
10
BUILDING.md
10
BUILDING.md
@@ -636,7 +636,7 @@ Optional requirements to build the MSI installer package:
|
|||||||
* The .NET SDK component from [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/)
|
* The .NET SDK component from [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/)
|
||||||
* This component can be installed via the Visual Studio Installer Application
|
* This component can be installed via the Visual Studio Installer Application
|
||||||
|
|
||||||
Optional requirements for compiling for Windows 10 on ARM (ARM64):
|
Optional requirements for compiling for Windows on ARM (ARM64):
|
||||||
|
|
||||||
* Visual Studio 17.6.0 or newer
|
* Visual Studio 17.6.0 or newer
|
||||||
* Visual Studio optional components
|
* Visual Studio optional components
|
||||||
@@ -644,6 +644,14 @@ Optional requirements for compiling for Windows 10 on ARM (ARM64):
|
|||||||
* Visual C++ ATL for ARM64
|
* Visual C++ ATL for ARM64
|
||||||
* Windows 10 SDK 10.0.17763.0 or newer
|
* Windows 10 SDK 10.0.17763.0 or newer
|
||||||
|
|
||||||
|
Optional requirements for compiling with ClangCL:
|
||||||
|
|
||||||
|
* Visual Studio optional components
|
||||||
|
* C++ Clang Compiler for Windows
|
||||||
|
* MSBuild support for LLVM toolset
|
||||||
|
|
||||||
|
NOTE: Currently we only support compiling with Clang that comes from Visual Studio.
|
||||||
|
|
||||||
##### Option 2: Automated install with Boxstarter
|
##### Option 2: Automated install with Boxstarter
|
||||||
|
|
||||||
A [Boxstarter](https://boxstarter.org/) script can be used for easy setup of
|
A [Boxstarter](https://boxstarter.org/) script can be used for easy setup of
|
||||||
|
|||||||
@@ -13,11 +13,16 @@ if not exist "%InstallerPath%" goto :no-vswhere
|
|||||||
set "Path=%Path%;%InstallerPath%"
|
set "Path=%Path%;%InstallerPath%"
|
||||||
where vswhere 2> nul > nul
|
where vswhere 2> nul > nul
|
||||||
if errorlevel 1 goto :no-vswhere
|
if errorlevel 1 goto :no-vswhere
|
||||||
|
:: VC.Tools are needed even when using clang because of the vcvarsall.bat usage
|
||||||
if "%2"=="arm64" (
|
if "%2"=="arm64" (
|
||||||
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.ARM64
|
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.ARM64
|
||||||
) else (
|
) else (
|
||||||
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
|
set VSWHERE_REQ=-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
|
||||||
)
|
)
|
||||||
|
if "%4"=="1" (
|
||||||
|
set VSWHERE_REQ=%VSWHERE_REQ% -requires Microsoft.VisualStudio.Component.VC.Llvm.Clang
|
||||||
|
set VSWHERE_REQ=%VSWHERE_REQ% -requires Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset
|
||||||
|
)
|
||||||
set VSWHERE_PRP=-property installationPath
|
set VSWHERE_PRP=-property installationPath
|
||||||
set VSWHERE_LMT=-version %1
|
set VSWHERE_LMT=-version %1
|
||||||
vswhere -prerelease > nul
|
vswhere -prerelease > nul
|
||||||
|
|||||||
27
vcbuild.bat
27
vcbuild.bat
@@ -187,8 +187,6 @@ if defined nosnapshot set configure_flags=%configure_flags% --without-snap
|
|||||||
if defined nonpm set configure_flags=%configure_flags% --without-npm
|
if defined nonpm set configure_flags=%configure_flags% --without-npm
|
||||||
if defined nocorepack set configure_flags=%configure_flags% --without-corepack
|
if defined nocorepack set configure_flags=%configure_flags% --without-corepack
|
||||||
if defined ltcg set configure_flags=%configure_flags% --with-ltcg
|
if defined ltcg set configure_flags=%configure_flags% --with-ltcg
|
||||||
:: If clang-cl build is requested, set it to 17.0, which is the version shipped with VS 2022.
|
|
||||||
if defined clang_cl set configure_flags=%configure_flags% --clang-cl=17.0
|
|
||||||
if defined release_urlbase set configure_flags=%configure_flags% --release-urlbase=%release_urlbase%
|
if defined release_urlbase set configure_flags=%configure_flags% --release-urlbase=%release_urlbase%
|
||||||
if defined download_arg set configure_flags=%configure_flags% %download_arg%
|
if defined download_arg set configure_flags=%configure_flags% %download_arg%
|
||||||
if defined enable_vtune_arg set configure_flags=%configure_flags% --enable-vtune-profiling
|
if defined enable_vtune_arg set configure_flags=%configure_flags% --enable-vtune-profiling
|
||||||
@@ -256,7 +254,7 @@ echo Looking for Visual Studio 2022
|
|||||||
@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
|
@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
|
||||||
@rem detect the version searched for
|
@rem detect the version searched for
|
||||||
if not defined target_env set "VCINSTALLDIR="
|
if not defined target_env set "VCINSTALLDIR="
|
||||||
call tools\msvs\vswhere_usability_wrapper.cmd "[17.6,18.0)" %target_arch% "prerelease"
|
call tools\msvs\vswhere_usability_wrapper.cmd "[17.6,18.0)" %target_arch% "prerelease" %clang_cl%
|
||||||
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
|
if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
|
||||||
@rem check if VS2022 is already setup, and for the requested arch
|
@rem check if VS2022 is already setup, and for the requested arch
|
||||||
if "_%VisualStudioVersion%_" == "_17.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2022
|
if "_%VisualStudioVersion%_" == "_17.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2022
|
||||||
@@ -276,13 +274,34 @@ set PLATFORM_TOOLSET=v143
|
|||||||
goto msbuild-found
|
goto msbuild-found
|
||||||
|
|
||||||
:msbuild-not-found
|
:msbuild-not-found
|
||||||
echo Failed to find a suitable Visual Studio installation.
|
set "clang_echo="
|
||||||
|
if defined clang_cl set "clang_echo= or Clang compiler/LLVM toolset"
|
||||||
|
echo Failed to find a suitable Visual Studio installation%clang_echo%.
|
||||||
echo Try to run in a "Developer Command Prompt" or consult
|
echo Try to run in a "Developer Command Prompt" or consult
|
||||||
echo https://github.com/nodejs/node/blob/HEAD/BUILDING.md#windows
|
echo https://github.com/nodejs/node/blob/HEAD/BUILDING.md#windows
|
||||||
goto exit
|
goto exit
|
||||||
|
|
||||||
:msbuild-found
|
:msbuild-found
|
||||||
|
|
||||||
|
@rem check if the clang-cl build is requested
|
||||||
|
if not defined clang_cl goto clang-skip
|
||||||
|
@rem x64 is hard coded as it is used for both cross and native compilation.
|
||||||
|
set "clang_path=%VCINSTALLDIR%\Tools\Llvm\x64\bin\clang.exe"
|
||||||
|
for /F "tokens=3" %%i in ('"%clang_path%" --version') do (
|
||||||
|
set clang_version=%%i
|
||||||
|
goto clang-found
|
||||||
|
)
|
||||||
|
|
||||||
|
:clang-not-found
|
||||||
|
echo Failed to find Clang compiler in %clang_path%.
|
||||||
|
goto exit
|
||||||
|
|
||||||
|
:clang-found
|
||||||
|
echo Found Clang version %clang_version%
|
||||||
|
set configure_flags=%configure_flags% --clang-cl=%clang_version%
|
||||||
|
|
||||||
|
:clang-skip
|
||||||
|
|
||||||
set project_generated=
|
set project_generated=
|
||||||
:project-gen
|
:project-gen
|
||||||
@rem Skip project generation if requested.
|
@rem Skip project generation if requested.
|
||||||
|
|||||||
Reference in New Issue
Block a user