summaryrefslogtreecommitdiff
path: root/xmake/plugins
diff options
context:
space:
mode:
authorruki <[email protected]>2025-06-12 09:05:02 +0800
committerGitHub <[email protected]>2025-06-12 09:05:02 +0800
commitaa951bad4efc83de89bdf82ee9430a89e951fe37 (patch)
tree0ba82c107972174568df774c356fd8881b2e3052 /xmake/plugins
parent773407f7df280a5fc50d2aa6419875297e711bb2 (diff)
parentc02d24431fd3392a19064760f7627738d72b3ef6 (diff)
Merge pull request #6538 from xmake-io/vsxmake
Improve vsxmake generator with namespaces
Diffstat (limited to 'xmake/plugins')
-rw-r--r--xmake/plugins/project/vstudio/impl/vsutils.lua4
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua5
-rw-r--r--xmake/plugins/project/vsxmake/vsxmake.lua25
3 files changed, 19 insertions, 15 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vsutils.lua b/xmake/plugins/project/vstudio/impl/vsutils.lua
index 9abf7a7b9..265a7c7aa 100644
--- a/xmake/plugins/project/vstudio/impl/vsutils.lua
+++ b/xmake/plugins/project/vstudio/impl/vsutils.lua
@@ -52,3 +52,7 @@ function vsarch(arch)
return arch
end
+-- translate file path (with namespace characters '::', it's invalid path characters on windows)
+function translate_path(filepath)
+ return (filepath:gsub("::", "#"))
+end
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua
index d9c4b4b6b..670f5d994 100644
--- a/xmake/plugins/project/vsxmake/getinfo.lua
+++ b/xmake/plugins/project/vsxmake/getinfo.lua
@@ -495,9 +495,10 @@ function main(outputdir, vsinfo)
local _target = targets[targetname]
-- init target info
- _target.target = targetname
+ _target.targetname = targetname
+ _target.targetname_inpath = vsutils.translate_path(targetname)
_target.vcxprojdir = path.join(vsinfo.vcxproj_rootdir, targetname)
- _target.vcxprojdir_relative_sln = path.relative(_target.vcxprojdir, vsinfo.solution_dir)
+ _target.vcxprojdir_relative_sln = vsutils.translate_path(path.relative(_target.vcxprojdir, vsinfo.solution_dir))
_target.target_id = hash.uuid4(targetname)
_target.kind = target:kind()
_target.absscriptdir = target:scriptdir()
diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua
index d5cd5e078..6477e9982 100644
--- a/xmake/plugins/project/vsxmake/vsxmake.lua
+++ b/xmake/plugins/project/vsxmake/vsxmake.lua
@@ -26,6 +26,7 @@ import("render")
import("getinfo")
import("core.project.config")
import("core.cache.localcache")
+import("vstudio.impl.vsutils", {rootdir = path.join(os.programdir(), "plugins", "project")})
local template_root = path.join(os.programdir(), "scripts", "vsxmake", "vsproj", "templates")
local template_sln = path.join(template_root, "sln", "vsxmake.sln")
@@ -166,6 +167,7 @@ end
function _trycp(file, target, targetname)
targetname = targetname or path.filename(file)
local targetfile = path.join(target, targetname)
+ targetfile = vsutils.translate_path(targetfile)
if os.isfile(targetfile) then
dprint("skipped file %s since the file already exists", path.relative(targetfile))
return
@@ -174,6 +176,7 @@ function _trycp(file, target, targetname)
end
function _writefileifneeded(file, content)
+ file = vsutils.translate_path(file)
if os.isfile(file) and io.readfile(file) == content then
dprint("skipped file %s since the file has the same content", path.relative(file))
return
@@ -219,11 +222,7 @@ function make(version)
end
return function(outputdir)
-
- -- trace
vprint("using project kind vs%d", version)
-
- -- check
assert(version >= 2010, "vsxmake does not support vs version lower than 2010")
-- get info and params
@@ -240,20 +239,20 @@ function make(version)
for _, target in ipairs(info.targets) do
local paramsprovidertarget = _buildparams(info, target, "<!-- nil -->")
- local proj_dir = info._targets[target].vcxprojdir
+ local vcxproj_dir = info._targets[target].vcxprojdir
-- write project file
- local proj = path.join(proj_dir, target .. ".vcxproj")
- _writefileifneeded(proj, render(template_vcx, "#([A-Za-z0-9_,%.%*%(%)]+)#", "@([^@]+)@", paramsprovidertarget))
+ local vcxproj_file = path.join(vcxproj_dir, target .. ".vcxproj")
+ _writefileifneeded(vcxproj_file, render(template_vcx, "#([A-Za-z0-9_,%.%*%(%)]+)#", "@([^@]+)@", paramsprovidertarget))
- local projfil = path.join(proj_dir, target .. ".vcxproj.filters")
- _writefileifneeded(projfil, render(template_fil, "#([A-Za-z0-9_,%.%*%(%)]+)#", "@([^@]+)@", paramsprovidertarget))
+ local vcxproj_filters = path.join(vcxproj_dir, target .. ".vcxproj.filters")
+ _writefileifneeded(vcxproj_filters, render(template_fil, "#([A-Za-z0-9_,%.%*%(%)]+)#", "@([^@]+)@", paramsprovidertarget))
-- add project custom file
- _trycp(template_props, proj_dir)
- _trycp(template_targets, proj_dir)
- _trycp(template_items, proj_dir)
- _trycp(template_itemfil, proj_dir)
+ _trycp(template_props, vcxproj_dir)
+ _trycp(template_targets, vcxproj_dir)
+ _trycp(template_items, vcxproj_dir)
+ _trycp(template_itemfil, vcxproj_dir)
end
-- clear config and local cache