-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
91 lines (83 loc) · 3.2 KB
/
build.zig
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
const std = @import("std");
// TODO: support homebrew targets
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const SampleCore = struct {
name: []const u8,
path: []const u8,
desc: []const u8,
single_threaded: bool = true,
};
// TODO: https://github.com/ziglang/zig/issues/2231
// TODO: add more samples. webgpu dawn example, small libretro frontend...
// TODO: add my demo frontend here
// TODO: implement vulkan demo
const sample_cores = [_]SampleCore{
.{
.name = "basic",
.path = "samples/cores/basic.zig",
.desc = "A libretro v1 core skeleton",
},
.{
.name = "basic-cairo",
.path = "samples/cores/basic-cairo.zig",
.desc = "Showcasing software rendering with the Cairo 2D graphics library",
},
// TODO: disabled until dependency works with latest zig
//.{
// .name = "viewer",
// .path = "samples/cores/viewer.zig",
// .desc = "A simple image viewer using zigimg",
//},
.{
.name = "bytepusher",
.path = "samples/cores/bytepusher.zig",
.desc = "A BytePusher VM",
},
.{
.name = "basic-gl",
.path = "samples/cores/gl/basic.zig",
.desc = "A simple OpenGL triangle demo",
},
};
inline for (sample_cores) |core| {
const lib = b.addSharedLibrary(.{
.name = core.name ++ "_libretro",
.root_source_file = b.path(core.path),
.target = target,
.optimize = optimize,
.single_threaded = core.single_threaded,
});
// TODO: disabled until dependency works with latest zig
//const img = b.dependency("zigimg", .{
// .target = target,
// .optimize = optimize,
//});
//lib.root_module.addImport("zigimg", img.module("zigimg"));
const gl_bindings = @import("zigglgen").generateBindingsModule(b, .{
.api = .gl,
.version = .@"4.1",
.profile = .compatibility,
});
lib.root_module.addImport("gl", gl_bindings);
// TODO: don't prefix artifact name with lib on linux, and turn dashes into underscores
const retro_mod = b.addModule("retro", .{
.root_source_file = b.path("retro.zig"),
});
lib.root_module.addImport("retro", retro_mod);
lib.rdynamic = true;
if (!lib.rootModuleTarget().isWasm()) lib.linkLibC();
if (std.mem.eql(u8, core.name, "basic-cairo")) {
lib.linkSystemLibrary("cairo");
lib.addIncludePath(.{ .cwd_relative = "/usr/include/cairo" });
}
b.installArtifact(lib);
// TODO: what extension to use?
//const lib_install = b.addInstallFileWithDir(lib.getEmittedBin(), .lib, core.name ++ "_libretro.so");
//lib_install.step.dependOn(&lib.step);
//b.getInstallStep().dependOn(&lib_install.step);
//const run_step = b.step("run-" ++ core.name, core.desc ++ " (Run in RetroArch)";
//run_step.dependOn(&lib.step);
}
}