From 18379cf86c1ab86f390544067cf340d20b4659e2 Mon Sep 17 00:00:00 2001 From: torque Date: Thu, 1 Jun 2023 22:35:12 -0700 Subject: [PATCH] build.zig: trip over the finish line for becoming a module It's pretty easy. This is the first step to spinning zed off as a separate project, which has been the plan for a while now. --- build.zig | 60 +++++++++---------------------------------------------- 1 file changed, 9 insertions(+), 51 deletions(-) diff --git a/build.zig b/build.zig index b69ecf2..f7a4796 100644 --- a/build.zig +++ b/build.zig @@ -1,12 +1,14 @@ const std = @import("std"); -pub fn build(b: *std.build.Builder) void { - const target = b.standardTargetOptions(.{}); - const optimize = b.standardOptimizeOption(.{}); +pub fn build(b: *std.Build) void { + const target: std.Build.CrossTarget = b.standardTargetOptions(.{}); + const optimize: std.builtin.Mode = b.standardOptimizeOption(.{}); - demo(b, target, optimize); - tokenator(b, target, optimize); - zed(b, target, optimize); + const noclip = b.addModule("noclip", .{ + .source_file = .{ .path = "source/noclip.zig" } + }); + + demo(b, noclip, target, optimize); const test_step = b.step("test", "Run unit tests"); const tests = b.addTest(.{ @@ -19,9 +21,8 @@ pub fn build(b: *std.build.Builder) void { test_step.dependOn(&tests.step); } -fn demo(b: *std.build.Builder, target: anytype, optimize: anytype) void { +fn demo(b: *std.Build, noclip: *std.Build.Module, target: std.Build.CrossTarget, optimize: std.builtin.Mode) void { const demo_step = b.step("demo", "Build and install CLI demo program"); - const noclip = b.createModule(.{ .source_file = .{ .path = "source/noclip.zig" } }); const exe = b.addExecutable(.{ .name = "noclip-demo", @@ -34,46 +35,3 @@ fn demo(b: *std.build.Builder, target: anytype, optimize: anytype) void { demo_step.dependOn(&install_demo.step); } - -fn tokenator(b: *std.build.Builder, target: anytype, optimize: anytype) void { - const tok_step = b.step("tokenator", "Build documentation tokenizer"); - const noclip = b.createModule(.{ .source_file = .{ .path = "source/noclip.zig" } }); - - const exe = b.addExecutable(.{ - .name = "tokenator", - .root_source_file = .{ .path = "documentation/tokenator.zig" }, - .target = target, - .optimize = optimize, - }); - exe.addModule("noclip", noclip); - const install_tok = b.addInstallArtifact(exe); - - tok_step.dependOn(&install_tok.step); -} - -fn zed(b: *std.build.Builder, target: anytype, optimize: anytype) void { - const tok_step = b.step("zed", "Build documentation generator"); - const noclip = b.createModule(.{ .source_file = .{ .path = "source/noclip.zig" } }); - - const exe = b.addExecutable(.{ - .name = "zed", - .root_source_file = .{ .path = "documentation/zed.zig" }, - .target = target, - .optimize = optimize, - }); - exe.addModule("noclip", noclip); - const install_tok = b.addInstallArtifact(exe); - - tok_step.dependOn(&install_tok.step); - - const test_step = b.step("run-zed-tests", "Test documentation generator"); - const tests = b.addTest(.{ - .name = "test-zed", - .root_source_file = .{ .path = "documentation/zed.zig" }, - .target = target, - .optimize = optimize, - }); - - const runcmd = b.addRunArtifact(tests); - test_step.dependOn(&runcmd.step); -}