diff options
| author | ruki <[email protected]> | 2020-12-29 23:04:03 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-29 23:04:03 +0800 |
| commit | a9307b7687e1b29dfdecd1db0c86ae0d4c5ba501 (patch) | |
| tree | 7d164dbcd76e3d429199fddf9c86288af7b08728 | |
| parent | 9358e68caf11067b683bfad56c75714222ac6f57 (diff) | |
add project groups for vsxmake
4 files changed, 35 insertions, 3 deletions
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 1cc3efac2..97fa6eb76 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -265,6 +265,24 @@ function _make_vsinfo_archs() return vsinfo_archs end +function _make_vsinfo_groups() + local groups = {} + for targetname, target in pairs(project.targets()) do + if not target:isphony() then + local group_path = target:get("group") + if group_path then + for _, group_name in ipairs(path.split(group_path)) do + local group = groups[group_name] or {} + group.group = group_name + group.group_id = hash.uuid4(group_name) + groups[group_name] = group + end + end + end + end + return groups +end + -- make vstudio project function main(outputdir, vsinfo) @@ -290,9 +308,15 @@ function main(outputdir, vsinfo) -- init modes vsinfo.modes = _make_vsinfo_modes() + -- init archs vsinfo.archs = _make_vsinfo_archs() + -- init groups + local groups = _make_vsinfo_groups() + vsinfo.groups = table.keys(groups) + vsinfo._groups = groups + -- load targets local targets = {} vsinfo._sub2 = {} @@ -366,13 +390,12 @@ function main(outputdir, vsinfo) _target.sourcefiles = table.unique(table.join(_target.sourcefiles or {}, (target:sourcefiles()))) _target.headerfiles = table.unique(table.join(_target.headerfiles or {}, (target:headerfiles()))) + -- save deps _target.deps = table.unique(table.join(_target.deps or {}, table.keys(target:deps()), nil)) end end end end - - -- leave project directory os.cd(oldir) for _, target in pairs(targets) do target._sub2 = {} diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/sln/ProjectGroup(group) b/xmake/plugins/project/vsxmake/vsproj/templates/sln/ProjectGroup(group) new file mode 100644 index 000000000..2a32553a7 --- /dev/null +++ b/xmake/plugins/project/vsxmake/vsproj/templates/sln/ProjectGroup(group) @@ -0,0 +1,2 @@ +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "#group#", "#group#", "{#group_id#}" +EndProject diff --git a/xmake/plugins/project/vsxmake/vsproj/templates/sln/vsxmake.sln b/xmake/plugins/project/vsxmake/vsproj/templates/sln/vsxmake.sln index fa719dfff..6dddb0e7e 100644 --- a/xmake/plugins/project/vsxmake/vsproj/templates/sln/vsxmake.sln +++ b/xmake/plugins/project/vsxmake/vsproj/templates/sln/vsxmake.sln @@ -11,6 +11,7 @@ Microsoft Visual Studio Solution File, Format Version #solution_version#.0 VisualStudioVersion = #vs_version# MinimumVisualStudioVersion = 10.0 #Import(Project)# +#Import(ProjectGroup)# Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Properties", "Properties", "{007754BD-BB1F-452F-A0D8-13EF216C5ED9}" ProjectSection(SolutionItems) = preProject Xmake.Custom.props = Xmake.Custom.props diff --git a/xmake/plugins/project/vsxmake/vsxmake.lua b/xmake/plugins/project/vsxmake/vsxmake.lua index cb238ca12..95058ebe4 100644 --- a/xmake/plugins/project/vsxmake/vsxmake.lua +++ b/xmake/plugins/project/vsxmake/vsxmake.lua @@ -57,7 +57,10 @@ function _buildparams(info, target, default) opt = table.join(target, opt) end for _, k in ipairs(opt) do - local v = (i._sub or {})[k] or (i._sub2 or {})[k] or (i._sub3 or {})[k] or (i._sub4 or {})[k]or i[k] + local v = (i._sub or {})[k] or (i._sub2 or {})[k] or (i._sub3 or {})[k] or (i._sub4 or {})[k] or i[k] + if v == nil and i._groups then + v = i._groups[k] + end if v == nil then raise("key '" .. k .. "' not found") end @@ -82,6 +85,9 @@ function _buildparams(info, target, default) if args.arch then table.insert(r, info.archs) end + if args.group then + table.insert(r, info.groups) + end if args.dir then table.insert(r, info._sub[target].dirs) end |
