From 9988aa6bfabeadd87855dd1e2253aed0d37d9587 Mon Sep 17 00:00:00 2001 From: Jengamon Date: Mon, 27 Mar 2023 13:29:18 -0700 Subject: [PATCH 1/5] Update build.zig Add module --- build.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.zig b/build.zig index 960acb0..7b1e824 100644 --- a/build.zig +++ b/build.zig @@ -11,6 +11,10 @@ pub fn build(b: *Build) void { // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const optimize = b.standardOptimizeOption(.{}); + + _ = b.addModule("linenoise", .{ + .source_file = .{ .path = "src/main.zig" }, + }); // Static library const lib = b.addStaticLibrary(.{ From bea724f0841d6f167f2878e1b53b8c31ac41048e Mon Sep 17 00:00:00 2001 From: Jengamon Date: Mon, 27 Mar 2023 13:54:03 -0700 Subject: [PATCH 2/5] Use Zig modules, rather than Git submodules - Lets people use other VCS - (UNSURE) currently committing build.zig.zon, not sure if I should do that for libraries --- .gitmodules | 3 --- build.zig | 10 ++++++++-- build.zig.zon | 10 ++++++++++ src/unicode.zig | 2 +- src/zig-wcwidth | 1 - 5 files changed, 19 insertions(+), 7 deletions(-) delete mode 100644 .gitmodules create mode 100644 build.zig.zon delete mode 160000 src/zig-wcwidth diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 895c3a9..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "src/zig-wcwidth"] - path = src/zig-wcwidth - url = https://github.com/joachimschmidt557/zig-wcwidth diff --git a/build.zig b/build.zig index 7b1e824..9c14267 100644 --- a/build.zig +++ b/build.zig @@ -11,11 +11,16 @@ pub fn build(b: *Build) void { // Standard release options allow the person running `zig build` to select // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const optimize = b.standardOptimizeOption(.{}); - + _ = b.addModule("linenoise", .{ .source_file = .{ .path = "src/main.zig" }, }); + const wcwidth = b.dependency("wcwidth", .{ + .target = target, + .optimize = optimize, + }); + // Static library const lib = b.addStaticLibrary(.{ .name = "linenoise", @@ -23,6 +28,7 @@ pub fn build(b: *Build) void { .target = target, .optimize = optimize, }); + lib.addModule("wcwidth", wcwidth.module("wcwidth")); lib.linkLibC(); lib.install(); @@ -55,7 +61,7 @@ pub fn build(b: *Build) void { // C example var c_example = b.addExecutable(.{ - .name = "example", + .name = "example", .root_source_file = FileSource.relative("examples/example.c"), .target = target, .optimize = optimize, diff --git a/build.zig.zon b/build.zig.zon new file mode 100644 index 0000000..06cf03c --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,10 @@ +.{ + .name = "linenoise", + .version = "0.1.0", + .dependencies = .{ + .wcwidth = .{ + .url = "https://github.com/Jengamon/zig-wcwidth/archive/42de26e5612ce9b86fffe882dc552ce63c59e521.tar.gz", + .hash = "1220eb67f8265fb314bbb2a27f3ccff51d16f53fcb006be4288e151e3ac4491ffa10", + }, + }, +} diff --git a/src/unicode.zig b/src/unicode.zig index 429dac7..5a294a1 100644 --- a/src/unicode.zig +++ b/src/unicode.zig @@ -2,7 +2,7 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const expectEqualSlices = std.testing.expectEqualSlices; -const wcwidth = @import("zig-wcwidth/src/main.zig").wcwidth; +const wcwidth = @import("wcwidth").wcwidth; pub fn width(s: []const u8) usize { var result: usize = 0; diff --git a/src/zig-wcwidth b/src/zig-wcwidth deleted file mode 160000 index e4a3422..0000000 --- a/src/zig-wcwidth +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e4a342233ea9803fc7f54d4597cf4294d77d57bc From b630e8cd26613e86bb6b309d44c8985511024125 Mon Sep 17 00:00:00 2001 From: Jengamon Date: Mon, 27 Mar 2023 14:20:22 -0700 Subject: [PATCH 3/5] Use deps properly --- build.zig | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/build.zig b/build.zig index 9c14267..94c9ff3 100644 --- a/build.zig +++ b/build.zig @@ -12,15 +12,21 @@ pub fn build(b: *Build) void { // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("linenoise", .{ - .source_file = .{ .path = "src/main.zig" }, - }); - const wcwidth = b.dependency("wcwidth", .{ .target = target, .optimize = optimize, }); + _ = b.addModule("linenoise", .{ + .source_file = .{ .path = "src/main.zig" }, + .dependencies = &.{ + .{ + .name = "wcwidth", + .module = wcwidth.module("wcwidth"), + }, + }, + }); + // Static library const lib = b.addStaticLibrary(.{ .name = "linenoise", From 192a12d2beb90ea3edc6ad23c8a695282f4e14e8 Mon Sep 17 00:00:00 2001 From: Jengamon Date: Thu, 6 Apr 2023 07:20:24 -0700 Subject: [PATCH 4/5] Use main wcwidth, and adjust to use modules --- build.zig | 8 +++----- build.zig.zon | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/build.zig b/build.zig index 94c9ff3..ffd8452 100644 --- a/build.zig +++ b/build.zig @@ -17,7 +17,7 @@ pub fn build(b: *Build) void { .optimize = optimize, }); - _ = b.addModule("linenoise", .{ + const linenoise = b.addModule("linenoise", .{ .source_file = .{ .path = "src/main.zig" }, .dependencies = &.{ .{ @@ -45,7 +45,7 @@ pub fn build(b: *Build) void { .target = target, .optimize = optimize, }); - + main_tests.addModule("wcwidth", wcwidth.module("wcwidth")); const test_step = b.step("test", "Run library tests"); test_step.dependOn(&main_tests.step); @@ -56,9 +56,7 @@ pub fn build(b: *Build) void { .target = target, .optimize = optimize, }); - example.addAnonymousModule("linenoise", .{ - .source_file = FileSource.relative("src/main.zig"), - }); + example.addModule("linenoise", linenoise); var example_run = example.run(); diff --git a/build.zig.zon b/build.zig.zon index 06cf03c..c3cde11 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -3,8 +3,8 @@ .version = "0.1.0", .dependencies = .{ .wcwidth = .{ - .url = "https://github.com/Jengamon/zig-wcwidth/archive/42de26e5612ce9b86fffe882dc552ce63c59e521.tar.gz", - .hash = "1220eb67f8265fb314bbb2a27f3ccff51d16f53fcb006be4288e151e3ac4491ffa10", + .url = "https://github.com/joachimschmidt557/zig-wcwidth/archive/f7296a31e83fe26240137404b56e64b9997afe04.tar.gz", + .hash = "12208294054b53630bc7a693cf2d8be329b434350986575b30f1ca657b982498f9a3", }, }, } From f6915e439debcaac0197a469748071622b5b4d73 Mon Sep 17 00:00:00 2001 From: Jengamon Date: Thu, 6 Apr 2023 07:23:53 -0700 Subject: [PATCH 5/5] Remove unnecessary line --- build.zig | 1 - 1 file changed, 1 deletion(-) diff --git a/build.zig b/build.zig index ffd8452..254b6b0 100644 --- a/build.zig +++ b/build.zig @@ -45,7 +45,6 @@ pub fn build(b: *Build) void { .target = target, .optimize = optimize, }); - main_tests.addModule("wcwidth", wcwidth.module("wcwidth")); const test_step = b.step("test", "Run library tests"); test_step.dependOn(&main_tests.step);