Merge pull request #1248 from der-teufel-programming/main

WIP: Update Ghostty to use the new build system API
This commit is contained in:
Mitchell Hashimoto
2024-01-07 15:34:38 -08:00
committed by GitHub
28 changed files with 284 additions and 218 deletions

245
build.zig
View File

@ -1,8 +1,8 @@
const std = @import("std");
const builtin = @import("builtin");
const fs = std.fs;
const LibExeObjStep = std.build.LibExeObjStep;
const RunStep = std.build.RunStep;
const CompileStep = std.Build.Step.Compile;
const RunStep = std.Build.Step.Run;
const apprt = @import("src/apprt.zig");
const font = @import("src/font/main.zig");
@ -20,7 +20,7 @@ const Version = @import("src/build/Version.zig");
// but we liberally update it. In the future, we'll be more careful about
// using released versions so that package managers can integrate better.
comptime {
const required_zig = "0.12.0-dev.1754+2a3226453";
const required_zig = "0.12.0-dev.2059+42389cb9c";
const current_zig = builtin.zig_version;
const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable;
if (current_zig.order(min_zig) == .lt) {
@ -47,9 +47,9 @@ pub fn build(b: *std.Build) !void {
const target = target: {
var result = b.standardTargetOptions(.{});
if (result.isDarwin()) {
if (result.os_version_min == null) {
result.os_version_min = .{ .semver = .{ .major = 12, .minor = 0, .patch = 0 } };
if (result.result.isDarwin()) {
if (result.query.os_version_min == null) {
result.query.os_version_min = .{ .semver = .{ .major = 12, .minor = 0, .patch = 0 } };
}
}
@ -81,13 +81,13 @@ pub fn build(b: *std.Build) !void {
font.Backend,
"font-backend",
"The font backend to use for discovery and rasterization.",
) orelse font.Backend.default(target, wasm_target);
) orelse font.Backend.default(target.result, wasm_target);
app_runtime = b.option(
apprt.Runtime,
"app-runtime",
"The app runtime to use. Not all values supported on all platforms.",
) orelse apprt.Runtime.default(target);
) orelse apprt.Runtime.default(target.result);
libadwaita = b.option(
bool,
@ -99,7 +99,7 @@ pub fn build(b: *std.Build) !void {
renderer.Impl,
"renderer",
"The app runtime to use. Not all values supported on all platforms.",
) orelse renderer.Impl.default(target, wasm_target);
) orelse renderer.Impl.default(target.result, wasm_target);
const static = b.option(
bool,
@ -136,7 +136,7 @@ pub fn build(b: *std.Build) !void {
"This defaults to LD_LIBRARY_PATH if we're in a Nix shell environment on NixOS.",
) orelse patch_rpath: {
// We only do the patching if we're targeting our own CPU and its Linux.
if (!target.isLinux() or !target.isNativeCpu()) break :patch_rpath null;
if (!(target.result.os.tag == .linux) or !target.query.isNativeCpu()) break :patch_rpath null;
// If we're in a nix shell we default to doing this.
// Note: we purposely never deinit envmap because we leak the strings
@ -215,7 +215,7 @@ pub fn build(b: *std.Build) !void {
// Exe
if (exe_) |exe| {
exe.addOptions("build_options", exe_options);
exe.root_module.addOptions("build_options", exe_options);
// Add the shared dependencies
_ = try addDeps(b, exe, static);
@ -223,9 +223,9 @@ pub fn build(b: *std.Build) !void {
// If we're in NixOS but not in the shell environment then we issue
// a warning because the rpath may not be setup properly.
const is_nixos = is_nixos: {
if (!target.isLinux()) break :is_nixos false;
if (!target.isNativeCpu()) break :is_nixos false;
if (target.getOsTag() != builtin.os.tag) break :is_nixos false;
if (target.result.os.tag != .linux) break :is_nixos false;
if (!target.query.isNativeCpu()) break :is_nixos false;
if (!target.query.isNativeOs()) break :is_nixos false;
break :is_nixos if (std.fs.accessAbsolute("/etc/NIXOS", .{})) true else |_| false;
};
if (is_nixos and env.get("IN_NIX_SHELL") == null) {
@ -253,7 +253,7 @@ pub fn build(b: *std.Build) !void {
// Building with LTO on Windows is broken.
// https://github.com/ziglang/zig/issues/15958
if (target.isWindows()) exe.want_lto = false;
if (target.result.os.tag == .windows) exe.want_lto = false;
// If we're installing, we get the install step so we can add
// additional dependencies to it.
@ -277,7 +277,7 @@ pub fn build(b: *std.Build) !void {
}
// App (Mac)
if (target.isDarwin()) {
if (target.result.isDarwin()) {
const bin_install = b.addInstallFile(
exe.getEmittedBin(),
"Ghostty.app/Contents/MacOS/ghostty",
@ -298,7 +298,7 @@ pub fn build(b: *std.Build) !void {
});
b.getInstallStep().dependOn(&install.step);
if (target.isDarwin() and exe_ != null) {
if (target.result.isDarwin() and exe_ != null) {
const mac_install = b.addInstallDirectory(options: {
var copy = install.options;
copy.install_dir = .{
@ -321,7 +321,7 @@ pub fn build(b: *std.Build) !void {
});
b.getInstallStep().dependOn(&install.step);
if (target.isDarwin() and exe_ != null) {
if (target.result.isDarwin() and exe_ != null) {
const mac_install = b.addInstallDirectory(options: {
var copy = install.options;
copy.install_dir = .{
@ -345,7 +345,7 @@ pub fn build(b: *std.Build) !void {
const src_source = wf.add("share/terminfo/ghostty.terminfo", str.items);
const src_install = b.addInstallFile(src_source, "share/terminfo/ghostty.terminfo");
b.getInstallStep().dependOn(&src_install.step);
if (target.isDarwin() and exe_ != null) {
if (target.result.isDarwin() and exe_ != null) {
const mac_src_install = b.addInstallFile(
src_source,
"Ghostty.app/Contents/Resources/terminfo/ghostty.terminfo",
@ -356,17 +356,17 @@ pub fn build(b: *std.Build) !void {
// Convert to termcap source format if thats helpful to people and
// install it. The resulting value here is the termcap source in case
// that is used for other commands.
if (!target.isWindows()) {
if (target.result.os.tag != .windows) {
const run_step = RunStep.create(b, "infotocap");
run_step.addArg("infotocap");
run_step.addFileSourceArg(src_source);
run_step.addFileArg(src_source);
const out_source = run_step.captureStdOut();
_ = run_step.captureStdErr(); // so we don't see stderr
const cap_install = b.addInstallFile(out_source, "share/terminfo/ghostty.termcap");
b.getInstallStep().dependOn(&cap_install.step);
if (target.isDarwin() and exe_ != null) {
if (target.result.isDarwin() and exe_ != null) {
const mac_cap_install = b.addInstallFile(
out_source,
"Ghostty.app/Contents/Resources/terminfo/ghostty.termcap",
@ -376,11 +376,11 @@ pub fn build(b: *std.Build) !void {
}
// Compile the terminfo source into a terminfo database
if (!target.isWindows()) {
if (target.result.os.tag != .windows) {
const run_step = RunStep.create(b, "tic");
run_step.addArgs(&.{ "tic", "-x", "-o" });
const path = run_step.addOutputFileArg("terminfo");
run_step.addFileSourceArg(src_source);
run_step.addFileArg(src_source);
_ = run_step.captureStdErr(); // so we don't see stderr
// Depend on the terminfo source install step so that Zig build
@ -390,15 +390,15 @@ pub fn build(b: *std.Build) !void {
{
const copy_step = RunStep.create(b, "copy terminfo db");
copy_step.addArgs(&.{ "cp", "-R" });
copy_step.addFileSourceArg(path);
copy_step.addFileArg(path);
copy_step.addArg(b.fmt("{s}/share", .{b.install_prefix}));
b.getInstallStep().dependOn(&copy_step.step);
}
if (target.isDarwin() and exe_ != null) {
if (target.result.isDarwin() and exe_ != null) {
const copy_step = RunStep.create(b, "copy terminfo db");
copy_step.addArgs(&.{ "cp", "-R" });
copy_step.addFileSourceArg(path);
copy_step.addFileArg(path);
copy_step.addArg(
b.fmt("{s}/Ghostty.app/Contents/Resources", .{b.install_prefix}),
);
@ -421,7 +421,7 @@ pub fn build(b: *std.Build) !void {
}
// App (Linux)
if (target.isLinux()) {
if (target.result.os.tag == .linux) {
// https://developer.gnome.org/documentation/guidelines/maintainer/integrating.html
// Desktop file so that we have an icon and other metadata
@ -445,21 +445,21 @@ pub fn build(b: *std.Build) !void {
}
// On Mac we can build the embedding library.
if (builtin.target.isDarwin() and target.isDarwin()) {
if (builtin.target.isDarwin() and target.result.isDarwin()) {
const static_lib_aarch64 = lib: {
const lib = b.addStaticLibrary(.{
.name = "ghostty",
.root_source_file = .{ .path = "src/main_c.zig" },
.target = .{
.target = b.resolveTargetQuery(.{
.cpu_arch = .aarch64,
.os_tag = .macos,
.os_version_min = target.os_version_min,
},
.os_version_min = target.query.os_version_min,
}),
.optimize = optimize,
});
lib.bundle_compiler_rt = true;
lib.linkLibC();
lib.addOptions("build_options", exe_options);
lib.root_module.addOptions("build_options", exe_options);
// Create a single static lib with all our dependencies merged
var lib_list = try addDeps(b, lib, true);
@ -479,16 +479,16 @@ pub fn build(b: *std.Build) !void {
const lib = b.addStaticLibrary(.{
.name = "ghostty",
.root_source_file = .{ .path = "src/main_c.zig" },
.target = .{
.target = b.resolveTargetQuery(.{
.cpu_arch = .x86_64,
.os_tag = .macos,
.os_version_min = target.os_version_min,
},
.os_version_min = target.query.os_version_min,
}),
.optimize = optimize,
});
lib.bundle_compiler_rt = true;
lib.linkLibC();
lib.addOptions("build_options", exe_options);
lib.root_module.addOptions("build_options", exe_options);
// Create a single static lib with all our dependencies merged
var lib_list = try addDeps(b, lib, true);
@ -542,7 +542,7 @@ pub fn build(b: *std.Build) !void {
// wasm
{
// Build our Wasm target.
const wasm_crosstarget: std.zig.CrossTarget = .{
const wasm_crosstarget: std.Target.Query = .{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
.cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp },
@ -570,10 +570,10 @@ pub fn build(b: *std.Build) !void {
const wasm = b.addSharedLibrary(.{
.name = "ghostty-wasm",
.root_source_file = .{ .path = "src/main_wasm.zig" },
.target = wasm_crosstarget,
.target = b.resolveTargetQuery(wasm_crosstarget),
.optimize = optimize,
});
wasm.addOptions("build_options", exe_options);
wasm.root_module.addOptions("build_options", exe_options);
// So that we can use web workers with our wasm binary
wasm.import_memory = true;
@ -582,7 +582,7 @@ pub fn build(b: *std.Build) !void {
wasm.shared_memory = wasm_shared;
// Stack protector adds extern requirements that we don't satisfy.
wasm.stack_protector = false;
wasm.root_module.stack_protector = false;
// Wasm-specific deps
_ = try addDeps(b, wasm, true);
@ -601,9 +601,9 @@ pub fn build(b: *std.Build) !void {
const main_test = b.addTest(.{
.name = "wasm-test",
.root_source_file = .{ .path = "src/main_wasm.zig" },
.target = wasm_crosstarget,
.target = b.resolveTargetQuery(wasm_crosstarget),
});
main_test.addOptions("build_options", exe_options);
main_test.root_module.addOptions("build_options", exe_options);
_ = try addDeps(b, main_test, true);
test_step.dependOn(&main_test.step);
}
@ -641,7 +641,7 @@ pub fn build(b: *std.Build) !void {
{
if (emit_test_exe) b.installArtifact(main_test);
_ = try addDeps(b, main_test, true);
main_test.addOptions("build_options", exe_options);
main_test.root_module.addOptions("build_options", exe_options);
const test_run = b.addRunArtifact(main_test);
test_step.dependOn(&test_run.step);
@ -650,94 +650,125 @@ pub fn build(b: *std.Build) !void {
}
/// Used to keep track of a list of file sources.
const FileSourceList = std.ArrayList(std.build.FileSource);
const LazyPathList = std.ArrayList(std.Build.LazyPath);
/// Adds and links all of the primary dependencies for the exe.
fn addDeps(
b: *std.Build,
step: *std.build.LibExeObjStep,
step: *std.Build.Step.Compile,
static: bool,
) !FileSourceList {
var static_libs = FileSourceList.init(b.allocator);
) !LazyPathList {
var static_libs = LazyPathList.init(b.allocator);
errdefer static_libs.deinit();
// For dynamic linking, we prefer dynamic linking and to search by
// mode first. Mode first will search all paths for a dynamic library
// before falling back to static.
const dynamic_link_opts: std.build.Step.Compile.LinkSystemLibraryOptions = .{
const dynamic_link_opts: std.Build.Module.LinkSystemLibraryOptions = .{
.preferred_link_mode = .Dynamic,
.search_strategy = .mode_first,
};
const target_triple: []const u8 = try step.rootModuleTarget().zigTriple(b.allocator);
const cpu_opts: []const u8 = try step.root_module.resolved_target.?.query.serializeCpuAlloc(b.allocator);
// Dependencies
const cimgui_dep = b.dependency("cimgui", .{ .target = step.target, .optimize = step.optimize });
const js_dep = b.dependency("zig_js", .{ .target = step.target, .optimize = step.optimize });
const libxev_dep = b.dependency("libxev", .{ .target = step.target, .optimize = step.optimize });
const objc_dep = b.dependency("zig_objc", .{ .target = step.target, .optimize = step.optimize });
const cimgui_dep = b.dependency("cimgui", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const js_dep = b.dependency("zig_js", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const libxev_dep = b.dependency("libxev", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const objc_dep = b.dependency("zig_objc", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const fontconfig_dep = b.dependency("fontconfig", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const freetype_dep = b.dependency("freetype", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.@"enable-libpng" = true,
});
const glslang_dep = b.dependency("glslang", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const spirv_cross_dep = b.dependency("spirv_cross", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const mach_glfw_dep = b.dependency("mach_glfw", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const libpng_dep = b.dependency("libpng", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const macos_dep = b.dependency("macos", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const oniguruma_dep = b.dependency("oniguruma", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const opengl_dep = b.dependency("opengl", .{});
const pixman_dep = b.dependency("pixman", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const tracy_dep = b.dependency("tracy", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.optimize = step.root_module.optimize.?,
});
const zlib_dep = b.dependency("zlib", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
const harfbuzz_dep = b.dependency("harfbuzz", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.@"enable-freetype" = true,
.@"enable-coretext" = font_backend.hasCoretext(),
});
const ziglyph_dep = b.dependency("ziglyph", .{
.target = step.target,
.optimize = step.optimize,
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
// Wasm we do manually since it is such a different build.
if (step.target.getCpuArch() == .wasm32) {
if (step.rootModuleTarget().cpu.arch == .wasm32) {
// We link this package but its a no-op since Tracy
// never actually WORKS with wasm.
step.addModule("tracy", tracy_dep.module("tracy"));
step.addModule("zig-js", js_dep.module("zig-js"));
step.root_module.addImport("tracy", tracy_dep.module("tracy"));
step.root_module.addImport("zig-js", js_dep.module("zig-js"));
return static_libs;
}
@ -745,8 +776,8 @@ fn addDeps(
// On Linux, we need to add a couple common library paths that aren't
// on the standard search list. i.e. GTK is often in /usr/lib/x86_64-linux-gnu
// on x86_64.
if (step.target.isLinux()) {
const triple = try step.target.linuxTriple(b.allocator);
if (step.rootModuleTarget().os.tag == .linux) {
const triple = try step.rootModuleTarget().linuxTriple(b.allocator);
step.addLibraryPath(.{ .path = b.fmt("/usr/lib/{s}", .{triple}) });
}
@ -760,42 +791,42 @@ fn addDeps(
// We always require the system SDK so that our system headers are available.
// This makes things like `os/log.h` available for cross-compiling.
if (step.target.isDarwin()) {
if (step.rootModuleTarget().isDarwin()) {
try @import("apple_sdk").addPaths(b, step);
}
// We always need the Zig packages
// TODO: This can't be the right way to use the new Zig modules system,
// so take a closer look at this again later.
if (font_backend.hasFontconfig()) step.addModule(
if (font_backend.hasFontconfig()) step.root_module.addImport(
"fontconfig",
fontconfig_dep.module("fontconfig"),
);
step.addModule("oniguruma", oniguruma_dep.module("oniguruma"));
step.addModule("freetype", freetype_dep.module("freetype"));
step.addModule("glslang", glslang_dep.module("glslang"));
step.addModule("spirv_cross", spirv_cross_dep.module("spirv_cross"));
step.addModule("harfbuzz", harfbuzz_dep.module("harfbuzz"));
step.addModule("xev", libxev_dep.module("xev"));
step.addModule("opengl", opengl_dep.module("opengl"));
step.addModule("pixman", pixman_dep.module("pixman"));
step.addModule("ziglyph", ziglyph_dep.module("ziglyph"));
step.root_module.addImport("oniguruma", oniguruma_dep.module("oniguruma"));
step.root_module.addImport("freetype", freetype_dep.module("freetype"));
step.root_module.addImport("glslang", glslang_dep.module("glslang"));
step.root_module.addImport("spirv_cross", spirv_cross_dep.module("spirv_cross"));
step.root_module.addImport("harfbuzz", harfbuzz_dep.module("harfbuzz"));
step.root_module.addImport("xev", libxev_dep.module("xev"));
step.root_module.addImport("opengl", opengl_dep.module("opengl"));
step.root_module.addImport("pixman", pixman_dep.module("pixman"));
step.root_module.addImport("ziglyph", ziglyph_dep.module("ziglyph"));
// Mac Stuff
if (step.target.isDarwin()) {
step.addModule("objc", objc_dep.module("objc"));
step.addModule("macos", macos_dep.module("macos"));
if (step.rootModuleTarget().isDarwin()) {
step.root_module.addImport("objc", objc_dep.module("objc"));
step.root_module.addImport("macos", macos_dep.module("macos"));
step.linkLibrary(macos_dep.artifact("macos"));
try static_libs.append(macos_dep.artifact("macos").getEmittedBin());
}
// cimgui
step.addModule("cimgui", cimgui_dep.module("cimgui"));
step.root_module.addImport("cimgui", cimgui_dep.module("cimgui"));
step.linkLibrary(cimgui_dep.artifact("cimgui"));
try static_libs.append(cimgui_dep.artifact("cimgui").getEmittedBin());
// Tracy
step.addModule("tracy", tracy_dep.module("tracy"));
step.root_module.addImport("tracy", tracy_dep.module("tracy"));
if (tracy) {
step.linkLibrary(tracy_dep.artifact("tracy"));
try static_libs.append(tracy_dep.artifact("tracy").getEmittedBin());
@ -871,7 +902,7 @@ fn addDeps(
.none => {},
.glfw => {
step.addModule("glfw", mach_glfw_dep.module("mach-glfw"));
step.root_module.addImport("glfw", mach_glfw_dep.module("mach-glfw"));
@import("mach_glfw").link(mach_glfw_dep.builder, step);
},
@ -887,8 +918,8 @@ fn addDeps(
fn benchSteps(
b: *std.Build,
target: std.zig.CrossTarget,
optimize: std.builtin.Mode,
target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode,
install: bool,
) !void {
// Open the directory ./src/bench
@ -920,7 +951,7 @@ fn benchSteps(
.root_source_file = .{ .path = path },
.target = target,
.optimize = optimize,
.main_pkg_path = .{ .path = "./src" },
// .main_pkg_path = .{ .path = "./src" },
});
if (install) b.installArtifact(c_exe);
_ = try addDeps(b, c_exe, true);
@ -929,10 +960,10 @@ fn benchSteps(
fn conformanceSteps(
b: *std.Build,
target: std.zig.CrossTarget,
target: std.Build.ResolvedTarget,
optimize: std.builtin.Mode,
) !std.StringHashMap(*LibExeObjStep) {
var map = std.StringHashMap(*LibExeObjStep).init(b.allocator);
) !std.StringHashMap(*CompileStep) {
var map = std.StringHashMap(*CompileStep).init(b.allocator);
// Open the directory ./conformance
const c_dir_path = (comptime root()) ++ "/conformance";

View File

@ -5,24 +5,24 @@
.dependencies = .{
// Zig libs
.libxev = .{
.url = "https://github.com/mitchellh/libxev/archive/7eada4333c36b3e16f4dc2abad707149ef7b6de5.tar.gz",
.hash = "1220be2c7b3f3a07b9150720140c7038f454a9ce0cbc5d303767c1e4a50856ec1b01",
.url = "https://github.com/mitchellh/libxev/archive/74bc7aea4a8f88210f0ad4215108613ab7e7af1a.tar.gz",
.hash = "122029743e5d96aa1b57a1b99ff58bf13ff9ed6d8f624ac3ae8074062feb91c5bd8d",
},
.mach_glfw = .{
.url = "https://github.com/hexops/mach-glfw/archive/577220552e1b31c4496d2e0df2fb5fbc9287b966.tar.gz",
.hash = "12204779ba2f14b46f569110f774d5c3f48b7a105b6717e668bc410710bceae62072",
.url = "https://github.com/der-teufel-programming/mach-glfw/archive/fe077f52e51c4eb7e4ff6bbe8d3ee3ecd9cc743d.tar.gz",
.hash = "1220838cb1781e328a0218facaa7e92ae97fd5bbcd81dd0429ac43c5b36fe70c1990",
},
.zig_objc = .{
.url = "https://github.com/mitchellh/zig-objc/archive/10e552bd37c2f61b9f570d5ceb145165c6f1854b.tar.gz",
.hash = "122045926c2a90c61ca2ce907cc83a91ede0d49c989209fff2e2db421a88caf88e91",
.url = "https://github.com/mitchellh/zig-objc/archive/294e0f3765a96613b45ff7dd594bf99e22409e96.tar.gz",
.hash = "1220ae28cc6af7600c6f23db1573b33ca3b8accd15e60a1fe1a2c979c20868f151fa",
},
.zig_js = .{
.url = "https://github.com/mitchellh/zig-js/archive/60ac42ab137461cdba2b38cc6c5e16376470aae6.tar.gz",
.hash = "1220319b42fbc0116f3f198343256018e9f1da9483cef259201afe4ebab0ce0d8f6a",
.url = "https://github.com/mitchellh/zig-js/archive/d4edb682733aef8dc3933683272bdf7c8b9fe658.tar.gz",
.hash = "1220df81f0e65cc9ccd3628572c611e6f267a71f1bff1be19d50f4ac49ee2a83c324",
},
.ziglyph = .{
.url = "https://codeberg.org/dude_the_builder/ziglyph/archive/ef6a97e3e6d31786e4c5152abb8393f32ce52279.tar.gz",
.hash = "1220847f934ea57e90ffb4d447a43e37ff4dce2aab23c84513dfff591376350ffd31",
.url = "https://codeberg.org/dude_the_builder/ziglyph/archive/0e17bd36a4e882b194a87c283bd78562ea215116.tar.gz",
.hash = "12208553f3f47e51494e187f4c0e6f6b3844e3993436cad4a0e8c4db4e99645967b5",
},
// C libs

12
flake.lock generated
View File

@ -147,11 +147,11 @@
},
"nixpkgs-zig-0-12": {
"locked": {
"lastModified": 1703276979,
"narHash": "sha256-WD3FdpkPRLm0PJC26bZT/cSoPNgKANHq14U5O+CfLqI=",
"lastModified": 1704663772,
"narHash": "sha256-BIDaFQlRhjhrFk+UE7OsV3Jfo/9cbWAWwdjmdy1Hn34=",
"owner": "vancluever",
"repo": "nixpkgs",
"rev": "d81c22905455c896e79db93fdace8771db1bd995",
"rev": "4f7ae324049ecdf3a84db0bb59d2442bb080304f",
"type": "github"
},
"original": {
@ -194,11 +194,11 @@
]
},
"locked": {
"lastModified": 1702850407,
"narHash": "sha256-dG9eKPJXgZNcXkNJwBdx/7byx08Z3ppXU1E54EY1/t0=",
"lastModified": 1704542888,
"narHash": "sha256-Fb8tc4cXUkWw+Fva6JKbjkFFpZwu4c+ictSAQGEYjIM=",
"owner": "mitchellh",
"repo": "zig-overlay",
"rev": "f5d3c30b3f36ec5d3d5dd81fad850f5523767e5d",
"rev": "112cfb72e47cb85d17fc8075a4d70ab56964453d",
"type": "github"
},
"original": {

View File

@ -10,7 +10,7 @@ help() {
echo "To fix, please (manually) re-run the script from the repository root,"
echo "commit, and push the update:"
echo ""
echo " ./nix/build-support/check-zigCacheHash.sh --update"
echo " ./nix/build-support/check-zig-cache-hash.sh --update"
echo " git add nix/zigCacheHash.nix"
echo " git commit -m \"nix: update Zig cache hash\""
echo " git push"
@ -52,7 +52,7 @@ fi
# Write out the cache file
cat > "${CACHE_HASH_FILE}" <<EOS
# This file is auto-generated! check build-support/check-zigCacheHash.sh for
# This file is auto-generated! check build-support/check-zig-cache-hash.sh for
# more details.
"${ZIG_CACHE_HASH}"
EOS

View File

@ -1,3 +1,3 @@
# This file is auto-generated! check build-support/check-zig-cache-hash.sh for
# more details.
"sha256-Dn9KRvSteFvHWy6ULEQbRIQZf+bVfpVYWsImGm32qeI="
"sha256-iRXzPgzOkt+TTcqPCRQubP3dN6lS+Wvn17l+0I/pDGg="

View File

@ -7,7 +7,12 @@ 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);
}
pub fn addPathsModule(b: *std.Build, m: *std.Build.Module) !void {
_ = b;
@import("macos_sdk").addPathsModule(m);
}

View File

@ -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/mitchellh/zig-build-macos-sdk/archive/ee70f27c08680307fa35ada92e6b2c36e0ff84c6.tar.gz",
.hash = "1220b415f529f1c04ed876c2b481e9f8119d353d4e3d4d7c8607ee302d2142e13eca",
},
},
}

View File

@ -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" } });
const module = b.addModule("cimgui", .{ .root_source_file = .{ .path = "main.zig" } });
const imgui = b.dependency("imgui", .{});
const freetype = b.dependency("freetype", .{
@ -21,11 +21,12 @@ 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");
}
lib.addIncludePath(imgui.path(""));
module.addIncludePath(.{ .path = "vendor" });
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
@ -34,7 +35,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 +58,11 @@ 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);
try @import("apple_sdk").addPathsModule(b, module);
}
lib.addCSourceFile(.{
.file = imgui.path("backends/imgui_impl_metal.mm"),
.flags = flags.items,

View File

@ -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" } });
const module = 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) {
@ -40,6 +40,8 @@ pub fn build(b: *std.Build) !void {
lib.addIncludePath(upstream.path(""));
lib.addIncludePath(.{ .path = "override/include" });
module.addIncludePath(upstream.path(""));
module.addIncludePath(.{ .path = "override/include" });
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
@ -86,8 +88,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()) {
switch (target.result.ptrBitWidth()) {
32 => try flags.appendSlice(&.{
"-DSIZEOF_VOID_P=4",
"-DALIGNOF_VOID_P=4",
@ -100,7 +102,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 +135,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 +148,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",

View File

@ -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" } });
const module = b.addModule("freetype", .{ .root_source_file = .{ .path = "main.zig" } });
const upstream = b.dependency("freetype", .{});
const lib = b.addStaticLibrary(.{
@ -15,6 +15,8 @@ pub fn build(b: *std.Build) !void {
});
lib.linkLibC();
lib.addIncludePath(upstream.path("include"));
module.addIncludePath(upstream.path("include"));
module.addIncludePath(.{ .path = "" });
// Dependencies
const zlib_dep = b.dependency("zlib", .{ .target = target, .optimize = optimize });
@ -38,14 +40,13 @@ pub fn build(b: *std.Build) !void {
});
if (libpng_enabled) try flags.append("-DFT_CONFIG_OPTION_USE_PNG=1");
for (srcs) |src| {
lib.addCSourceFile(.{
.file = upstream.path(src),
.flags = flags.items,
});
}
lib.addCSourceFiles(.{
.dependency = upstream,
.files = srcs,
.flags = flags.items,
});
switch (target.getOsTag()) {
switch (target.result.os.tag) {
.linux => lib.addCSourceFile(.{
.file = upstream.path("builds/unix/ftsystem.c"),
.flags = flags.items,
@ -59,7 +60,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"),

View File

@ -4,12 +4,15 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
_ = b.addModule("glslang", .{ .source_file = .{ .path = "main.zig" } });
const module = b.addModule("glslang", .{ .root_source_file = .{ .path = "main.zig" } });
const upstream = b.dependency("glslang", .{});
const lib = try buildGlslang(b, upstream, target, optimize);
b.installArtifact(lib);
module.addIncludePath(upstream.path(""));
module.addIncludePath(.{ .path = "override" });
{
const test_exe = b.addTest(.{
.name = "test",
@ -30,7 +33,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 +111,7 @@ fn buildGlslang(
},
});
if (!target.isWindows()) {
if (target.result.os.tag != .windows) {
lib.addCSourceFiles(.{
.dependency = upstream,
.flags = flags.items,

View File

@ -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") },
},
@ -32,16 +32,18 @@ pub fn build(b: *std.Build) !void {
lib.linkLibC();
lib.linkLibCpp();
lib.addIncludePath(upstream.path("src"));
module.addIncludePath(upstream.path("src"));
const freetype_dep = b.dependency("freetype", .{ .target = target, .optimize = optimize });
lib.linkLibrary(freetype_dep.artifact("freetype"));
module.addIncludePath(freetype_dep.builder.dependency("freetype", .{}).path("include"));
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
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",
@ -60,7 +62,9 @@ pub fn build(b: *std.Build) !void {
if (coretext_enabled) {
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"});
try apple_sdk.addPaths(b, lib);
try apple_sdk.addPathsModule(b, module);
lib.linkFramework("ApplicationServices");
module.linkFramework("ApplicationServices", .{});
}
lib.addCSourceFile(.{
@ -85,8 +89,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");

View File

@ -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");
}

View File

@ -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",

View File

@ -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,8 +29,19 @@ 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.result.isDarwin()) {
module.linkFramework("Carbon", .{});
module.linkFramework("CoreFoundation", .{});
module.linkFramework("CoreGraphics", .{});
module.linkFramework("CoreText", .{});
module.linkFramework("CoreVideo", .{});
}
if (!target.query.isNative()) {
try apple_sdk.addPaths(b, lib);
try apple_sdk.addPathsModule(b, module);
}
b.installArtifact(lib);
{
@ -41,8 +52,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");

View File

@ -5,10 +5,11 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
_ = b.addModule("oniguruma", .{ .source_file = .{ .path = "main.zig" } });
const module = b.addModule("oniguruma", .{ .root_source_file = .{ .path = "main.zig" } });
const upstream = b.dependency("oniguruma", .{});
const lib = try buildOniguruma(b, upstream, target, optimize);
module.addIncludePath(upstream.path("src"));
b.installArtifact(lib);
{
@ -31,7 +32,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 +40,7 @@ fn buildOniguruma(
.target = target,
.optimize = optimize,
});
const t = lib.target_info.target;
const t = target.result;
lib.linkLibC();
lib.addIncludePath(upstream.path("src"));

View File

@ -1,5 +1,6 @@
const std = @import("std");
pub fn build(b: *std.Build) !void {
_ = b.addModule("opengl", .{ .source_file = .{ .path = "main.zig" } });
const module = b.addModule("opengl", .{ .root_source_file = .{ .path = "main.zig" } });
module.addIncludePath(.{ .path = "../../vendor/glad/include" });
}

View File

@ -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,12 +13,14 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize,
});
lib.linkLibC();
if (!target.isWindows()) {
if (target.result.os.tag != .windows) {
lib.linkSystemLibrary("pthread");
}
lib.addIncludePath(upstream.path(""));
lib.addIncludePath(.{ .path = "" });
module.addIncludePath(upstream.path("pixman"));
module.addIncludePath(.{ .path = "" });
var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
@ -42,7 +44,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",
@ -50,12 +52,11 @@ pub fn build(b: *std.Build) !void {
});
}
for (srcs) |src| {
lib.addCSourceFile(.{
.file = upstream.path(src),
.flags = flags.items,
});
}
lib.addCSourceFiles(.{
.dependency = upstream,
.files = srcs,
.flags = flags.items,
});
lib.installHeader("pixman-version.h", "pixman-version.h");
lib.installHeadersDirectoryOptions(.{
@ -75,8 +76,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");

View File

@ -4,9 +4,11 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
_ = b.addModule("spirv_cross", .{ .source_file = .{ .path = "main.zig" } });
const upstream = b.dependency("spirv_cross", .{});
const module = b.addModule("spirv_cross", .{ .root_source_file = .{ .path = "main.zig" } });
module.addIncludePath(upstream.path(""));
const lib = try buildSpirvCross(b, upstream, target, optimize);
b.installArtifact(lib);
@ -30,7 +32,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(.{

View File

@ -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",
});

View File

@ -53,12 +53,12 @@ pub const Runtime = enum {
/// GTK-backed. Rich windowed application. GTK is dynamically linked.
gtk,
pub fn default(target: std.zig.CrossTarget) Runtime {
pub fn default(target: std.Target) Runtime {
// The Linux default is GTK because it is full featured.
if (target.isLinux()) return .gtk;
if (target.os.tag == .linux) return .gtk;
// Windows we currently only support glfw
if (target.isWindows()) return .glfw;
if (target.os.tag == .windows) return .glfw;
// Otherwise, we do NONE so we don't create an exe. The GLFW
// build is opt-in because it is missing so many features compared

View File

@ -3,9 +3,9 @@
const LibtoolStep = @This();
const std = @import("std");
const Step = std.build.Step;
const RunStep = std.build.RunStep;
const FileSource = std.build.FileSource;
const Step = std.Build.Step;
const RunStep = std.Build.Step.Run;
const LazyPath = std.Build.LazyPath;
pub const Options = struct {
/// The name of this step.
@ -16,14 +16,14 @@ pub const Options = struct {
out_name: []const u8,
/// Library files (.a) to combine.
sources: []FileSource,
sources: []LazyPath,
};
/// The step to depend on.
step: *Step,
/// The output file from the libtool run.
output: FileSource,
output: LazyPath,
/// Run libtool against a list of library files to combine into a single
/// static library.
@ -33,7 +33,7 @@ pub fn create(b: *std.Build, opts: Options) *LibtoolStep {
const run_step = RunStep.create(b, b.fmt("libtool {s}", .{opts.name}));
run_step.addArgs(&.{ "libtool", "-static", "-o" });
const output = run_step.addOutputFileArg(opts.out_name);
for (opts.sources) |source| run_step.addFileSourceArg(source);
for (opts.sources) |source| run_step.addFileArg(source);
self.* = .{
.step = &run_step.step,

View File

@ -3,9 +3,9 @@
const LipoStep = @This();
const std = @import("std");
const Step = std.build.Step;
const RunStep = std.build.RunStep;
const FileSource = std.build.FileSource;
const Step = std.Build.Step;
const RunStep = std.Build.Step.Run;
const LazyPath = std.Build.LazyPath;
pub const Options = struct {
/// The name of the xcframework to create.
@ -15,14 +15,14 @@ pub const Options = struct {
out_name: []const u8,
/// Library file (dylib, a) to package.
input_a: FileSource,
input_b: FileSource,
input_a: LazyPath,
input_b: LazyPath,
};
step: *Step,
/// Resulting binary
output: FileSource,
output: LazyPath,
pub fn create(b: *std.Build, opts: Options) *LipoStep {
const self = b.allocator.create(LipoStep) catch @panic("OOM");
@ -30,8 +30,8 @@ pub fn create(b: *std.Build, opts: Options) *LipoStep {
const run_step = RunStep.create(b, b.fmt("lipo {s}", .{opts.name}));
run_step.addArgs(&.{ "lipo", "-create", "-output" });
const output = run_step.addOutputFileArg(opts.out_name);
run_step.addFileSourceArg(opts.input_a);
run_step.addFileSourceArg(opts.input_b);
run_step.addFileArg(opts.input_a);
run_step.addFileArg(opts.input_b);
self.* = .{
.step = &run_step.step,

View File

@ -4,9 +4,9 @@
const XCFrameworkStep = @This();
const std = @import("std");
const Step = std.build.Step;
const RunStep = std.build.RunStep;
const FileSource = std.build.FileSource;
const Step = std.Build.Step;
const RunStep = std.Build.Step.Run;
const LazyPath = std.Build.LazyPath;
pub const Options = struct {
/// The name of the xcframework to create.
@ -16,10 +16,10 @@ pub const Options = struct {
out_path: []const u8,
/// Library file (dylib, a) to package.
library: std.build.FileSource,
library: LazyPath,
/// Path to a directory with the headers.
headers: std.build.FileSource,
headers: LazyPath,
};
step: *Step,
@ -42,9 +42,9 @@ pub fn create(b: *std.Build, opts: Options) *XCFrameworkStep {
run.has_side_effects = true;
run.addArgs(&.{ "xcodebuild", "-create-xcframework" });
run.addArg("-library");
run.addFileSourceArg(opts.library);
run.addFileArg(opts.library);
run.addArg("-headers");
run.addFileSourceArg(opts.headers);
run.addFileArg(opts.headers);
run.addArg("-output");
run.addArg(opts.out_path);
break :run run;

View File

@ -63,10 +63,10 @@ pub const Backend = enum {
/// meant to be called at comptime by the build.zig script. To get the
/// backend look at build_options.
pub fn default(
target: std.zig.CrossTarget,
target: std.Target,
wasm_target: WasmTarget,
) Backend {
if (target.getCpuArch() == .wasm32) {
if (target.cpu.arch == .wasm32) {
return switch (wasm_target) {
.browser => .web_canvas,
};

View File

@ -30,10 +30,10 @@ pub const Impl = enum {
webgl,
pub fn default(
target: std.zig.CrossTarget,
target: std.Target,
wasm_target: WasmTarget,
) Impl {
if (target.getCpuArch() == .wasm32) {
if (target.cpu.arch == .wasm32) {
return switch (wasm_target) {
.browser => .webgl,
};

View File

@ -161,7 +161,7 @@ test "Padding balanced on zero" {
const cell: CellSize = .{ .width = 10, .height = 20 };
const screen: ScreenSize = .{ .width = 0, .height = 0 };
const padding = Padding.balanced(screen, grid, cell);
try testing.expectEqual(padding, .{});
try testing.expectEqual(Padding{}, padding);
}
test "GridSize update exact" {

View File

@ -1209,7 +1209,7 @@ test "OSC: get palette color" {
const cmd = p.end('\x1b').?;
try testing.expect(cmd == .report_color);
try testing.expectEqual(cmd.report_color.kind, .{ .palette = 1 });
try testing.expectEqual(Command.ColorKind{ .palette = 1 }, cmd.report_color.kind);
try testing.expectEqual(cmd.report_color.terminator, .st);
}
@ -1223,7 +1223,7 @@ test "OSC: set palette color" {
const cmd = p.end('\x1b').?;
try testing.expect(cmd == .set_color);
try testing.expectEqual(cmd.set_color.kind, .{ .palette = 17 });
try testing.expectEqual(Command.ColorKind{ .palette = 17 }, cmd.set_color.kind);
try testing.expectEqualStrings(cmd.set_color.value, "rgb:aa/bb/cc");
}