1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Add project for dependencies, restructure targets and cleanup unused

This commit is contained in:
ζeh Matt
2025-04-23 00:32:16 +03:00
parent d0cf4b5cc5
commit 1e2d94fc95
11 changed files with 432 additions and 433 deletions

298
openrct2.deps.targets Normal file
View File

@@ -0,0 +1,298 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- DownloadDependency task -->
<UsingTask TaskName="DownloadDependency"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Name Required="true" ParameterType="System.String" />
<Url Required="true" ParameterType="System.String" />
<Sha1 Required="true" ParameterType="System.String" />
<CheckFile Required="false" ParameterType="System.String" />
<OutputDirectory Required="true" ParameterType="System.String" />
</ParameterGroup>
<Task>
<Reference Include="System.IO.Compression, Version=4.0.0.0" />
<Reference Include="System.IO.Compression.FileSystem" />
<Using Namespace="System"/>
<Using Namespace="System.IO"/>
<Using Namespace="System.IO.Compression"/>
<Using Namespace="System.Net"/>
<Using Namespace="System.Text"/>
<Using Namespace="Microsoft.Build.Framework"/>
<Using Namespace="Microsoft.Build.Utilities"/>
<Code Type="Method" Language="cs">
<![CDATA[
public override bool Execute()
{
if (!String.IsNullOrEmpty(CheckFile))
{
string checkSha1 = GetSha1FromCheckFile(CheckFile, Name);
if (String.Equals(checkSha1, Sha1, StringComparison.OrdinalIgnoreCase) && Directory.Exists(OutputDirectory))
{
Log.LogMessage(MessageImportance.Normal, String.Format("{0} up to date", Name));
return true;
}
}
string tempFile = Path.GetTempFileName();
try
{
// Download the file
Log.LogMessage(MessageImportance.Normal, String.Format("Downloading '{0}'.", Url));
var client = new WebClient();
client.DownloadFile(Url, tempFile);
// Check the file matches
string actualSha1;
if (!CheckFileSha1(tempFile, Sha1, out actualSha1))
{
Log.LogError("Download file did not match expected SHA1\n expected: {0}\n actual: {1}", Sha1, actualSha1);
return false;
}
// Extract contents
Log.LogMessage(MessageImportance.Normal, String.Format("Extracting to '{0}'.", OutputDirectory));
if (!Directory.Exists(OutputDirectory))
{
Directory.CreateDirectory(OutputDirectory);
}
ExtractZip(tempFile, OutputDirectory, overwrite: true);
SetSha1InCheckFile(CheckFile, Name, Sha1);
}
catch (Exception ex)
{
Log.LogErrorFromException(ex, showStackTrace: false);
}
finally
{
try
{
File.Delete(tempFile);
}
catch
{
}
}
return true;
}
private string GetSha1FromCheckFile(string checkFile, string name)
{
string result = null;
try
{
if (File.Exists(checkFile))
{
string[] lines = File.ReadAllLines(checkFile);
string sha1;
GetCheckFileLineIndexSha1(lines, name, out sha1);
return sha1;
}
}
catch (Exception ex)
{
Log.LogWarningFromException(ex, showStackTrace: false);
}
return result;
}
private void SetSha1InCheckFile(string checkFile, string name, string sha1)
{
try
{
string newLine = String.Format("{0} = {1}", name, sha1.ToLower());
string[] lines = new string[0];
int lineIndex = -1;
if (File.Exists(checkFile))
{
lines = File.ReadAllLines(checkFile);
string oldsha1;
lineIndex = GetCheckFileLineIndexSha1(lines, name, out oldsha1);
}
if (lineIndex == -1)
{
if (lines.Length == 0 || lines[lines.Length - 1].Trim().Length > 0)
{
Array.Resize(ref lines, lines.Length + 1);
}
lineIndex = lines.Length - 1;
// End with new line
Array.Resize(ref lines, lines.Length + 1);
}
lines[lineIndex] = newLine;
File.WriteAllLines(checkFile, lines);
}
catch (Exception ex)
{
Log.LogWarningFromException(ex, showStackTrace: false);
}
}
private int GetCheckFileLineIndexSha1(string[] lines, string name, out string sha1)
{
for (int i = 0; i < lines.Length; i++)
{
string line = lines[i];
string[] lineParts = line.Split('=');
if (lineParts.Length == 2)
{
string lineTag = lineParts[0].Trim();
string lineSha1 = lineParts[1].Trim();
if (lineTag == name)
{
sha1 = lineSha1;
return i;
}
}
}
sha1 = null;
return -1;
}
private bool CheckFileSha1(string file, string expectedSha1, out string actualSha1)
{
using (var fs = new FileStream(file, FileMode.Open))
{
var hasher = System.Security.Cryptography.SHA1.Create();
byte[] hash = hasher.ComputeHash(fs);
actualSha1 = BytesToHexString(hash);
if (String.Equals(actualSha1, expectedSha1, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
private string BytesToHexString(byte[] data)
{
var sb = new StringBuilder();
foreach (byte b in data)
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
private static void ExtractZip(string zipPath, string destinationDirectory, bool overwrite)
{
var archive = ZipFile.OpenRead(zipPath);
if (!overwrite)
{
archive.ExtractToDirectory(destinationDirectory);
return;
}
foreach (ZipArchiveEntry file in archive.Entries)
{
string fileName = Path.Combine(destinationDirectory, file.FullName);
string directory = Path.GetDirectoryName(fileName);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
if (file.Name != String.Empty)
{
file.ExtractToFile(fileName, true);
}
}
}
]]>
</Code>
</Task>
</UsingTask>
<!-- 3rd party libraries / dependencies -->
<PropertyGroup>
<RootDir>$(MsBuildThisFileDirectory)</RootDir>
<DependenciesCheckFile>$(RootDir).dependencies</DependenciesCheckFile>
<LibsUrl Condition="'$(Platform)'=='ARM64'">https://github.com/OpenRCT2/Dependencies/releases/download/v37/openrct2-libs-v37-arm64-windows-static.zip</LibsUrl>
<LibsSha1 Condition="'$(Platform)'=='ARM64'">508bbd39b9be3d746ed8e17b6c0e7a79f6fa13c8</LibsSha1>
<LibsUrl Condition="'$(Platform)'=='x64'">https://github.com/OpenRCT2/Dependencies/releases/download/v37/openrct2-libs-v37-x64-windows-static.zip</LibsUrl>
<LibsSha1 Condition="'$(Platform)'=='x64'">28fabdb3fe8ddb7c73cd1c5e57ec8df5bd6232e5</LibsSha1>
<LibsUrl Condition="'$(Platform)'=='Win32'">https://github.com/OpenRCT2/Dependencies/releases/download/v37/openrct2-libs-v37-x86-windows-static.zip</LibsUrl>
<LibsSha1 Condition="'$(Platform)'=='Win32'">9984c1e317dcfb3aaf8e17f1db2ebb0f771e2373</LibsSha1>
<TitleSequencesUrl>https://github.com/OpenRCT2/title-sequences/releases/download/v0.4.14/title-sequences.zip</TitleSequencesUrl>
<TitleSequencesSha1>6c04781b959b468e1f65ec2d2f21f5aaa5e5724d</TitleSequencesSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.6.1/objects.zip</ObjectsUrl>
<ObjectsSha1>749a9df9ed728676ef7c3b87c8a6b813069476d3</ObjectsSha1>
<OpenSFXUrl>https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v1.0.5/opensound.zip</OpenSFXUrl>
<OpenSFXSha1>b1b1f1b241d2cbff63a1889c4dc5a09bdf769bfb</OpenSFXSha1>
<OpenMSXUrl>https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6/openmusic.zip</OpenMSXUrl>
<OpenMSXSha1>ba170fa6d777b309c15420f4b6eb3fa25082a9d1</OpenMSXSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.87/replays.zip</ReplaysUrl>
<ReplaysSha1>6061B53DE346BD853BB997E635AC7374B1A7D2F0</ReplaysSha1>
</PropertyGroup>
<!-- Unified Dependency Target -->
<Target Name="DownloadAllDependencies"
BeforeTargets="PrepareForBuild"
DependsOnTargets="DownloadLibs;DownloadTitleSequences;DownloadObjects;DownloadOpenSFX;DownloadOpenMSX;DownloadReplays">
<!-- Add completion marker -->
<Touch Files="$(DependenciesCheckFile)" AlwaysCreate="true" />
</Target>
<!-- Target Implementations -->
<Target Name="DownloadLibs">
<!-- libs -->
<DownloadDependency Name="Libs"
Url="$(LibsUrl)"
Sha1="$(LibsSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(RootDir)lib\$(Platform)" />
</Target>
<!-- Target to download the title sequences -->
<Target Name="DownloadTitleSequences">
<DownloadDependency Name="TitleSequences"
Url="$(TitleSequencesUrl)"
Sha1="$(TitleSequencesSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)data\sequence" />
</Target>
<!-- Target to download the objects -->
<Target Name="DownloadObjects">
<DownloadDependency Name="Objects"
Url="$(ObjectsUrl)"
Sha1="$(ObjectsSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)data\object" />
</Target>
<!-- Target to download OpenSFX -->
<Target Name="DownloadOpenSFX">
<DownloadDependency Name="OpenSFX"
Url="$(OpenSFXUrl)"
Sha1="$(OpenSFXSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)data" />
</Target>
<!-- Target to download OpenMSX -->
<Target Name="DownloadOpenMSX">
<DownloadDependency Name="OpenMSX"
Url="$(OpenMSXUrl)"
Sha1="$(OpenMSXSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)data" />
</Target>
<!-- Target to download replays -->
<Target Name="DownloadReplays">
<DownloadDependency Name="Replays"
Url="$(ReplaysUrl)"
Sha1="$(ReplaysSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)testdata\replays" />
</Target>
</Project>

View File

@@ -30,36 +30,6 @@
<SlnProperties Condition="'$(OPENRCT2_BUILD_SERVER)'!=''">$(SlnProperties);OPENRCT2_CL_ADDITIONALOPTIONS=$(OPENRCT2_CL_ADDITIONALOPTIONS)</SlnProperties>
</PropertyGroup>
<!-- 3rd party libraries / dependencies -->
<PropertyGroup>
<DependenciesCheckFile>$(RootDir).dependencies</DependenciesCheckFile>
<LibsUrl Condition="'$(Platform)'=='ARM64'">https://github.com/OpenRCT2/Dependencies/releases/download/v37/openrct2-libs-v37-arm64-windows-static.zip</LibsUrl>
<LibsSha1 Condition="'$(Platform)'=='ARM64'">508bbd39b9be3d746ed8e17b6c0e7a79f6fa13c8</LibsSha1>
<LibsUrl Condition="'$(Platform)'=='x64'">https://github.com/OpenRCT2/Dependencies/releases/download/v37/openrct2-libs-v37-x64-windows-static.zip</LibsUrl>
<LibsSha1 Condition="'$(Platform)'=='x64'">28fabdb3fe8ddb7c73cd1c5e57ec8df5bd6232e5</LibsSha1>
<LibsUrl Condition="'$(Platform)'=='Win32'">https://github.com/OpenRCT2/Dependencies/releases/download/v37/openrct2-libs-v37-x86-windows-static.zip</LibsUrl>
<LibsSha1 Condition="'$(Platform)'=='Win32'">9984c1e317dcfb3aaf8e17f1db2ebb0f771e2373</LibsSha1>
<TitleSequencesUrl>https://github.com/OpenRCT2/title-sequences/releases/download/v0.4.14/title-sequences.zip</TitleSequencesUrl>
<TitleSequencesSha1>6c04781b959b468e1f65ec2d2f21f5aaa5e5724d</TitleSequencesSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.6.1/objects.zip</ObjectsUrl>
<ObjectsSha1>749a9df9ed728676ef7c3b87c8a6b813069476d3</ObjectsSha1>
<OpenSFXUrl>https://github.com/OpenRCT2/OpenSoundEffects/releases/download/v1.0.5/opensound.zip</OpenSFXUrl>
<OpenSFXSha1>b1b1f1b241d2cbff63a1889c4dc5a09bdf769bfb</OpenSFXSha1>
<OpenMSXUrl>https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6/openmusic.zip</OpenMSXUrl>
<OpenMSXSha1>ba170fa6d777b309c15420f4b6eb3fa25082a9d1</OpenMSXSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.87/replays.zip</ReplaysUrl>
<ReplaysSha1>6061B53DE346BD853BB997E635AC7374B1A7D2F0</ReplaysSha1>
</PropertyGroup>
<Target Name="DownloadLibs">
<!-- libs -->
<DownloadDependency Name="Libs"
Url="$(LibsUrl)"
Sha1="$(LibsSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(RootDir)lib\$(Platform)" />
</Target>
<Target Name="Clean">
<PropertyGroup>
<SlnProperties>$(SlnProperties);Configuration=$(Configuration)</SlnProperties>
@@ -93,53 +63,9 @@
<Message Text="SlnProperties: $(SlnProperties)" />
<MSBuild Projects="openrct2.sln" Targets="Rebuild" Properties="$(SlnProperties);IsSolutionBuild=true" />
</Target>
<!-- Target to download the title sequences -->
<Target Name="DownloadTitleSequences" AfterTargets="Build">
<DownloadDependency Name="TitleSequences"
Url="$(TitleSequencesUrl)"
Sha1="$(TitleSequencesSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)data\sequence" />
</Target>
<!-- Target to download the objects -->
<Target Name="DownloadObjects" AfterTargets="Build">
<DownloadDependency Name="Objects"
Url="$(ObjectsUrl)"
Sha1="$(ObjectsSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)data\object" />
</Target>
<!-- Target to download OpenSFX -->
<Target Name="DownloadOpenSFX" AfterTargets="Build">
<DownloadDependency Name="OpenSFX"
Url="$(OpenSFXUrl)"
Sha1="$(OpenSFXSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)data" />
</Target>
<!-- Target to download OpenMSX -->
<Target Name="DownloadOpenMSX" AfterTargets="Build">
<DownloadDependency Name="OpenMSX"
Url="$(OpenMSXUrl)"
Sha1="$(OpenMSXSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)data" />
</Target>
<!-- Target to download replays -->
<Target Name="DownloadReplays" AfterTargets="Build">
<DownloadDependency Name="Replays"
Url="$(ReplaysUrl)"
Sha1="$(ReplaysSha1)"
CheckFile="$(DependenciesCheckFile)"
OutputDirectory="$(TargetDir)testdata\replays" />
</Target>
<!-- Import custom build tasks -->
<Import Project="openrct2.deps.targets" />
<Import Project="openrct2.targets" />
</Project>

View File

@@ -4,21 +4,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenrct2", "src\openrct2\libopenrct2.vcxproj", "{D24D94F6-2A74-480C-B512-629C306CE92F}"
ProjectSection(ProjectDependencies) = postProject
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5} = {C453DA76-44B3-4AC8-AAA2-2B64A76993A5}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-win", "src\openrct2-win\openrct2-win.vcxproj", "{7A9A57D5-7006-4208-A290-5491BA3C8808}"
ProjectSection(ProjectDependencies) = postProject
{8DD8AB7D-2EA6-44E3-8265-BAF08E832951} = {8DD8AB7D-2EA6-44E3-8265-BAF08E832951}
{B6808F71-30B4-4499-8FF6-0B1C86391842} = {B6808F71-30B4-4499-8FF6-0B1C86391842}
{D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tests", "test\tests\tests.vcxproj", "{62B020FA-E4FB-4C6E-B32A-DC999470F155}"
ProjectSection(ProjectDependencies) = postProject
{7A9A57D5-7006-4208-A290-5491BA3C8808} = {7A9A57D5-7006-4208-A290-5491BA3C8808}
{8DD8AB7D-2EA6-44E3-8265-BAF08E832951} = {8DD8AB7D-2EA6-44E3-8265-BAF08E832951}
{B6808F71-30B4-4499-8FF6-0B1C86391842} = {B6808F71-30B4-4499-8FF6-0B1C86391842}
{D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{2202A816-377D-4FA0-A7AF-7D4105F8A4FB}"
EndProject
@@ -27,17 +19,10 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopenrct2ui", "src\openrct2-ui\libopenrct2ui.vcxproj", "{8DD8AB7D-2EA6-44E3-8265-BAF08E832951}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-cli", "src\openrct2-cli\openrct2-cli.vcxproj", "{B6808F71-30B4-4499-8FF6-0B1C86391842}"
ProjectSection(ProjectDependencies) = postProject
{D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-data", "src\openrct2-data\openrct2-data.vcxproj", "{70EEED2D-2344-4F28-87B7-3EFC4E78B923}"
ProjectSection(ProjectDependencies) = postProject
{7A9A57D5-7006-4208-A290-5491BA3C8808} = {7A9A57D5-7006-4208-A290-5491BA3C8808}
{8DD8AB7D-2EA6-44E3-8265-BAF08E832951} = {8DD8AB7D-2EA6-44E3-8265-BAF08E832951}
{B6808F71-30B4-4499-8FF6-0B1C86391842} = {B6808F71-30B4-4499-8FF6-0B1C86391842}
{D24D94F6-2A74-480C-B512-629C306CE92F} = {D24D94F6-2A74-480C-B512-629C306CE92F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openrct2-deps", "src\openrct2-deps\openrct2-deps.vcxproj", "{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -160,6 +145,24 @@ Global
{70EEED2D-2344-4F28-87B7-3EFC4E78B923}.ReleaseLTCG|Win32.Build.0 = Release|Win32
{70EEED2D-2344-4F28-87B7-3EFC4E78B923}.ReleaseLTCG|x64.ActiveCfg = Release|x64
{70EEED2D-2344-4F28-87B7-3EFC4E78B923}.ReleaseLTCG|x64.Build.0 = Release|x64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Debug|arm64.ActiveCfg = Debug|arm64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Debug|arm64.Build.0 = Debug|arm64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Debug|Win32.ActiveCfg = Debug|Win32
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Debug|Win32.Build.0 = Debug|Win32
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Debug|x64.ActiveCfg = Debug|x64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Debug|x64.Build.0 = Debug|x64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Release|arm64.ActiveCfg = Release|arm64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Release|arm64.Build.0 = Release|arm64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Release|Win32.ActiveCfg = Release|Win32
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Release|Win32.Build.0 = Release|Win32
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Release|x64.ActiveCfg = Release|x64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.Release|x64.Build.0 = Release|x64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.ReleaseLTCG|arm64.ActiveCfg = ReleaseLTCG|arm64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.ReleaseLTCG|arm64.Build.0 = ReleaseLTCG|arm64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.ReleaseLTCG|Win32.ActiveCfg = ReleaseLTCG|Win32
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.ReleaseLTCG|Win32.Build.0 = ReleaseLTCG|Win32
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.ReleaseLTCG|x64.ActiveCfg = ReleaseLTCG|x64
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5}.ReleaseLTCG|x64.Build.0 = ReleaseLTCG|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -171,6 +174,7 @@ Global
{8DD8AB7D-2EA6-44E3-8265-BAF08E832951} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB}
{B6808F71-30B4-4499-8FF6-0B1C86391842} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB}
{70EEED2D-2344-4F28-87B7-3EFC4E78B923} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB}
{C453DA76-44B3-4AC8-AAA2-2B64A76993A5} = {2202A816-377D-4FA0-A7AF-7D4105F8A4FB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AE225595-70B7-4580-92EF-6F2B461EBFC7}

View File

@@ -1,335 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- 7z Task -->
<UsingTask TaskName="_7z"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Inputs Required="true" ParameterType="System.String" />
<Output Required="true" ParameterType="System.String" />
</ParameterGroup>
<Task>
<Using Namespace="System"/>
<Using Namespace="System.Diagnostics"/>
<Using Namespace="System.IO"/>
<Code Type="Method" Language="cs">
<![CDATA[
public override bool Execute()
{
string appPath = Find7zPath();
if (appPath == null)
{
Log.LogError("Unable to find 7z.exe.");
return false;
}
var argsSB = new StringBuilder();
argsSB.Append("a -tzip -mx9 -mtc=off ");
argsSB.Append("\"" + Output + "\" ");
foreach (string input in Inputs.Split(';'))
{
argsSB.Append("\"" + input + "\" ");
}
string args = argsSB.ToString();
Log.LogMessage(MessageImportance.Normal, "7z " + args);
var psi = new ProcessStartInfo(appPath, args);
psi.CreateNoWindow = true;
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
var process = Process.Start(psi);
process.WaitForExit();
if (process.ExitCode != 0)
{
string appError = process.StandardError.ReadToEnd();
appError = appError.Replace("\r\n", "\n");
appError = appError.Replace("\r", "\n");
appError = appError.Replace("\n", " ");
int colonIndex = appError.IndexOf(":");
if (colonIndex != -1)
{
appError = appError.Substring(colonIndex + 1);
}
appError = appError.Trim();
Log.LogError(appError);
return false;
}
string appOutput = process.StandardOutput.ReadToEnd();
Log.LogMessage(MessageImportance.Normal, appOutput);
return true;
}
private string Find7zPath()
{
const string DefaultAppFileName = "7z.exe";
string DefaultAppPath = Path.Combine("7-Zip", DefaultAppFileName);
// HACK needed as SpecialFolder.ProgramFiles returns x86 for a 32-bit process
string programFiles = Path.Combine(Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)), "Program Files");
string appPath = Path.Combine(programFiles, DefaultAppPath);
if (File.Exists(appPath))
{
return appPath;
}
programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
appPath = Path.Combine(programFiles, DefaultAppPath);
if (File.Exists(appPath))
{
return appPath;
}
programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
appPath = Path.Combine(programFiles, DefaultAppPath);
if (File.Exists(appPath))
{
return appPath;
}
string[] envPaths = Environment.GetEnvironmentVariable("PATH").Split(';');
foreach (string envPath in envPaths)
{
appPath = Path.Combine(envPath, DefaultAppFileName);
if (File.Exists(appPath))
{
return appPath;
}
}
return null;
}
]]>
</Code>
</Task>
</UsingTask>
<!-- Unzip task -->
<UsingTask TaskName="Unzip"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Input Required="true" ParameterType="System.String" />
<OutputDirectory Required="true" ParameterType="System.String" />
</ParameterGroup>
<Task>
<Reference Include="System.IO.Compression.FileSystem" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Log.LogMessage(MessageImportance.Normal, String.Format("Extracting '{0}' to '{1}'.", Input, OutputDirectory));
System.IO.Compression.ZipFile.ExtractToDirectory(Input, OutputDirectory);
]]>
</Code>
</Task>
</UsingTask>
<!-- DownloadDependency task -->
<UsingTask TaskName="DownloadDependency"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Name Required="true" ParameterType="System.String" />
<Url Required="true" ParameterType="System.String" />
<Sha1 Required="true" ParameterType="System.String" />
<CheckFile Required="false" ParameterType="System.String" />
<OutputDirectory Required="true" ParameterType="System.String" />
</ParameterGroup>
<Task>
<Reference Include="System.IO.Compression, Version=4.0.0.0" />
<Reference Include="System.IO.Compression.FileSystem" />
<Using Namespace="System"/>
<Using Namespace="System.IO"/>
<Using Namespace="System.IO.Compression"/>
<Using Namespace="System.Net"/>
<Using Namespace="System.Text"/>
<Using Namespace="Microsoft.Build.Framework"/>
<Using Namespace="Microsoft.Build.Utilities"/>
<Code Type="Method" Language="cs">
<![CDATA[
public override bool Execute()
{
if (!String.IsNullOrEmpty(CheckFile))
{
string checkSha1 = GetSha1FromCheckFile(CheckFile, Name);
if (String.Equals(checkSha1, Sha1, StringComparison.OrdinalIgnoreCase) && Directory.Exists(OutputDirectory))
{
Log.LogMessage(MessageImportance.Normal, String.Format("{0} up to date", Name));
return true;
}
}
string tempFile = Path.GetTempFileName();
try
{
// Download the file
Log.LogMessage(MessageImportance.Normal, String.Format("Downloading '{0}'.", Url));
var client = new WebClient();
client.DownloadFile(Url, tempFile);
// Check the file matches
string actualSha1;
if (!CheckFileSha1(tempFile, Sha1, out actualSha1))
{
Log.LogError("Download file did not match expected SHA1\n expected: {0}\n actual: {1}", Sha1, actualSha1);
return false;
}
// Extract contents
Log.LogMessage(MessageImportance.Normal, String.Format("Extracting to '{0}'.", OutputDirectory));
if (!Directory.Exists(OutputDirectory))
{
Directory.CreateDirectory(OutputDirectory);
}
ExtractZip(tempFile, OutputDirectory, overwrite: true);
SetSha1InCheckFile(CheckFile, Name, Sha1);
}
catch (Exception ex)
{
Log.LogErrorFromException(ex, showStackTrace: false);
}
finally
{
try
{
File.Delete(tempFile);
}
catch
{
}
}
return true;
}
private string GetSha1FromCheckFile(string checkFile, string name)
{
string result = null;
try
{
if (File.Exists(checkFile))
{
string[] lines = File.ReadAllLines(checkFile);
string sha1;
GetCheckFileLineIndexSha1(lines, name, out sha1);
return sha1;
}
}
catch (Exception ex)
{
Log.LogWarningFromException(ex, showStackTrace: false);
}
return result;
}
private void SetSha1InCheckFile(string checkFile, string name, string sha1)
{
try
{
string newLine = String.Format("{0} = {1}", name, sha1.ToLower());
string[] lines = new string[0];
int lineIndex = -1;
if (File.Exists(checkFile))
{
lines = File.ReadAllLines(checkFile);
string oldsha1;
lineIndex = GetCheckFileLineIndexSha1(lines, name, out oldsha1);
}
if (lineIndex == -1)
{
if (lines.Length == 0 || lines[lines.Length - 1].Trim().Length > 0)
{
Array.Resize(ref lines, lines.Length + 1);
}
lineIndex = lines.Length - 1;
// End with new line
Array.Resize(ref lines, lines.Length + 1);
}
lines[lineIndex] = newLine;
File.WriteAllLines(checkFile, lines);
}
catch (Exception ex)
{
Log.LogWarningFromException(ex, showStackTrace: false);
}
}
private int GetCheckFileLineIndexSha1(string[] lines, string name, out string sha1)
{
for (int i = 0; i < lines.Length; i++)
{
string line = lines[i];
string[] lineParts = line.Split('=');
if (lineParts.Length == 2)
{
string lineTag = lineParts[0].Trim();
string lineSha1 = lineParts[1].Trim();
if (lineTag == name)
{
sha1 = lineSha1;
return i;
}
}
}
sha1 = null;
return -1;
}
private bool CheckFileSha1(string file, string expectedSha1, out string actualSha1)
{
using (var fs = new FileStream(file, FileMode.Open))
{
var hasher = System.Security.Cryptography.SHA1.Create();
byte[] hash = hasher.ComputeHash(fs);
actualSha1 = BytesToHexString(hash);
if (String.Equals(actualSha1, expectedSha1, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
private string BytesToHexString(byte[] data)
{
var sb = new StringBuilder();
foreach (byte b in data)
{
sb.Append(b.ToString("x2"));
}
return sb.ToString();
}
private static void ExtractZip(string zipPath, string destinationDirectory, bool overwrite)
{
var archive = ZipFile.OpenRead(zipPath);
if (!overwrite)
{
archive.ExtractToDirectory(destinationDirectory);
return;
}
foreach (ZipArchiveEntry file in archive.Entries)
{
string fileName = Path.Combine(destinationDirectory, file.FullName);
string directory = Path.GetDirectoryName(fileName);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
if (file.Name != String.Empty)
{
file.ExtractToFile(fileName, true);
}
}
}
]]>
</Code>
</Task>
</UsingTask>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Property Definitions with Default Values -->
<PropertyGroup>
<SolutionDir Condition="'$(SolutionDir)' == ''">$(MSBuildThisFileDirectory)</SolutionDir>
@@ -350,7 +20,7 @@
<G2InputFile Condition="'$(G2InputFile)' == ''">$(ResourcesG2Path)sprites.json</G2InputFile>
<DataOutputPath Condition="'$(DataOutputPath)' == ''">$(OutDir)data\</DataOutputPath>
</PropertyGroup>
<!-- File Group Definitions -->
<ItemGroup>
<G2Input Include="$(G2InputFile)" />

View File

@@ -75,5 +75,13 @@
<ItemGroup>
<ClCompile Include="Cli.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\openrct2-deps\openrct2-deps.vcxproj">
<Project>{c453da76-44b3-4ac8-aaa2-2b64a76993a5}</Project>
</ProjectReference>
<ProjectReference Include="..\openrct2\libopenrct2.vcxproj">
<Project>{d24d94f6-2a74-480c-b512-629c306ce92f}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@@ -38,24 +38,24 @@
<Platform>arm64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\openrct2-cli\openrct2-cli.vcxproj">
<Project>{b6808f71-30b4-4499-8ff6-0b1c86391842}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{70eeed2d-2344-4f28-87b7-3efc4e78b923}</ProjectGuid>
<RootNamespace>openrct2-data</RootNamespace>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
</PropertyGroup>
<Import Project="..\..\openrct2.common.props" />
<PropertyGroup>
<TargetName>openrct2-data</TargetName>
<LibraryPath>$(SolutionDir)bin;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<Import Project="..\..\openrct2.targets" Condition="'$(IsSolutionBuild)' != 'true'" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|arm64">
<Configuration>Debug</Configuration>
<Platform>arm64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseLTCG|arm64">
<Configuration>ReleaseLTCG</Configuration>
<Platform>arm64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseLTCG|Win32">
<Configuration>ReleaseLTCG</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="ReleaseLTCG|x64">
<Configuration>ReleaseLTCG</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|arm64">
<Configuration>Release</Configuration>
<Platform>arm64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{c453da76-44b3-4ac8-aaa2-2b64a76993a5}</ProjectGuid>
<RootNamespace>openrct2-deps</RootNamespace>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Utility</ConfigurationType>
</PropertyGroup>
<Import Project="..\..\openrct2.common.props" />
<PropertyGroup>
<TargetName>openrct2-deps</TargetName>
<LibraryPath>$(SolutionDir)bin;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<Import Project="..\..\openrct2.deps.targets" Condition="'$(IsSolutionBuild)' != 'true'" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@@ -238,6 +238,11 @@
<ClCompile Include="windows\Viewport.cpp" />
<ClCompile Include="windows\Water.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\openrct2-deps\openrct2-deps.vcxproj">
<Project>{c453da76-44b3-4ac8-aaa2-2b64a76993a5}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8DD8AB7D-2EA6-44E3-8265-BAF08E832951}</ProjectGuid>
<RootNamespace>openrct2-ui</RootNamespace>
@@ -263,4 +268,4 @@
</Lib>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>
</Project>

View File

@@ -78,5 +78,16 @@
<ItemGroup>
<Manifest Include="openrct2-win.manifest" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\openrct2-deps\openrct2-deps.vcxproj">
<Project>{c453da76-44b3-4ac8-aaa2-2b64a76993a5}</Project>
</ProjectReference>
<ProjectReference Include="..\openrct2-ui\libopenrct2ui.vcxproj">
<Project>{8dd8ab7d-2ea6-44e3-8265-baf08e832951}</Project>
</ProjectReference>
<ProjectReference Include="..\openrct2\libopenrct2.vcxproj">
<Project>{d24d94f6-2a74-480c-b512-629c306ce92f}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="'$(SolutionDir)'==''">..\..\</SolutionDir>
@@ -44,11 +45,13 @@
<ProjectGuid>{D24D94F6-2A74-480C-B512-629C306CE92F}</ProjectGuid>
<RootNamespace>openrct2-lib</RootNamespace>
<ProjectName>libopenrct2</ProjectName>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="..\..\openrct2.common.props" />
<Import Project="..\..\openrct2.deps.targets" Condition="'$(IsSolutionBuild)' != 'true'" />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>__ENABLE_DISCORD__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -1158,5 +1161,10 @@
<WarningLevel>TurnOffAllWarnings</WarningLevel>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\openrct2-deps\openrct2-deps.vcxproj">
<Project>{c453da76-44b3-4ac8-aaa2-2b64a76993a5}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>

View File

@@ -109,5 +109,13 @@
<None Include="testdata\sprites\example.dat" />
<None Include="testdata\sprites\manifest.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\openrct2-deps\openrct2-deps.vcxproj">
<Project>{c453da76-44b3-4ac8-aaa2-2b64a76993a5}</Project>
</ProjectReference>
<ProjectReference Include="..\..\src\openrct2\libopenrct2.vcxproj">
<Project>{d24d94f6-2a74-480c-b512-629c306ce92f}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>