Skip to content

Commit 6087867

Browse files
committed
Declare all cmake variables
1 parent 8e12ceb commit 6087867

File tree

1 file changed

+61
-40
lines changed

1 file changed

+61
-40
lines changed

build.zig

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
const std = @import("std");
22

3+
const version = .{ .major = 0, .minor = 17 };
4+
35
pub fn build(b: *std.Build) !void {
46
const target = b.standardTargetOptions(.{});
57
const optimize = b.standardOptimizeOption(.{});
68

79
const upstream = b.dependency("upstream", .{ .target = target, .optimize = optimize });
810

9-
const config = b.addConfigHeader(.{
10-
.style = .{ .cmake = upstream.path("cmake/config.h.in") },
11-
.include_path = "config.h",
12-
}, cmake_config);
11+
const config = b.addConfigHeader(
12+
.{
13+
.style = .{ .cmake = upstream.path("cmake/config.h.in") },
14+
.include_path = "config.h",
15+
},
16+
cmake_config,
17+
);
1318
const json_config = b.addConfigHeader(
1419
.{
1520
.style = .{ .cmake = upstream.path("cmake/json_config.h.in") },
@@ -41,55 +46,61 @@ pub fn build(b: *std.Build) !void {
4146
.optimize = optimize,
4247
.link_libc = true,
4348
});
49+
lib.addIncludePath(upstream.path(""));
4450
lib.addConfigHeader(config);
4551
lib.addConfigHeader(json_config);
4652
lib.addConfigHeader(json);
4753
lib.installHeader(json_config.getOutput(), "json-c/json_config.h");
4854
lib.installHeader(json.getOutput(), "json-c/json.h");
49-
lib.addIncludePath(upstream.path(""));
5055
lib.root_module.addCMacro("_GNU_SOURCE", "1");
5156
lib.addCSourceFiles(.{
5257
.root = upstream.path(""),
53-
.files = &.{
54-
"arraylist.c",
55-
"debug.c",
56-
"json_c_version.c",
57-
"json_object.c",
58-
"json_object_iterator.c",
59-
"json_patch.c",
60-
"json_pointer.c",
61-
"json_tokener.c",
62-
"json_util.c",
63-
"json_visit.c",
64-
"libjson.c",
65-
"linkhash.c",
66-
"printbuf.c",
67-
"random_seed.c",
68-
"strerror_override.c",
69-
},
58+
.files = &source_files,
7059
.flags = &CFLAGS,
7160
});
72-
lib.installHeadersDirectory(upstream.path(""), "json-c", .{
73-
.include_extensions = &.{
74-
"arraylist.h",
75-
"debug.h",
76-
"json_c_version.h",
77-
"json_inttypes.h",
78-
"json_object.h",
79-
"json_object_iterator.h",
80-
"json_tokener.h",
81-
"json_types.h",
82-
"json_util.h",
83-
"json_visit.h",
84-
"linkhash.h",
85-
"printbuf.h",
86-
"json_pointer.h",
87-
"json_patch.h",
88-
},
89-
});
61+
lib.installHeadersDirectory(
62+
upstream.path(""),
63+
"json-c",
64+
.{ .include_extensions = &public_headers },
65+
);
9066
b.installArtifact(lib);
9167
}
9268

69+
const source_files = .{
70+
"arraylist.c",
71+
"debug.c",
72+
"json_c_version.c",
73+
"json_object.c",
74+
"json_object_iterator.c",
75+
"json_patch.c",
76+
"json_pointer.c",
77+
"json_tokener.c",
78+
"json_util.c",
79+
"json_visit.c",
80+
"libjson.c",
81+
"linkhash.c",
82+
"printbuf.c",
83+
"random_seed.c",
84+
"strerror_override.c",
85+
};
86+
87+
const public_headers = .{
88+
"arraylist.h",
89+
"debug.h",
90+
"json_c_version.h",
91+
"json_inttypes.h",
92+
"json_object.h",
93+
"json_object_iterator.h",
94+
"json_patch.h",
95+
"json_pointer.h",
96+
"json_tokener.h",
97+
"json_types.h",
98+
"json_util.h",
99+
"json_visit.h",
100+
"linkhash.h",
101+
"printbuf.h",
102+
};
103+
93104
const CFLAGS = .{
94105
"-Wall",
95106
"-Wextra",
@@ -155,4 +166,14 @@ const cmake_config = .{
155166
.SIZEOF_SSIZE_T = @sizeOf(isize),
156167
.SPEC___THREAD = "__thread",
157168
.STDC_HEADERS = 1,
169+
170+
.json_c_strtoll = null,
171+
.json_c_strtoull = null,
172+
.PROJECT_NAME = "json-c",
173+
.JSON_C_BUGREPORT = "json-c@googlegroups.com",
174+
.CPACK_PACKAGE_VERSION_MAJOR = version.major,
175+
.CPACK_PACKAGE_VERSION_MINOR = version.minor,
176+
.CPACK_PACKAGE_VERSION_PATCH = 0,
177+
.ENABLE_RDRAND = null,
178+
.OVERRIDE_GET_RANDOM_SEED = null,
158179
};

0 commit comments

Comments
 (0)