diff options
| -rw-r--r-- | xmake/core/project/target.lua | 9 | ||||
| -rw-r--r-- | xmake/rules/swig/xmake.lua | 4 |
2 files changed, 11 insertions, 2 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 3e2d308f9..52126b78c 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1605,6 +1605,15 @@ function _instance:sourcekinds() table.insert(sourcekinds, sourcekind) end end + -- if the source file is added dynamically, we may not be able to get the sourcekinds, + -- so we can only continue to get it from the rule + -- https://github.com/xmake-io/xmake/issues/1622#issuecomment-927726697 + for _, ruleinst in ipairs(self:orderules()) do + local rule_sourcekinds = ruleinst:get("sourcekinds") + if rule_sourcekinds then + table.insert(sourcekinds, rule_sourcekinds) + end + end sourcekinds = table.unique(sourcekinds) self._SOURCEKINDS = sourcekinds end diff --git a/xmake/rules/swig/xmake.lua b/xmake/rules/swig/xmake.lua index 738cc12fd..29b2673a2 100644 --- a/xmake/rules/swig/xmake.lua +++ b/xmake/rules/swig/xmake.lua @@ -70,14 +70,14 @@ rule("swig.base") rule("swig.c") set_extensions(".i") - add_deps("swig.base") + add_deps("swig.base", "c.build") on_buildcmd_file(function (target, batchcmds, sourcefile, opt) import("build_module_file")(target, batchcmds, sourcefile, table.join({sourcekind = "cc"}, opt)) end) rule("swig.cpp") set_extensions(".i") - add_deps("swig.base") + add_deps("swig.base", "c++.build") on_buildcmd_file(function (target, batchcmds, sourcefile, opt) import("build_module_file")(target, batchcmds, sourcefile, table.join({sourcekind = "cxx"}, opt)) end) |
