Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn build(b: *std.Build) !void {
const sdl_ttf_dep = b.dependency("sdl_ttf", .{});
const freetype_dep = b.dependency("freetype", .{});
const wayland_scanner_dep = b.dependency("wayland_scanner", .{
.target = b.host,
.target = b.graph.host,
.optimize = .ReleaseFast,
});
const font_dep = b.dependency("fonts", .{});
Expand Down Expand Up @@ -41,12 +41,12 @@ pub fn build(b: *std.Build) !void {
.ReleaseFast, .ReleaseSmall, .ReleaseSafe => 0,
.Debug => 3,
};
lib.defineCMacro("SDL_ASSERT_LEVEL", b.fmt("{d}", .{SDL_ASSERT_LEVEL}));
lib.root_module.addCMacro("SDL_ASSERT_LEVEL", b.fmt("{d}", .{SDL_ASSERT_LEVEL}));

if (optimize != .Debug) {
lib.defineCMacro("NDEBUG", "1");
lib.defineCMacro("__FILE__", "\"__FILE__\"");
lib.defineCMacro("__LINE__", "0");
lib.root_module.addCMacro("NDEBUG", "1");
lib.root_module.addCMacro("__FILE__", "\"__FILE__\"");
lib.root_module.addCMacro("__LINE__", "0");
}

lib.linkLibC();
Expand All @@ -65,7 +65,7 @@ pub fn build(b: *std.Build) !void {
lib.linkSystemLibrary("version");
lib.linkSystemLibrary("oleaut32");
lib.linkSystemLibrary("ole32");
lib.defineCMacro("SDL_USE_BUILTIN_OPENGL_DEFINITIONS", "1");
lib.root_module.addCMacro("SDL_USE_BUILTIN_OPENGL_DEFINITIONS", "1");
},
.macos => {
lib.addCSourceFiles(.{
Expand All @@ -78,7 +78,7 @@ pub fn build(b: *std.Build) !void {
.files = &objective_c_src_files,
.flags = &.{"-fobjc-arc"},
});
lib.defineCMacro("SDL_USE_BUILTIN_OPENGL_DEFINITIONS", "1");
lib.root_module.addCMacro("SDL_USE_BUILTIN_OPENGL_DEFINITIONS", "1");

// TODO: re-check which frameworks are needed
lib.linkFramework("AudioToolbox");
Expand All @@ -94,14 +94,14 @@ pub fn build(b: *std.Build) !void {
lib.linkFramework("CoreVideo");
lib.linkFramework("ForceFeedback");
lib.linkFramework("Foundation");
lib.linkFrameworkWeak("GameController");
lib.linkFramework("GameController");
lib.linkFramework("IOKit");
lib.linkFrameworkWeak("Metal");
lib.linkFrameworkWeak("QuartzCore");
lib.linkFrameworkWeak("UniformTypeIdentifiers");
lib.linkFramework("Metal");
lib.linkFramework("QuartzCore");
lib.linkFramework("UniformTypeIdentifiers");
lib.linkSystemLibrary("objc");

const sdk = std.zig.system.darwin.getSdk(b.allocator, b.host.result) orelse
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse
@panic("macOS SDK is missing");
lib.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
lib.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
Expand Down Expand Up @@ -376,7 +376,7 @@ pub fn build(b: *std.Build) !void {

inline for (std.meta.fields(@TypeOf(values))) |f| {
const value = b.fmt("{any}", .{@field(values, f.name)});
lib.defineCMacro(f.name, value);
lib.root_module.addCMacro(f.name, value);
}

// SDL3_DYNAMIC_API=/my/actual/libSDL3.so.0
Expand All @@ -387,7 +387,7 @@ pub fn build(b: *std.Build) !void {

// Avoid
// SDL/include/build_config/SDL_build_config_minimal.h
lib.defineCMacro("SDL_build_config_minimal_h_", "1");
lib.root_module.addCMacro("SDL_build_config_minimal_h_", "1");

//--

Expand Down Expand Up @@ -523,7 +523,7 @@ pub fn build(b: *std.Build) !void {
SDL_ttf.linkLibrary(freetype_dep.artifact("freetype"));

if (target.result.os.tag == .macos) {
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.host.result) orelse
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse
@panic("macOS SDK is missing");
SDL_ttf.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
SDL_ttf.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
Expand Down Expand Up @@ -582,7 +582,7 @@ pub fn build(b: *std.Build) !void {
exe.root_module.addImport("sdl", module);

if (target.result.os.tag == .macos) {
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.host.result) orelse
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse
@panic("macOS SDK is missing");
exe.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
exe.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
Expand Down Expand Up @@ -855,7 +855,7 @@ pub fn build(b: *std.Build) !void {
exe.linkLibrary(test_utils);

if (target.result.os.tag == .macos) {
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.host.result) orelse
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse
@panic("macOS SDK is missing");
exe.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
exe.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
Expand Down Expand Up @@ -928,7 +928,7 @@ pub fn build(b: *std.Build) !void {
exe.linkLibrary(lib);

if (target.result.os.tag == .macos) {
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.host.result) orelse
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse
@panic("macOS SDK is missing");
exe.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
exe.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
Expand Down
5 changes: 3 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// SPDX-License-Identifier: Zlib

.{
.name = "sdl",
.version = "0.0.0",
.name = .sdl,
.version = "0.0.1",
.fingerprint = 0xec638ccb9c209e38,
.paths = .{""},
.dependencies = .{
.sdl = .{
Expand Down
3 changes: 2 additions & 1 deletion build/fonts/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// SPDX-License-Identifier: Zlib

.{
.name = "fonts",
.name = .fonts,
.version = "0.0.0",
.fingerprint = 0x7303e8fb6c57db3a,
.paths = .{""},
.dependencies = .{
.intel_one_mono = .{
Expand Down
14 changes: 7 additions & 7 deletions build/freetype/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub fn build(b: *std.Build) !void {
});
{
if (optimize != .Debug) {
lib.defineCMacro("NDEBUG", "1");
lib.defineCMacro("__FILE__", "\"__FILE__\"");
lib.defineCMacro("__LINE__", "0");
lib.root_module.addCMacro("NDEBUG", "1");
lib.root_module.addCMacro("__FILE__", "\"__FILE__\"");
lib.root_module.addCMacro("__LINE__", "0");
}

lib.addCSourceFiles(.{
Expand Down Expand Up @@ -72,9 +72,9 @@ pub fn build(b: *std.Build) !void {
.flags = &.{},
});

lib.defineCMacro("FT2_BUILD_LIBRARY", "1");
lib.defineCMacro("HAVE_UNISTD_H", "");
lib.defineCMacro("HAVE_FCNTL_H", "");
lib.root_module.addCMacro("FT2_BUILD_LIBRARY", "1");
lib.root_module.addCMacro("HAVE_UNISTD_H", "");
lib.root_module.addCMacro("HAVE_FCNTL_H", "");

switch (target.result.os.tag) {
.windows => {
Expand Down Expand Up @@ -109,7 +109,7 @@ pub fn build(b: *std.Build) !void {
lib.installHeadersDirectory(freetype_dep.path("include/freetype"), "freetype", .{});

if (target.result.os.tag == .macos) {
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.host.result) orelse
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse
@panic("macOS SDK is missing");
lib.addSystemIncludePath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/usr/include" }) });
lib.addSystemFrameworkPath(.{ .cwd_relative = b.pathJoin(&.{ sdk, "/System/Library/Frameworks" }) });
Expand Down
3 changes: 2 additions & 1 deletion build/freetype/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// SPDX-License-Identifier: Zlib

.{
.name = "freetype",
.name = .freetype,
.version = "0.0.0",
.fingerprint = 0xac2059b689838d78,
.paths = .{""},
.dependencies = .{
// NOTE: matches SDL_ttf's external/freetype submodule
Expand Down
4 changes: 2 additions & 2 deletions build/wayland_scanner/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub fn build(b: *std.Build) !void {

const expat = b.addStaticLibrary(.{
.name = "expat",
.target = b.host,
.target = b.graph.host,
.optimize = optimize,
});
{
Expand Down Expand Up @@ -68,7 +68,7 @@ pub fn build(b: *std.Build) !void {

const wayland_scanner = b.addExecutable(.{
.name = "wayland-scanner",
.target = b.host,
.target = b.graph.host,
.optimize = optimize,
});
{
Expand Down
3 changes: 2 additions & 1 deletion build/wayland_scanner/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
// SPDX-License-Identifier: Zlib

.{
.name = "wayland_scanner",
.name = .wayland_scanner,
.version = "0.0.0",
.fingerprint = 0x501ba345c1864a85,
.paths = .{""},
.dependencies = .{
.wayland = .{
Expand Down