From 39a4260ffd83bae7bb44bb098872c96382fb5ba3 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 19 Jun 2023 12:04:35 -0500 Subject: [PATCH] chore: update to the new build system --- .gitmodules | 3 --- build.zig | 46 ++++++---------------------------------------- build.zig.zon | 10 ++++++++++ lib/zig-network | 1 - 4 files changed, 16 insertions(+), 44 deletions(-) create mode 100644 build.zig.zon delete mode 160000 lib/zig-network diff --git a/.gitmodules b/.gitmodules index 7e17c41..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "lib/zig-network"] - path = lib/zig-network - url = https://github.com/MasterQ32/zig-network diff --git a/build.zig b/build.zig index 504704d..cde8047 100644 --- a/build.zig +++ b/build.zig @@ -1,50 +1,16 @@ const std = @import("std"); -const CompileStep = std.Build.CompileStep; - -fn path(comptime suffix: []const u8) []const u8 { - if (suffix[0] == '/') @compileError("expected a relative path"); - return comptime (std.fs.path.dirname(@src().file) orelse ".") ++ std.fs.path.sep_str ++ suffix; -} - -pub fn getModule(b: *std.Build) *std.build.Module { - // https://github.com/MasterQ32/zig-network - const network = b.createModule(.{ .source_file = .{ .path = path("lib/zig-network/network.zig") } }); - - return b.createModule(.{ - .source_file = .{ .path = path("src/lib.zig") }, - .dependencies = &.{.{ .name = "network", .module = network }}, - }); -} pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); - // const optimize = b.standardOptimizeOption(.{}); + const net_dep = b.dependency("zig-network", .{}); // https://github.com/MasterQ32/zig-network - // -- Library -- - - const lib_test = b.addTest(.{ - .root_source_file = .{ .path = "src/lib.zig" }, - .target = target, + _ = b.addModule("gdbstub", .{ + .source_file = .{ .path = "src/lib.zig" }, + .dependencies = &.{.{ .name = "network", .module = net_dep.module("network") }}, }); + const lib_test = b.addTest(.{ .root_source_file = .{ .path = "src/lib.zig" }, .target = target }); + const test_step = b.step("test", "Run Library Tests"); test_step.dependOn(&lib_test.step); - - // -- Executable -- - - // const exe = b.addExecutable(.{ - // .name = "gdbserver", - // .root_source_file = .{ .path = "src/main.zig" }, - // .target = target, - // .optimize = optimize, - // }); - // link(exe); - // exe.install(); - - // const run_cmd = exe.run(); - // run_cmd.step.dependOn(b.getInstallStep()); - // if (b.args) |args| run_cmd.addArgs(args); - - // const run_step = b.step("run", "Run the app"); - // run_step.dependOn(&run_cmd.step); } diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..9e349a9 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,10 @@ +.{ + .name = "zba-gdbstub", + .version = "0.1.0", + .dependencies = .{ + .@"zig-network" = .{ + .url = "https://github.com/MasterQ32/zig-network/archive/86c315be67c7567195cc426615d81202a39bbb91.tar.gz", + .hash = "1220746fef79fb9774d76a0a5d746ccf30cfc847bce4a3a7388c3451817b7ab92869", + }, + }, +} diff --git a/lib/zig-network b/lib/zig-network deleted file mode 160000 index 45ae8cf..0000000 --- a/lib/zig-network +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 45ae8cf0ce3972eb4dddad3f5def8613c9b546f3