Skip to content

Commit

Permalink
Xcode workspace cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoot authored and bkaradzic committed Feb 8, 2018
1 parent 4391392 commit 7d4f3ab
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/_manifest.lua
Expand Up @@ -69,7 +69,7 @@
"actions/xcode/_xcode.lua",
"actions/xcode/xcode_common.lua",
"actions/xcode/xcode_project.lua",
"actions/xcode/xcode4_workspace.lua",
"actions/xcode/xcode_workspace.lua",
"actions/xcode/xcode4.lua",
"actions/xcode/xcode8.lua",
"actions/xcode/xcode9.lua",
Expand Down
4 changes: 3 additions & 1 deletion src/actions/xcode/xcode4.lua
Expand Up @@ -4,6 +4,8 @@
--

local premake = premake
premake.xcode4 = { }

local xcode = premake.xcode
local xcode4 = premake.xcode4

Expand Down Expand Up @@ -302,7 +304,7 @@
default_platform = "Universal",

onsolution = function(sln)
premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", xcode4.workspace_generate)
premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", xcode.workspace_generate)
end,

onproject = function(prj)
Expand Down
6 changes: 1 addition & 5 deletions src/actions/xcode/xcode8.lua
Expand Up @@ -10,10 +10,6 @@
local xcode4 = premake.xcode4
local xcode8 = premake.xcode8

function xcode8.workspace_generate(sln)
return xcode4.workspace_generate(sln)
end

function xcode8.XCBuildConfiguration_Project(tr, prj, cfg)
local options = xcode4.XCBuildConfiguration_Project(tr, prj, cfg)

Expand Down Expand Up @@ -98,7 +94,7 @@
default_platform = "Native",

onsolution = function(sln)
premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", xcode8.workspace_generate)
premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", xcode.workspace_generate)
end,

onproject = function(prj)
Expand Down
6 changes: 1 addition & 5 deletions src/actions/xcode/xcode9.lua
Expand Up @@ -11,10 +11,6 @@ local xcode4 = premake.xcode4
local xcode8 = premake.xcode8
local xcode9 = premake.xcode9

function xcode9.workspace_generate(sln)
return xcode8.workspace_generate(sln)
end

function xcode9.XCBuildConfiguration_Project(tr, prj, cfg)
local options = xcode8.XCBuildConfiguration_Project(tr, prj, cfg)

Expand Down Expand Up @@ -82,7 +78,7 @@ newaction
default_platform = "Native",

onsolution = function(sln)
premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", xcode9.workspace_generate)
premake.generate(sln, "%%.xcworkspace/contents.xcworkspacedata", xcode.workspace_generate)
end,

onproject = function(prj)
Expand Down
@@ -1,20 +1,17 @@
premake.xcode4 = {}
local premake = premake
local xcode = premake.xcode

local xcode4 = premake.xcode4

function xcode4.workspace_head()
function xcode.workspace_head()
_p('<?xml version="1.0" encoding="UTF-8"?>')
_p('<Workspace')
_p(1,'version = "1.0">')

_p(1,'version = "1.0">')
end

function xcode4.workspace_tail()
function xcode.workspace_tail()
_p('</Workspace>')
end

function xcode4.workspace_file_ref(prj, indent)

function xcode.workspace_file_ref(prj, indent)
local projpath = path.getrelative(prj.solution.location, prj.location)
if projpath == '.' then projpath = ''
else projpath = projpath ..'/'
Expand All @@ -24,50 +21,48 @@ function xcode4.workspace_file_ref(prj, indent)
_p(indent, '</FileRef>')
end

function xcode4.workspace_group(grp, indent)
function xcode.workspace_group(grp, indent)
_p(indent, '<Group')
_p(indent + 1, 'location = "container:"')
_p(indent + 1, 'name = "%s">', grp.name)

for _, child in ipairs(grp.groups) do
xcode4.workspace_group(child, indent + 1)
xcode.workspace_group(child, indent + 1)
end

for _, prj in ipairs(grp.projects) do
xcode4.workspace_file_ref(prj, indent + 1)
xcode.workspace_file_ref(prj, indent + 1)
end

_p(indent, '</Group>')
end

function xcode4.workspace_generate(sln)
premake.xcode.preparesolution(sln)

xcode4.workspace_head()

xcode4.reorderProjects(sln)
function xcode.workspace_generate(sln)
xcode.preparesolution(sln)
xcode.workspace_head()
xcode.reorderProjects(sln)

for grp in premake.solution.eachgroup(sln) do
if grp.parent == nil then
xcode4.workspace_group(grp, 1)
xcode.workspace_group(grp, 1)
end
end

for prj in premake.solution.eachproject(sln) do
if prj.group == nil then
xcode4.workspace_file_ref(prj, 1)
xcode.workspace_file_ref(prj, 1)
end
end
xcode4.workspace_tail()

xcode.workspace_tail()
end

--
-- If a startup project is specified, move it to the front of the project list.
-- If a startup project is specified, move it to the front of the project list.
-- This will make Visual Studio treat it like a startup project.
--

function xcode4.reorderProjects(sln)
function xcode.reorderProjects(sln)
if sln.startproject then
for i, prj in ipairs(sln.projects) do
if sln.startproject == prj.name then
Expand Down

0 comments on commit 7d4f3ab

Please sign in to comment.