mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-27 09:43:55 +00:00
WIP: Update to new build module API after Zig PR #18160
Temporarily change dependency sources to forks until they update
This commit is contained in:
@@ -7,7 +7,7 @@ pub fn build(b: *std.Build) !void {
|
||||
_ = optimize;
|
||||
}
|
||||
|
||||
pub fn addPaths(b: *std.Build, step: *std.build.CompileStep) !void {
|
||||
pub fn addPaths(b: *std.Build, step: *std.Build.Step.Compile) !void {
|
||||
_ = b;
|
||||
@import("macos_sdk").addPaths(step);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
.version = "0.1.0",
|
||||
.dependencies = .{
|
||||
.macos_sdk = .{
|
||||
.url = "https://github.com/mitchellh/zig-build-macos-sdk/archive/7a7cb3816617dbaf87ecbc3fd90ad56a6f828275.tar.gz",
|
||||
.hash = "1220a1dd91457d0131b50db15fb1bc51208ecadf1a23ad5dfa2d3a6bb3d1de5230c1",
|
||||
.url = "https://github.com/der-teufel-programming/zig-build-macos-sdk/archive/51dc3ff03b6f103043ed12f7d4508d270475b569.tar.gz",
|
||||
.hash = "12201f1da86d5de762253305b89775ca70c4f1c818695a128649b88f358ca7a4f61f",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
_ = b.addModule("cimgui", .{ .source_file = .{ .path = "main.zig" } });
|
||||
_ = b.addModule("cimgui", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const imgui = b.dependency("imgui", .{});
|
||||
const freetype = b.dependency("freetype", .{
|
||||
@@ -21,7 +21,7 @@ pub fn build(b: *std.Build) !void {
|
||||
lib.linkLibC();
|
||||
lib.linkLibCpp();
|
||||
lib.linkLibrary(freetype.artifact("freetype"));
|
||||
if (target.isWindows()) {
|
||||
if (target.result.os.tag == .windows) {
|
||||
lib.linkSystemLibrary("imm32");
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ pub fn build(b: *std.Build) !void {
|
||||
"-DIMGUI_USE_WCHAR32=1",
|
||||
"-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1",
|
||||
});
|
||||
if (target.isWindows()) {
|
||||
if (target.result.os.tag == .windows) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DIMGUI_IMPL_API=extern\t\"C\"\t__declspec(dllexport)",
|
||||
});
|
||||
@@ -57,8 +57,8 @@ pub fn build(b: *std.Build) !void {
|
||||
.flags = flags.items,
|
||||
});
|
||||
|
||||
if (target.isDarwin()) {
|
||||
if (!target.isNative()) try @import("apple_sdk").addPaths(b, lib);
|
||||
if (target.result.isDarwin()) {
|
||||
if (!target.query.isNative()) try @import("apple_sdk").addPaths(b, lib);
|
||||
lib.addCSourceFile(.{
|
||||
.file = imgui.path("backends/imgui_impl_metal.mm"),
|
||||
.flags = flags.items,
|
||||
|
||||
@@ -10,10 +10,10 @@ pub fn build(b: *std.Build) !void {
|
||||
bool,
|
||||
"enable-libxml2-iconv",
|
||||
"Build libxml2 with iconv",
|
||||
) orelse (target.getOsTag() != .windows);
|
||||
) orelse (target.result.os.tag != .windows);
|
||||
const freetype_enabled = b.option(bool, "enable-freetype", "Build freetype") orelse true;
|
||||
|
||||
_ = b.addModule("fontconfig", .{ .source_file = .{ .path = "main.zig" } });
|
||||
_ = b.addModule("fontconfig", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const upstream = b.dependency("fontconfig", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
@@ -22,7 +22,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibC();
|
||||
if (!target.isWindows()) {
|
||||
if (target.result.os.tag != .windows) {
|
||||
lib.linkSystemLibrary("pthread");
|
||||
}
|
||||
if (freetype_enabled) {
|
||||
@@ -86,8 +86,8 @@ pub fn build(b: *std.Build) !void {
|
||||
"-fno-sanitize=undefined",
|
||||
"-fno-sanitize-trap=undefined",
|
||||
});
|
||||
const target_info = try NativeTargetInfo.detect(target);
|
||||
switch (target_info.target.ptrBitWidth()) {
|
||||
// const target_info = try NativeTargetInfo.detect(target);
|
||||
switch (target.result.ptrBitWidth()) {
|
||||
32 => try flags.appendSlice(&.{
|
||||
"-DSIZEOF_VOID_P=4",
|
||||
"-DALIGNOF_VOID_P=4",
|
||||
@@ -100,7 +100,7 @@ pub fn build(b: *std.Build) !void {
|
||||
|
||||
else => @panic("unsupported arch"),
|
||||
}
|
||||
if (target.isWindows()) {
|
||||
if (target.result.os.tag == .windows) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DFC_CACHEDIR=\"LOCAL_APPDATA_FONTCONFIG_CACHE\"",
|
||||
"-DFC_TEMPLATEDIR=\"c:/share/fontconfig/conf.avail\"",
|
||||
@@ -133,7 +133,7 @@ pub fn build(b: *std.Build) !void {
|
||||
"-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"",
|
||||
"-DFC_DEFAULT_FONTS=\"<dir>/usr/share/fonts</dir><dir>/usr/local/share/fonts</dir>\"",
|
||||
});
|
||||
if (target.isLinux()) {
|
||||
if (target.result.os.tag == .linux) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_SYS_STATFS_H",
|
||||
"-DHAVE_SYS_VFS_H",
|
||||
@@ -146,7 +146,7 @@ pub fn build(b: *std.Build) !void {
|
||||
"-DLIBXML_STATIC",
|
||||
"-DLIBXML_PUSH_ENABLED",
|
||||
});
|
||||
if (target.isWindows()) {
|
||||
if (target.result.os.tag == .windows) {
|
||||
// NOTE: this should be defined on all targets
|
||||
try flags.appendSlice(&.{
|
||||
"-Werror=implicit-function-declaration",
|
||||
|
||||
@@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const libpng_enabled = b.option(bool, "enable-libpng", "Build libpng") orelse false;
|
||||
|
||||
_ = b.addModule("freetype", .{ .source_file = .{ .path = "main.zig" } });
|
||||
_ = b.addModule("freetype", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const upstream = b.dependency("freetype", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
@@ -45,7 +45,7 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
}
|
||||
|
||||
switch (target.getOsTag()) {
|
||||
switch (target.result.os.tag) {
|
||||
.linux => lib.addCSourceFile(.{
|
||||
.file = upstream.path("builds/unix/ftsystem.c"),
|
||||
.flags = flags.items,
|
||||
@@ -59,7 +59,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.flags = flags.items,
|
||||
}),
|
||||
}
|
||||
switch (target.getOsTag()) {
|
||||
switch (target.result.os.tag) {
|
||||
.windows => {
|
||||
lib.addCSourceFile(.{
|
||||
.file = upstream.path("builds/windows/ftdebug.c"),
|
||||
|
||||
@@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
_ = b.addModule("glslang", .{ .source_file = .{ .path = "main.zig" } });
|
||||
_ = b.addModule("glslang", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const upstream = b.dependency("glslang", .{});
|
||||
const lib = try buildGlslang(b, upstream, target, optimize);
|
||||
@@ -30,7 +30,7 @@ pub fn build(b: *std.Build) !void {
|
||||
fn buildGlslang(
|
||||
b: *std.Build,
|
||||
upstream: *std.Build.Dependency,
|
||||
target: std.zig.CrossTarget,
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
) !*std.Build.Step.Compile {
|
||||
const lib = b.addStaticLibrary(.{
|
||||
@@ -108,7 +108,7 @@ fn buildGlslang(
|
||||
},
|
||||
});
|
||||
|
||||
if (!target.isWindows()) {
|
||||
if (target.result.os.tag != .windows) {
|
||||
lib.addCSourceFiles(.{
|
||||
.dependency = upstream,
|
||||
.flags = flags.items,
|
||||
|
||||
@@ -17,8 +17,8 @@ pub fn build(b: *std.Build) !void {
|
||||
const upstream = b.dependency("harfbuzz", .{});
|
||||
|
||||
const module = b.addModule("harfbuzz", .{
|
||||
.source_file = .{ .path = "main.zig" },
|
||||
.dependencies = &.{
|
||||
.root_source_file = .{ .path = "main.zig" },
|
||||
.imports = &.{
|
||||
.{ .name = "freetype", .module = freetype.module("freetype") },
|
||||
.{ .name = "macos", .module = macos.module("macos") },
|
||||
},
|
||||
@@ -41,7 +41,7 @@ pub fn build(b: *std.Build) !void {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_STDBOOL_H",
|
||||
});
|
||||
if (!target.isWindows()) {
|
||||
if (target.result.os.tag != .windows) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_UNISTD_H",
|
||||
"-DHAVE_SYS_MMAN_H",
|
||||
@@ -85,8 +85,8 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
|
||||
var it = module.dependencies.iterator();
|
||||
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*);
|
||||
var it = module.import_table.iterator();
|
||||
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
||||
test_exe.linkLibrary(freetype_dep.artifact("freetype"));
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
|
||||
@@ -12,7 +12,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibC();
|
||||
if (target.isLinux()) {
|
||||
if (target.result.os.tag == .linux) {
|
||||
lib.linkSystemLibrary("m");
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn build(b: *std.Build) !void {
|
||||
|
||||
lib.addIncludePath(upstream.path("include"));
|
||||
lib.addIncludePath(.{ .path = "override/include" });
|
||||
if (target.isWindows()) {
|
||||
if (target.result.os.tag == .windows) {
|
||||
lib.addIncludePath(.{ .path = "override/config/win32" });
|
||||
lib.linkSystemLibrary("ws2_32");
|
||||
} else {
|
||||
@@ -42,7 +42,7 @@ pub fn build(b: *std.Build) !void {
|
||||
"-DLIBXML_AUTOMATA_ENABLED=1",
|
||||
"-DWITHOUT_TRIO=1",
|
||||
});
|
||||
if (!target.isWindows()) {
|
||||
if (target.result.os.tag != .windows) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_ARPA_INET_H=1",
|
||||
"-DHAVE_ARPA_NAMESER_H=1",
|
||||
|
||||
@@ -6,7 +6,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const module = b.addModule("macos", .{ .source_file = .{ .path = "main.zig" } });
|
||||
const module = b.addModule("macos", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "macos",
|
||||
@@ -29,7 +29,7 @@ pub fn build(b: *std.Build) !void {
|
||||
lib.linkFramework("CoreGraphics");
|
||||
lib.linkFramework("CoreText");
|
||||
lib.linkFramework("CoreVideo");
|
||||
if (!target.isNative()) try apple_sdk.addPaths(b, lib);
|
||||
if (!target.query.isNative()) try apple_sdk.addPaths(b, lib);
|
||||
|
||||
b.installArtifact(lib);
|
||||
|
||||
@@ -41,8 +41,8 @@ pub fn build(b: *std.Build) !void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
var it = module.dependencies.iterator();
|
||||
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*);
|
||||
var it = module.import_table.iterator();
|
||||
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
||||
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
|
||||
@@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
_ = b.addModule("oniguruma", .{ .source_file = .{ .path = "main.zig" } });
|
||||
_ = b.addModule("oniguruma", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const upstream = b.dependency("oniguruma", .{});
|
||||
const lib = try buildOniguruma(b, upstream, target, optimize);
|
||||
@@ -31,7 +31,7 @@ pub fn build(b: *std.Build) !void {
|
||||
fn buildOniguruma(
|
||||
b: *std.Build,
|
||||
upstream: *std.Build.Dependency,
|
||||
target: std.zig.CrossTarget,
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
) !*std.Build.Step.Compile {
|
||||
const lib = b.addStaticLibrary(.{
|
||||
@@ -39,7 +39,7 @@ fn buildOniguruma(
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const t = lib.target_info.target;
|
||||
const t = target.result;
|
||||
lib.linkLibC();
|
||||
lib.addIncludePath(upstream.path("src"));
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
_ = b.addModule("opengl", .{ .source_file = .{ .path = "main.zig" } });
|
||||
_ = b.addModule("opengl", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const module = b.addModule("pixman", .{ .source_file = .{ .path = "main.zig" } });
|
||||
const module = b.addModule("pixman", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const upstream = b.dependency("pixman", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) !void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibC();
|
||||
if (!target.isWindows()) {
|
||||
if (!(target.result.os.tag == .windows)) {
|
||||
lib.linkSystemLibrary("pthread");
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ pub fn build(b: *std.Build) !void {
|
||||
"-fno-sanitize=undefined",
|
||||
"-fno-sanitize-trap=undefined",
|
||||
});
|
||||
if (!target.isWindows()) {
|
||||
if (!(target.result.os.tag == .windows)) {
|
||||
try flags.appendSlice(&.{
|
||||
"-DHAVE_PTHREADS=1",
|
||||
|
||||
@@ -75,8 +75,8 @@ pub fn build(b: *std.Build) !void {
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
var it = module.dependencies.iterator();
|
||||
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*);
|
||||
var it = module.import_table.iterator();
|
||||
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
||||
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
|
||||
@@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
_ = b.addModule("spirv_cross", .{ .source_file = .{ .path = "main.zig" } });
|
||||
_ = b.addModule("spirv_cross", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||
|
||||
const upstream = b.dependency("spirv_cross", .{});
|
||||
const lib = try buildSpirvCross(b, upstream, target, optimize);
|
||||
@@ -30,7 +30,7 @@ pub fn build(b: *std.Build) !void {
|
||||
fn buildSpirvCross(
|
||||
b: *std.Build,
|
||||
upstream: *std.Build.Dependency,
|
||||
target: std.zig.CrossTarget,
|
||||
target: std.Build.ResolvedTarget,
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
) !*std.Build.Step.Compile {
|
||||
const lib = b.addStaticLibrary(.{
|
||||
|
||||
@@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
_ = b.addModule("tracy", .{ .source_file = .{ .path = "tracy.zig" } });
|
||||
_ = b.addModule("tracy", .{ .root_source_file = .{ .path = "tracy.zig" } });
|
||||
|
||||
const upstream = b.dependency("tracy", .{});
|
||||
const lib = b.addStaticLibrary(.{
|
||||
@@ -14,7 +14,7 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
lib.linkLibC();
|
||||
lib.linkLibCpp();
|
||||
if (target.isWindows()) {
|
||||
if (target.result.os.tag == .windows) {
|
||||
lib.linkSystemLibrary("Advapi32");
|
||||
lib.linkSystemLibrary("User32");
|
||||
lib.linkSystemLibrary("Ws2_32");
|
||||
@@ -29,7 +29,7 @@ pub fn build(b: *std.Build) !void {
|
||||
"-DTRACY_ENABLE",
|
||||
"-fno-sanitize=undefined",
|
||||
});
|
||||
if (target.isWindows()) {
|
||||
if (target.result.os.tag == .windows) {
|
||||
try flags.appendSlice(&.{
|
||||
"-D_WIN32_WINNT=0x601",
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user