Skip to content

Commit

Permalink
Trying to setup xmake to work via github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomspilman committed Jul 8, 2024
1 parent 7f3bc9d commit 70b38cc
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
with:
dotnet-version: '8.0.x'

- name: Setup Xmake
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest

- name: Setup Java
uses: actions/setup-java@v4
with:
Expand Down
13 changes: 13 additions & 0 deletions build/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,17 @@ out IEnumerable<string> processOutput

return processOutput.Any(match => match.StartsWith($"{workload} "));
}

public int XMake(string workingDir, params string[] args)
{
return this.StartProcess(
"xmake",
new ProcessSettings()
{
WorkingDirectory = workingDir,
Arguments = string.Join(" ", args),
RedirectStandardOutput = false,
}
);
}
}
30 changes: 30 additions & 0 deletions build/BuildFrameworksTasks/BuildDesktopVKTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

namespace BuildScripts;

[TaskName("Build DesktopVK")]
public sealed class BuildDesktopVKTask : FrostingTask<BuildContext>
{
// TEMP: Until OSX and Linux is setup to work.
public override bool ShouldRun(BuildContext context) => context.IsRunningOnWindows();

public override void Run(BuildContext context)
{
context.XMake(@"src\monogame\", "repo -u -v -y");

int exit = context.XMake(@"src\monogame\", "f -m debug -v -y");
if (exit < 0)
throw new Exception($"Setting debug config failed! {exit}");

exit = context.XMake(@"src\monogame\", "-r");
if (exit < 0)
throw new Exception($"Rebuild debug failed! {exit}");

exit = context.XMake(@"src\monogame\", "f -m release -v -y");
if (exit < 0)
throw new Exception($"Setting release config failed! {exit}");

exit = context.XMake(@"src\monogame\", "-r");
if (exit < 0)
throw new Exception($"Rebuild release failed! {exit}");
}
}
1 change: 1 addition & 0 deletions build/Tasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace BuildScripts;
[TaskName("Build Frameworks")]
[IsDependentOn(typeof(BuildConsoleCheckTask))]
[IsDependentOn(typeof(BuildNativeTask))]
[IsDependentOn(typeof(BuildDesktopVKTask))]
[IsDependentOn(typeof(BuildDesktopGLTask))]
[IsDependentOn(typeof(BuildWindowsDXTask))]
[IsDependentOn(typeof(BuildAndroidTask))]
Expand Down
15 changes: 7 additions & 8 deletions src/monogame/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,31 @@
set_kind("shared")
set_basename("monogame.native")
add_defines("DLL_EXPORT")
add_rules("mode.release", "mode.debug")

-- Always include the common bits.
add_files("common/*.cpp")
add_includedirs("include")

-- Required dependencies.
add_requires("libsdl 2.30.*")
add_requires("vulkansdk")

target("desktopvk")

set_targetdir("../../Artifacts/monogame.native/$(os)/desktopvk/$(mode)")

-- SDL is supported on all desktop platforms.
add_defines("MG_SDL2")
add_files("sdl/*.cpp")
add_includedirs("../../ThirdParty/Dependencies/SDL/include")
add_links("SDL2-static")
if is_plat("windows") then
add_linkdirs("../../ThirdParty/Dependencies/SDL/Windows/x64")
add_links("winmm", "imm32", "user32", "gdi32", "advapi32", "setupapi", "ole32", "oleaut32", "version", "shell32")
end
add_packages("libsdl")

-- Vulkan is supported for all desktop platforms.
add_defines("MG_VULKAN");
add_files("vulkan/*.cpp")
add_includedirs("../../ThirdParty/Dependencies/VulkanSDK/Include")
add_packages("vulkansdk")
if is_plat("windows") then
add_files("vulkan/vulkan.rc")
add_linkdirs("../../ThirdParty/Dependencies/VulkanSDK/Lib/Windows")
end
add_links("volk")

Expand Down

0 comments on commit 70b38cc

Please sign in to comment.