This consistently shaves off about 40ms (~130ms -> ~90ms, 30% reduction) from build times when iterating.
On Windows, I suspect the result will be much greater due to slow filesystem perf there and the fact
that this reduces the # of files read.
This was originally brought to my attention as a possibility by @meshula in hexops/dawn#2, the way this
works is by reducing compilation units so that C headers only need to be read/parsed/interpreted once
rather than once per individual C source file we are compiling.
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This substantially reduces consecutive build times when using mach/glfw.
`system_sdk.getSdkPath` is frequently invoked as part of the build process, and previously it was
doing some fairly involved work (ensuring the native SDK is at the right revision, needless
`git fetch` in native SDKs to check for updates, etc.)
We now do far less work in `getSdkPath`, and additionally cache the result in-memory. This improves
build times substantially, but especially so with consecutive (non-cold-cache) build times:
* For `mach/glfw`: ~2s before, ~160ms after
* For `mach/gpu`: , ~16s before, ~3.6s after
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
The GLFW implementation takes a constant pointer to a `VkAllocationCallbacks` struct; casting it to a mutable pointer equivalent here doesn't break anything, but does prevent passing a valid const pointer, which is often what one should prefer to do.
As well, the `@alignOf` builtin takes the alignment expected of the type directly, so `@alignOf(*T)` returns the alignment of `*T`, not `T`, so that has also been corrected.
Prior to this change, an older commit of Mach or mach-glfw would use the latest
version of the native system SDKs, which would sometimes be incompatible. Better
is to ensure that we actually pin the revision we're using, so a given revision
of mach or mach-glfw is using a specific revision of the native SDKs.
Similarly, we previously had no mechanism for updating SDKs: it was either cloned,
or it wasn't. This introduces a simple `git fetch` prior to hard-resetting the SDK
to the target pinned revision - effectively giving us automatic updates for anyone
using an older revision.
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Prior to this the Apple SDK license agreement prompt would appear for 11.3 but
not 12.0 by accident. This fixes the issue.
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
The latest Zig master supports specifying a specific macOS version for libc, via
the target triple (ziglang/zig#10215):
* x86_64-macos.10 (Catalina)
* x86_64-macos.11 (Big Sur)
* x86_64-macos.12 (Monterey)
* aarch64-macos.11 (Big Sur)
* aarch64-macos.12 (Monterey)
Mach's `system_sdk.zig` can now download the relevant XCode framework stubs
for Big Sur (11) and Monterey (12). Although we don't have an SDK for Catalina (10)
currently, we use the Big Sur (11) SDK in that case and it generally works fine.
By default, Zig targets the N-3 version (e.g. `x86_64-macos` defaults to `x86_64-macos.10`).
Targeting the minimum supported version is useful for compatability, it guarantees the produced
binary will run on any later macOS version. Targeting the newer version can be useful if you
wish to use newer APIs not available in previous versions.
Fixeshexops/mach#102
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This removes a linker hack which was preventing building with the latest
Zig master version. Of particular note, anyone wishing to use this library
will need to ensure they are up to date with latest master.
The binary releases available at https://ziglang.org/download/ (1783+eec825c and
beyond) are sufficient (really, anything released after today.)
Fixeshexops/mach#103
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Bring back the 'c.GLFW_NOT_INITIALIZED' prong in 'convertError', such that if it is ever passed that error code, we can differentiate it from just an invalid input; because it is a valid input, we just guarantee that it won't occur.