-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
190 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,3 +403,5 @@ tools/ | |
# Artifacts | ||
artifacts/ | ||
artifacts-*/ | ||
|
||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Library.SDL", "src\MonoGame.Library.SDL.csproj", "{F9BD9E87-2B0B-4CB8-9C39-3FACD66E14AF}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "build\Build.csproj", "{8363325E-56EB-4B87-B170-C28237FB80CC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F9BD9E87-2B0B-4CB8-9C39-3FACD66E14AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F9BD9E87-2B0B-4CB8-9C39-3FACD66E14AF}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F9BD9E87-2B0B-4CB8-9C39-3FACD66E14AF}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F9BD9E87-2B0B-4CB8-9C39-3FACD66E14AF}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{8363325E-56EB-4B87-B170-C28237FB80CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8363325E-56EB-4B87-B170-C28237FB80CC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8363325E-56EB-4B87-B170-C28237FB80CC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8363325E-56EB-4B87-B170-C28237FB80CC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dotnet run --project build/Build.csproj -- $args | ||
exit $LASTEXITCODE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dotnet run --project ./build/Build.csproj -- "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Using Include="Cake.Frosting" /> | ||
<Using Include="Cake.Common.Tools.DotNet" /> | ||
<Using Include="Cake.Common.Tools.DotNet.MSBuild" /> | ||
<Using Include="Cake.Common.Tools.DotNet.Pack" /> | ||
<Using Include="Cake.Common.IO" /> | ||
<Using Include="Cake.Common" /> | ||
<Using Include="Cake.Core" /> | ||
<Using Include="Cake.Core.Diagnostics" /> | ||
<Using Include="Cake.Core.IO" /> | ||
<Using Include="Cake.FileHelpers" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Cake.FileHelpers" Version="6.1.3" /> | ||
<PackageReference Include="Cake.Frosting" Version="3.1.0" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName("Build Linux")] | ||
public sealed class BuildLinuxTask : FrostingTask<BuildContext> | ||
{ | ||
public override bool ShouldRun(BuildContext context) => context.IsRunningOnLinux(); | ||
|
||
public override void Run(BuildContext context) | ||
{ | ||
// Build | ||
var buildDir = "sdl/build"; | ||
context.CreateDirectory(buildDir); | ||
context.StartProcess("cmake", new ProcessSettings { WorkingDirectory = buildDir, Arguments = "../ -DCMAKE_BUILD_TYPE=Release" }); | ||
context.StartProcess("make", new ProcessSettings { WorkingDirectory = buildDir }); | ||
|
||
// Copy artifact | ||
context.CreateDirectory(context.ArtifactsDir); | ||
foreach (var filePath in context.GetFiles(buildDir + "/*")) | ||
{ | ||
if (filePath.GetFilename().ToString().StartsWith("libSDL2-2.0.so.0.")) | ||
{ | ||
context.CopyFile(filePath, $"{context.ArtifactsDir}/libSDL2-2.0.so.0"); | ||
return; | ||
} | ||
} | ||
|
||
throw new Exception("Failed to locate the artifact file of libSDL2-2.0.so :/"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName("Build macOS")] | ||
public sealed class BuildMacOSTask : FrostingTask<BuildContext> | ||
{ | ||
public override bool ShouldRun(BuildContext context) => context.IsRunningOnMacOs(); | ||
|
||
public override void Run(BuildContext context) | ||
{ | ||
// Build | ||
var buildDir = "sdl/build"; | ||
context.CreateDirectory(buildDir); | ||
context.StartProcess("cmake", new ProcessSettings { WorkingDirectory = buildDir, Arguments = "../ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 -DCMAKE_OSX_ARCHITECTURES=arm64;x86_64 -DCMAKE_BUILD_TYPE=Release" }); | ||
context.StartProcess("make", new ProcessSettings { WorkingDirectory = buildDir }); | ||
|
||
// Copy artifact | ||
context.CreateDirectory(context.ArtifactsDir); | ||
context.CopyFile("sdl/build/libSDL2-2.0.0.dylib", $"{context.ArtifactsDir}/libSDL2-2.0.0.dylib"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName("Build Windows")] | ||
public sealed class BuildWindowsTask : FrostingTask<BuildContext> | ||
{ | ||
public override bool ShouldRun(BuildContext context) => context.IsRunningOnWindows(); | ||
|
||
public override void Run(BuildContext context) | ||
{ | ||
// Build | ||
var buildDir = "sdl/build"; | ||
context.CreateDirectory(buildDir); | ||
context.StartProcess("cmake", new ProcessSettings { WorkingDirectory = buildDir, Arguments = "-A x64 ../" }); | ||
context.StartProcess("msbuild", new ProcessSettings { WorkingDirectory = buildDir, Arguments = "SDL2.sln /p:Configuration=Release" }); | ||
|
||
// Copy artifact | ||
context.CreateDirectory(context.ArtifactsDir); | ||
context.CopyFile("sdl/build/Release/SDL2.dll", $"{context.ArtifactsDir}/SDL2.dll"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
namespace BuildScripts; | ||
|
||
[TaskName("Package")] | ||
public sealed class PackageTask : FrostingTask<BuildContext> | ||
{ | ||
public override bool ShouldRun(BuildContext context) => context.IsRunningOnLinux(); | ||
|
||
public override void Run(BuildContext context) | ||
{ | ||
var sdlMajor = context.FindRegexMatchGroupInFile("sdl/include/SDL_version.h", @"#define SDL_MAJOR_VERSION +(?<ver>\d+)", 1, System.Text.RegularExpressions.RegexOptions.Singleline); | ||
var sdlMinor = context.FindRegexMatchGroupInFile("sdl/include/SDL_version.h", @"#define SDL_MINOR_VERSION +(?<ver>\d+)", 1, System.Text.RegularExpressions.RegexOptions.Singleline); | ||
var sdlPatch = context.FindRegexMatchGroupInFile("sdl/include/SDL_version.h", @"#define SDL_PATCHLEVEL +(?<ver>\d+)", 1, System.Text.RegularExpressions.RegexOptions.Singleline); | ||
var sdlVersion = $"{sdlMajor}.{sdlMinor}.{sdlPatch}"; | ||
var dnMsBuildSettings = new DotNetMSBuildSettings(); | ||
dnMsBuildSettings.WithProperty("Version", sdlVersion + "." + context.EnvironmentVariable("GITHUB_RUN_NUMBER")); | ||
dnMsBuildSettings.WithProperty("RepositoryUrl", "https://github.com/" + context.EnvironmentVariable("GITHUB_REPOSITORY")); | ||
|
||
context.DotNetPack("MonoGame.Library.SDL.csproj", new DotNetPackSettings | ||
{ | ||
MSBuildSettings = dnMsBuildSettings, | ||
Verbosity = DotNetVerbosity.Minimal, | ||
Configuration = "Release" | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
namespace BuildScripts; | ||
|
||
public static class Program | ||
{ | ||
public static int Main(string[] args) | ||
=> new CakeHost() | ||
.UseWorkingDirectory("../") | ||
.UseContext<BuildContext>() | ||
.Run(args); | ||
|
||
public static string GetArgument(this ICakeArguments args, string argName, string defaultArgValue) | ||
=> args.HasArgument(argName) ? args.GetArgument(argName) : defaultArgValue; | ||
} | ||
|
||
public class BuildContext : FrostingContext | ||
{ | ||
public string ArtifactsDir { get; } | ||
|
||
public BuildContext(ICakeContext context) : base(context) | ||
{ | ||
ArtifactsDir = context.Arguments.GetArgument("artifactsDir", "artifacts"); | ||
} | ||
} | ||
|
||
[TaskName("Default")] | ||
[IsDependentOn(typeof(BuildWindowsTask))] | ||
[IsDependentOn(typeof(BuildMacOSTask))] | ||
[IsDependentOn(typeof(BuildLinuxTask))] | ||
public class DefaultTask : FrostingTask | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters