From 70b38cccfe23437ebe4f8e49cb544668c778bbc1 Mon Sep 17 00:00:00 2001 From: Tom Spilman Date: Sun, 7 Jul 2024 13:16:47 -0500 Subject: [PATCH] Trying to setup xmake to work via github actions --- .github/workflows/main.yml | 5 ++++ build/BuildContext.cs | 13 ++++++++ .../BuildDesktopVKTask.cs | 30 +++++++++++++++++++ build/Tasks.cs | 1 + src/monogame/xmake.lua | 15 +++++----- 5 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 build/BuildFrameworksTasks/BuildDesktopVKTask.cs diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d55f74a4421..1870eba1f9e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: diff --git a/build/BuildContext.cs b/build/BuildContext.cs index 695fbd9488c..3b25c7e8929 100644 --- a/build/BuildContext.cs +++ b/build/BuildContext.cs @@ -145,4 +145,17 @@ out IEnumerable 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, + } + ); + } } diff --git a/build/BuildFrameworksTasks/BuildDesktopVKTask.cs b/build/BuildFrameworksTasks/BuildDesktopVKTask.cs new file mode 100644 index 00000000000..6b676570c94 --- /dev/null +++ b/build/BuildFrameworksTasks/BuildDesktopVKTask.cs @@ -0,0 +1,30 @@ + +namespace BuildScripts; + +[TaskName("Build DesktopVK")] +public sealed class BuildDesktopVKTask : FrostingTask +{ + // 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}"); + } +} diff --git a/build/Tasks.cs b/build/Tasks.cs index 65df1342f4e..8522921b797 100644 --- a/build/Tasks.cs +++ b/build/Tasks.cs @@ -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))] diff --git a/src/monogame/xmake.lua b/src/monogame/xmake.lua index 630a7b0be33..353f009c92e 100644 --- a/src/monogame/xmake.lua +++ b/src/monogame/xmake.lua @@ -6,11 +6,16 @@ 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)") @@ -18,20 +23,14 @@ target("desktopvk") -- 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")