From 64c41bd8ef06038cebdbbf39a85da51d69e718e7 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 31 May 2022 22:21:31 +0800 Subject: fix path for batchcmds --- xmake/modules/private/utils/batchcmds.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'xmake/modules/private/utils/batchcmds.lua') diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua index a5a636f07..cf2c421d9 100644 --- a/xmake/modules/private/utils/batchcmds.lua +++ b/xmake/modules/private/utils/batchcmds.lua @@ -241,6 +241,17 @@ function batchcmds:compile(sourcefiles, objectfile, opt) local compiler_inst = compiler.load(sourcekind, opt) local program, argv = compiler_inst:compargv(sourcefiles, path(objectfile), opt) + -- we need translate path for the project generator + for idx, item in ipairs(argv) do + if type(item) == "string" then + if item:startswith("-I") then + argv[idx] = path(item:sub(3), function (p) return "-I" .. p end) + elseif item:startswith("/I") then + argv[idx] = path(item:sub(3), function (p) return "/I" .. p end) + end + end + end + -- add compilation command and bind run environments of compiler self:mkdir(path.directory(objectfile)) self:vrunv(program, argv, {envs = table.join(compiler_inst:runenvs(), opt.envs)}) @@ -265,6 +276,19 @@ function batchcmds:link(objectfiles, targetfile, opt) local linker_inst = target and target:linker() or linker.load(opt.targetkind, opt.sourcekinds, opt) local program, argv = linker_inst:linkargv(objectfiles, path(targetfile), opt) + -- we need translate path for the project generator + 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) + end + end + end + -- add link command and bind run environments of linker self:mkdir(path.directory(targetfile)) self:vrunv(program, argv, {envs = table.join(linker_inst:runenvs(), opt.envs)}) -- cgit v1.3.1