Skip to content

Commit 6321544

Browse files
Copilotyne
andcommitted
Add Zig implementation and build files
Co-authored-by: yne <5113053+yne@users.noreply.github.com>
1 parent cf2ace1 commit 6321544

File tree

6 files changed

+484
-1
lines changed

6 files changed

+484
-1
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Build artifacts
2+
vcd
3+
*.o
4+
*.exe
5+
6+
# Zig build cache
7+
zig-cache/
8+
zig-out/
9+
10+
# IDE files
11+
.vscode/
12+
.idea/
13+
*.swp
14+
*.swo
15+
*~

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
TARGET?=vcd
22
all: $(TARGET)
3+
$(TARGET):
4+
zig build-exe vcd.zig -O ReleaseFast -femit-bin=$(TARGET)
35
install: $(TARGET); install -v -D $< $(DESTDIR)/usr/bin/$<
4-
clean: ; $(RM) $(TARGET)
6+
clean: ; $(RM) $(TARGET) && $(RM) -rf zig-cache zig-out

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,19 @@ Manually download install a [prebuilt binary](../../releases)
4646
4747
### From sources
4848
49+
Requires [Zig](https://ziglang.org/) compiler (v0.11.0 or later).
50+
4951
```bash
5052
make
5153
sudo make install
5254
```
5355

56+
Or build directly with Zig:
57+
58+
```bash
59+
zig build-exe vcd.zig -O ReleaseFast
60+
```
61+
5462
### From Package Manager
5563

5664
Arch-based distribution:

build.zig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const std = @import("std");
2+
3+
pub fn build(b: *std.Build) void {
4+
const target = b.standardTargetOptions(.{});
5+
const optimize = b.standardOptimizeOption(.{});
6+
7+
const exe = b.addExecutable(.{
8+
.name = "vcd",
9+
.root_source_file = b.path("vcd.zig"),
10+
.target = target,
11+
.optimize = optimize,
12+
});
13+
14+
b.installArtifact(exe);
15+
16+
const run_cmd = b.addRunArtifact(exe);
17+
run_cmd.step.dependOn(b.getInstallStep());
18+
19+
if (b.args) |args| {
20+
run_cmd.addArgs(args);
21+
}
22+
23+
const run_step = b.step("run", "Run the app");
24+
run_step.dependOn(&run_cmd.step);
25+
}

vcd

-20.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)