1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
--
-- 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'
-- Build the list of target platforms
local hascpp = premake.hascppproject(sln)
local hasdotnet = premake.hasdotnetproject(sln)
local platforms = { }
if hasdotnet then
table.insert(platforms, "Any CPU")
end
if hasdotnet and hascpp then
table.insert(platforms, "Mixed Platforms")
end
if hascpp then
platforms.cppdefault = #platforms + 1
for _, p in ipairs(premake.vstudio_get_platforms(sln.platforms, _ACTION)) do
table.insert(platforms, p)
end
end
-- Mark the file as Unicode
io.printf('\239\187\191')
-- Write the solution file version header
if _ACTION == "vs2005" then
io.printf('Microsoft Visual Studio Solution File, Format Version 9.00')
io.printf('# Visual Studio 2005')
else
io.printf('Microsoft Visual Studio Solution File, Format Version 10.00')
io.printf('# Visual Studio 2008')
end
-- 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)), "\\")
io.printf('Project("{%s}") = "%s", "%s", "{%s}"', _VS.tool(prj), prj.name, projpath, prj.uuid)
local deps = premake.getdependencies(prj)
if #deps > 0 then
io.printf('\tProjectSection(ProjectDependencies) = postProject')
for _, dep in ipairs(deps) do
io.printf('\t\t{%s} = {%s}', dep.uuid, dep.uuid)
end
io.printf('\tEndProjectSection')
end
io.printf('EndProject')
end
io.printf('Global')
premake.vs2005_solution_configurations(sln, platforms)
premake.vs2005_solution_project_configurations(sln, platforms)
premake.vs2005_solution_properties(sln)
io.printf('EndGlobal')
end
--
-- Write out the contents of the SolutionConfigurationPlatforms section, which
-- lists all of the configuration/platform pairs that exist in the solution.
--
function premake.vs2005_solution_configurations(sln, platforms)
io.printf('\tGlobalSection(SolutionConfigurationPlatforms) = preSolution')
for _, cfgname in ipairs(sln.configurations) do
for _, platname in ipairs(platforms) do
io.printf('\t\t%s|%s = %s|%s', cfgname, platname, cfgname, platname)
end
end
io.printf('\tEndGlobalSection')
end
--
-- Write out the contents of the ProjectConfigurationPlatforms section, which maps
-- the configuration/platform pairs into each project of the solution.
--
function premake.vs2005_solution_project_configurations(sln, platforms)
io.printf('\tGlobalSection(ProjectConfigurationPlatforms) = postSolution')
for prj in premake.eachproject(sln) do
for _, cfgname in ipairs(sln.configurations) do
for i, platname in ipairs(platforms) do
local mappedname = premake.vs2005_map_platform(prj, platforms, i)
io.printf('\t\t{%s}.%s|%s.ActiveCfg = %s|%s', prj.uuid, cfgname, platname, cfgname, mappedname)
if (platname == mappedname or platname == "Mixed Platforms") then
io.printf('\t\t{%s}.%s|%s.Build.0 = %s|%s', prj.uuid, cfgname, platname, cfgname, mappedname)
end
end
end
end
io.printf('\tEndGlobalSection')
end
--
-- Write out contents of the SolutionProperties section; current unused.
--
function premake.vs2005_solution_properties(sln)
io.printf('\tGlobalSection(SolutionProperties) = preSolution')
io.printf('\t\tHideSolutionNode = FALSE')
io.printf('\tEndGlobalSection')
end
--
-- Map a solution-level platform to one compatible with the provided project.
-- C++ platforms are mapped to "Any CPU" for .NET projects, and vice versa.
--
function premake.vs2005_map_platform(prj, platforms, i)
-- .NET projects always use "Any CPU" platform (for now, at least)
if premake.isdotnetproject(prj) then
return "Any CPU"
end
-- C++ projects use the current platform, or the first C++ platform
-- if the current one is for .NET
return platforms[math.max(i, platforms.cppdefault)]
end
|