all: use mach-glfw via package manager
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
2caffc8d35
commit
3359c6163b
8 changed files with 35 additions and 40 deletions
|
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const freetype = @import("libs/freetype/build.zig");
|
||||
const glfw = @import("libs/glfw/build.zig");
|
||||
const glfw = @import("mach_glfw");
|
||||
const sysaudio = @import("mach_sysaudio");
|
||||
pub const gpu_dawn = @import("libs/gpu-dawn/build.zig"); // TODO(build-system): make this private
|
||||
const gpu = @import("libs/gpu/build.zig").Sdk(.{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@
|
|||
.url = "https://github.com/hexops/mach-sysaudio/archive/bc03624694ddf3a7d348efdeccf82404eb019236.tar.gz",
|
||||
.hash = "12203830507ce345848f27ffd27369e726c35ce115edb66f9ba9ee524d8a46c0a87a",
|
||||
},
|
||||
.mach_glfw = .{
|
||||
.url = "https://github.com/hexops/mach-glfw/archive/98418ac4dc7d21ffbfebdee8045473fa2e35d528.tar.gz",
|
||||
.hash = "1220d685dabe227073aa11a8b7bb9eecfc8cbe5a08e128c23c173c2baddf8da9258e",
|
||||
},
|
||||
.direct3d_headers = .{
|
||||
.url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz",
|
||||
.hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const glfw = @import("libs/mach-glfw/build.zig");
|
||||
const glfw = @import("mach_glfw");
|
||||
const gpu_dawn = @import("libs/mach-gpu-dawn/build.zig");
|
||||
const gpu = @import("libs/mach-gpu/build.zig").Sdk(.{
|
||||
.gpu_dawn = gpu_dawn,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@
|
|||
.url = "https://github.com/hexops/mach-gamemode/archive/6e71d19d7eecbf0230e5c445dbe9281e45393245.tar.gz",
|
||||
.hash = "1220ff812193615e03375a342a7c8a52f368eab219bceab3039de1915f9c945f2a66",
|
||||
},
|
||||
.mach_glfw = .{
|
||||
.url = "https://github.com/hexops/mach-glfw/archive/98418ac4dc7d21ffbfebdee8045473fa2e35d528.tar.gz",
|
||||
.hash = "1220d685dabe227073aa11a8b7bb9eecfc8cbe5a08e128c23c173c2baddf8da9258e",
|
||||
},
|
||||
.direct3d_headers = .{
|
||||
.url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz",
|
||||
.hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12",
|
||||
|
|
|
|||
|
|
@ -42,19 +42,29 @@ A minimal Vulkan example can be found in the [mach-glfw-vulkan-example](https://
|
|||
|
||||
## Getting started
|
||||
|
||||
### Adding dependency (using Git)
|
||||
### Adding dependency
|
||||
|
||||
In a `libs` subdirectory of the root of your project:
|
||||
Create a `build.zig.zon` file in your project (replace `$LATEST_COMMIT` with the latest commit hash):
|
||||
|
||||
```sh
|
||||
git clone https://github.com/hexops/mach-glfw
|
||||
```
|
||||
.{
|
||||
.name = "mypkg",
|
||||
.version = "0.1.0",
|
||||
.dependencies = .{
|
||||
.mach_glfw = .{
|
||||
.url = "https://github.com/hexops/mach-glfw/archive/$LATEST_COMMIT.tar.gz",
|
||||
},
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
Then in your `build.zig` add:
|
||||
Run `zig build` in your project, and the compiler instruct you to add a `.hash = "..."` field next to `.url`.
|
||||
|
||||
Then use the dependency in your `build.zig`:
|
||||
|
||||
```zig
|
||||
...
|
||||
const glfw = @import("libs/mach-glfw/build.zig");
|
||||
const glfw = @import("mach_glfw");
|
||||
|
||||
pub fn build(b: *Build) !void {
|
||||
...
|
||||
|
|
@ -63,37 +73,6 @@ pub fn build(b: *Build) !void {
|
|||
}
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
|
||||
### (optional) Adding dependency using Gyro
|
||||
|
||||
</summary>
|
||||
|
||||
```sh
|
||||
gyro add --src github hexops/mach-glfw --root src/main.zig --alias glfw
|
||||
gyro add --build_dep --src github hexops/mach-glfw --root build.zig --alias build-glfw
|
||||
```
|
||||
|
||||
Then in your `build.zig` add:
|
||||
|
||||
```zig
|
||||
...
|
||||
const pkgs = @import("deps.zig").pkgs;
|
||||
const glfw = @import("build-glfw");
|
||||
|
||||
pub fn build(b: *Build) !void {
|
||||
...
|
||||
|
||||
exe.addModule("glfw", pkgs.glfw);
|
||||
try glfw.link(b, exe, .{});
|
||||
}
|
||||
```
|
||||
|
||||
**Note: You should use `gyro build` instead of `zig build` to use gyro**
|
||||
|
||||
</details>
|
||||
|
||||
# Next steps
|
||||
|
||||
Now in your code you may import and use GLFW:
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
.name = "mach-gpu-dawn",
|
||||
.version = "0.2.0",
|
||||
.dependencies = .{
|
||||
.mach_glfw = .{
|
||||
.url = "https://github.com/hexops/mach-glfw/archive/98418ac4dc7d21ffbfebdee8045473fa2e35d528.tar.gz",
|
||||
.hash = "1220d685dabe227073aa11a8b7bb9eecfc8cbe5a08e128c23c173c2baddf8da9258e",
|
||||
},
|
||||
.direct3d_headers = .{
|
||||
.url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz",
|
||||
.hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ const std = @import("std");
|
|||
pub fn build(b: *std.Build) !void {
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const glfw = @import("libs/mach-glfw/build.zig");
|
||||
const glfw = @import("mach_glfw");
|
||||
const gpu_dawn = @import("libs/mach-gpu-dawn/build.zig");
|
||||
const gpu = Sdk(.{
|
||||
.gpu_dawn = gpu_dawn,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
.name = "mach-gpu",
|
||||
.version = "0.2.0",
|
||||
.dependencies = .{
|
||||
.mach_glfw = .{
|
||||
.url = "https://github.com/hexops/mach-glfw/archive/98418ac4dc7d21ffbfebdee8045473fa2e35d528.tar.gz",
|
||||
.hash = "1220d685dabe227073aa11a8b7bb9eecfc8cbe5a08e128c23c173c2baddf8da9258e",
|
||||
},
|
||||
.direct3d_headers = .{
|
||||
.url = "https://github.com/hexops/direct3d-headers/archive/773dce3f079eecdccc7c71d1318a0741649d568b.tar.gz",
|
||||
.hash = "12200d2155216c5eb5f111282cd355b5433cad6a68fd040294e695149cba329f7c12",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue