diff options
| author | ruki <[email protected]> | 2024-11-08 10:16:28 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-11-08 10:16:28 +0800 |
| commit | c2b956073bfd299974e42cdf708c436ffa7775d3 (patch) | |
| tree | 17df467f76502c4170c7b1375c270147b8560158 | |
| parent | 86936573d8659a0a3a0d4507c1e89f65459e202f (diff) | |
| parent | f7ce4ee457a3df00b67dc2799e5de6d2ad859285 (diff) | |
Merge pull request #5795 from xmake-io/group
improve vs/vsxmake group
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_solution.lua | 23 | ||||
| -rw-r--r-- | xmake/plugins/project/vsxmake/getinfo.lua | 17 |
2 files changed, 28 insertions, 12 deletions
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua index c9cae25c1..d4a16c207 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_solution.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_solution.lua @@ -63,16 +63,21 @@ function _make_projects(slnfile, vsinfo) slnfile:leave("EndProject") local group_path = target:get("group") if group_path and #(group_path:trim()) > 0 then - for _, group_name in ipairs(path.split(group_path)) do - groups[group_name] = hash.uuid4("group." .. group_name) + local group_current_path + local group_names = path.split(group_path) + for idx, group_name in ipairs(group_names) do + group_current_path = group_current_path and path.join(group_current_path, group_name) or group_name + groups[group_current_path] = hash.uuid4("group." .. group_current_path) end end end -- make all groups local project_group_uuid = "2150E333-8FDC-42A3-9474-1A3956D46DE8" - for group_name, group_uuid in table.orderpairs(groups) do - slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"", project_group_uuid, group_name, group_name, group_uuid) + for group_path, group_uuid in table.orderpairs(groups) do + local group_name = path.filename(group_path) + slnfile:enter("Project(\"{%s}\") = \"%s\", \"%s\", \"{%s}\"", + project_group_uuid, group_name, group_name, group_uuid) slnfile:leave("EndProject") end end @@ -117,15 +122,18 @@ function _make_global(slnfile, vsinfo) local group_path = target:get("group") if group_path then -- target -> group - local group_name = path.filename(group_path) - slnfile:print("{%s} = {%s}", hash.uuid4(targetname), hash.uuid4("group." .. group_name)) + group_path = path.normalize(group_path) + slnfile:print("{%s} = {%s}", hash.uuid4(targetname), hash.uuid4("group." .. group_path)) -- group -> group -> ... + local group_current_path local group_names = path.split(group_path) for idx, group_name in ipairs(group_names) do + group_current_path = group_current_path and path.join(group_current_path, group_name) or group_name local group_name_sub = group_names[idx + 1] local key = group_name .. (group_name_sub or "") if group_name_sub and not subgroups[key] then - slnfile:print("{%s} = {%s}", hash.uuid4("group." .. group_name_sub), hash.uuid4("group." .. group_name)) + slnfile:print("{%s} = {%s}", hash.uuid4("group." .. path.join(group_current_path, group_name_sub)), + hash.uuid4("group." .. group_current_path)) subgroups[key] = true end end @@ -162,3 +170,4 @@ function make(vsinfo) -- exit solution file slnfile:close() end + diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 8c1a477e7..e566ab160 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -301,18 +301,25 @@ function _make_vsinfo_groups() for targetname, target in table.orderpairs(project.targets()) do local group_path = target:get("group") if group_path and #(group_path:trim()) > 0 then + group_path = path.normalize(group_path) local group_name = path.filename(group_path) local group_names = path.split(group_path) + local group_current_path for idx, name in ipairs(group_names) do - local group = groups["group." .. name] or {} + group_current_path = group_current_path and path.join(group_current_path, name) or name + local group = groups["group." .. group_current_path] or {} group.group = name - group.group_id = hash.uuid4("group." .. name) + group.group_id = hash.uuid4("group." .. group_current_path) if idx > 1 then - group_deps["group_dep." .. name] = {current_id = group.group_id, parent_id = hash.uuid4("group." .. group_names[idx - 1])} + group_deps["group_dep." .. group_current_path] = { + current_id = group.group_id, + parent_id = hash.uuid4("group." .. path.directory(group_current_path))} end - groups["group." .. name] = group + groups["group." .. group_current_path] = group end - group_deps["group_dep.target." .. targetname] = {current_id = hash.uuid4(targetname), parent_id = groups["group." .. group_name].group_id} + group_deps["group_dep.target." .. targetname] = { + current_id = hash.uuid4(targetname), + parent_id = groups["group." .. group_path].group_id} end end return groups, group_deps |
