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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
<%
eol = "\r\n"
local csc = premake.csc
-- translate the action to format and tool versions
local vsversion, toolversion
if _ACTION == "vs2005" then
vsversion = "8.0.50727"
toolversion = nil
elseif _ACTION == "vs2008" then
vsversion = "9.0.50727"
toolversion = "3.5"
end
--
-- Figure out what elements a particular source code file need in its item
-- block, based on its build action and any related files in the project.
--
function getelements(prj, action, fname)
if action == "Compile" and fname:endswith(".cs") then
if fname:endswith(".Designer.cs") then
-- is there a matching *.cs file?
local basename = fname:sub(1, -13)
local testname = basename .. ".cs"
if premake.findfile(prj, testname) then
return "Dependency", testname
end
-- is there a matching *.resx file?
testname = basename .. ".resx"
if premake.findfile(prj, testname) then
return "AutoGen", testname
end
else
-- is there a *.Designer.cs file?
local basename = fname:sub(1, -4)
local testname = basename .. ".Designer.cs"
if premake.findfile(prj, testname) then
return "SubTypeForm"
end
end
end
if action == "EmbeddedResource" and fname:endswith(".resx") then
-- is there a matching *.cs file?
local basename = fname:sub(1, -6)
local testname = path.getname(basename .. ".cs")
if premake.findfile(prj, testname) then
if premake.findfile(prj, basename .. ".Designer.cs") then
return "DesignerType", testname
else
return "Dependency", testname
end
else
-- is there a matching *.Designer.cs?
testname = path.getname(basename .. ".Designer.cs")
if premake.findfile(prj, testname) then
return "AutoGenerated"
end
end
end
if action == "Content" then
return "CopyNewest"
end
return "None"
end
-- end of preprocessing; template starts here --
%>
<% if toolversion then %>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="<%= toolversion %>">
<% else %>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<% end %>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' "><%= premake.esc(this.solution.configurations[1]) %></Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion><%= vsversion %></ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{<%= this.uuid %>}</ProjectGuid>
<OutputType><%= csc.getkind(this) %></OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace><%= this.buildtarget.basename %></RootNamespace>
<AssemblyName><%= this.buildtarget.basename %></AssemblyName>
</PropertyGroup>
<% for cfg in premake.eachconfig(this) do %>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == '<%= premake.esc(cfg.name) %>|AnyCPU' ">
<% if cfg.flags.Symbols then %>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<% else %>
<DebugType>pdbonly</DebugType>
<% end %>
<Optimize><%= iif(cfg.flags.Optimize or cfg.flags.OptimizeSize or cfg.flags.OptimizeSpeed, "true", "false") %></Optimize>
<OutputPath><%= cfg.buildtarget.directory %></OutputPath>
<DefineConstants><%= table.concat(premake.esc(cfg.defines), ";") %></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<% if cfg.flags.Unsafe then %>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<% end %>
<% if cfg.flags.FatalWarnings then %>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<% end %>
</PropertyGroup>
<% end %>
<ItemGroup>
<% for _, prj in ipairs(premake.getlinks(this, "siblings", "object")) do %>
<ProjectReference Include="<%= path.translate(path.getrelative(this.location, _VS.projectfile(prj)), "\\") %>">
<Project>{<%= prj.uuid %>}</Project>
<Name><%= premake.esc(prj.name) %></Name>
</ProjectReference>
<% end %>
<% for _, linkname in ipairs(premake.getlinks(this, "system", "fullpath")) do %>
<Reference Include="<%= premake.esc(linkname) %>" />
<% end %>
</ItemGroup>
<ItemGroup>
<%
for fcfg in premake.eachfile(this) do
local action = csc.getbuildaction(fcfg)
local fname = path.translate(premake.esc(fcfg.name), "\\")
local elements, dependency = getelements(this, action, fcfg.name)
if elements == "None" then
%>
<<%= action %> Include="<%= fname %>" />
<%
else
%>
<<%= action %> Include="<%= fname %>">
<% if elements == "AutoGen" then %>
<AutoGen>True</AutoGen>
<% elseif elements == "AutoGenerated" then %>
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput><%= premake.esc(path.getbasename(fcfg.name)) %>.Designer.cs</LastGenOutput>
<% elseif elements == "SubTypeDesigner" then %>
<SubType>Designer</SubType>
<% elseif elements == "SubTypeForm" then %>
<SubType>Form</SubType>
<% elseif elements == "PreserveNewest" then %>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<% end %>
<% if dependency then %>
<DependentUpon><%= path.translate(premake.esc(dependency), "\\") %></DependentUpon>
<% end %>
</<%= action %>>
<%
end
end
%>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
|