Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building on macOS #4320

Merged
merged 17 commits into from
Feb 24, 2025

Conversation

doinkythederp
Copy link
Contributor

@doinkythederp doinkythederp commented Feb 22, 2025

This pull request refactors the build script to work properly on macOS.

The problem

The current Cake build script doesn't work on ARM Macs because the Cake Git APIs are only complied for x86/x86_64, not arm64. There are also some places that incorrectly handle differences between macOS and Linux.

The solution

Cake Frosting is a newer option for setting up a Cake project which drops the need for a build.cake DSL and just gives you a normal csproj to write your build logic in. It has the same user-facing API as Cake without the aforementioned issues when building on ARM. It also has better IntelliSense in multi-platform IDEs like JetBrains Rider.

I re-organized the build script to use the Cake Frosting style and improved the logic for finding tool paths on macOS.

I also added a JetBrains Rider config which improves the development experience on macOS because it allows developers to open the Visual Studio solution without being on Windows.

Structural changes

I moved the free-standing functions like GetVersion, etc. into the new BuildContext class so they could be accessed from any task. I also refactored the MakeIn function into a MakeTask class which is more ergonomic when using Cake Frosting. I also put many of the top-level variables into a BuildPaths class.

TODO

  • Make it build on macOS
    • Confirm that it actually starts up, works, etc
  • Update CI
  • Confirm that it still builds (and works) on Windows and Linux.
  • Make the tests pass
    • Currently they aren't passing because I have Dotnet 9.0 installed while CKAN targets Dotnet 8.0, so they're refusing to run.

@doinkythederp doinkythederp marked this pull request as draft February 22, 2025 06:31
@doinkythederp doinkythederp marked this pull request as ready for review February 22, 2025 08:00
@doinkythederp
Copy link
Contributor Author

This is ready for review, I'd love it if someone could confirm this doesn't break builds for them!

@doinkythederp
Copy link
Contributor Author

I've confirmed that this doesn't affect building on Linux on account of the CI still working:

https://github.com/doinkythederp/CKAN/actions/runs/13471224444

@HebaruSan HebaruSan added Build Issues affecting the build system macOS Issues specific for macOS labels Feb 22, 2025
@HebaruSan

This comment was marked as resolved.

@HebaruSan

This comment was marked as resolved.

@doinkythederp
Copy link
Contributor Author

Ubuntu 24.04 says:

media/sf_CKAN/build/BuildContext.cs(128,14): error CS0121: The call is ambiguous between the following methods or properties: 'string.Split(char[]?, StringSplitOptions)' and 'string.Split(string?, StringSplitOptions)' [/media/sf_CKAN/build/Build.csproj]

Possibly a dotnet versioning thing? This VM has 8.0.112.

Resolved in 9cf2633 (#4320)

@HebaruSan

This comment was marked as resolved.

@doinkythederp
Copy link
Contributor Author

OK, I can now build on all systems, so I'm reviewing the actual changes.

Looks like the target defaulting is broken:

> .\build.ps1 test

Error: Unknown command 'test'.

       test
       ^^^^ No such command
$ ./build.sh test

Error: Unknown command 'test'.

      test
      ^^^^ No such command

That's one of the things that was deleted in build and build.ps1, looks like it wasn't carried forward to the new stuff?

CKAN/build.ps1

Lines 46 to 52 in 27c6d9a

if ($Arg0) {
if ($Arg0[0] -eq "-") {
$cakeArgs += "${Arg0}"
} else {
$cakeArgs += "--target=${Arg0}"
}
}

CKAN/build

Lines 48 to 57 in 27c6d9a

if [ -n "$arg0" ]; then
case $arg0 in
-*)
cakeArgs="$cakeArgs $arg0"
;;
*)
cakeArgs="$cakeArgs --target=$arg0"
;;
esac
fi

Oops! I think when I applied the template for Cake Frosting it must have overwritten that.

Copy link
Member

@HebaruSan HebaruSan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for working on this! 🚀

@HebaruSan HebaruSan merged commit 3927330 into KSP-CKAN:master Feb 24, 2025
2 checks passed
@doinkythederp doinkythederp deleted the refactor/support-macos-host branch February 24, 2025 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build Issues affecting the build system macOS Issues specific for macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants