Skip to content

Commit

Permalink
Initial Commit of code
Browse files Browse the repository at this point in the history
  • Loading branch information
dellis1972 committed Jun 12, 2024
1 parent 2bf4390 commit 45461b6
Show file tree
Hide file tree
Showing 9 changed files with 207 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build

on: [push, pull_request]

jobs:
build:
name: build-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
fail-fast: false
steps:
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3

- name: Install Mac Dependencies
if: runner.os == 'macOS'
run: |
brew install cmake autoconf automake libtool
- name: Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get install cmake autoconf automake libtool

- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Run Cake
run: dotnet run --project ./build/Build.csproj --universalBinary=true
env:
ACTIONS_RUNTIME_TOKEN: ${{ env.ACTIONS_RUNTIME_TOKEN }}
ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

deploy:
name: deploy
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
needs: [ build ]
steps:
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3

- name: Clone repository
uses: actions/checkout@v4
with:
submodules: recursive

#- name: Rename License File
# run: mv ./basis_universal/LICENSE ./basis_universal/LICENSE

- name: Run CAKE
run: dotnet run --project ./build/Build.csproj -- --target=Package --universalBinary=true --toolname=basisu --executablename=basisu --commandname=mgcb-basisu --licensepath=basis_universal/LICENSE
env:
ACTIONS_RUNTIME_TOKEN: ${{ env.ACTIONS_RUNTIME_TOKEN }}
ACTIONS_RUNTIME_URL: "${{ env.ACTIONS_RUNTIME_URL }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Make a release
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
name: 'MonoGame.Tool.FFprobe ${{ github.ref_name }}'
tag: ${{ github.ref_name }}
allowUpdates: true
removeArtifacts: true
artifacts: "artifacts/**/*.nupkg"
token: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions Build.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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}") = "Build", "build\Build.csproj", "{05EA3CA1-0ABE-4772-978B-DCC60854A51C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Tool.BuildScripts", "buildscripts\MonoGame.Tool.BuildScripts.csproj", "{6CE6C044-1BE5-4380-9CFD-FB1E0CFD013B}"
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
{05EA3CA1-0ABE-4772-978B-DCC60854A51C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{05EA3CA1-0ABE-4772-978B-DCC60854A51C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{05EA3CA1-0ABE-4772-978B-DCC60854A51C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{05EA3CA1-0ABE-4772-978B-DCC60854A51C}.Release|Any CPU.Build.0 = Release|Any CPU
{6CE6C044-1BE5-4380-9CFD-FB1E0CFD013B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6CE6C044-1BE5-4380-9CFD-FB1E0CFD013B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6CE6C044-1BE5-4380-9CFD-FB1E0CFD013B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CE6C044-1BE5-4380-9CFD-FB1E0CFD013B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dotnet run --project build/Build.csproj --universalBinary=true -- $args
exit $LASTEXITCODE;
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dotnet run --project ./build/Build.csproj --universalBinary=true -- "$@"
37 changes: 37 additions & 0 deletions build/Build.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<Using Include="Cake.Frosting" />
<Using Include="Cake.Common.Build" />
<Using Include="Cake.Common.Diagnostics" />
<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" />
<PackageReference Include="Cake.Homebrew" Version="0.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\buildscripts\MonoGame.Tool.BuildScripts.csproj" />
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions build/BuildLinuxTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace BuildScripts;

[TaskName("Build Linux")]
[IsDependentOn(typeof(PrepTask))]
[IsDependeeOf(typeof(BuildToolTask))]
public sealed class BuildLinuxTask : FrostingTask<BuildContext>
{
public override bool ShouldRun(BuildContext context) => context.IsRunningOnLinux();

public override void Run(BuildContext context)
{
var buildWorkingDir = "basis_universal/";
context.StartProcess("cmake", new ProcessSettings { WorkingDirectory = buildWorkingDir, Arguments = "CMakeLists.txt" });
context.StartProcess("make", new ProcessSettings { WorkingDirectory = buildWorkingDir, Arguments = "" });
context.CopyFile($"{buildWorkingDir}basisu", $"{context.ArtifactsDir}/basisu");
}
}
20 changes: 20 additions & 0 deletions build/BuildMacOSTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Runtime.InteropServices;

namespace BuildScripts;

[TaskName("Build macOS")]
[IsDependentOn(typeof(PrepTask))]
[IsDependeeOf(typeof(BuildToolTask))]
public sealed class BuildMacOSTask : FrostingTask<BuildContext>
{
public override bool ShouldRun(BuildContext context) => context.IsRunningOnMacOs();

public override void Run(BuildContext context)
{
var buildWorkingDir = "basis_universal/";
context.StartProcess("cmake", new ProcessSettings { WorkingDirectory = buildWorkingDir, Arguments = "-DCMAKE_OSX_ARCHITECTURES=\"x86_64;arm64\" CMakeLists.txt" });
context.StartProcess("make", new ProcessSettings { WorkingDirectory = buildWorkingDir, Arguments = "" });
var files = Directory.GetFiles(System.IO.Path.Combine (buildWorkingDir, "bin_osx"), "basisu", SearchOption.TopDirectoryOnly);
context.CopyFile(files[0], $"{context.ArtifactsDir}/basisu");
}
}
18 changes: 18 additions & 0 deletions build/BuildWindowsTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace BuildScripts;

[TaskName("Build Windows")]
[IsDependentOn(typeof(PrepTask))]
[IsDependeeOf(typeof(BuildToolTask))]
public sealed class BuildWindowsTask : FrostingTask<BuildContext>
{
public override bool ShouldRun(BuildContext context) => context.IsRunningOnWindows();

public override void Run(BuildContext context)
{
var buildWorkingDir = "basis_universal/";
context.StartProcess("cmake", new ProcessSettings { WorkingDirectory = buildWorkingDir, Arguments = "CMakeLists.txt" });
context.StartProcess("make", new ProcessSettings { WorkingDirectory = buildWorkingDir, Arguments = "" });
var files = Directory.GetFiles(System.IO.Path.Combine (buildWorkingDir, "bin_windows"), "basisu.exe", SearchOption.TopDirectoryOnly);
context.CopyFile(files[0], $"{context.ArtifactsDir}/basisu.exe");
}
}
11 changes: 11 additions & 0 deletions build/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace BuildScripts;

public static class Program
{
public static int Main(string[] args)
=> new CakeHost()
.AddAssembly(typeof(BuildContext).Assembly)
.UseWorkingDirectory("../")
.UseContext<BuildContext>()
.Run(args);
}

0 comments on commit 45461b6

Please sign in to comment.