summaryrefslogtreecommitdiff
path: root/xmake/modules/private/utils/batchcmds.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-03-28 00:54:26 +0800
committerruki <[email protected]>2024-03-28 00:54:26 +0800
commitdfa1b3d3b8681f6cba252edc900e6542d15c46e6 (patch)
tree5e27e05f44a3052583096f8634076db8ed9c8b78 /xmake/modules/private/utils/batchcmds.lua
parent518fc29b6aae6f4db40c7f6b760e269266a41475 (diff)
fix batchcmds for cmake path #4881
Diffstat (limited to 'xmake/modules/private/utils/batchcmds.lua')
-rw-r--r--xmake/modules/private/utils/batchcmds.lua17
1 files changed, 10 insertions, 7 deletions
diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua
index feba05b3c..a954261d9 100644
--- a/xmake/modules/private/utils/batchcmds.lua
+++ b/xmake/modules/private/utils/batchcmds.lua
@@ -284,7 +284,7 @@ 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)(.*)"}
for idx, item in ipairs(argv) do
if type(item) == "string" then
for _, pattern in ipairs(patterns) do
@@ -322,14 +322,16 @@ 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
@@ -452,3 +454,4 @@ function new(opt)
opt = opt or {}
return batchcmds {_TARGET = opt.target, _CMDS = {}}
end
+