chore: update to zig master
current zig master has changes to build system TODO: make use of Zig's package manager
This commit is contained in:
		
							
								
								
									
										59
									
								
								build.zig
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								build.zig
									
									
									
									
									
								
							@@ -1,54 +1,49 @@
 | 
				
			|||||||
const std = @import("std");
 | 
					const std = @import("std");
 | 
				
			||||||
 | 
					const CompileStep = std.Build.CompileStep;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
fn path(comptime suffix: []const u8) []const u8 {
 | 
					fn path(comptime suffix: []const u8) []const u8 {
 | 
				
			||||||
    if (suffix[0] == '/') @compileError("expected a relative path");
 | 
					    if (suffix[0] == '/') @compileError("expected a relative path");
 | 
				
			||||||
    return comptime (std.fs.path.dirname(@src().file) orelse ".") ++ std.fs.path.sep_str ++ suffix;
 | 
					    return comptime (std.fs.path.dirname(@src().file) orelse ".") ++ std.fs.path.sep_str ++ suffix;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const pkgs = struct {
 | 
					pub fn link(exe: *CompileStep) void {
 | 
				
			||||||
    const Pkg = std.build.Pkg;
 | 
					    // create zig-network module
 | 
				
			||||||
 | 
					    const b = exe.builder;
 | 
				
			||||||
    pub const gdbstub: Pkg = .{
 | 
					 | 
				
			||||||
        .name = "gdbstub",
 | 
					 | 
				
			||||||
        .source = .{ .path = path("src/lib.zig") },
 | 
					 | 
				
			||||||
        .dependencies = &[_]Pkg{network},
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // https://github.com/MasterQ32/zig-network
 | 
					    // https://github.com/MasterQ32/zig-network
 | 
				
			||||||
    pub const network: Pkg = .{
 | 
					    const network = b.createModule(.{ .source_file = .{ .path = path("lib/zig-network/network.zig") } });
 | 
				
			||||||
        .name = "network",
 | 
					 | 
				
			||||||
        .source = .{ .path = path("lib/zig-network/network.zig") },
 | 
					 | 
				
			||||||
    };
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn link(exe: *std.build.LibExeObjStep) void {
 | 
					    const gdbstub = b.createModule(.{
 | 
				
			||||||
    exe.addPackage(pkgs.gdbstub);
 | 
					        .source_file = .{ .path = path("src/lib.zig") },
 | 
				
			||||||
 | 
					        .dependencies = &.{.{ .name = "network", .module = network }},
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    exe.addModule("gdbstub", gdbstub);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub fn build(b: *std.build.Builder) void {
 | 
					pub fn build(b: *std.Build) void {
 | 
				
			||||||
    const target = b.standardTargetOptions(.{});
 | 
					    const target = b.standardTargetOptions(.{});
 | 
				
			||||||
    _ = target;
 | 
					    // const optimize = b.standardOptimizeOption(.{});
 | 
				
			||||||
    const mode = b.standardReleaseOptions();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // -- library --
 | 
					    // -- Library --
 | 
				
			||||||
    const lib = b.addStaticLibrary("gdbstub", "src/lib.zig");
 | 
					 | 
				
			||||||
    lib.addPackage(pkgs.network);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    lib.setBuildMode(mode);
 | 
					    const lib_test = b.addTest(.{
 | 
				
			||||||
    lib.install();
 | 
					        .root_source_file = .{ .path = "src/lib.zig" },
 | 
				
			||||||
 | 
					        .target = target,
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const lib_tests = b.addTest("src/lib.zig");
 | 
					    const test_step = b.step("test", "Run Library Tests");
 | 
				
			||||||
    lib_tests.setBuildMode(mode);
 | 
					    test_step.dependOn(&lib_test.step);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const test_step = b.step("lib-test", "Run Library Tests");
 | 
					    // -- Executable --
 | 
				
			||||||
    test_step.dependOn(&lib_tests.step);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // // -- Executable --
 | 
					    // const exe = b.addExecutable(.{
 | 
				
			||||||
    // const exe = b.addExecutable("gdbserver", "src/main.zig");
 | 
					    //     .name = "gdbserver",
 | 
				
			||||||
 | 
					    //     .root_source_file = .{ .path = "src/main.zig" },
 | 
				
			||||||
 | 
					    //     .target = target,
 | 
				
			||||||
 | 
					    //     .optimize = optimize,
 | 
				
			||||||
 | 
					    // });
 | 
				
			||||||
    // link(exe);
 | 
					    // link(exe);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // exe.setTarget(target);
 | 
					 | 
				
			||||||
    // exe.setBuildMode(mode);
 | 
					 | 
				
			||||||
    // exe.install();
 | 
					    // exe.install();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // const run_cmd = exe.run();
 | 
					    // const run_cmd = exe.run();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user