Skip to content

Conversation

garettbass
Copy link

This at least works well enough for run-example to correctly compile and run.

Copy link
Contributor

@MasonRemaley MasonRemaley left a comment

Choose a reason for hiding this comment

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

Awesome thanks for the PR! I'm out of town right now, but I'll look at it more carefully when I get back next week. In the meantime I left a quick note on the CI setup.

matrix:
zig-version: [master]
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
Copy link
Contributor

@MasonRemaley MasonRemaley Oct 3, 2025

Choose a reason for hiding this comment

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

The way I've set the YAML up here is a bit confusing. This list you've updated here is the list of operating systems the tests run on, however the actual tests also need to be updated.

Right now they look like this:

- name: Build for Windows
  run: zig build example -Dtarget=x86_64-windows-gnu --summary all

- name: Build for Linux
  run: zig build example -Dtarget=x86_64-linux-gnu --summary all

The first one attempts to cross compile to Windows from the host platform, the second attempts to cross compile to Linux from the host platform. If the macOS config is able to be used as a cross compile target, then all you need to do is add it to the above list as well and cross compilation to a macOS app will be tested on all three platforms.

That's the ideal scenario, I'd like to achieve it if possible. OTOH if this is impossible (e.g. maybe it requires sharing files that Apple forbids us from sharing) then the macOS test can just be made conditional to only run on macOS. I'm not an expert on GitHub's CI, but I'm guessing there's a way to wrap it in an if statement or something.

Copy link
Author

@garettbass garettbass Oct 4, 2025

Choose a reason for hiding this comment

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

Technically, it is possible to cross compile to macOS from Linux or Windows. I was able to make a proof of concept of that on another branch by placing the necessary MacOSX.sdk in the repo's deps directory. I tested by cross compiling from my Steam Deck's linux desktop. It is more difficult for me to test on Windows right now, so I haven't tried there yet.

Based on the wording of the Mac SDK license, I'm not sure we're allowed to use the SDK on non-apple branded hardware, so it may be legally troublesome even though it is technically simple.

.name = .sdl,
.fingerprint = 0xec638ccbd103848b,
.version = "0.0.0",
.minimum_zig_version = "0.15.0-dev.1218+bc8e1a74c",
Copy link
Author

Choose a reason for hiding this comment

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

Not sure this is ok, my VSCode toolchain for zig couldn't locate the specific dev version

.HAVE_LIBDECOR_H = 1,
.HAVE_LIBURING_H = 1,

.HAVE_SIGTIMEDWAIT = 1,
Copy link
Author

Choose a reason for hiding this comment

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

I wasn't able to cross compile from macOS to linux, nor natively compile on Steam Deck without adding this. I got a compile error caused by SDL's static declaration of sigtimedwait() conflicting with the previous non-static declaration.

sysroot
else
std.zig.system.darwin.getSdk(b.allocator, &target) orelse
@panic("SDK not found");
Copy link
Author

Choose a reason for hiding this comment

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

This message should probably provide more context about installing Xcode which contains these SDKs.

b.sysroot = sdk;

lib.addSystemFrameworkPath(.{
.cwd_relative = b.pathJoin(&.{ sdk, "System/Library/Frameworks" }),
Copy link
Author

Choose a reason for hiding this comment

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

These should probably be "/System/..." and "/usr/..." in case sdk is ""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants