diff options
| author | Arthur LAURENT <[email protected]> | 2022-08-05 06:11:54 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2022-08-05 06:23:19 +0200 |
| commit | cf4a7193ea34e3f82d710114343c7fb1f00e261d (patch) | |
| tree | eb8940dc25c5feaf565705740f74fcd338d629fb /xmake/rules/c++/modules/modules_support/clang.lua | |
| parent | 08bf176c09948d0a9662ca72b804e42e90ad341d (diff) | |
Assert on multiple provides
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/clang.lua')
| -rw-r--r-- | xmake/rules/c++/modules/modules_support/clang.lua | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/xmake/rules/c++/modules/modules_support/clang.lua b/xmake/rules/c++/modules/modules_support/clang.lua index 2cc4b0bb4..734fa5a4d 100644 --- a/xmake/rules/c++/modules/modules_support/clang.lua +++ b/xmake/rules/c++/modules/modules_support/clang.lua @@ -235,33 +235,34 @@ function build_modules(target, batchcmds, objectfiles, modules, opt) local depmtime = 0 for _, objectfile in ipairs(objectfiles) do local m = modules[objectfile] - if m then - batchcmds:mkdir(path.directory(objectfile)) - - local args = { emitmoduleinterfaceflag } - local bmiflags = {} - local bmifiles = {} - for name, provide in pairs(m.provides) do - batchcmds:show_progress(opt.progress, "${color.build.object}generating.cxx.module.bmi %s", name) - - local bmifile = provide.bmi - table.join2(args, { "-c", "-x", "c++-module", "--precompile", provide.sourcefile, "-o", bmifile }) - table.insert(bmifiles, bmifile) - - batchcmds:add_depfiles(provide.sourcefile) - - table.join2(bmiflags, {modulefileflag .. bmifile}) - depmtime = math.max(depmtime, os.mtime(bmifile)) + if m and m.provides then + -- assume there that provides is only one, until we encounter the case + local length = 0 + local name, provide + for k, v in pairs(m.provides) do + length = length + 1 + name = k + provide = v + if length > 1 then + raise("multiple provides are not supported now!") + end end + local bmifile = provide.bmi + + local args = { emitmoduleinterfaceflag, "-c", "-x", "c++-module", "--precompile", provide.sourcefile, "-o", bmifile } + 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)) - batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, bmifiles, {"-c", "-o", objectfile})) + batchcmds:vrunv(compinst:program(), table.join(compinst:compflags({target = target}), common_args, {bmifile}, {"-c", "-o", objectfile})) + batchcmds:add_depfiles(provide.sourcefile) + + local bmiflags = modulefileflag .. bmifile target:add("cxxflags", bmiflags, {public = true, force = true}) target:add("objectfiles", objectfile) - for _, f in ipairs(bmiflags) do - target:data_add("cxx.modules.flags", f) - end + target:data_add("cxx.modules.flags", f) + depmtime = math.max(depmtime, os.mtime(bmifile)) end end batchcmds:set_depmtime(depmtime) |
