initial commit
This commit is contained in:
commit
d0e7445421
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.zig-cache
|
||||
zig-out
|
55
build.zig
Normal file
55
build.zig
Normal file
@ -0,0 +1,55 @@
|
||||
const std = @import("std");
|
||||
const Module = std.Build.Module;
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const libdaq_dep = b.dependency("libdaq", .{});
|
||||
_ = libdaq_dep; // TODO: Build libdaq
|
||||
|
||||
var lib: *Module = undefined;
|
||||
{
|
||||
lib = b.createModule(.{
|
||||
.root_source_file = b.path("src/root.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const unit_tests = b.addTest(.{
|
||||
.root_source_file = b.path("src/root.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const run_unit_tests = b.addRunArtifact(unit_tests);
|
||||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&run_unit_tests.step);
|
||||
}
|
||||
|
||||
{
|
||||
const raylib_dep = b.dependency("raylib-zig", .{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "daq-view",
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
exe.linkLibrary(raylib_dep.artifact("raylib"));
|
||||
exe.root_module.addImport("raylib", raylib_dep.module("raylib"));
|
||||
|
||||
b.installArtifact(exe);
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
const run_step = b.step("run", "Run the program");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
}
|
||||
}
|
21
build.zig.zon
Normal file
21
build.zig.zon
Normal file
@ -0,0 +1,21 @@
|
||||
.{
|
||||
.name = "Baigiamasis projektas",
|
||||
.version = "0.1.0",
|
||||
|
||||
.dependencies = .{
|
||||
.libdaq = .{
|
||||
.url = "https://github.com/snort3/libdaq/archive/refs/tags/v3.0.17.tar.gz",
|
||||
.hash = "1220338b42823b08d2f848549d03958b19836b4794c12f9a7875bca37a8f9477a5c0",
|
||||
},
|
||||
.@"raylib-zig" = .{
|
||||
.url = "https://github.com/Not-Nik/raylib-zig/archive/43d15b05c2b97cab30103fa2b46cff26e91619ec.tar.gz",
|
||||
.hash = "12204a223b19043e17b79300413d02f60fc8004c0d9629b8d8072831e352a78bf212"
|
||||
},
|
||||
},
|
||||
|
||||
.paths = .{
|
||||
"build.zig",
|
||||
"build.zig.zon",
|
||||
"src",
|
||||
},
|
||||
}
|
36
src/main.zig
Normal file
36
src/main.zig
Normal file
@ -0,0 +1,36 @@
|
||||
const std = @import("std");
|
||||
const rl = @import("raylib");
|
||||
|
||||
fn toTraceLogLevel(log_level: std.log.Level) rl.TraceLogLevel {
|
||||
return switch (log_level) {
|
||||
.err => rl.TraceLogLevel.log_error,
|
||||
.warn => rl.TraceLogLevel.log_warning,
|
||||
.info => rl.TraceLogLevel.log_info,
|
||||
.debug => rl.TraceLogLevel.log_all,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn main() !void {
|
||||
rl.setTraceLogLevel(toTraceLogLevel(std.log.default_level));
|
||||
|
||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||
const allocator = gpa.allocator();
|
||||
defer _ = gpa.deinit();
|
||||
|
||||
_ = allocator;
|
||||
|
||||
rl.initWindow(800, 450, "DAQ view");
|
||||
defer rl.closeWindow();
|
||||
rl.setWindowState(.{ .window_resizable = true });
|
||||
|
||||
rl.setTargetFPS(60);
|
||||
|
||||
while (!rl.windowShouldClose()) {
|
||||
rl.beginDrawing();
|
||||
defer rl.endDrawing();
|
||||
|
||||
rl.clearBackground(rl.Color.white);
|
||||
|
||||
rl.drawText("Congrats! You created your first window!", 190, 200, 20, rl.Color.light_gray);
|
||||
}
|
||||
}
|
10
src/root.zig
Normal file
10
src/root.zig
Normal file
@ -0,0 +1,10 @@
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
|
||||
export fn add(a: i32, b: i32) i32 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
test "basic add functionality" {
|
||||
try testing.expect(add(3, 7) == 10);
|
||||
}
|
Loading…
Reference in New Issue
Block a user