Skip to content

Commit a675dea

Browse files
authored
Start making Zig build forward-compatible with 0.13 (#16)
* Use path function for build script This matches the doc examples, and should be more forward-compatible (and it does indeed fix the build script for Zig 0.13) * Add dot-prefixed cache dir to gitignore I assume this is a change in recent zig
1 parent e5a29c3 commit a675dea

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

native/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
zig-cache/
2+
.zig-cache/
23
zig-out/
34
*.o
45
*.a

native/build.zig

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ pub fn build(b: *std.Build) void {
1414
});
1515
const libpotrace_flags = .{ "-std=gnu17", "-DHAVE_CONFIG_H" };
1616
libpotrace.linkLibC();
17-
libpotrace.addIncludePath(.{ .path = "lib/potrace-1.16/src" });
18-
libpotrace.addIncludePath(.{ .path = "lib/potrace-config" });
19-
libpotrace.addCSourceFile(.{ .file = .{ .path = "lib/potrace-1.16/src/curve.c" }, .flags = &libpotrace_flags });
20-
libpotrace.addCSourceFile(.{ .file = .{ .path = "lib/potrace-1.16/src/trace.c" }, .flags = &libpotrace_flags });
21-
libpotrace.addCSourceFile(.{ .file = .{ .path = "lib/potrace-1.16/src/decompose.c" }, .flags = &libpotrace_flags });
22-
libpotrace.addCSourceFile(.{ .file = .{ .path = "lib/potrace-1.16/src/potracelib.c" }, .flags = &libpotrace_flags });
17+
libpotrace.addIncludePath(b.path("lib/potrace-1.16/src"));
18+
libpotrace.addIncludePath(b.path("lib/potrace-config"));
19+
libpotrace.addCSourceFile(.{ .file = b.path("lib/potrace-1.16/src/curve.c"), .flags = &libpotrace_flags });
20+
libpotrace.addCSourceFile(.{ .file = b.path("lib/potrace-1.16/src/trace.c"), .flags = &libpotrace_flags });
21+
libpotrace.addCSourceFile(.{ .file = b.path("lib/potrace-1.16/src/decompose.c"), .flags = &libpotrace_flags });
22+
libpotrace.addCSourceFile(.{ .file = b.path("lib/potrace-1.16/src/potracelib.c"), .flags = &libpotrace_flags });
2323

2424
const libclipper2 = b.addStaticLibrary(.{
2525
.name = "clipper2",
@@ -30,54 +30,47 @@ pub fn build(b: *std.Build) void {
3030
const libclipper2_flags = .{ "-std=gnu++17", "-fno-exceptions", "-Dthrow=abort" };
3131
libclipper2.linkLibC();
3232
libclipper2.linkSystemLibrary("c++");
33-
libclipper2.addIncludePath(.{ .path = "lib/clipper2/CPP/Clipper2Lib" });
34-
libclipper2.addIncludePath(.{ .path = "src" });
33+
libclipper2.addIncludePath(b.path("lib/clipper2/CPP/Clipper2Lib"));
34+
libclipper2.addIncludePath(b.path("src"));
3535
libclipper2.addCSourceFile(.{
36-
.file = .{ .path = "lib/clipper2/CPP/Clipper2Lib/clipper.engine.cpp" },
36+
.file = b.path("lib/clipper2/CPP/Clipper2Lib/clipper.engine.cpp"),
3737
.flags = &libclipper2_flags,
3838
});
3939
libclipper2.addCSourceFile(.{
40-
.file = .{ .path = "lib/clipper2/CPP/Clipper2Lib/clipper.offset.cpp" },
40+
.file = b.path("lib/clipper2/CPP/Clipper2Lib/clipper.offset.cpp"),
4141
.flags = &libclipper2_flags,
4242
});
4343
libclipper2.addCSourceFile(.{
44-
.file = .{ .path = "src/clipperwrapper.cpp" },
44+
.file = b.path("src/clipperwrapper.cpp"),
4545
.flags = &libclipper2_flags,
4646
});
4747

48-
const libgingerbread = b.addExecutable(.{
49-
.name = "gingerbread",
50-
.root_source_file = .{ .path = "src/gingerbread.zig" },
51-
.version = .{ .major = 1, .minor = 0, .patch = 0 },
52-
.target = target,
53-
.optimize = optimize,
54-
.strip = true
55-
});
48+
const libgingerbread = b.addExecutable(.{ .name = "gingerbread", .root_source_file = b.path("src/gingerbread.zig"), .version = .{ .major = 1, .minor = 0, .patch = 0 }, .target = target, .optimize = optimize, .strip = true });
5649
libgingerbread.entry = .disabled;
5750
libgingerbread.rdynamic = true;
5851
libgingerbread.wasi_exec_model = std.builtin.WasiExecModel.reactor;
5952
libgingerbread.linkLibC();
6053
libgingerbread.linkLibrary(libpotrace);
6154
libgingerbread.linkLibrary(libclipper2);
62-
libgingerbread.addIncludePath(.{ .path = "src" });
63-
libgingerbread.addIncludePath(.{ .path = "lib/potrace-1.16/src" });
55+
libgingerbread.addIncludePath(b.path("src"));
56+
libgingerbread.addIncludePath(b.path("lib/potrace-1.16/src"));
6457

6558
b.installArtifact(libgingerbread);
6659

6760
// const main = b.addTest(.{
6861
// .name = "main",
69-
// .root_source_file = .{ .path = "src/tests.zig" },
62+
// .root_source_file = b.path("src/tests.zig"),
7063
// .target = target,
7164
// .optimize = optimize,
7265
// .link_libc = true,
7366
// });
7467
// main.linkLibrary(libpotrace);
7568
// main.linkLibrary(libclipper2);
76-
// main.addIncludePath(.{ .path = "src/" });
77-
// main.addIncludePath(.{ .path = "lib/potrace-1.16/src" });
78-
// main.addIncludePath(.{ .path = "lib/potrace-config" });
79-
// main.addIncludePath(.{ .path = "lib/stb" });
80-
// main.addCSourceFile(.{ .file = .{ .path = "src/load_image.c" }, .flags = &.{
69+
// main.addIncludePath(b.path("src/"));
70+
// main.addIncludePath(b.path("lib/potrace-1.16/src"));
71+
// main.addIncludePath(b.path("lib/potrace-config"));
72+
// main.addIncludePath(b.path("lib/stb"));
73+
// main.addCSourceFile(.{ .file = b.path("src/load_image.c"), .flags = &.{
8174
// "-std=gnu17",
8275
// } });
8376

0 commit comments

Comments
 (0)