Skip to content

Commit

Permalink
Merge pull request #4987 from star-hengxing/meson
Browse files Browse the repository at this point in the history
Imrpove meson with clang toolchain
  • Loading branch information
waruqi authored Apr 18, 2024
2 parents 5f33d0c + dcef638 commit 78627bc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions xmake/modules/package/tools/meson.lua
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,21 @@ function _get_configs_file(package, opt)
file:print("c=['%s']", executable_path(cc))
end
local cxx = package:build_getenv("cxx")
if cxx then
-- https://github.com/xmake-io/xmake/discussions/4979
if cxx and package:has_tool("cxx", "clang", "gcc") then
local dir = path.directory(cxx)
local name = path.filename(cxx)
name = name:gsub("clang$", "clang++")
name = name:gsub("clang%-", "clang++-") -- clang-xx
name = name:gsub("clang%.", "clang++.") -- clang.exe
name = name:gsub("gcc$", "g++")
name = name:gsub("gcc%-", "g++-")
name = name:gsub("gcc%.", "g++.")
if dir and dir ~= "." then
cxx = path.join(dir, name)
else
cxx = name
end
file:print("cpp=['%s']", executable_path(cxx))
end
local ld = package:build_getenv("ld")
Expand Down Expand Up @@ -295,7 +309,7 @@ function _get_configs(package, configs, opt)

-- add prefix
configs = configs or {}
table.insert(configs, "--prefix=" .. package:installdir())
table.insert(configs, "--prefix=" .. (opt.prefix or package:installdir()))
table.insert(configs, "--libdir=lib")

-- set build type
Expand Down

0 comments on commit 78627bc

Please sign in to comment.