diff options
| -rw-r--r-- | xmake/modules/private/utils/batchcmds.lua | 24 | ||||
| -rw-r--r-- | xmake/rules/qt/moc/xmake.lua | 7 |
2 files changed, 30 insertions, 1 deletions
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)}) diff --git a/xmake/rules/qt/moc/xmake.lua b/xmake/rules/qt/moc/xmake.lua index 2e5e3db31..5a10f73f8 100644 --- a/xmake/rules/qt/moc/xmake.lua +++ b/xmake/rules/qt/moc/xmake.lua @@ -68,7 +68,12 @@ rule("qt.moc") for _, pathmap in ipairs(pathmaps) do for _, item in ipairs(target:get(pathmap[1])) do local pathitem = path(item, function (p) - return table.unwrap(compiler.map_flags("cxx", pathmap[2], p)) + local item = table.unwrap(compiler.map_flags("cxx", pathmap[2], p)) + if item then + -- we always need use '/' to fix it for project generator, because it will use path.translate in cl.lua + item = item:gsub("\\", "/") + end + return item end) table.insert(flags, pathitem) end |
