From 4a9651de2e9ac1d29ed89dd3af555506358d07f5 Mon Sep 17 00:00:00 2001 From: Nicholaus Clark Date: Fri, 15 Dec 2023 08:22:40 -0500 Subject: [PATCH] Custom LLVM Versions for VS2019+ --- modules/vstudio/_preload.lua | 16 ++++++++ .../tests/vc2019/test_toolset_settings.lua | 39 +++++++++++++++++++ modules/vstudio/vs2010_vcxproj.lua | 15 +++++++ website/docs/llvmdir.md | 23 +++++++++++ website/docs/llvmversion.md | 23 +++++++++++ website/sidebars.js | 2 + 6 files changed, 118 insertions(+) create mode 100644 website/docs/llvmdir.md create mode 100644 website/docs/llvmversion.md diff --git a/modules/vstudio/_preload.lua b/modules/vstudio/_preload.lua index cfd73e75af..292515f3c5 100644 --- a/modules/vstudio/_preload.lua +++ b/modules/vstudio/_preload.lua @@ -265,6 +265,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. -- diff --git a/modules/vstudio/tests/vc2019/test_toolset_settings.lua b/modules/vstudio/tests/vc2019/test_toolset_settings.lua index df5c60731c..8dee1364d4 100644 --- a/modules/vstudio/tests/vc2019/test_toolset_settings.lua +++ b/modules/vstudio/tests/vc2019/test_toolset_settings.lua @@ -59,6 +59,45 @@ end +--- +-- Check the project settings with the llvm version +--- + + function suite.toolsetClang_llvmVersion() + toolset "clang" + llvmversion "16" + prepare() + test.capture [[ + + Application + false + Unicode + ClangCL + 16 + + ]] + end + +--- +-- Check the project settings with the llvm version +--- + + function suite.toolsetClang_llvmDir() + toolset "clang" + llvmdir "llvm/dir" + prepare() + test.capture [[ + + Application + false + Unicode + ClangCL + llvm\dir + + ]] + end + + -- -- If AllModulesPublic flag is set, add element (supported from VS2019) -- diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index e2f77c0d17..c0c912a646 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -224,6 +224,7 @@ return { m.configurationType, m.platformToolset, + m.llvmTools, m.toolsVersion, } else @@ -238,6 +239,7 @@ m.enableUnityBuild, m.sanitizers, m.toolsVersion, + m.llvmTools, m.wholeProgramOptimization, m.nmakeOutDirs, m.windowsSDKDesktopARMSupport, @@ -2776,6 +2778,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")) diff --git a/website/docs/llvmdir.md b/website/docs/llvmdir.md new file mode 100644 index 0000000000..b961b7ca96 --- /dev/null +++ b/website/docs/llvmdir.md @@ -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" +``` diff --git a/website/docs/llvmversion.md b/website/docs/llvmversion.md new file mode 100644 index 0000000000..c8aea82d83 --- /dev/null +++ b/website/docs/llvmversion.md @@ -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" +``` diff --git a/website/sidebars.js b/website/sidebars.js index 730fd4b06a..18b55f6f67 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -202,6 +202,8 @@ module.exports = { 'links', 'locale', 'location', + 'llvmdir', + 'llvmversion', 'makesettings', 'namespace', 'nativewchar',