Skip to content

Commit

Permalink
Better handle default toolset
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed May 9, 2023
1 parent 0c85fc7 commit 9399230
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
4 changes: 3 additions & 1 deletion _preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
valid_languages = {"C", "C++"},
valid_tools = {cc = { "gcc", "clang", "msc" }},

toolset = "gcc",
toolset = iif(os.target() == "windows", "msc-v142", -- Visual Studio 2019
iif(os.target() == "macosx", "clang",
"gcc")),

-- Workspace and project generation logic
onWorkspace = function(wks)
Expand Down
21 changes: 2 additions & 19 deletions ninja.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,6 @@ local function shouldcompileascpp(filecfg)
return path.iscppfile(filecfg.abspath)
end

local function getDefaultToolsetFromOs()
local system_name = os.target()

if system_name == "windows" then
return "msc"
elseif system_name == "macosx" then
return "clang"
elseif system_name == "linux" then
return "gcc"
else
p.warnOnce("unknown_system", "no toolchain set and unknown system " .. system_name .. " so assuming toolchain is gcc")
return "gcc"
end
end

local function getFileDependencies(cfg)
local dependencies = {}
if #cfg.prebuildcommands > 0 or cfg.prebuildmessage then
Expand Down Expand Up @@ -603,12 +588,10 @@ function ninja.generateProjectCfg(cfg)

local prj = cfg.project
local key = prj.name .. "_" .. cfg.buildcfg
-- TODO why premake doesn't provide default name always ?
local toolset_name = _OPTIONS.cc or cfg.toolset or ninja.getDefaultToolsetFromOs()
local toolset, toolset_version = p.tools.canonical(toolset_name)
local toolset, toolset_version = p.tools.canonical(cfg.toolset)

if not toolset then
p.error("Unknown toolset " .. toolset_name)
p.error("Unknown toolset " .. cfg.toolset)
end

-- Some toolset fixes
Expand Down

0 comments on commit 9399230

Please sign in to comment.