Skip to content

Commit

Permalink
Merge pull request #2172 from nickclark2016/issues/1864
Browse files Browse the repository at this point in the history
Custom LLVM Versions for VS2019+
  • Loading branch information
samsinsane committed Apr 7, 2024
2 parents 86dff6f + 4a9651d commit db072b4
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 0 deletions.
16 changes: 16 additions & 0 deletions modules/vstudio/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,22 @@
kind = "string",
}

-- Directory of LLVM install
p.api.register {
name = "llvmdir",
scope = "config",
kind = "directory",
tokens = "true",
}

-- Version of LLVM Install
p.api.register {
name = "llvmversion",
scope = "config",
kind = "string",
tokens = "true",
}

--
-- Decide when the full module should be loaded.
--
Expand Down
39 changes: 39 additions & 0 deletions modules/vstudio/tests/vc2019/test_toolset_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,45 @@
end


---
-- Check the project settings with the llvm version
---

function suite.toolsetClang_llvmVersion()
toolset "clang"
llvmversion "16"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>ClangCL</PlatformToolset>
<LLVMToolsVersion>16</LLVMToolsVersion>
</PropertyGroup>
]]
end

---
-- Check the project settings with the llvm version
---

function suite.toolsetClang_llvmDir()
toolset "clang"
llvmdir "llvm/dir"
prepare()
test.capture [[
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>ClangCL</PlatformToolset>
<LLVMInstallDir>llvm\dir</LLVMInstallDir>
</PropertyGroup>
]]
end


--
-- If AllModulesPublic flag is set, add <AllProjectBMIsArePublic> element (supported from VS2019)
--
Expand Down
15 changes: 15 additions & 0 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
return {
m.configurationType,
m.platformToolset,
m.llvmTools,
m.toolsVersion,
}
else
Expand All @@ -238,6 +239,7 @@
m.enableUnityBuild,
m.sanitizers,
m.toolsVersion,
m.llvmTools,
m.wholeProgramOptimization,
m.nmakeOutDirs,
m.windowsSDKDesktopARMSupport,
Expand Down Expand Up @@ -2784,6 +2786,19 @@
end
end

function m.llvmTools(cfg)
local llvmdir = cfg.llvmdir
local llvmversion = cfg.llvmversion

if llvmdir and _ACTION >= "vs2019" then
m.element("LLVMInstallDir", nil, vstudio.path(cfg, llvmdir))
end

if llvmversion and _ACTION >= "vs2019" then
m.element("LLVMToolsVersion", nil, llvmversion)
end
end

function m.enableUnityBuild(cfg)
if _ACTION >= "vs2017" and cfg.enableunitybuild then
m.element("EnableUnitySupport", nil, iif(cfg.enableunitybuild == "On", "true", "false"))
Expand Down
23 changes: 23 additions & 0 deletions website/docs/llvmdir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Specifies a custom LLVM install location for Visual Studio.

```lua
llvmdir "path"
```

### Parameters ###

`path` specifies a directory containing the LLVM installation.

### Applies To ###

Project configurations.

### Availability ###

Premake 5.0.0 beta 3 or later for Visual Studio 2019 and later.

## Examples ##

```lua
llvmdir "/path/to/install"
```
23 changes: 23 additions & 0 deletions website/docs/llvmversion.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Specifies a version for a custom installation of LLVM for Visual Studio.

```lua
llvmversion "version"
```

### Parameters ###

`version` specifies the version of the LLVM installation.

### Applies To ###

Project configurations.

### Availability ###

Premake 5.0.0 beta 3 or later for Visual Studio 2019 and later.

## Examples ##

```lua
llvmversion "16"
```
2 changes: 2 additions & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ module.exports = {
'links',
'locale',
'location',
'llvmdir',
'llvmversion',
'makesettings',
'namespace',
'nativewchar',
Expand Down

0 comments on commit db072b4

Please sign in to comment.