Skip to content

Commit

Permalink
zig-build: lazyPath fixes
Browse files Browse the repository at this point in the history
compat: v0.12.0, v0.13.0 & v0.14.0-dev
* switch zlib-master to latest release (git tag branch)
  • Loading branch information
kassane committed Sep 12, 2024
1 parent d963343 commit 3c98e72
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/zig_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fetch-depth: 0
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.12.0
version: 0.13.0

- name: Build Summary
run: zig build -DBUILD_TESTS -DBUILD_EXAMPLES -DUSE_SYSTEM_MINIZIP --summary all -freference-trace
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ cmake

.vscode

zig-cache/
zig-out/
*zig-cache/
zig-out/
55 changes: 32 additions & 23 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
const std = @import("std");

// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be libcuted by an external
// runner.
const xlsxw_version: std.SemanticVersion = .{
.major = 1,
.minor = 1,
.patch = 9,
};

pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});

// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});

const shared = b.option(bool, "SHARED_LIBRARY", "Build the Shared Library [default: false]") orelse false;
Expand All @@ -27,11 +22,7 @@ pub fn build(b: *std.Build) void {
.name = "xlsxwriter",
.target = target,
.optimize = optimize,
.version = .{
.major = 1,
.minor = 1,
.patch = 7,
},
.version = xlsxw_version,
}) else b.addStaticLibrary(.{
.name = "xlsxwriter",
.target = target,
Expand Down Expand Up @@ -95,17 +86,26 @@ pub fn build(b: *std.Build) void {

// md5
if (!md5)
lib.addCSourceFile(.{ .file = .{ .path = "third_party/md5/md5.c" }, .flags = cflags })
lib.addCSourceFile(.{
.file = b.path("third_party/md5/md5.c"),
.flags = cflags,
})
else
lib.linkSystemLibrary("crypto");

// dtoa
if (dtoa)
lib.addCSourceFile(.{ .file = b.path("third_party/dtoa/emyg_dtoa.c"), .flags = cflags });
lib.addCSourceFile(.{
.file = b.path("third_party/dtoa/emyg_dtoa.c"),
.flags = cflags,
});

// tmpfileplus
if (stdtmpfile)
lib.addCSourceFile(.{ .file = .{ .path = "third_party/tmpfileplus/tmpfileplus.c" }, .flags = cflags })
lib.addCSourceFile(.{
.file = b.path("third_party/tmpfileplus/tmpfileplus.c"),
.flags = cflags,
})
else
lib.defineCMacro("USE_STANDARD_TMPFILE", null);

Expand Down Expand Up @@ -253,10 +253,13 @@ fn buildExe(b: *std.Build, info: BuildInfo) void {
.optimize = info.lib.root_module.optimize.?,
.target = info.lib.root_module.resolved_target.?,
});
exe.addCSourceFile(.{ .file = b.path(info.path), .flags = cflags });
exe.addCSourceFile(.{
.file = b.path(info.path),
.flags = cflags,
});
exe.linkLibrary(info.lib);
for (info.lib.root_module.include_dirs.items) |include| {
exe.root_module.include_dirs.append(b.allocator, include) catch {};
exe.root_module.include_dirs.append(b.allocator, include) catch @panic("OOM");
}
exe.linkLibC();
b.installArtifact(exe);
Expand All @@ -281,8 +284,14 @@ fn buildTest(b: *std.Build, info: BuildInfo) void {
.target = info.lib.root_module.resolved_target.?,
});
exe.defineCMacro("TESTING", null);
exe.addCSourceFile(.{ .file = b.path(info.path), .flags = cflags });
exe.addCSourceFile(.{ .file = b.path("test/unit/test_all.c"), .flags = cflags });
exe.addCSourceFile(.{
.file = b.path(info.path),
.flags = cflags,
});
exe.addCSourceFile(.{
.file = b.path("test/unit/test_all.c"),
.flags = cflags,
});
exe.addIncludePath(b.path("test/unit"));
for (info.lib.root_module.include_dirs.items) |include| {
exe.root_module.include_dirs.append(b.allocator, include) catch {};
Expand Down
10 changes: 6 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
.{
.name = "libxlsxwriter",
.version = "1.1.7",
.version = "1.1.9",
.dependencies = .{
.zlib = .{
.url = "git+https://github.com/madler/zlib#0f51fb4933fc9ce18199cb2554dacea8033e7fd3",
.hash = "12204f12291d6eeb1e05f19d8ab0c7f46c9073fae4c3568dcae7aade149db0b45047",
.lazy = true,
.url = "git+https://github.com/madler/zlib#v1.3.1",
.hash = "1220fed0c74e1019b3ee29edae2051788b080cd96e90d56836eea857b0b966742efb",
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"Readme.md",
"License.txt",
"src",
"include",
"third_party",
},
}
//syntax tip: zig - anon struct (json-like)

0 comments on commit 3c98e72

Please # to comment.