Implement some simple flags and runtime log-levels
I used flags.zig from Isaac Freund for parsing basic CLI arguments,
I don't need much else since most configuration is in Kdl.
e967499fb1/common/flags.zig
I also removed some of the duplicated bits for the exe_check step
since I realized I can just use the beansprout executable for all of it.
This commit is contained in:
parent
54421ef8f5
commit
ec7474c9af
8 changed files with 277 additions and 65 deletions
112
build.zig
112
build.zig
|
|
@ -36,7 +36,10 @@ pub fn build(b: *std.Build) void {
|
|||
scanner.generate("river_layer_shell_v1", 1);
|
||||
scanner.generate("zwlr_layer_shell_v1", 3);
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
const options = b.addOptions();
|
||||
options.addOption([]const u8, "version", version);
|
||||
|
||||
const beansprout = b.addExecutable(.{
|
||||
.name = "beansprout",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
|
|
@ -45,42 +48,26 @@ pub fn build(b: *std.Build) void {
|
|||
.strip = strip,
|
||||
}),
|
||||
});
|
||||
exe.pie = pie;
|
||||
beansprout.pie = pie;
|
||||
|
||||
// Make sure to also add new imports to the exe_check step
|
||||
exe.root_module.addImport("wayland", wayland);
|
||||
exe.root_module.addImport("kdl", kdl);
|
||||
exe.root_module.addImport("known_folders", known_folders);
|
||||
exe.root_module.addImport("pixman", pixman);
|
||||
exe.root_module.addImport("xkbcommon", xkbcommon);
|
||||
exe.root_module.addImport("zigimg", zigimg);
|
||||
beansprout.root_module.addOptions("build_options", options);
|
||||
|
||||
exe.linkLibC();
|
||||
exe.linkSystemLibrary("wayland-client");
|
||||
exe.linkSystemLibrary("pixman-1");
|
||||
exe.linkSystemLibrary("xkbcommon");
|
||||
beansprout.root_module.addImport("wayland", wayland);
|
||||
beansprout.root_module.addImport("kdl", kdl);
|
||||
beansprout.root_module.addImport("known_folders", known_folders);
|
||||
beansprout.root_module.addImport("pixman", pixman);
|
||||
beansprout.root_module.addImport("xkbcommon", xkbcommon);
|
||||
beansprout.root_module.addImport("zigimg", zigimg);
|
||||
|
||||
b.installArtifact(exe);
|
||||
beansprout.linkLibC();
|
||||
beansprout.linkSystemLibrary("wayland-client");
|
||||
beansprout.linkSystemLibrary("pixman-1");
|
||||
beansprout.linkSystemLibrary("xkbcommon");
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
|
||||
// By making the run step depend on the install step, it will be run from the
|
||||
// installation directory rather than directly from within the cache directory.
|
||||
// This is not necessary, however, if the application depends on other installed
|
||||
// files, this ensures they will be present and in the expected location.
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
|
||||
// This allows the user to pass arguments to the application in the build
|
||||
// command itself, like this: `zig build run -- arg1 arg2 etc`
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
|
||||
const run_step = b.step("run", "Run beansprout");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
b.installArtifact(beansprout);
|
||||
|
||||
const exe_unit_tests = b.addTest(.{
|
||||
.root_module = exe.root_module,
|
||||
.root_module = beansprout.root_module,
|
||||
});
|
||||
|
||||
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
|
||||
|
|
@ -88,29 +75,44 @@ pub fn build(b: *std.Build) void {
|
|||
const test_step = b.step("test", "Run unit tests");
|
||||
test_step.dependOn(&run_exe_unit_tests.step);
|
||||
|
||||
// check step used for zls to give comptime info
|
||||
const exe_check = b.addExecutable(.{
|
||||
.name = "beansprout",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.strip = strip,
|
||||
}),
|
||||
});
|
||||
|
||||
exe_check.root_module.addImport("wayland", wayland);
|
||||
exe_check.root_module.addImport("kdl", kdl);
|
||||
exe_check.root_module.addImport("known_folders", known_folders);
|
||||
exe_check.root_module.addImport("pixman", pixman);
|
||||
exe_check.root_module.addImport("xkbcommon", xkbcommon);
|
||||
exe_check.root_module.addImport("zigimg", zigimg);
|
||||
|
||||
exe_check.linkLibC();
|
||||
exe_check.linkSystemLibrary("wayland-client");
|
||||
exe_check.linkSystemLibrary("pixman-1");
|
||||
exe_check.linkSystemLibrary("xkbcommon");
|
||||
|
||||
// Use by zls to get inline compilation errors
|
||||
const check = b.step("check", "Check if beansprout compiles");
|
||||
check.dependOn(&exe_check.step);
|
||||
check.dependOn(&beansprout.step);
|
||||
}
|
||||
|
||||
const version = manifest.version;
|
||||
/// Needed until https://github.com/ziglang/zig/issues/22775
|
||||
/// is addressed.
|
||||
const manifest: struct {
|
||||
name: @Type(.enum_literal),
|
||||
version: []const u8,
|
||||
fingerprint: u64,
|
||||
minimum_zig_version: []const u8,
|
||||
dependencies: struct {
|
||||
wayland: struct {
|
||||
url: []const u8,
|
||||
hash: []const u8,
|
||||
},
|
||||
xkbcommon: struct {
|
||||
url: []const u8,
|
||||
hash: []const u8,
|
||||
},
|
||||
kdl: struct {
|
||||
url: []const u8,
|
||||
hash: []const u8,
|
||||
},
|
||||
known_folders: struct {
|
||||
url: []const u8,
|
||||
hash: []const u8,
|
||||
},
|
||||
pixman: struct {
|
||||
url: []const u8,
|
||||
hash: []const u8,
|
||||
},
|
||||
zigimg: struct {
|
||||
url: []const u8,
|
||||
hash: []const u8,
|
||||
},
|
||||
},
|
||||
paths: []const []const u8,
|
||||
} = @import("build.zig.zon");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue