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 960acb0..254b6b0 100644 --- a/build.zig +++ b/build.zig @@ -12,6 +12,21 @@ pub fn build(b: *Build) void { // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const optimize = b.standardOptimizeOption(.{}); + const wcwidth = b.dependency("wcwidth", .{ + .target = target, + .optimize = optimize, + }); + + const linenoise = b.addModule("linenoise", .{ + .source_file = .{ .path = "src/main.zig" }, + .dependencies = &.{ + .{ + .name = "wcwidth", + .module = wcwidth.module("wcwidth"), + }, + }, + }); + // Static library const lib = b.addStaticLibrary(.{ .name = "linenoise", @@ -19,6 +34,7 @@ pub fn build(b: *Build) void { .target = target, .optimize = optimize, }); + lib.addModule("wcwidth", wcwidth.module("wcwidth")); lib.linkLibC(); lib.install(); @@ -29,7 +45,6 @@ pub fn build(b: *Build) void { .target = target, .optimize = optimize, }); - const test_step = b.step("test", "Run library tests"); test_step.dependOn(&main_tests.step); @@ -40,9 +55,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(); @@ -51,7 +64,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..c3cde11 --- /dev/null +++ b/build.zig.zon @@ -0,0 +1,10 @@ +.{ + .name = "linenoise", + .version = "0.1.0", + .dependencies = .{ + .wcwidth = .{ + .url = "https://github.com/joachimschmidt557/zig-wcwidth/archive/f7296a31e83fe26240137404b56e64b9997afe04.tar.gz", + .hash = "12208294054b53630bc7a693cf2d8be329b434350986575b30f1ca657b982498f9a3", + }, + }, +} 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