Skip to content

Commit

Permalink
fix: adopt with upstream (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 authored Jan 7, 2024
1 parent 086e718 commit 672015b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ endif

.PHONY: clean
clean:
rm -f zig-out zig-cache
rm -rf zig-out zig-cache
12 changes: 5 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ pub fn build(b: *std.Build) !void {
try addExample(b, run_all_step);
}

fn addExample(b: *std.Build, run_all: *std.build.Step) !void {
fn addExample(b: *std.Build, run_all: *std.Build.Step) !void {
const gt_zig_0_11 = builtin.zig_version.minor > 11;
const src_dir = if (gt_zig_0_11)
try fs.cwd().openDir("src", .{ .iterate = true })
else
try fs.cwd().openIterableDir("src", .{});

const target = b.standardTargetOptions(.{});
var it = src_dir.iterate();
while (try it.next()) |entry| {
switch (entry.kind) {
Expand All @@ -24,26 +25,23 @@ fn addExample(b: *std.Build, run_all: *std.build.Step) !void {
const exe = b.addExecutable(.{
.name = try allocPrint(b.allocator, "examples-{s}", .{name}),
.root_source_file = .{ .path = try allocPrint(b.allocator, "src/{s}.zig", .{name}) },
.target = .{},
.target = target,
.optimize = .Debug,
});
if (std.mem.eql(u8, "13-01", name) and gt_zig_0_11) {
const zigcli = b.dependency("zigcli", .{});
exe.addModule("simargs", zigcli.module("simargs"));
exe.root_module.addImport("simargs", zigcli.module("simargs"));
} else if (std.mem.eql(u8, "14-01", name)) {
exe.linkSystemLibrary("sqlite3");
exe.linkLibC();
// const sqlite = b.dependency("sqlite", .{});
// exe.addModule("sqlite", sqlite.module("sqlite"));
// exe.linkLibrary(sqlite.artifact("sqlite"));
} else if (std.mem.eql(u8, "14-02", name)) {
exe.linkSystemLibrary("libpq");
exe.linkLibC();
} else if (std.mem.eql(u8, "15-01", name)) {
const lib = b.addStaticLibrary(.{
.name = "regex_slim",
.optimize = .Debug,
.target = .{},
.target = target,
});
lib.addIncludePath(.{ .path = "lib" });
if (gt_zig_0_11) {
Expand Down
9 changes: 3 additions & 6 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
.version = "0.1.0",
.paths = .{
"src",
"lib",
"build.zig",
"build.zig.zon",
},
.dependencies = .{
.zigcli = .{
.url = "https://github.com/jiacai2050/zigcli/archive/d5db773.tar.gz",
.hash = "1220f4ba4de1b2574bc0f10977bcce464933f7c01c9a071b4484f1b0bda56de30a67",
},
.sqlite = .{
.url = "https://github.com/vrischmann/zig-sqlite/archive/aa6f95b.tar.gz",
.hash = "1220d751f09c5c18c45f0a42af71ff255e62ae73deb34567ca42e9e67c614a4daa5a",
.url = "https://github.com/jiacai2050/zigcli/archive/1e83260.tar.gz",
.hash = "12202a9e207619ea538b0d60456391a4699864a432dfdad236bfd6cfc691663b67e8",
},
},
}
2 changes: 1 addition & 1 deletion src/08-02.zig
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn main() !void {
try child.collectOutput(&stdout, &stderr, 1024);
const term = try child.wait();

try std.testing.expectEqual(term, .{ .Exited = 0 });
try std.testing.expectEqual(term.Exited, 0);
try std.testing.expectEqualStrings("hello world", stdout.items);
try std.testing.expectEqualStrings("", stderr.items);
}

0 comments on commit 672015b

Please sign in to comment.