Commit graph

114 commits

Author SHA1 Message Date
Ali Chraghi
6de027bb40 build: replace depracted functions 2022-08-27 11:12:07 -07:00
Ali Chraghi
f556550501 build: fix memory leaks 2022-08-27 11:05:36 -07:00
Michal Ziulek
4296b2865b glfw: simplify build script, remove redundant allocs, improve -fno-stage1 support 2022-08-15 17:12:53 -07:00
Stephen Gutekanst
1e04811040 glfw: fix -fno-stage1 thisDir invocations
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-08-05 22:24:57 -07:00
Casey Banner
8faba61460 glfw: add shared option which builds glfw into its own shared library (#442)
* Add shared option which builds glfw into it's own shared library
* glfw: separate shared test build step
* glfw: cleanup shared linking

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Co-authored-by: Stephen Gutekanst <stephen@hexops.com>
2022-07-31 13:56:13 -07:00
Ali Chraghi
383d5f4d6e all: build: install tests exe 2022-07-25 11:21:37 -07:00
Ali Chraghi
b1f4b98a9f glfw: build: produce static library 2022-07-24 09:28:56 -07:00
alichraghi
e0884da649 build: add mode paramater to testStep functions 2022-07-20 18:55:59 -07:00
alichraghi
26f5a7a490 build: add test-mach step to test src/ and test for testing all sub-projects 2022-07-19 09:25:55 -07:00
PiergiorgioZagaria
8b41d754ee glfw: do not link to wayland-client (no longer necessary, loaded at runtime by GLFW) 2022-06-29 20:54:04 -07:00
PiergiorgioZagaria
b4ea44c647 glfw: support compiling for wayland 2022-06-29 20:54:04 -07:00
PiergiorgioZagaria
952ea5c3c5 glfw: support compiling with stage2 (-fno-stage1) (#365) 2022-06-24 10:12:45 -07:00
Stephen Gutekanst
e328c652d0 glfw: prepare build system to support runtime Wayland/X11 detection
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-06-11 17:39:25 -07:00
Stephen Gutekanst
e24a0c4ce9 glfw: update build system to glfw@master
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-06-11 17:39:25 -07:00
Stephen Gutekanst
ab26356574 glfw: ensure upstream submodule is cloned
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-06-11 17:39:25 -07:00
kamidev
87848578c8 Change std.build.Pkg.path -> std.build.Pkg.source
Fixes breaking change in latest Zig master, see https://github.com/ziglang/zig/pull/11557
2022-05-29 08:25:52 -07:00
Isaac Freund
f8110189eb build: never use pkg-config to link system libraries (#217)
Every library we want to link against is either provided by the Zig
toolchain or part of our SDK. Therefore, using pkg-config to link
against libraries on the host system is never what we intend.

To fix this, use linkSystemLibraryName() everywhere instead of
linkSystemLibrary() as the latter integrates with pkg-config while the
former just passes -lfoo to the zig compiler.

In combination with Zig commit 38d6e1d8a8 fixing an std.build bug,
this change fixes the linking of the necessary X11 libraries on my
x86_64 glibc based Void Linux system.
2022-04-12 12:08:30 -07:00
Silver
00891b408f glfw: add type to pkg def in build.zig 2022-04-07 18:42:15 -07:00
Stephen Gutekanst
a74ad932a2 glfw: add std.build.Pkg definition
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-04-05 00:16:51 -07:00
Stephen Gutekanst
d8079d6245 glfw: use lowercase shell32 for Linux
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-04 16:10:51 -07:00
Stephen Gutekanst
d0f625628f glfw: fix x86_64-windows-msvc compilation support
This fixes compilation for msvc ABI. This currently only works under Windows,
I believe because Zig requires the Windows SDK to be present for msvc compilation
/ does not allow cross compilation with MSVC. Still, this is nice to have.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-04 15:59:36 -07:00
Stephen Gutekanst
a0fc183a20 glfw: reduce compilation units to bring iteration time down to ~90ms
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>
2021-12-10 03:52:41 -08:00
Stephen Gutekanst
0011df2be5 glfw: add build-system TODOs
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-30 11:29:56 -07:00
Stephen Gutekanst
95515eaf7c glfw: update system_sdk to match latest Zig master macOS version targeting
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.

Fixes hexops/mach#102

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-27 00:15:15 -07:00
Stephen Gutekanst
01ad3b836c glfw: support building with latest Zig master
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.)

Fixes hexops/mach#103

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-26 22:29:58 -07:00
InKryption
fa5f102b2a constify unmutated variables in build files 2021-11-22 12:59:11 -07:00
Ali Chraghi
da3e76eff1 glfw: fix typo prevents building for Wayland 2021-11-15 17:49:13 -07:00
Stephen Gutekanst
03fc8bc424 glfw: fix linking difference between sysroot and non-sysroot (#63)
This effectively gives us the dependencies we need in any case, and works around ziglang/zig#10103

Importantly, this removes a blocker for landing WebGPU support in hexops/mach#62

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-07 17:38:06 -07:00
Stephen Gutekanst
4e93fbddd1 glfw: expose system SDK build options
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 21:47:48 -07:00
Stephen Gutekanst
e752666062 glfw: refactor system SDK inclusion into helper file
This refactors the logic for system SDK inclusion out of the GLFW-specific `build.zig`,
and should make it very easy for anyone to copy this file and start getting cross-platform
builds of their own OpenGL/Vulkan Zig projects.

There may be some libraries we need to add for Vulkan to these SDKs, I haven't yet tested
that - but the overall idea here seems sound.

Fixes hexops/mach#39

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 21:31:52 -07:00
Stephen Gutekanst
058443c3da glfw: workaround framework dependency inclusion bug for now
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-29 12:31:28 -07:00
Stephen Gutekanst
0f5de6d435 glfw: do not set sysroot (prevents linking libs not in our system SDKs) (#47)
* glfw: do not set sysroot (prevents linking libs not in our system SDKs)

Fixes hexops/mach#40

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-24 21:14:13 -07:00
Stephen Gutekanst
94f530b3f1 glfw: add intermediate static lib
Previously, @Avokadoen and @mattnite ran into issues including the GLFW library
in other projects, e.g. https://github.com/Avokadoen/zig_vulkan/issues/17

In #24 we removed the intermediate static library, which solved the issue. The
problem is that when the function is invoked in the directory of the project
including GLFW, then our code:

```
const lib = b.addStaticLibrary("glfw", "src/main.zig");
```

Would refer to the project's `src/main.zig` -- not the GLFW library `main.zig`.

Although removing the intermediate lib worked around the issue, it created a
new one - slower compilation: hexops/mach#31

This fixes the issue by ensuring that the path we pass to `addStaticLibrary` is
in fact absolute, not relative.

Fixes hexops/mach#31

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-24 13:55:52 -07:00
Stephen Gutekanst
77cf3dd85c glfw: build: eliminate duplicative arena allocator
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-24 13:42:20 -07:00
Stephen Gutekanst
72997552e3 glfw: update TODO
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-16 18:39:57 -07:00
Stephen Gutekanst
ed2d9942cc glfw: default Linux to GLESv3
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-16 18:39:57 -07:00
Stephen Gutekanst
dd7305bd1e glfw: add glfw.getInstanceProcAddress
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-16 18:39:57 -07:00
Stephen Gutekanst
d2bf86e0ce glfw: default to GLES v3 instead of v2.
GLES v3 has >70% device support.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-16 18:39:57 -07:00
Stephen Gutekanst
ff49e34c6c glfw: fix panic when pressing enter on Apple SDK license prompt (fixes #22)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-09-13 20:49:34 -07:00
Stephen Gutekanst
76ecf85d54 new approach to mac SDK inclusion
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-09-12 12:56:51 -07:00
Stephen Gutekanst
e5143ebc49 glfw: remove macOS sysroot workaround (not needed in latest Zig)
Also, removing is required in order to workaround an issue with includes.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-09-12 12:56:51 -07:00
Matthew Knight
53d81db18f remove intermediate static lib (#24) 2021-09-05 18:49:45 -07:00
Stephen Gutekanst
c127d4976b glfw: add Linux SDK / cross compilation support
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-29 21:18:19 -07:00
Stephen Gutekanst
732ca31181 glfw: add preliminary Linux support
Helps #4

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-26 01:29:47 -07:00
Stephen Gutekanst
99eff884e4 glfw: macos: add Metal support
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-26 01:12:00 -07:00
Stephen Gutekanst
831a1153da glfw: windows: correct opengl32/GLESv2 linkage
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-26 01:11:12 -07:00
Stephen Gutekanst
d2ef671f04 glfw: always linkLibC
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-26 01:09:19 -07:00
Stephen Gutekanst
109c4e1d3b glfw: add Windows x86_64 support
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-25 22:59:08 -07:00
Stephen Gutekanst
34776c80e3 glfw: correct cross compilation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-25 17:04:51 -07:00
Stephen Gutekanst
93b42d3aad glfw: add SDK_PATH for easier testing of changes to SDKs (#6)
This change makes it easier to test SDKs locally, e.g. if you have:

```
% tree projects/
projects
├── mach
│   └── glfw
└── sdk-macos-11.3
```

In the `projects/mach/glfw` directory it is now easy to test changes to `sdk-macos-11.3` using:

```sh
SDK_PATH="$(pwd)/../.." zig build test -Dtarget=aarch64-macos
```

And it'll use your local SDK, instead of the one in the appdata dir.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-24 13:38:43 -07:00