Skip to content

Commit 96d5d54

Browse files
committed
Add CI
1 parent a28a3c7 commit 96d5d54

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

.github/workflows/main.yml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
os: [ubuntu-latest, macos-latest, windows-latest]
10+
runs-on: ${{matrix.os}}
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: goto-bus-stop/setup-zig@v2
14+
with:
15+
version: 0.13.0
16+
- name: prepare-linux
17+
if: runner.os == 'Linux'
18+
run: |
19+
sudo apt-get update
20+
sudo apt-get install libglu1-mesa-dev mesa-common-dev xorg-dev libasound-dev
21+
- name: build-native
22+
run: zig build --summary all
23+
- name: build-web
24+
run: zig build --summary all -Dtarget=wasm32-emscripten

build.zig

+7-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn build(b: *std.Build) !void {
7979
const target = b.standardTargetOptions(.{});
8080
const optimize = b.standardOptimizeOption(.{});
8181
const platform = b.option([]const u8, "platform", "Plaftorm to use: sdl or sokol") orelse "sdl";
82-
const is_sdl_platform = !std.mem.eql(u8, platform, "sokol");
82+
const is_sdl_platform = !target.result.isWasm() and !std.mem.eql(u8, platform, "sokol");
8383
const sdl_sdk = sdl.init(b, "");
8484

8585
_ = getZimpactModule(b, .{
@@ -113,7 +113,6 @@ pub fn build(b: *std.Build) !void {
113113
// build Z Drop sample
114114
const sample: []const u8 = "zdrop";
115115
if (!target.result.isWasm()) {
116-
const run_step = b.step(b.fmt("run", .{}), b.fmt("Run {s}.zig example", .{sample}));
117116
// for native platforms, build into a regular executable
118117
const exe = b.addExecutable(.{
119118
.name = sample,
@@ -125,16 +124,18 @@ pub fn build(b: *std.Build) !void {
125124
sdl_sdk.link(exe, .dynamic);
126125
}
127126
exe.root_module.addImport("zimpact", mod_zi);
127+
const install_exe = b.addInstallArtifact(exe, .{});
128+
install_exe.step.dependOn(assets_step);
129+
b.getInstallStep().dependOn(&install_exe.step);
128130

129131
const run_cmd = b.addRunArtifact(exe);
130-
run_cmd.step.dependOn(&b.addInstallArtifact(exe, .{}).step);
132+
const run_step = b.step(b.fmt("run", .{}), b.fmt("Run {s}.zig example", .{sample}));
133+
run_cmd.step.dependOn(&install_exe.step);
134+
run_step.dependOn(&run_cmd.step);
131135

132136
if (b.args) |args| {
133137
run_cmd.addArgs(args);
134138
}
135-
136-
run_step.dependOn(assets_step);
137-
run_step.dependOn(&run_cmd.step);
138139
} else {
139140
try buildWeb(b, .{
140141
.root_source_file = b.path("samples/zdrop/main.zig"),

0 commit comments

Comments
 (0)