1<?xml version="1.0" encoding="utf-8"?>
2<!-- Main msbuild project for OpenRCT2 -->
3<!-- Inputs (/p: or environment variables)
4       - OPENRCT2_BUILD_SERVER
5       - OPENRCT2_BRANCH
6       - OPENRCT2_SHA1
7       - OPENRCT2_SHA1_SHORT
8       - OPENRCT2_DESCRIBE
9  -->
10<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
11  <!-- Import custom build tasks -->
12  <Import Project="openrct2.targets" />
13
14  <PropertyGroup>
15    <Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
16    <Platform Condition="'$(Platform)'==''">x64</Platform>
17
18    <!-- Set dynamic OpenRCT2 #defines -->
19    <OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_BUILD_SERVER)'!=''">/D "OPENRCT2_BUILD_SERVER=\"$(OPENRCT2_BUILD_SERVER)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
20    <OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_BRANCH)'!=''">/D "OPENRCT2_BRANCH=\"$(OPENRCT2_BRANCH)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
21    <OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_SHA1)'!=''">/D "OPENRCT2_COMMIT_SHA1=\"$(OPENRCT2_SHA1)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
22    <OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_SHA1_SHORT)'!=''">/D "OPENRCT2_COMMIT_SHA1_SHORT=\"$(OPENRCT2_SHA1_SHORT)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
23    <OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(OPENRCT2_DESCRIBE)'!=''">/D "OPENRCT2_VERSION_TAG=\"$(OPENRCT2_DESCRIBE)\"" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
24    <OPENRCT2_CL_ADDITIONALOPTIONS Condition="'$(Configuration)'=='Release'">/D "USE_BREAKPAD" $(OPENRCT2_CL_ADDITIONALOPTIONS)</OPENRCT2_CL_ADDITIONALOPTIONS>
25
26    <RootDir>$(MsBuildThisFileDirectory)</RootDir>
27    <TargetDir>$(RootDir)bin\</TargetDir>
28
29    <OutputExe>$(TargetDir)openrct2.exe</OutputExe>
30    <g2Output>$(TargetDir)data\g2.dat</g2Output>
31
32    <!-- Set openrct2.sln properties -->
33    <SlnProperties>$(SlnProperties);Platform=$(Platform)</SlnProperties>
34    <SlnProperties Condition="'$(OPENRCT2_BUILD_SERVER)'!=''">$(SlnProperties);OPENRCT2_CL_ADDITIONALOPTIONS=$(OPENRCT2_CL_ADDITIONALOPTIONS)</SlnProperties>
35  </PropertyGroup>
36
37  <!-- 3rd party libraries / dependencies -->
38  <PropertyGroup>
39    <DependenciesCheckFile>$(RootDir).dependencies</DependenciesCheckFile>
40    <LibsUrl Condition="'$(Platform)'=='Win32'">https://github.com/OpenRCT2/Dependencies/releases/download/v26/openrct2-libs-v26-x86-windows-static.zip</LibsUrl>
41    <LibsSha1 Condition="'$(Platform)'=='Win32'">d7445387108b70fb23ccc06b73c8bdd8a44a0706</LibsSha1>
42    <LibsUrl Condition="'$(Platform)'=='x64'">https://github.com/OpenRCT2/Dependencies/releases/download/v26/openrct2-libs-v26-x64-windows-static.zip</LibsUrl>
43    <LibsSha1 Condition="'$(Platform)'=='x64'">6ebb2866211be6458cb4219271a636abc69fa54a</LibsSha1>
44    <GtestVersion>2fe3bd994b3189899d93f1d5a881e725e046fdc2</GtestVersion>
45    <GtestUrl>https://github.com/google/googletest/archive/$(GtestVersion).zip</GtestUrl>
46    <GtestSha1>058b9df80244c03f1633cb06e9f70471a29ebb8e</GtestSha1>
47    <TitleSequencesUrl>https://github.com/OpenRCT2/title-sequences/releases/download/v0.1.2c/title-sequences.zip</TitleSequencesUrl>
48    <TitleSequencesSha1>304d13a126c15bf2c86ff13b81a2f2cc1856ac8d</TitleSequencesSha1>
49    <ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.0.21/objects.zip</ObjectsUrl>
50    <ObjectsSha1>c38af45d51a6e440386180feacf76c64720b6ac5</ObjectsSha1>
51    <ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.57/replays.zip</ReplaysUrl>
52    <ReplaysSha1>DF9C3B48755B19FDD4D0EC721007B98CD5B6F420</ReplaysSha1>
53  </PropertyGroup>
54
55  <ItemGroup>
56    <g2Inputs Include="$(RootDir)resources\g2\*" />
57  </ItemGroup>
58
59  <Target Name="DownloadLibs">
60    <!-- libs -->
61    <DownloadDependency Name="Libs"
62                        Url="$(LibsUrl)"
63                        Sha1="$(LibsSha1)"
64                        CheckFile="$(DependenciesCheckFile)"
65                        OutputDirectory="$(RootDir)lib\$(Platform)" />
66
67    <!-- googletest -->
68    <DownloadDependency Name="googletest"
69                        Url="$(GtestUrl)"
70                        Sha1="$(GtestSha1)"
71                        CheckFile="$(DependenciesCheckFile)"
72                        OutputDirectory="$(RootDir)lib" />
73    <PropertyGroup>
74      <GtestSrc>$(RootDir)lib\googletest-$(GtestVersion)</GtestSrc>
75      <GtestDst>$(RootDir)lib\googletest</GtestDst>
76    </PropertyGroup>
77    <Exec Command="cmd /c &quot;if exist &quot;$(GtestSrc)&quot; ( rmdir /S /Q &quot;$(GtestDst)&quot; 2> nul &amp; move &quot;$(GtestSrc)&quot; &quot;$(GtestDst)&quot; )&quot;" />
78  </Target>
79
80  <Target Name="Clean">
81    <PropertyGroup>
82      <SlnProperties>$(SlnProperties);Configuration=$(Configuration)</SlnProperties>
83    </PropertyGroup>
84    <Delete Files="@(CleanItems)" />
85    <RemoveDir Directories="$(TargetDir)data" />
86    <MSBuild Projects="openrct2.sln" Targets="Clean" Properties="$(SlnProperties)" />
87  </Target>
88
89  <Target Name="BeforeBuild" BeforeTargets="Build;Rebuild" DependsOnTargets="DownloadLibs">
90    <PropertyGroup>
91      <BuildString Condition="'$(OPENRCT2_SHA1_SHORT)'!=''">$(OPENRCT2_SHA1_SHORT)</BuildString>
92      <BuildString Condition="'$(OPENRCT2_BRANCH)'!=''">$(BuildString) ($(OPENRCT2_BRANCH))</BuildString>
93      <BuildString Condition="'$(OPENRCT2_DESCRIBE)'!=''">$(BuildString) ($(OPENRCT2_DESCRIBE))</BuildString>
94    </PropertyGroup>
95    <ItemGroup>
96      <DataItems Include="$(RootDir)data\**\*" />
97    </ItemGroup>
98    <Message Condition="'$(BuildString)'!=''" Text="Building $(BuildString)" Importance="high" />
99    <Copy SourceFiles="@(CopyItems)" DestinationFolder="$(TargetDir)" SkipUnchangedFiles="true" />
100    <Copy SourceFiles="@(DataItems)" DestinationFolder="$(TargetDir)data\%(RecursiveDir)" SkipUnchangedFiles="true" />
101  </Target>
102
103  <Target Name="Build">
104    <PropertyGroup>
105      <SlnProperties>$(SlnProperties);Configuration=$(Configuration)</SlnProperties>
106    </PropertyGroup>
107    <Message Text="SlnProperties: $(SlnProperties)" />
108    <MSBuild Projects="openrct2.sln" Targets="Build" Properties="$(SlnProperties)" />
109  </Target>
110  <Target Name="Rebuild">
111    <PropertyGroup>
112      <SlnProperties>$(SlnProperties);Configuration=$(Configuration)</SlnProperties>
113    </PropertyGroup>
114    <Message Text="SlnProperties: $(SlnProperties)" />
115    <MSBuild Projects="openrct2.sln" Targets="Rebuild" Properties="$(SlnProperties)" />
116  </Target>
117
118  <!-- Target to build g2.dat containing OpenRCT2 sprites -->
119  <Target Name="g2" AfterTargets="Build" Inputs="@(g2Inputs)" Outputs="$(g2Output)"
120          Condition="'$(TestConfig)'!='true'">
121    <Message Text="Building g2.dat..." Importance="high" />
122    <Exec Command="&quot;$(OutputExe)&quot; sprite build &quot;$(g2Output)&quot; &quot;$(RootDir)resources\g2\sprites.json&quot;"
123          StandardOutputImportance="normal" />
124  </Target>
125
126  <!-- Target to download the title sequences -->
127  <Target Name="DownloadTitleSequences" AfterTargets="Build">
128    <DownloadDependency Name="TitleSequences"
129                        Url="$(TitleSequencesUrl)"
130                        Sha1="$(TitleSequencesSha1)"
131                        CheckFile="$(DependenciesCheckFile)"
132                        OutputDirectory="$(TargetDir)data\sequence" />
133  </Target>
134
135  <!-- Target to download the objects -->
136  <Target Name="DownloadObjects" AfterTargets="Build">
137    <DownloadDependency Name="Objects"
138                        Url="$(ObjectsUrl)"
139                        Sha1="$(ObjectsSha1)"
140                        CheckFile="$(DependenciesCheckFile)"
141                        OutputDirectory="$(TargetDir)data\object" />
142  </Target>
143
144  <!-- Target to download replays -->
145  <Target Name="DownloadReplays" AfterTargets="Build">
146    <DownloadDependency Name="Replays"
147                        Url="$(ReplaysUrl)"
148                        Sha1="$(ReplaysSha1)"
149                        CheckFile="$(DependenciesCheckFile)"
150                        OutputDirectory="$(TargetDir)testdata\replays" />
151  </Target>
152</Project>
153