|
1 | 1 | const std = @import("std");
|
2 | 2 |
|
| 3 | +const version = .{ .major = 0, .minor = 17 }; |
| 4 | + |
3 | 5 | pub fn build(b: *std.Build) !void {
|
4 | 6 | const target = b.standardTargetOptions(.{});
|
5 | 7 | const optimize = b.standardOptimizeOption(.{});
|
6 | 8 |
|
7 | 9 | const upstream = b.dependency("upstream", .{ .target = target, .optimize = optimize });
|
8 | 10 |
|
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 | + ); |
13 | 18 | const json_config = b.addConfigHeader(
|
14 | 19 | .{
|
15 | 20 | .style = .{ .cmake = upstream.path("cmake/json_config.h.in") },
|
@@ -41,55 +46,61 @@ pub fn build(b: *std.Build) !void {
|
41 | 46 | .optimize = optimize,
|
42 | 47 | .link_libc = true,
|
43 | 48 | });
|
| 49 | + lib.addIncludePath(upstream.path("")); |
44 | 50 | lib.addConfigHeader(config);
|
45 | 51 | lib.addConfigHeader(json_config);
|
46 | 52 | lib.addConfigHeader(json);
|
47 | 53 | lib.installHeader(json_config.getOutput(), "json-c/json_config.h");
|
48 | 54 | lib.installHeader(json.getOutput(), "json-c/json.h");
|
49 |
| - lib.addIncludePath(upstream.path("")); |
50 | 55 | lib.root_module.addCMacro("_GNU_SOURCE", "1");
|
51 | 56 | lib.addCSourceFiles(.{
|
52 | 57 | .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, |
70 | 59 | .flags = &CFLAGS,
|
71 | 60 | });
|
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 | + ); |
90 | 66 | b.installArtifact(lib);
|
91 | 67 | }
|
92 | 68 |
|
| 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 | + |
93 | 104 | const CFLAGS = .{
|
94 | 105 | "-Wall",
|
95 | 106 | "-Wextra",
|
@@ -155,4 +166,14 @@ const cmake_config = .{
|
155 | 166 | .SIZEOF_SSIZE_T = @sizeOf(isize),
|
156 | 167 | .SPEC___THREAD = "__thread",
|
157 | 168 | .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, |
158 | 179 | };
|
0 commit comments