diff options
| author | Arthur LAURENT <[email protected]> | 2022-08-07 05:40:30 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2022-08-07 05:40:30 +0200 |
| commit | dffff05e4c8048e4fb379275382493dcf35483c4 (patch) | |
| tree | d0bd1a213df2fac6d6422cf085194670ab87ecd6 /xmake/rules/c++/modules/modules_support | |
| parent | f079c8e059ead5aeef0400ef360b6201150e1478 (diff) | |
Fix header unit path in module mapper
Diffstat (limited to 'xmake/rules/c++/modules/modules_support')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index b50fd4bf2..00d110a5e 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -36,11 +36,10 @@ function _get_module_mapper() return mapper_file end --- add a module or header unit into the mapper +-- add a module into the mapper -- -- e.g -- -fmodule-file=foo=build/.gens/Foo/rules/modules/cache/foo.ifc --- -fmodule-file=foo=build/.gens/Foo/rules/modules/cache/foo.ifc -- function _add_module_to_mapper(target, file, module, bmi) local modulefileflag = get_modulefileflag(target) @@ -54,6 +53,22 @@ function _add_module_to_mapper(target, file, module, bmi) f:close() end +-- add a header unit into the mapper +-- +-- e.g +-- -fmodule-file=build/.gens/Foo/rules/modules/cache/foo.hpp.ifc +-- +function _add_headerunit_to_mapper(target, file, bmi) + local modulefileflag = get_modulefileflag(target) + for line in io.lines(file) do + if line:startswith(modulefileflag .. bmi) then + return + end + end + local f = io.open(file, "a") + f:print("%s%s", modulefileflag, bmi) + f:close() +end -- load module support for the current target function load(target) @@ -175,13 +190,13 @@ function generate_stl_headerunits_for_batchcmds(target, batchcmds, headerunits, for i, headerunit in ipairs(headerunits) do local bmifile = path.join(stlcachedir, headerunit.name .. get_bmi_extension()) if not os.isfile(bmifile) then - local args = {modulecachepathflag .. stlcachedir, "-c", "-o", bmifile, "-x", "c++-system-header", headerunit.path} + local args = {modulecachepathflag .. stlcachedir, "-c", "-o", 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)) -- libc++ have a builtin module mapper if not target:data_set("cxx.modules.use_libc++") then - _add_module_to_mapper(target, mapper_file, headerunit.name, bmifile) + _add_headerunit_to_mapper(target, mapper_file, bmifile) end end depmtime = math.max(depmtime, os.mtime(bmifile)) @@ -234,7 +249,7 @@ function generate_user_headerunits_for_batchcmds(target, batchcmds, headerunits, 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)) batchcmds:add_depfiles(headerunit.path) - _add_module_to_mapper(target, mapper_file, headerunit.name, bmifile) + _add_headerunit_to_mapper(target, mapper_file, bmifile) depmtime = math.max(depmtime, os.mtime(bmifile)) end |
