Repository navigation
Expand file tree
/
Copy pathbuild.zig
More file actions
100 lines (88 loc) · 3.07 KB
/
Copy pathbuild.zig
File metadata and controls
100 lines (88 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const upstream = b.dependency("upstream", .{});
const libusb_opt = b.option(bool, "libusb", "Enable libusb (default: true)") orelse true;
const jaylink_mod = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
});
if (libusb_opt) {
const libusb_dep = b.dependency("libusb", .{ .target = target, .optimize = optimize, .linkage = .static, .@"system-libudev" = false });
const libusb = libusb_dep.artifact("usb");
jaylink_mod.linkLibrary(libusb);
}
const jaylink_lib = b.addLibrary(.{
.name = "jaylink",
.root_module = jaylink_mod,
});
b.installArtifact(jaylink_lib);
const build_zig_zon = @import("build.zig.zon");
const semver = std.SemanticVersion.parse(build_zig_zon.version) catch unreachable;
const version = b.addConfigHeader(
.{ .style = .{ .autoconf_at = upstream.path("libjaylink/version.h.in") } },
.{
.JAYLINK_VERSION_PACKAGE_MAJOR = @as(i64, @intCast(semver.major)),
.JAYLINK_VERSION_PACKAGE_MINOR = @as(i64, @intCast(semver.minor)),
.JAYLINK_VERSION_PACKAGE_MICRO = @as(i64, @intCast(semver.patch)),
.JAYLINK_VERSION_PACKAGE = build_zig_zon.version,
.JAYLINK_VERSION_LIBRARY_CURRENT = 0,
.JAYLINK_VERSION_LIBRARY_REVISION = 0,
.JAYLINK_VERSION_LIBRARY_AGE = 0,
.JAYLINK_VERSION_LIBRARY = "0:0:0",
},
);
const config = b.addConfigHeader(
.{ .style = .{ .blank = {} }, .include_path = "config.h" },
.{
.HAVE_LIBUSB = if (libusb_opt) true else null,
},
);
jaylink_lib.installHeadersDirectory(upstream.path("libjaylink"), "libjaylink", .{});
jaylink_lib.installHeader(version.getOutputFile(), "libjaylink/version.h");
jaylink_mod.addConfigHeader(version);
jaylink_mod.addConfigHeader(config);
jaylink_mod.addIncludePath(upstream.path("libjaylink"));
jaylink_mod.addCSourceFiles(.{
.root = upstream.path("libjaylink"),
.files = &.{
"buffer.c",
"core.c",
"device.c",
"discovery.c",
"discovery_tcp.c",
"emucom.c",
"error.c",
"fileio.c",
"jtag.c",
"list.c",
"log.c",
"socket.c",
"strutil.c",
"swd.c",
"swo.c",
"target.c",
"transport.c",
"transport_tcp.c",
"util.c",
"version.c",
},
.flags = &.{
"-DHAVE_CONFIG_H",
},
});
if (libusb_opt) {
jaylink_mod.addCSourceFiles(.{
.root = upstream.path("libjaylink"),
.files = &.{
"discovery_usb.c",
"transport_usb.c",
},
.flags = &.{
"-DHAVE_CONFIG_H",
},
});
}
}