-
Notifications
You must be signed in to change notification settings - Fork 3
adds macos config #9
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
base: main
Are you sure you want to change the base?
adds macos config #9
Conversation
There was a problem hiding this 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] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
TODO: fetch macOS SDK dependencies on other platforms. See example here: webui-dev/zig-webui#107
… desktop requires HAVE_SIGTIMEDWAIT = 1
.name = .sdl, | ||
.fingerprint = 0xec638ccbd103848b, | ||
.version = "0.0.0", | ||
.minimum_zig_version = "0.15.0-dev.1218+bc8e1a74c", |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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" }), |
There was a problem hiding this comment.
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 ""
This at least works well enough for
run-example
to correctly compile and run.