add tui
This commit is contained in:
parent
aefe5fa327
commit
9c6bae6963
22
build.zig
22
build.zig
|
@ -30,19 +30,21 @@ pub fn build(b: *Build) !void {
|
||||||
} else {
|
} else {
|
||||||
try buildNative(b, target, optimize, dep_sokol, dep_cimgui);
|
try buildNative(b, target, optimize, dep_sokol, dep_cimgui);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try buildTui(b, target, optimize);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn buildNative(b: *Build, target: ResolvedTarget, optimize: OptimizeMode, dep_sokol: *Dependency, dep_cimgui: *Dependency) !void {
|
fn buildNative(b: *Build, target: ResolvedTarget, optimize: OptimizeMode, dep_sokol: *Dependency, dep_cimgui: *Dependency) !void {
|
||||||
const demo = b.addExecutable(.{
|
const demo = b.addExecutable(.{
|
||||||
.name = "demo",
|
.name = "demo",
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/gui/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
demo.root_module.addImport("sokol", dep_sokol.module("sokol"));
|
demo.root_module.addImport("sokol", dep_sokol.module("sokol"));
|
||||||
demo.root_module.addImport("cimgui", dep_cimgui.module("cimgui"));
|
demo.root_module.addImport("cimgui", dep_cimgui.module("cimgui"));
|
||||||
b.installArtifact(demo);
|
b.installArtifact(demo);
|
||||||
b.step("run", "Run demo").dependOn(&b.addRunArtifact(demo).step);
|
b.step("run-gui", "Run demo").dependOn(&b.addRunArtifact(demo).step);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn buildWasm(b: *Build, target: ResolvedTarget, optimize: OptimizeMode, dep_sokol: *Dependency, dep_cimgui: *Dependency) !void {
|
fn buildWasm(b: *Build, target: ResolvedTarget, optimize: OptimizeMode, dep_sokol: *Dependency, dep_cimgui: *Dependency) !void {
|
||||||
|
@ -50,7 +52,7 @@ fn buildWasm(b: *Build, target: ResolvedTarget, optimize: OptimizeMode, dep_soko
|
||||||
// needs to be linked in a separate build step with the Emscripten linker
|
// needs to be linked in a separate build step with the Emscripten linker
|
||||||
const demo = b.addStaticLibrary(.{
|
const demo = b.addStaticLibrary(.{
|
||||||
.name = "demo",
|
.name = "demo",
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/gui/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
@ -86,5 +88,17 @@ fn buildWasm(b: *Build, target: ResolvedTarget, optimize: OptimizeMode, dep_soko
|
||||||
// ...and a special run step to start the web build output via 'emrun'
|
// ...and a special run step to start the web build output via 'emrun'
|
||||||
const run = sokol.emRunStep(b, .{ .name = "demo", .emsdk = dep_emsdk });
|
const run = sokol.emRunStep(b, .{ .name = "demo", .emsdk = dep_emsdk });
|
||||||
run.step.dependOn(&link_step.step);
|
run.step.dependOn(&link_step.step);
|
||||||
b.step("run", "Run demo").dependOn(&run.step);
|
b.step("run-gui", "Run demo").dependOn(&run.step);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn buildTui(b: *Build, target: ResolvedTarget, optimize: OptimizeMode) !void {
|
||||||
|
const tui = b.addExecutable(.{
|
||||||
|
.name = "demo",
|
||||||
|
.root_source_file = b.path("src/tui/main.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
b.installArtifact(tui);
|
||||||
|
b.step("run-tui", "Run TUI").dependOn(&b.addRunArtifact(tui).step);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,10 @@
|
||||||
zls
|
zls
|
||||||
];
|
];
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
alsa-lib
|
|
||||||
lldb
|
lldb
|
||||||
|
|
||||||
|
# GUI
|
||||||
|
alsa-lib
|
||||||
xorg.libX11
|
xorg.libX11
|
||||||
xorg.libXcursor
|
xorg.libXcursor
|
||||||
xorg.libXi
|
xorg.libXi
|
||||||
|
|
8
justfile
8
justfile
|
@ -2,6 +2,8 @@ alias b := build
|
||||||
build:
|
build:
|
||||||
zig build
|
zig build
|
||||||
|
|
||||||
alias r := run
|
gui:
|
||||||
run:
|
zig build run-gui
|
||||||
zig build run
|
|
||||||
|
tui:
|
||||||
|
zig build run-tui
|
||||||
|
|
11
src/tui/main.zig
Normal file
11
src/tui/main.zig
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
const std = @import("std");
|
||||||
|
|
||||||
|
pub fn main() !void {
|
||||||
|
const stdout = std.io.getStdOut().writer();
|
||||||
|
try stdout.print("Can spawn process: {}\n", .{std.process.can_spawn});
|
||||||
|
|
||||||
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
|
const alloc = gpa.allocator();
|
||||||
|
var lldb_child = std.process.Child.init(&[_][]const u8{"lldb-vscode"}, alloc);
|
||||||
|
_ = try lldb_child.spawnAndWait();
|
||||||
|
}
|
Loading…
Reference in a new issue