2009-03-25 23:04:32 +00:00
|
|
|
--
|
|
|
|
-- vs2005_solution.lua
|
|
|
|
-- Generate a Visual Studio 2005 or 2008 solution.
|
|
|
|
-- Copyright (c) 2009 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
function premake.vs2005_solution(sln)
|
|
|
|
io.eol = '\r\n'
|
2009-05-06 23:25:50 +00:00
|
|
|
|
|
|
|
-- Precompute Visual Studio configurations
|
2009-05-06 23:37:14 +00:00
|
|
|
sln.vstudio_configs = premake.vstudio_buildconfigs(sln)
|
2009-03-25 23:04:32 +00:00
|
|
|
|
|
|
|
-- Mark the file as Unicode
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\239\187\191')
|
2009-03-25 23:04:32 +00:00
|
|
|
|
|
|
|
-- Write the solution file version header
|
2009-05-06 23:25:50 +00:00
|
|
|
_p('Microsoft Visual Studio Solution File, Format Version %s', iif(_ACTION == 'vs2005', '9.00', '10.00'))
|
|
|
|
_p('# Visual Studio %s', iif(_ACTION == 'vs2005', '2005', '2008'))
|
2009-04-09 20:02:49 +00:00
|
|
|
|
2009-03-25 23:04:32 +00:00
|
|
|
-- Write out the list of project entries
|
|
|
|
for prj in premake.eachproject(sln) do
|
|
|
|
-- Build a relative path from the solution file to the project file
|
|
|
|
local projpath = path.translate(path.getrelative(sln.location, _VS.projectfile(prj)), "\\")
|
|
|
|
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('Project("{%s}") = "%s", "%s", "{%s}"', _VS.tool(prj), prj.name, projpath, prj.uuid)
|
2009-03-25 23:04:32 +00:00
|
|
|
local deps = premake.getdependencies(prj)
|
|
|
|
if #deps > 0 then
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\tProjectSection(ProjectDependencies) = postProject')
|
2009-03-25 23:04:32 +00:00
|
|
|
for _, dep in ipairs(deps) do
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\t\t{%s} = {%s}', dep.uuid, dep.uuid)
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\tEndProjectSection')
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('EndProject')
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|
|
|
|
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('Global')
|
2009-05-06 23:25:50 +00:00
|
|
|
premake.vs2005_solution_platforms(sln)
|
|
|
|
premake.vs2005_solution_project_platforms(sln)
|
2009-03-25 23:04:32 +00:00
|
|
|
premake.vs2005_solution_properties(sln)
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('EndGlobal')
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Write out the contents of the SolutionConfigurationPlatforms section, which
|
|
|
|
-- lists all of the configuration/platform pairs that exist in the solution.
|
|
|
|
--
|
|
|
|
|
2009-05-06 23:25:50 +00:00
|
|
|
function premake.vs2005_solution_platforms(sln)
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution')
|
2009-05-06 23:25:50 +00:00
|
|
|
for _, cfg in ipairs(sln.vstudio_configs) do
|
|
|
|
_p('\t\t%s = %s', cfg.name, cfg.name)
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\tEndGlobalSection')
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Write out the contents of the ProjectConfigurationPlatforms section, which maps
|
|
|
|
-- the configuration/platform pairs into each project of the solution.
|
|
|
|
--
|
|
|
|
|
2009-05-06 23:25:50 +00:00
|
|
|
function premake.vs2005_solution_project_platforms(sln)
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution')
|
2009-03-25 23:04:32 +00:00
|
|
|
for prj in premake.eachproject(sln) do
|
2009-05-06 23:25:50 +00:00
|
|
|
for _, cfg in ipairs(sln.vstudio_configs) do
|
|
|
|
|
|
|
|
-- .NET projects always map to the "Any CPU" platform (for now, at
|
|
|
|
-- least). For C++, "Any CPU" and "Mixed Platforms" map to the first
|
|
|
|
-- C++ compatible target platform in the solution list.
|
|
|
|
local mapped
|
|
|
|
if premake.isdotnetproject(prj) then
|
|
|
|
mapped = "Any CPU"
|
|
|
|
else
|
|
|
|
if cfg.platform == "Any CPU" or cfg.platform == "Mixed Platforms" then
|
|
|
|
mapped = sln.vstudio_configs[3].platform
|
2009-04-09 20:02:49 +00:00
|
|
|
else
|
2009-05-06 23:25:50 +00:00
|
|
|
mapped = cfg.platform
|
2009-04-09 20:02:49 +00:00
|
|
|
end
|
2009-05-06 23:25:50 +00:00
|
|
|
end
|
2009-04-09 20:02:49 +00:00
|
|
|
|
2009-05-06 23:25:50 +00:00
|
|
|
_p('\t\t{%s}.%s.ActiveCfg = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped)
|
|
|
|
if mapped == cfg.platform or cfg.platform == "Mixed Platforms" then
|
|
|
|
_p('\t\t{%s}.%s.Build.0 = %s|%s', prj.uuid, cfg.name, cfg.buildcfg, mapped)
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\tEndGlobalSection')
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
2009-04-09 20:02:49 +00:00
|
|
|
-- Write out contents of the SolutionProperties section; currently unused.
|
2009-03-25 23:04:32 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
function premake.vs2005_solution_properties(sln)
|
2009-04-11 11:49:07 +00:00
|
|
|
_p('\tGlobalSection(SolutionProperties) = preSolution')
|
|
|
|
_p('\t\tHideSolutionNode = FALSE')
|
|
|
|
_p('\tEndGlobalSection')
|
2009-03-25 23:04:32 +00:00
|
|
|
end
|