Skip to content

Commit

Permalink
Merge pull request #4888 from xmake-io/cmake
Browse files Browse the repository at this point in the history
fix batchcmds for cmake path #4881
  • Loading branch information
waruqi committed Mar 27, 2024
2 parents cc93ec4 + 5f77517 commit 4d4edd5
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions xmake/modules/private/utils/batchcmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,12 @@ function batchcmds:compilev(argv, opt)
end

-- we need to translate path for the project generator
local patterns = {"(^[%-/]external:I)(.*)", "(^[%-/]I)(.*)", "(^[%-/]Fp)(.*)", "(^[%-/]Fd)(.*)"}
local patterns = {"^([%-/]external:I)(.*)",
"^([%-/]I)(.*)",
"^([%-/]Fp)(.*)",
"^([%-/]Fd)(.*)",
"^([%-/]Yu)(.*)",
"^([%-/]FI)(.*)"}
for idx, item in ipairs(argv) do
if type(item) == "string" then
for _, pattern in ipairs(patterns) do
Expand Down Expand Up @@ -322,14 +327,18 @@ function batchcmds:link(objectfiles, targetfile, opt)
local program, argv = linker_inst:linkargv(objectfiles, path(targetfile), opt)

-- we need to translate path for the project generator
local patterns = {"^([%-/]L)(.*)",
"^([%-/]F)(.*)",
"^([%-/]libpath:)(.*)"}
for idx, item in ipairs(argv) do
if type(item) == "string" then
if item:startswith("-L") then
argv[idx] = path(item:sub(3), function (p) return "-L" .. p end)
elseif item:startswith("-F") then
argv[idx] = path(item:sub(3), function (p) return "-F" .. p end)
elseif item:startswith("-libpath:") then
argv[idx] = path(item:sub(10), function (p) return "-libpath:" .. p end)
for _, pattern in ipairs(patterns) do
local _, count = item:gsub(pattern, function (prefix, value)
argv[idx] = path(value, function (p) return prefix .. p end)
end)
if count > 0 then
break
end
end
end
end
Expand Down Expand Up @@ -452,3 +461,4 @@ function new(opt)
opt = opt or {}
return batchcmds {_TARGET = opt.target, _CMDS = {}}
end

0 comments on commit 4d4edd5

Please sign in to comment.