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

zig-build: lazyPath fixes #455

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions .github/workflows/zig_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ jobs:
with:
submodules: recursive
fetch-depth: 0
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.12.0
- uses: mlugg/setup-zig@v1 # default latest-release version

- 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)
Loading