Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Zig modules #14

Merged
merged 5 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

23 changes: 18 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,29 @@ 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",
.root_source_file = FileSource.relative("src/c.zig"),
.target = target,
.optimize = optimize,
});
lib.addModule("wcwidth", wcwidth.module("wcwidth"));
lib.linkLibC();
lib.install();

Expand All @@ -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);

Expand All @@ -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();

Expand All @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -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",
},
},
}
2 changes: 1 addition & 1 deletion src/unicode.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/zig-wcwidth
Submodule zig-wcwidth deleted from e4a342