summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/modules/modules_support/common.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-24 22:45:24 +0800
committerruki <[email protected]>2022-08-24 22:45:24 +0800
commitee55b56ef385023a290e495f6626ab7aeea2c5b8 (patch)
tree913bef27565fe91265b32b526b08877588287a42 /xmake/rules/c++/modules/modules_support/common.lua
parente94c67aea65b7b64246a79b7f125c11f3268371d (diff)
improve module deps
Diffstat (limited to 'xmake/rules/c++/modules/modules_support/common.lua')
-rw-r--r--xmake/rules/c++/modules/modules_support/common.lua21
1 files changed, 11 insertions, 10 deletions
diff --git a/xmake/rules/c++/modules/modules_support/common.lua b/xmake/rules/c++/modules/modules_support/common.lua
index 734a2d070..1e3231231 100644
--- a/xmake/rules/c++/modules/modules_support/common.lua
+++ b/xmake/rules/c++/modules/modules_support/common.lua
@@ -381,29 +381,30 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile)
local rule = {outputs = {jsonfile}}
rule["primary-output"] = target:objectfile(sourcefile)
- local module_name
+ local module_name_export
+ local module_name_private
local module_deps = {}
local sourcecode = io.readfile(sourcefile)
sourcecode = sourcecode:gsub("//.-\n", "\n")
sourcecode = sourcecode:gsub("/%*.-%*/", "")
for _, line in ipairs(sourcecode:split("\n", {plain = true})) do
- if not module_name then
- module_name = line:match("export%s+module%s+(.+)%s*;")
+ if not module_name_export then
+ module_name_export = line:match("export%s+module%s+(.+)%s*;")
end
- if not module_name then
- module_name = line:match("module%s+(.+)%s*;")
+ if not module_name_private then
+ module_name_private = line:match("module%s+(.+)%s*;")
end
local module_depname = line:match("import%s+(.+)%s*;")
-- we need parse module interface dep in cxx/impl_unit.cpp, e.g. hello.mpp and hello_impl.cpp
-- @see https://github.com/xmake-io/xmake/pull/2664#issuecomment-1213167314
if not module_depname and not has_module_extension(sourcefile) then
- module_depname = module_name
+ module_depname = module_name_private
end
if module_depname then
local module_dep = {}
-- partition? import :xxx;
if module_depname:startswith(":") then
- module_depname = (module_name or "") .. module_depname
+ module_depname = (module_name_export or module_name_private or "") .. module_depname
elseif module_depname:startswith("\"") then
module_depname = module_depname:sub(2, -2)
module_dep["lookup-method"] = "include-quote"
@@ -420,11 +421,11 @@ function fallback_generate_dependencies(target, jsonfile, sourcefile)
end
end
- if module_name then
- table.insert(rule.outputs, module_name .. bmi_extension(target))
+ if module_name_export then
+ table.insert(rule.outputs, module_name_export .. bmi_extension(target))
local provide = {}
- provide["logical-name"] = module_name
+ provide["logical-name"] = module_name_export
provide["source-path"] = path.absolute(sourcefile, project.directory())
rule.provides = {}