-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add build.zig #198
base: master
Are you sure you want to change the base?
Add build.zig #198
Conversation
Hi @desttinghim, this looks neat! I'd be particularly interested in using this to cross-compile the Go bindings. Is this possible?
Yes support for all three platforms would be required to merge this. |
Yes, I believe so. I have no experience with using go myself, but there have been some posts on using
This makes sense. I don't have any Apple devices I can use to test, but I'll push a |
This PR produced the following error when I tried testing, same error on both Mac and Linux: $ zig build
build.zig:249:18: error: expected ')', found ','
for (examples, example_names) |example, name| {
^ And if I try removing the code section for the examples, I then get this error: $ zig build
build.zig:3:21: error: root struct of file 'std' has no member named 'Build'
pub fn build(b: *std.Build) void {
~~~^~~~~~ |
Okay I'm getting past the above Build still fails though: Now seeing lots of Objective-C runtime related link errors on Mac.. |
Yes, this is using zig nightly. There have been a lot of changes since the latest stable release. I plan to stick to using zig 0.11 when it is released to make it easier for others to follow. Could you post the errors you are seeing? |
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 think I fixed it:
Curious are you also working on Zig bindings, or using the C API directly from Zig? |
I am using the C API directly at the moment. It wouldn't be terribly difficult to wrap into a more ziggish API but wrapping it is not a priority for me at the moment :) that being said, I wouldn't mind working on a set of bindings when I have the time. |
Even just our |
7e908f1
to
9927edc
Compare
@cody271now that zig 0.11.0 has been released, I am interested in getting this into a mergeable state. The 0.11.0 release is the first stable version of zig to include a package manager. Using the nightlies would be difficult due to the frequent changes - pinning to a stable release makes it much easier to provide support. |
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.
Few more nits / suggestions
Is this still intended to work with the recent Zig stable release, or does it need dev nightly? Packages for |
The new commits I pushed are not for 0.11.0, unfortunately. I updated to a nightly version of zig while troubleshooting a libui project that was failing to run on windows. The nightly version integrates a windows resource compiler into zig which simplifies getting a toolchain set up for windows significantly. I can move the most recent commit to a new branch and roll back to 0.11.0 here if you'd like. |
This comment was marked as resolved.
This comment was marked as resolved.
After having actually tried running this on a new machine, changed my mind: you had it right the first time. 😛 |
Ok, this is back to the build.zig for 0.12.0. Hopefully there aren't too many breaking changes before the release 😅 If we want to guarantee support for the latest nightly at all times, we will probably want to set up CI to download the latest version and run |
Yes the hope is that the upcoming 0.12.0 stable release from packages will just work, without depending on nightly download.. |
Another useful update has been merged into zig: ziglang/zig#18160 The short version is that zig modules with a c dependency will now forward that dependency. Previously all the c dependencies had to be added for each module you wanted to depend on it. I will update this branch to make use of the new build feature update the documentation on which zig version to use. On a related note, should I try and add the zig build step to the CI? |
0cfdd23
to
b49ab1d
Compare
This commit squashes several other commits into one. It introduces a build.zig script for compiling libui. This allows easy cross-compilation (at least between Linux and Windows). Additionally, a small change is made to some of the Windows code to detect the WIDL_EXPLICIT_AGGREGATE_RETURNS macro and work around an ABI bug between clang and msvc.
Co-authored-by: cody271 <cody271@hey.com>
Co-authored-by: cody271 <cody271@hey.com>
Adds `zig-linux` step to CI to test build.zig on linux. Changes build.zig to accept `libtype={static,shared}` option instead of using `shared={true,false}` so it is more consistent with the other github actions.
Adds the tests to the CI using zig as well.
This reverts commit f56ae5f. The zig-setup action does not confirm the signature of the downloaded zig files.
cmocka is not packaged for the zig build system
Running the build with zig in ci will be added in a later pull request.
These commits add a
build.zig
to libui. This allows for cross-compilation using the zig toolchain (compiling for windows from linux is as easy aszig build -Dtarget=x86_64-windows
) and for using zig's built-in package manager (currently only in the nightly build) to directly depend on libui-ng.The build.zig has not been configured to build for MacOS, though this should be easy to add.
It might be best to hold off on merging this until there is a stable release of zig including the package manager. The current expected release date is May.
I'm happy accepting constructive criticism on this PR; if you don't feel like merging the build.zig, that's fine - I mostly wrote it for a private project, and I am making a PR just in case it would be appreciated :)