summaryrefslogtreecommitdiff
path: root/xmake/plugins/project/vstudio/impl/vsutils.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2026-06-23 23:25:42 +0800
committerruki <[email protected]>2026-07-07 23:04:45 +0800
commit65ee93162232d0399a1b9f08701c42bc04f3f9ab (patch)
tree0f53d3877124e44ea58da8d2ff2fc0ea97cbb46e /xmake/plugins/project/vstudio/impl/vsutils.lua
parent147fdfa379133d0d7d7f075ac9b4905401ff7126 (diff)
add vstudio support for nonetype
Diffstat (limited to 'xmake/plugins/project/vstudio/impl/vsutils.lua')
-rw-r--r--xmake/plugins/project/vstudio/impl/vsutils.lua41
1 files changed, 41 insertions, 0 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vsutils.lua b/xmake/plugins/project/vstudio/impl/vsutils.lua
index 30832ae3f..2cf5e7bdb 100644
--- a/xmake/plugins/project/vstudio/impl/vsutils.lua
+++ b/xmake/plugins/project/vstudio/impl/vsutils.lua
@@ -20,6 +20,7 @@
-- imports
import("core.base.option")
+import("core.base.hashset")
import("core.project.config")
import("core.project.project")
import("core.cache.memcache")
@@ -64,6 +65,46 @@ function translate_path(filepath)
return (filepath:gsub("::", "#"))
end
+-- get the source files that are not natively built by VS, e.g. files added by add_files but handled
+-- by a custom rule. we list them as <None> in the project for display only (like add_extrafiles).
+-- this must be consistent with vs201x_vcxproj._make_source_files.
+-- @see https://github.com/xmake-io/xmake/issues/7619
+function otherfiles(target)
+
+ -- collect the source files that are natively built by VS
+ local builtfiles = hashset.new()
+ for _, targetinfo in ipairs(target.info or {}) do
+ for _, sourcebatch in pairs(targetinfo.sourcebatches or {}) do
+ local sourcekind = sourcebatch.sourcekind
+ local rulename = sourcebatch.rulename
+ if rulename == "c.build" or rulename == "c++.build" or rulename == "c++.build.modules"
+ or sourcekind == "as" or sourcekind == "mrc" or sourcekind == "cu" then
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ builtfiles:insert(sourcefile)
+ end
+ end
+ end
+ end
+
+ -- exclude the header/extra files and the precompiled header to avoid duplicate display
+ local excludefiles = hashset.from(table.join(target.headerfiles or {}, target.extrafiles or {}))
+ if target.pcheader then
+ excludefiles:insert(target.pcheader)
+ end
+ if target.pcxxheader then
+ excludefiles:insert(target.pcxxheader)
+ end
+
+ -- the remaining source files are the custom files
+ local results = {}
+ for _, sourcefile in ipairs(target.sourcefiles or {}) do
+ if not builtfiles:has(sourcefile) and not excludefiles:has(sourcefile) then
+ table.insert(results, sourcefile)
+ end
+ end
+ return results
+end
+
function reset_config_and_caches(mode, arch)
-- reload config, project and platform
-- modify config