From 740b0d520e5718464df394ed5b6f4e51aa834818 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 13 Aug 2022 11:56:43 +0800 Subject: improve generator --- xmake/rules/c++/modules/modules_support/clang.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support') diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index bd4448ae7..a29a56db7 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -433,7 +433,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op break end local bmifile = provide.bmi - local args = { "-c", "-x", "c++-module", "--precompile", provide.sourcefile, "-o", bmifile } + local args = {"-c", "-x", "c++-module", "--precompile", path(provide.sourcefile), "-o", path(bmifile)} local requiresflags if module.requires then requiresflags = get_requiresflags(target, module.requires) @@ -441,7 +441,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.module.bmi %s", name) batchcmds:mkdir(path.directory(objectfile)) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, requiresflags or {}, args)) - batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, requiresflags or {}, {bmifile}, {"-c", "-o", objectfile})) + batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, requiresflags or {}, path(bmifile), {"-c", "-o", path(objectfile)})) batchcmds:add_depfiles(provide.sourcefile) _add_module_to_mapper(target, name, bmifile) depmtime = math.max(depmtime, os.mtime(bmifile)) -- cgit v1.3.1 From e75f37dd0829ca2351bbc78d47f992e1f691cc53 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 13 Aug 2022 12:01:17 +0800 Subject: translate more paths --- xmake/rules/c++/modules/modules_support/clang.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support') diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index a29a56db7..1a3b0ee80 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -210,7 +210,7 @@ function generate_stl_headerunits_for_batchcmds(target, batchcmds, headerunits, -- don't build same header unit at the same time if not common.memcache():get2(headerunit.name, "building") then common.memcache():set2(headerunit.name, "building", true) - local args = {modulecachepathflag .. stlcachedir, "-c", "-o", bmifile, "-x", "c++-system-header", headerunit.name} + local args = {modulecachepathflag .. stlcachedir, "-c", "-o", path(bmifile), "-x", "c++-system-header", headerunit.name} batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.headerunit.bmi %s", headerunit.name) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args)) end @@ -308,7 +308,7 @@ function generate_user_headerunits_for_batchcmds(target, batchcmds, headerunits, local args = { modulecachepathflag .. cachedir, "-c", "-o", bmifile} if headerunit.type == ":quote" then - table.join2(args, {"-I", path.directory(headerunit.path), "-x", "c++-user-header", headerunit.path}) + table.join2(args, {"-I", path(headerunit.path):directory(), "-x", "c++-user-header", path(headerunit.path)}) elseif headerunit.type == ":angle" then table.join2(args, {"-x", "c++-system-header", headerunit.name}) end -- cgit v1.3.1 From ceee3b9f38385d3093aba79852a10f8affe6f0b6 Mon Sep 17 00:00:00 2001 From: ruki Date: Sat, 13 Aug 2022 22:38:41 +0800 Subject: translate path --- xmake/rules/c++/modules/modules_support/gcc.lua | 10 +++++----- xmake/rules/c++/modules/modules_support/msvc.lua | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support') diff --git a/xmake/rules/c++/modules/modules_support/gcc.lua b/xmake/rules/c++/modules/modules_support/gcc.lua index a37346bad..1405d1cfa 100644 --- a/xmake/rules/c++/modules/modules_support/gcc.lua +++ b/xmake/rules/c++/modules/modules_support/gcc.lua @@ -189,7 +189,7 @@ function generate_stl_headerunits_for_batchcmds(target, batchcmds, headerunits, for _, headerunit in ipairs(headerunits) do local bmifile = path.join(stlcachedir, headerunit.name .. get_bmi_extension()) if not os.isfile(bmifile) then - local args = { "-c", "-x", "c++-system-header", headerunit.name } + local args = {"-c", "-x", "c++-system-header", headerunit.name} batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.headerunit.bmi %s", headerunit.name) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args)) end @@ -276,13 +276,13 @@ function generate_user_headerunits_for_batchcmds(target, batchcmds, headerunits, local bmifile = (outputdir and path.join(outputdir, bmifilename) or bmifilename) batchcmds:mkdir(path.directory(objectfile)) - local args = { "-c" } + local args = {"-c"} local headerunit_path if headerunit.type == ":quote" then - table.join2(args, { "-I", path.directory(path.relative(headerunit.path, projectdir)), "-x", "c++-user-header", headerunit.name }) + table.join2(args, {"-I", path(path.relative(headerunit.path, projectdir)):directory(), "-x", "c++-user-header", headerunit.name}) headerunit_path = path.join(".", path.relative(headerunit.path, projectdir)) elseif headerunit.type == ":angle" then - table.join2(args, { "-x", "c++-system-header", headerunit.name }) + table.join2(args, {"-x", "c++-system-header", headerunit.name}) -- if path is relative then its a subtarget path headerunit_path = path.is_absolute(headerunit.path) and headerunit.path or path.join(".", headerunit.path) end @@ -375,7 +375,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op end local bmifile = provide.bmi - local args = {"-o", objectfile, "-c", provide.sourcefile} + local args = {"-o", path(objectfile), "-c", path(provide.sourcefile)} batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.module.bmi %s", name) batchcmds:mkdir(path.directory(objectfile)) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, args)) diff --git a/xmake/rules/c++/modules/modules_support/msvc.lua b/xmake/rules/c++/modules/modules_support/msvc.lua index 4f7c8edc2..5214f12df 100644 --- a/xmake/rules/c++/modules/modules_support/msvc.lua +++ b/xmake/rules/c++/modules/modules_support/msvc.lua @@ -219,7 +219,12 @@ function generate_stl_headerunits_for_batchcmds(target, batchcmds, headerunits, -- don't build same header unit at the same time if not common.memcache():get2(headerunit.name, "building") then common.memcache():set2(headerunit.name, "building", true) - local args = {headernameflag .. ":angle", headerunit.name, ifcoutputflag, headerunit.name:startswith("experimental/") and path.join(stlcachedir, "experimental") or stlcachedir, "-Fo" .. objectfile} + local args = { + headernameflag .. ":angle", + headerunit.name, + ifcoutputflag, + path(headerunit.name:startswith("experimental/") and path.join(stlcachedir, "experimental") or stlcachedir), + path(objectfile, function (p) return "-Fo" .. p end)} batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.headerunit.bmi %s", headerunit.name) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, args), {envs = vcvars}) batchcmds:add_depfiles(headerunit.path) @@ -468,7 +473,12 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op end local bmifile = provide.bmi - local args = {"-c", "-Fo" .. objectfile, interfaceflag, ifcoutputflag, bmifile, provide.sourcefile} + local args = {"-c", + path(objectfile, function (p) return "-Fo" .. p end), + interfaceflag, + ifcoutputflag, + path(bmifile), + path(provide.sourcefile)} batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.module.bmi %s", name) batchcmds:mkdir(path.directory(objectfile)) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, requiresflags or {}, args), {envs = vcvars}) -- cgit v1.3.1 From 63bdc1bfaff58ba837e325574c6aa5a8151c8ba8 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 14 Aug 2022 10:58:07 +0800 Subject: remove unused code --- xmake/rules/c++/modules/modules_support/common.lua | 5 ++--- xmake/rules/c++/modules/xmake.lua | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support') diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 39ad17f2e..0bd1e20d8 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -88,7 +88,6 @@ end -- patch sourcebatch function patch_sourcebatch(target, sourcebatch) - local cachedir = modules_cachedir(target) sourcebatch.sourcekind = "cxx" sourcebatch.objectfiles = {} sourcebatch.dependfiles = {} @@ -138,11 +137,11 @@ end -- this target contains module files? function contains_modules(target) - local target_with_modules = target:sourcebatches()["c++.build.modules"] and true or false + local target_with_modules = target:sourcebatches()["c++.build.modules.builder"] and true or false if not target_with_modules then for _, dep in ipairs(target:orderdeps()) do local sourcebatches = dep:sourcebatches() - if sourcebatches["c++.build.modules"] then + if sourcebatches["c++.build.modules.builder"] then target_with_modules = true break end diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index 276566a27..ae81ebc25 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -20,8 +20,6 @@ -- define rule: c++.build.modules rule("c++.build.modules") - set_extensions(".mpp", ".mxx", ".cppm", ".ixx") - add_deps("c++.build.modules.builder") add_deps("c++.build.modules.install") -- cgit v1.3.1 From 7553abdc8062e4ae45604e03b05986e84221b33c Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 14 Aug 2022 11:43:00 +0800 Subject: translate clang path --- xmake/rules/c++/modules/modules_support/clang.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support') diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 1a3b0ee80..fb3a2d1fa 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -210,7 +210,9 @@ function generate_stl_headerunits_for_batchcmds(target, batchcmds, headerunits, -- don't build same header unit at the same time if not common.memcache():get2(headerunit.name, "building") then common.memcache():set2(headerunit.name, "building", true) - local args = {modulecachepathflag .. stlcachedir, "-c", "-o", path(bmifile), "-x", "c++-system-header", headerunit.name} + local args = { + path(stlcachedir, function (p) return modulecachepathflag .. p end), + "-c", "-o", path(bmifile), "-x", "c++-system-header", headerunit.name} batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.headerunit.bmi %s", headerunit.name) batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), args)) end @@ -306,7 +308,7 @@ function generate_user_headerunits_for_batchcmds(target, batchcmds, headerunits, local bmifile = (outputdir and path.join(outputdir, bmifilename) or bmifilename) batchcmds:mkdir(path.directory(objectfile)) - local args = { modulecachepathflag .. cachedir, "-c", "-o", bmifile} + local args = {path(cachedir, function (p) return modulecachepathflag .. p end), "-c", "-o", path(bmifile)} if headerunit.type == ":quote" then table.join2(args, {"-I", path(headerunit.path):directory(), "-x", "c++-user-header", path(headerunit.path)}) elseif headerunit.type == ":angle" then @@ -421,7 +423,7 @@ function build_modules_for_batchcmds(target, batchcmds, objectfiles, modules, op -- build modules local depmtime = 0 - local common_args = {modulecachepathflag .. cachedir} + local common_args = {path(cachedir, function (p) return modulecachepathflag .. p end)} for _, objectfile in ipairs(objectfiles) do local module = modules[objectfile] if module then -- cgit v1.3.1 From cbf9452ce0bf312b6ddcc4ab4bcdf61553100a3c Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 14 Aug 2022 11:52:39 +0800 Subject: fix modules --- xmake/rules/c++/modules/modules_support/common.lua | 5 +++-- xmake/rules/c++/modules/xmake.lua | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'xmake/rules/c++/modules/modules_support') diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua index 0bd1e20d8..aa7c0fb59 100644 --- a/xmake/rules/c++/modules/modules_support/common.lua +++ b/xmake/rules/c++/modules/modules_support/common.lua @@ -137,11 +137,12 @@ end -- this target contains module files? function contains_modules(target) - local target_with_modules = target:sourcebatches()["c++.build.modules.builder"] and true or false + -- we can not use `"c++.build.modules.builder"`, because it contains sourcekind/cxx. + local target_with_modules = target:sourcebatches()["c++.build.modules"] and true or false if not target_with_modules then for _, dep in ipairs(target:orderdeps()) do local sourcebatches = dep:sourcebatches() - if sourcebatches["c++.build.modules.builder"] then + if sourcebatches["c++.build.modules"] then target_with_modules = true break end diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua index ae81ebc25..3ef960d7a 100644 --- a/xmake/rules/c++/modules/xmake.lua +++ b/xmake/rules/c++/modules/xmake.lua @@ -20,6 +20,7 @@ -- define rule: c++.build.modules rule("c++.build.modules") + set_extensions(".mpp", ".mxx", ".cppm", ".ixx") add_deps("c++.build.modules.builder") add_deps("c++.build.modules.install") -- cgit v1.3.1