mirror of
https://github.com/bdnugget/zig-template.git
synced 2026-11-07 09:07:34 +00:00
Template code
This commit is contained in:
1 parent
c00853ba13
commit
9d36a3316e
7 files changed
+85
No files matched your search
@@ -0,0 +1,3 @@
|
||||
* text=auto
|
||||
*.zig text eol=lf
|
||||
zigmod.* text eol=lf
|
||||
@@ -0,0 +1,5 @@
|
||||
zig-cache/
|
||||
zig-out/
|
||||
|
||||
.zigmod
|
||||
deps.zig
|
||||
@@ -1,2 +1,14 @@
|
||||
# zgt-template
|
||||
Simple template for a zgt app
|
||||
|
||||
## Building
|
||||
|
||||
On first build, don't forget to ensure [zigmod](https://github.com/nektro/zigmod/releases/latest)
|
||||
is downloaded and installed on your machine. Then, run:
|
||||
```sh
|
||||
zigmod fetch
|
||||
```
|
||||
And you're ready to go!
|
||||
|
||||
Then if you wish to run the app simply execute
|
||||
`zig build run` (`zigmod fetch` is no longer required)
|
||||
@@ -0,0 +1,37 @@
|
||||
qmconst std = @import("std");
|
||||
const deps = @import("deps.zig");
|
||||
|
||||
pub fn build(b: *std.build.Builder) !void {
|
||||
// Standard target options allows the person running `zig build` to choose
|
||||
// what target to build for. Here we do not override the defaults, which
|
||||
// means any target is allowed, and the default is native. Other options
|
||||
// for restricting supported target set are available.
|
||||
const target = b.standardTargetOptions(.{});
|
||||
|
||||
// Standard release options allow the person running `zig build` to select
|
||||
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
|
||||
const mode = b.standardReleaseOptions();
|
||||
|
||||
const exe = b.addExecutable("zgt-template", "src/main.zig");
|
||||
const pathToZgt = deps.pkgs.zgt.directory;
|
||||
try @import(".zigmod/deps/git/github.com/zenith391/zgt/build_zgt.zig").install(exe, pathToZgt);
|
||||
exe.setTarget(target);
|
||||
exe.setBuildMode(mode);
|
||||
exe.install();
|
||||
|
||||
const run_cmd = exe.run();
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
const exe_tests = b.addTest("src/main.zig");
|
||||
exe_tests.setTarget(target);
|
||||
exe_tests.setBuildMode(mode);
|
||||
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&exe_tests.step);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
const std = @import("std");
|
||||
const zgt = @import("zgt");
|
||||
|
||||
// This is required for youe app to build to WebAssembly and other particular architectures
|
||||
pub usingnamespace zgt.cross_platform;
|
||||
|
||||
pub fn main() !void {
|
||||
try zgt.backend.init();
|
||||
|
||||
var window = try zgt.Window.init();
|
||||
try window.set(
|
||||
zgt.Label(.{ .text = "Hello, World" })
|
||||
);
|
||||
|
||||
window.setTitle("Hello");
|
||||
window.resize(250, 100);
|
||||
window.show();
|
||||
|
||||
zgt.runEventLoop();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
2
|
||||
git https://github.com/zenith391/zgt commit-f15704fe639da850e589fa7a65eae3316ab659dd
|
||||
@@ -0,0 +1,6 @@
|
||||
id: eje8wf3r4lz8em2jnign4ocxywosgkrk1dr6lgcbb0y1ne6y
|
||||
name: zgt-template
|
||||
license: Unlicense
|
||||
description: Simple template for zgt apps
|
||||
root_dependencies:
|
||||
- src: git https://github.com/zenith391/zgt
|
||||
Reference in new issue
Block a user