Skip to content

Commit 004cfd7

Browse files
committed
use zlib from package manager
1 parent d236733 commit 004cfd7

File tree

8 files changed

+18
-1638
lines changed

8 files changed

+18
-1638
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "zlib/zlib"]
2-
path = zlib/zlib
3-
url = [email protected]:madler/zlib.git

build.zig

+18-12
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,48 @@
11
const std = @import("std");
2-
const zlib_build = @import("zlib/zlib.zig");
32

43
pub fn build(b: *std.Build) void {
54
const target = b.standardTargetOptions(.{});
65
const optimize = b.standardOptimizeOption(.{});
76

8-
const zlib = zlib_build.create(b, target, optimize);
9-
//b.installArtifact(zlib.step);
7+
// Define dependencies.
8+
const zlib = b.dependency("zlib", .{});
109

11-
const zlib_module = b.addModule("zlib", .{
12-
.source_file = .{ .path = "zlib/src/main.zig" },
13-
});
10+
// Define module
1411
const ws_module = b.addModule("ws", .{
1512
.source_file = .{ .path = "src/main.zig" },
16-
.dependencies = &[_]std.Build.ModuleDependency{.{ .name = "zlib", .module = zlib_module }},
13+
.dependencies = &[_]std.Build.ModuleDependency{.{ .name = "zlib", .module = zlib.module("zlib") }},
1714
});
1815

16+
// Build library.
1917
const ws_lib = b.addStaticLibrary(.{
2018
.name = "ws",
2119
.root_source_file = .{ .path = "src/main.zig" },
2220
.target = target,
2321
.optimize = optimize,
2422
});
25-
zlib.link(ws_lib, .{ .import_name = "zlib" });
23+
// Link z library and zlib module.
24+
ws_lib.linkLibrary(b.dependency("zlib", .{
25+
.target = target,
26+
.optimize = optimize,
27+
}).artifact("z"));
28+
ws_lib.addModule("zlib", zlib.module("zlib"));
2629
b.installArtifact(ws_lib);
2730

28-
// zig build test
31+
// Build test.
2932
const test_compile = b.addTest(.{
3033
.root_source_file = .{ .path = "src/main.zig" },
3134
.target = target,
3235
.optimize = optimize,
3336
});
34-
zlib.link(test_compile, .{ .import_name = "zlib" });
35-
37+
test_compile.linkLibrary(b.dependency("zlib", .{
38+
.target = target,
39+
.optimize = optimize,
40+
}).artifact("z"));
41+
test_compile.addModule("zlib", zlib.module("zlib"));
3642
const test_step = b.step("test", "Run unit tests");
3743
test_step.dependOn(&test_compile.step);
3844

39-
// build examples
45+
// Build examples.
4046
const bin = b.addExecutable(.{
4147
.name = "autobahn_client",
4248
.root_source_file = .{ .path = "examples/autobahn_client.zig" },

zlib/build.zig

-27
This file was deleted.

zlib/example/example1.zig

-50
This file was deleted.

0 commit comments

Comments
 (0)