Commit graph

45 commits

Author SHA1 Message Date
Stephen Gutekanst
d35957766b glfw: use lowercase shell32 for Linux
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2022-03-04 16:10:51 -07:00
Stephen Gutekanst
16c581b2ab 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
3ec74222e6 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
6c93a9d5a4 glfw: add build-system TODOs
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-30 11:29:56 -07:00
Stephen Gutekanst
1df13d0509 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
f91ceef291 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
aae3ea8577 constify unmutated variables in build files 2021-11-22 12:59:11 -07:00
Ali Chraghi
50719f5347 glfw: fix typo prevents building for Wayland 2021-11-15 17:49:13 -07:00
Stephen Gutekanst
9f906cfd94
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-05 12:20:24 -07:00
Stephen Gutekanst
e0cf70f045 glfw: expose system SDK build options
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 21:47:48 -07:00
Stephen Gutekanst
7d3ea16de6 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
2b4b06cf7b 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
3d38f56af6
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
a0677ea6a5 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
668499b10a glfw: build: eliminate duplicative arena allocator
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-24 13:42:20 -07:00
Stephen Gutekanst
eb939afa1d glfw: update TODO
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-16 18:39:57 -07:00
Stephen Gutekanst
f8eb5599a4 glfw: default Linux to GLESv3
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-16 18:39:57 -07:00
Stephen Gutekanst
ad7d6b405d glfw: add glfw.getInstanceProcAddress
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-16 18:39:57 -07:00
Stephen Gutekanst
4c103a344e 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
c3bdb99a14 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
73719acb29 new approach to mac SDK inclusion
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-09-12 12:56:51 -07:00
Stephen Gutekanst
6446dd782e 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
b3729e7323
remove intermediate static lib (#24) 2021-09-05 18:49:45 -07:00
Stephen Gutekanst
b1581b684c 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
7d5cd4bbcb 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
e650b6ed9e glfw: macos: add Metal support
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-26 01:12:00 -07:00
Stephen Gutekanst
73bf107907 glfw: windows: correct opengl32/GLESv2 linkage
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-26 01:11:12 -07:00
Stephen Gutekanst
0be6c041bf glfw: always linkLibC
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-26 01:09:19 -07:00
Stephen Gutekanst
45125bec55 glfw: add Windows x86_64 support
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-25 22:59:08 -07:00
Stephen Gutekanst
36eae62fea glfw: correct cross compilation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-25 17:04:51 -07:00
Stephen Gutekanst
f9e098c442
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
Stephen Gutekanst
161b0a540f glfw: correct comment style
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-16 11:52:38 -07:00
Stephen Gutekanst
6308a2f8dd glfw: move constants into separate modules
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-16 11:34:18 -07:00
Stephen Gutekanst
bfe841880d glfw: handle windows \r\n in Apple SDK prompt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-11 15:22:58 -07:00
Stephen Gutekanst
161e07575a glfw: link libc
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-11 15:22:58 -07:00
Stephen Gutekanst
c4d4953f28 glfw: use cross-platform getEnvVarOwned
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-11 15:22:58 -07:00
Stephen Gutekanst
93ead5c9eb glfw: remove symlinks from SDKs (using them on windows is annoying)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-11 15:22:58 -07:00
Stephen Gutekanst
25bfde3acf glfw: be sure to clone SDKs with symlinks
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-10 17:26:32 -07:00
Stephen Gutekanst
d0ff7bb2e9 glfw: correct Linux -> MacOS cross compilation (header includes)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-10 16:07:41 -07:00
Stephen Gutekanst
c3da3c9804 glfw: fix -Dtarget=x86_64-macos compilation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-10 14:47:10 -07:00
Stephen Gutekanst
c5c278232a glfw: build Linux sources
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-10 11:25:04 -07:00
Stephen Gutekanst
e19751d91a glfw: tidy up Options struct
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-10 10:04:18 -07:00
Stephen Gutekanst
2d98b0d382 glfw: build windows sources
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-10 10:04:18 -07:00
Stephen Gutekanst
bba27cf1aa glfw: macOS cross compilation with automatic setup
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-10 01:01:51 -07:00
Stephen Gutekanst
6e5ff09e55 glfw: add basic example, building+linking on macOS is working
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-07-06 20:53:10 -07:00