WIP: glfw: make the glfw package more friendly for projects outside of the mach project #23
No reviewers
Labels
No labels
CI
all
basisu
blog
bug
build
contributor-friendly
core
correctness
deferred
dev
direct3d-headers
docs
driver-os-issue
duplicate
dxcompiler
editor
examples
experiment
feature-idea
feedback
flac
freetype
gamemode
gkurve
glfw
gpu
gpu-dawn
harfbuzz
help welcome
in-progress
infrastructure
invalid
libmach
linux-audio-headers
long-term
mach
mach.gfx
mach.math
mach.physics
mach.testing
model3d
needs-triage
object
opengl-headers
opus
os/linux
os/macos
os/wasm
os/windows
package-manager
priority
proposal
proposal-accepted
question
roadmap
slipped
stability
sysaudio
sysgpu
sysjs
validating-fix
vulkan-zig-generated
wayland-headers
website
wontfix
wrench
www
x11-headers
xcode-frameworks
zig-update
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
hexops/mach!23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ext-glfw"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR enables executables to link with GLFW and expose some previously missing functions
@ -39,1 +39,3 @@pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {/// Extend a library by statically linking glfw with itpub fn linkStaticLibrary(b: *Builder, other_lib: *std.build.LibExeObjStep, options: Options) void {const engine_lib = b.addStaticLibrary("engine", "src/main.zig");Hi there @Avokadoen ! Really cool stuff here, thanks a ton for the PR - I'm quite excited to try out zig_vulkan now :)
I'd like to understand more what the changes to this build.zig do exactly so I can learn from you - my expectation was that anyone outside of the
machrepo could already do this:const glfw = @import("glfw/build.zig")glfw.link(b, myLibOrExe, .{})Based on these changes, though, it seems like either (1) that did not work for you or (2) there was an issue with "calling
glfw.link(...)leads to the entire library rebuilding"? Is my guess for either of those right?As an aside, I'd like to keep the external name just
glfw.linkinstead ofglfw.linkStaticLibraryfor a few reasons:Optionsstruct.What do you think?
@ -39,1 +39,3 @@pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {/// Extend a library by statically linking glfw with itpub fn linkStaticLibrary(b: *Builder, other_lib: *std.build.LibExeObjStep, options: Options) void {const engine_lib = b.addStaticLibrary("engine", "src/main.zig");Hi!
Let me just start by thanking you for the amazing work on the glfw building script and wrapper API.
It seems like calling
step.linkLibrary(lib)whenlibhas been initialized throughvar lib = b.addStaticLibrary("foo", "baz")makes the final build command dozig build-libeven when the desired command iszig build-exe. This means that anything that is not a library step can not utilize the link function defined in the glfw build script in master.The naming of the functions could be improved as the linkStaticLibrary function is referencing linking the glfw step with a another static library step i.e mach engine (linking with mach is done statically if i'm note mistaken?).
I agree dynamic linking is not very useful in the context of this project!
So to summarize, this PR aims to enable third party project to simply link using the
glfw.linkStep(b, third_party_step, .{}), and then athird_party_step.addPackagePath("glfw", "deps/mach/glfw/src/main.zig").PS: vulkan_zig is not very interesting at the moment from any perspective, but I working on changing that!
@ -39,1 +39,3 @@pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {/// Extend a library by statically linking glfw with itpub fn linkStaticLibrary(b: *Builder, other_lib: *std.build.LibExeObjStep, options: Options) void {const engine_lib = b.addStaticLibrary("engine", "src/main.zig");After trying to create a minimum requirement to reproduce the error i discovered that linking seems to work with a simple hello world linked using the existing link function. I'm converting the PR to a draft until I can submit an issue explaining things. I'll look into it tomorrow :^)
@ -39,1 +39,3 @@pub fn link(b: *Builder, step: *std.build.LibExeObjStep, options: Options) void {/// Extend a library by statically linking glfw with itpub fn linkStaticLibrary(b: *Builder, other_lib: *std.build.LibExeObjStep, options: Options) void {const engine_lib = b.addStaticLibrary("engine", "src/main.zig");This is more likely an issue debate rather than a PR debate at this point. It seems like a fresh zig project created with
init-exedoes not suffer from the side effect of being ran withbuild-liblike the zig_vulkan project. Currently unsure if this is a mach, zig_vulkan, or a zig compiler bug and so I'm hesitant to submit a issue on this project at this point. I will not prioritize this issue as my fork works for now. I'll submit an issue at a later point when I eventually get back to this.Pull request closed