LLVM.lua does not get VS version from build.sh ("Error finding an LLVM build")
cmcneish opened this issue · 1 comments
cmcneish commented
Brief Description
build/llvm/LLVM.lua detects the VS version from either cl.exe or msbuild.exe, but build/build.sh specifies (currently) vs=vs2022
.
If build.sh is run from a VS developer command prompt corresponding to a different version then generate()
will fail the following way:
[~]\CppSharp\build>sh build.sh generate -configuration Release -platform x64
Downloading and unpacking Premake...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 4064k 100 4064k 0 0 4064k 0 0:00:01 --:--:-- 0:00:01 12.6M
Archive: premake-5.0.0-beta2-windows.zip
inflating: [~]/CppSharp/build/premake/premake5.exe
Downloading: https://github.com/mono/CppSharp/releases/download/CppSharp/llvm-6eb36a-windows-vs2019-x64-RelWithDebInfo.7z
"C:\Program Files\7-Zip\7z.exe" x llvm-6eb36a-windows-vs2019-x64-RelWithDebInfo.7z -ollvm-6eb36a-windows-vs2019-x64-RelWithDebInfo -y
7-Zip 23.01 (x64) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20
Scanning the drive for archives:
1 file, 173727674 bytes (166 MiB)
Extracting archive: llvm-6eb36a-windows-vs2019-x64-RelWithDebInfo.7z
--
Path = llvm-6eb36a-windows-vs2019-x64-RelWithDebInfo.7z
Type = 7z
Physical Size = 173727674
Headers Size = 50259
Method = LZMA2:26
Solid = +
Blocks = 1
Everything is Ok
Folders: 410
Files: 3815
Size: 2164174658
Compressed: 173727674
Error: [~]/CppSharp/build/LLVM.lua:23: Error finding an LLVM build
[~]\CppSharp\build>
OS: Windows / OS X / Linux (include version and/or distro)
Used headers
N/A
Used settings
Target: MSVC/GCC/Clang
Other settings:
- mingw sh, unzip; activated in "Visual Studio 2019 Developer Command Prompt v16.11.34"
Stack trace or incompilable generated code
N/A
Sample fix (I didn't check if other uses of premake.sh need --vs as well):
[~]\CppSharp\build>git diff -w
diff --git a/build/LLVM.lua b/build/LLVM.lua
index 9ac89c54..85e1b12b 100644
--- a/build/LLVM.lua
+++ b/build/LLVM.lua
@@ -20,7 +20,7 @@ function SearchLLVM()
elseif os.isdir(LLVMRootDir) then
print("Using LLVM build: " .. LLVMRootDir)
else
- error("Error finding an LLVM build")
+ error("Error finding an LLVM build. Tried: " .. LLVMRootDirDebug .. " and " .. LLVMRootDirRelease)
end
end
diff --git a/build/build.sh b/build/build.sh
index 5cd81557..b9916bce 100755
--- a/build/build.sh
+++ b/build/build.sh
@@ -129,7 +129,7 @@ download_premake()
download_llvm()
{
- "$builddir/premake.sh" --file="$builddir/llvm/LLVM.lua" download_llvm --os=$os --arch=$platform --configuration=$configuration
+ "$builddir/premake.sh" --file="$builddir/llvm/LLVM.lua" download_llvm --vs=$vs --os=$os --arch=$platform --configuration=$configuration
}
clone_llvm()
diff --git a/build/llvm/LLVM.lua b/build/llvm/LLVM.lua
index 0a08c061..61c47de8 100644
--- a/build/llvm/LLVM.lua
+++ b/build/llvm/LLVM.lua
@@ -52,6 +52,10 @@ function clone_llvm()
end
function get_vs_version()
+ if _OPTIONS["vs"] then
+ return _OPTIONS["vs"]
+ end
+
local function map_msvc_to_vs_version(major, minor)
if major == "19" and minor >= "30" then return "vs2022"
elseif major == "19" and minor >= "20" then return "vs2019"
tritao commented
Can you send a PR?