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:
Krzysztof Wolicki
2024-01-03 21:50:32 +01:00
parent f93c41669e
commit 1913243c35
20 changed files with 213 additions and 172 deletions

255
build.zig
View File

@ -1,8 +1,8 @@
const std = @import("std"); const std = @import("std");
const builtin = @import("builtin"); const builtin = @import("builtin");
const fs = std.fs; const fs = std.fs;
const LibExeObjStep = std.build.LibExeObjStep; const CompileStep = std.Build.Step.Compile;
const RunStep = std.build.RunStep; const RunStep = std.Build.Step.Run;
const apprt = @import("src/apprt.zig"); const apprt = @import("src/apprt.zig");
const font = @import("src/font/main.zig"); const font = @import("src/font/main.zig");
@ -47,9 +47,9 @@ pub fn build(b: *std.Build) !void {
const target = target: { const target = target: {
var result = b.standardTargetOptions(.{}); var result = b.standardTargetOptions(.{});
if (result.isDarwin()) { if (result.result.isDarwin()) {
if (result.os_version_min == null) { if (result.query.os_version_min == null) {
result.os_version_min = .{ .semver = .{ .major = 12, .minor = 0, .patch = 0 } }; 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,
"font-backend", "font-backend",
"The font backend to use for discovery and rasterization.", "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( app_runtime = b.option(
apprt.Runtime, apprt.Runtime,
"app-runtime", "app-runtime",
"The app runtime to use. Not all values supported on all platforms.", "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( libadwaita = b.option(
bool, bool,
@ -99,7 +99,7 @@ pub fn build(b: *std.Build) !void {
renderer.Impl, renderer.Impl,
"renderer", "renderer",
"The app runtime to use. Not all values supported on all platforms.", "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( const static = b.option(
bool, 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.", "This defaults to LD_LIBRARY_PATH if we're in a Nix shell environment on NixOS.",
) orelse patch_rpath: { ) orelse patch_rpath: {
// We only do the patching if we're targeting our own CPU and its Linux. // 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. // If we're in a nix shell we default to doing this.
// Note: we purposely never deinit envmap because we leak the strings // Note: we purposely never deinit envmap because we leak the strings
@ -215,7 +215,7 @@ pub fn build(b: *std.Build) !void {
// Exe // Exe
if (exe_) |exe| { if (exe_) |exe| {
exe.addOptions("build_options", exe_options); exe.root_module.addOptions("build_options", exe_options);
// Add the shared dependencies // Add the shared dependencies
_ = try addDeps(b, exe, static); _ = 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 // If we're in NixOS but not in the shell environment then we issue
// a warning because the rpath may not be setup properly. // a warning because the rpath may not be setup properly.
const is_nixos = is_nixos: { const is_nixos = is_nixos: {
if (!target.isLinux()) break :is_nixos false; if (target.result.os.tag != .linux) break :is_nixos false;
if (!target.isNativeCpu()) break :is_nixos false; if (!target.query.isNativeCpu()) break :is_nixos false;
if (target.getOsTag() != builtin.os.tag) break :is_nixos false; if (!target.query.isNativeOs()) break :is_nixos false;
break :is_nixos if (std.fs.accessAbsolute("/etc/NIXOS", .{})) true else |_| false; break :is_nixos if (std.fs.accessAbsolute("/etc/NIXOS", .{})) true else |_| false;
}; };
if (is_nixos and env.get("IN_NIX_SHELL") == null) { if (is_nixos and env.get("IN_NIX_SHELL") == null) {
@ -273,7 +273,7 @@ pub fn build(b: *std.Build) !void {
} }
// App (Mac) // App (Mac)
if (target.isDarwin()) { if (target.result.isDarwin()) {
const bin_install = b.addInstallFile( const bin_install = b.addInstallFile(
exe.getEmittedBin(), exe.getEmittedBin(),
"Ghostty.app/Contents/MacOS/ghostty", "Ghostty.app/Contents/MacOS/ghostty",
@ -294,7 +294,7 @@ pub fn build(b: *std.Build) !void {
}); });
b.getInstallStep().dependOn(&install.step); b.getInstallStep().dependOn(&install.step);
if (target.isDarwin() and exe_ != null) { if (target.result.isDarwin() and exe_ != null) {
const mac_install = b.addInstallDirectory(options: { const mac_install = b.addInstallDirectory(options: {
var copy = install.options; var copy = install.options;
copy.install_dir = .{ copy.install_dir = .{
@ -317,7 +317,7 @@ pub fn build(b: *std.Build) !void {
}); });
b.getInstallStep().dependOn(&install.step); b.getInstallStep().dependOn(&install.step);
if (target.isDarwin() and exe_ != null) { if (target.result.isDarwin() and exe_ != null) {
const mac_install = b.addInstallDirectory(options: { const mac_install = b.addInstallDirectory(options: {
var copy = install.options; var copy = install.options;
copy.install_dir = .{ copy.install_dir = .{
@ -341,7 +341,7 @@ pub fn build(b: *std.Build) !void {
const src_source = wf.add("share/terminfo/ghostty.terminfo", str.items); const src_source = wf.add("share/terminfo/ghostty.terminfo", str.items);
const src_install = b.addInstallFile(src_source, "share/terminfo/ghostty.terminfo"); const src_install = b.addInstallFile(src_source, "share/terminfo/ghostty.terminfo");
b.getInstallStep().dependOn(&src_install.step); 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( const mac_src_install = b.addInstallFile(
src_source, src_source,
"Ghostty.app/Contents/Resources/terminfo/ghostty.terminfo", "Ghostty.app/Contents/Resources/terminfo/ghostty.terminfo",
@ -352,17 +352,17 @@ pub fn build(b: *std.Build) !void {
// Convert to termcap source format if thats helpful to people and // Convert to termcap source format if thats helpful to people and
// install it. The resulting value here is the termcap source in case // install it. The resulting value here is the termcap source in case
// that is used for other commands. // that is used for other commands.
if (!target.isWindows()) { if (target.result.os.tag != .windows) {
const run_step = RunStep.create(b, "infotocap"); const run_step = RunStep.create(b, "infotocap");
run_step.addArg("infotocap"); run_step.addArg("infotocap");
run_step.addFileSourceArg(src_source); run_step.addFileArg(src_source);
const out_source = run_step.captureStdOut(); const out_source = run_step.captureStdOut();
_ = run_step.captureStdErr(); // so we don't see stderr _ = run_step.captureStdErr(); // so we don't see stderr
const cap_install = b.addInstallFile(out_source, "share/terminfo/ghostty.termcap"); const cap_install = b.addInstallFile(out_source, "share/terminfo/ghostty.termcap");
b.getInstallStep().dependOn(&cap_install.step); 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( const mac_cap_install = b.addInstallFile(
out_source, out_source,
"Ghostty.app/Contents/Resources/terminfo/ghostty.termcap", "Ghostty.app/Contents/Resources/terminfo/ghostty.termcap",
@ -372,11 +372,11 @@ pub fn build(b: *std.Build) !void {
} }
// Compile the terminfo source into a terminfo database // Compile the terminfo source into a terminfo database
if (!target.isWindows()) { if (target.result.os.tag != .windows) {
const run_step = RunStep.create(b, "tic"); const run_step = RunStep.create(b, "tic");
run_step.addArgs(&.{ "tic", "-x", "-o" }); run_step.addArgs(&.{ "tic", "-x", "-o" });
const path = run_step.addOutputFileArg("terminfo"); 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 _ = run_step.captureStdErr(); // so we don't see stderr
// Depend on the terminfo source install step so that Zig build // Depend on the terminfo source install step so that Zig build
@ -386,15 +386,15 @@ pub fn build(b: *std.Build) !void {
{ {
const copy_step = RunStep.create(b, "copy terminfo db"); const copy_step = RunStep.create(b, "copy terminfo db");
copy_step.addArgs(&.{ "cp", "-R" }); copy_step.addArgs(&.{ "cp", "-R" });
copy_step.addFileSourceArg(path); copy_step.addFileArg(path);
copy_step.addArg(b.fmt("{s}/share", .{b.install_prefix})); copy_step.addArg(b.fmt("{s}/share", .{b.install_prefix}));
b.getInstallStep().dependOn(&copy_step.step); 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"); const copy_step = RunStep.create(b, "copy terminfo db");
copy_step.addArgs(&.{ "cp", "-R" }); copy_step.addArgs(&.{ "cp", "-R" });
copy_step.addFileSourceArg(path); copy_step.addFileArg(path);
copy_step.addArg( copy_step.addArg(
b.fmt("{s}/Ghostty.app/Contents/Resources", .{b.install_prefix}), b.fmt("{s}/Ghostty.app/Contents/Resources", .{b.install_prefix}),
); );
@ -417,7 +417,7 @@ pub fn build(b: *std.Build) !void {
} }
// App (Linux) // App (Linux)
if (target.isLinux()) { if (target.result.os.tag == .linux) {
// https://developer.gnome.org/documentation/guidelines/maintainer/integrating.html // https://developer.gnome.org/documentation/guidelines/maintainer/integrating.html
// Desktop file so that we have an icon and other metadata // Desktop file so that we have an icon and other metadata
@ -538,19 +538,23 @@ pub fn build(b: *std.Build) !void {
// wasm // wasm
{ {
// Build our Wasm target. // Build our Wasm target.
const wasm_crosstarget: std.zig.CrossTarget = .{ const wasm_crosstarget: std.Target = .{
.cpu_arch = .wasm32, .os = .{ .tag = .freestanding, .version_range = .{ .none = {} } },
.os_tag = .freestanding, .cpu = .{
.cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp }, .arch = .wasm32,
.cpu_features_add = std.Target.wasm.featureSet(&.{ .model = &std.Target.wasm.cpu.mvp,
// We use this to explicitly request shared memory. .features = std.Target.wasm.featureSet(&.{
.atomics, // We use this to explicitly request shared memory.
.atomics,
// Not explicitly used but compiler could use them if they want. // Not explicitly used but compiler could use them if they want.
.bulk_memory, .bulk_memory,
.reference_types, .reference_types,
.sign_ext, .sign_ext,
}), }),
},
.abi = std.Target.Abi.default(.wasm32, .{ .tag = .freestanding, .version_range = .{ .none = {} } }),
.ofmt = std.Target.ObjectFormat.default(.freestanding, .wasm32),
}; };
// Whether we're using wasm shared memory. Some behaviors change. // Whether we're using wasm shared memory. Some behaviors change.
@ -566,10 +570,13 @@ pub fn build(b: *std.Build) !void {
const wasm = b.addSharedLibrary(.{ const wasm = b.addSharedLibrary(.{
.name = "ghostty-wasm", .name = "ghostty-wasm",
.root_source_file = .{ .path = "src/main_wasm.zig" }, .root_source_file = .{ .path = "src/main_wasm.zig" },
.target = wasm_crosstarget, .target = .{
.result = wasm_crosstarget,
.query = std.Target.Query.fromTarget(wasm_crosstarget),
},
.optimize = optimize, .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 // So that we can use web workers with our wasm binary
wasm.import_memory = true; wasm.import_memory = true;
@ -578,7 +585,7 @@ pub fn build(b: *std.Build) !void {
wasm.shared_memory = wasm_shared; wasm.shared_memory = wasm_shared;
// Stack protector adds extern requirements that we don't satisfy. // Stack protector adds extern requirements that we don't satisfy.
wasm.stack_protector = false; wasm.root_module.stack_protector = false;
// Wasm-specific deps // Wasm-specific deps
_ = try addDeps(b, wasm, true); _ = try addDeps(b, wasm, true);
@ -597,9 +604,12 @@ pub fn build(b: *std.Build) !void {
const main_test = b.addTest(.{ const main_test = b.addTest(.{
.name = "wasm-test", .name = "wasm-test",
.root_source_file = .{ .path = "src/main_wasm.zig" }, .root_source_file = .{ .path = "src/main_wasm.zig" },
.target = wasm_crosstarget, .target = .{
.result = wasm_crosstarget,
.query = std.Target.Query.fromTarget(wasm_crosstarget),
},
}); });
main_test.addOptions("build_options", exe_options); main_test.root_module.addOptions("build_options", exe_options);
_ = try addDeps(b, main_test, true); _ = try addDeps(b, main_test, true);
test_step.dependOn(&main_test.step); test_step.dependOn(&main_test.step);
} }
@ -637,7 +647,7 @@ pub fn build(b: *std.Build) !void {
{ {
if (emit_test_exe) b.installArtifact(main_test); if (emit_test_exe) b.installArtifact(main_test);
_ = try addDeps(b, main_test, true); _ = 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); const test_run = b.addRunArtifact(main_test);
test_step.dependOn(&test_run.step); test_step.dependOn(&test_run.step);
@ -646,94 +656,125 @@ pub fn build(b: *std.Build) !void {
} }
/// Used to keep track of a list of file sources. /// 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. /// Adds and links all of the primary dependencies for the exe.
fn addDeps( fn addDeps(
b: *std.Build, b: *std.Build,
step: *std.build.LibExeObjStep, step: *std.Build.Step.Compile,
static: bool, static: bool,
) !FileSourceList { ) !LazyPathList {
var static_libs = FileSourceList.init(b.allocator); var static_libs = LazyPathList.init(b.allocator);
errdefer static_libs.deinit(); errdefer static_libs.deinit();
// For dynamic linking, we prefer dynamic linking and to search by // For dynamic linking, we prefer dynamic linking and to search by
// mode first. Mode first will search all paths for a dynamic library // mode first. Mode first will search all paths for a dynamic library
// before falling back to static. // 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, .preferred_link_mode = .Dynamic,
.search_strategy = .mode_first, .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 // Dependencies
const cimgui_dep = b.dependency("cimgui", .{ .target = step.target, .optimize = step.optimize }); const cimgui_dep = b.dependency("cimgui", .{
const js_dep = b.dependency("zig_js", .{ .target = step.target, .optimize = step.optimize }); .target = target_triple,
const libxev_dep = b.dependency("libxev", .{ .target = step.target, .optimize = step.optimize }); .cpu = cpu_opts,
const objc_dep = b.dependency("zig_objc", .{ .target = step.target, .optimize = step.optimize }); .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", .{ const fontconfig_dep = b.dependency("fontconfig", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const freetype_dep = b.dependency("freetype", .{ const freetype_dep = b.dependency("freetype", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.@"enable-libpng" = true, .@"enable-libpng" = true,
}); });
const glslang_dep = b.dependency("glslang", .{ const glslang_dep = b.dependency("glslang", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const spirv_cross_dep = b.dependency("spirv_cross", .{ const spirv_cross_dep = b.dependency("spirv_cross", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const mach_glfw_dep = b.dependency("mach_glfw", .{ const mach_glfw_dep = b.dependency("mach_glfw", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const libpng_dep = b.dependency("libpng", .{ const libpng_dep = b.dependency("libpng", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const macos_dep = b.dependency("macos", .{ const macos_dep = b.dependency("macos", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const oniguruma_dep = b.dependency("oniguruma", .{ const oniguruma_dep = b.dependency("oniguruma", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const opengl_dep = b.dependency("opengl", .{}); const opengl_dep = b.dependency("opengl", .{});
const pixman_dep = b.dependency("pixman", .{ const pixman_dep = b.dependency("pixman", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const tracy_dep = b.dependency("tracy", .{ const tracy_dep = b.dependency("tracy", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .optimize = step.root_module.optimize.?,
}); });
const zlib_dep = b.dependency("zlib", .{ const zlib_dep = b.dependency("zlib", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
const harfbuzz_dep = b.dependency("harfbuzz", .{ const harfbuzz_dep = b.dependency("harfbuzz", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.@"enable-freetype" = true, .@"enable-freetype" = true,
.@"enable-coretext" = font_backend.hasCoretext(), .@"enable-coretext" = font_backend.hasCoretext(),
}); });
const ziglyph_dep = b.dependency("ziglyph", .{ const ziglyph_dep = b.dependency("ziglyph", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
// Wasm we do manually since it is such a different build. // 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 // We link this package but its a no-op since Tracy
// never actually WORKS with wasm. // never actually WORKS with wasm.
step.addModule("tracy", tracy_dep.module("tracy")); step.root_module.addImport("tracy", tracy_dep.module("tracy"));
step.addModule("zig-js", js_dep.module("zig-js")); step.root_module.addImport("zig-js", js_dep.module("zig-js"));
return static_libs; return static_libs;
} }
@ -741,8 +782,8 @@ fn addDeps(
// On Linux, we need to add a couple common library paths that aren't // 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 the standard search list. i.e. GTK is often in /usr/lib/x86_64-linux-gnu
// on x86_64. // on x86_64.
if (step.target.isLinux()) { if (step.rootModuleTarget().os.tag == .linux) {
const triple = try step.target.linuxTriple(b.allocator); const triple = try step.rootModuleTarget().linuxTriple(b.allocator);
step.addLibraryPath(.{ .path = b.fmt("/usr/lib/{s}", .{triple}) }); step.addLibraryPath(.{ .path = b.fmt("/usr/lib/{s}", .{triple}) });
} }
@ -756,42 +797,42 @@ fn addDeps(
// We always require the system SDK so that our system headers are available. // We always require the system SDK so that our system headers are available.
// This makes things like `os/log.h` available for cross-compiling. // 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); try @import("apple_sdk").addPaths(b, step);
} }
// We always need the Zig packages // We always need the Zig packages
// TODO: This can't be the right way to use the new Zig modules system, // TODO: This can't be the right way to use the new Zig modules system,
// so take a closer look at this again later. // 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",
fontconfig_dep.module("fontconfig"), fontconfig_dep.module("fontconfig"),
); );
step.addModule("oniguruma", oniguruma_dep.module("oniguruma")); step.root_module.addImport("oniguruma", oniguruma_dep.module("oniguruma"));
step.addModule("freetype", freetype_dep.module("freetype")); step.root_module.addImport("freetype", freetype_dep.module("freetype"));
step.addModule("glslang", glslang_dep.module("glslang")); step.root_module.addImport("glslang", glslang_dep.module("glslang"));
step.addModule("spirv_cross", spirv_cross_dep.module("spirv_cross")); step.root_module.addImport("spirv_cross", spirv_cross_dep.module("spirv_cross"));
step.addModule("harfbuzz", harfbuzz_dep.module("harfbuzz")); step.root_module.addImport("harfbuzz", harfbuzz_dep.module("harfbuzz"));
step.addModule("xev", libxev_dep.module("xev")); step.root_module.addImport("xev", libxev_dep.module("xev"));
step.addModule("opengl", opengl_dep.module("opengl")); step.root_module.addImport("opengl", opengl_dep.module("opengl"));
step.addModule("pixman", pixman_dep.module("pixman")); step.root_module.addImport("pixman", pixman_dep.module("pixman"));
step.addModule("ziglyph", ziglyph_dep.module("ziglyph")); step.root_module.addImport("ziglyph", ziglyph_dep.module("ziglyph"));
// Mac Stuff // Mac Stuff
if (step.target.isDarwin()) { if (step.rootModuleTarget().isDarwin()) {
step.addModule("objc", objc_dep.module("objc")); step.root_module.addImport("objc", objc_dep.module("objc"));
step.addModule("macos", macos_dep.module("macos")); step.root_module.addImport("macos", macos_dep.module("macos"));
step.linkLibrary(macos_dep.artifact("macos")); step.linkLibrary(macos_dep.artifact("macos"));
try static_libs.append(macos_dep.artifact("macos").getEmittedBin()); try static_libs.append(macos_dep.artifact("macos").getEmittedBin());
} }
// cimgui // cimgui
step.addModule("cimgui", cimgui_dep.module("cimgui")); step.root_module.addImport("cimgui", cimgui_dep.module("cimgui"));
step.linkLibrary(cimgui_dep.artifact("cimgui")); step.linkLibrary(cimgui_dep.artifact("cimgui"));
try static_libs.append(cimgui_dep.artifact("cimgui").getEmittedBin()); try static_libs.append(cimgui_dep.artifact("cimgui").getEmittedBin());
// Tracy // Tracy
step.addModule("tracy", tracy_dep.module("tracy")); step.root_module.addImport("tracy", tracy_dep.module("tracy"));
if (tracy) { if (tracy) {
step.linkLibrary(tracy_dep.artifact("tracy")); step.linkLibrary(tracy_dep.artifact("tracy"));
try static_libs.append(tracy_dep.artifact("tracy").getEmittedBin()); try static_libs.append(tracy_dep.artifact("tracy").getEmittedBin());
@ -867,7 +908,7 @@ fn addDeps(
.none => {}, .none => {},
.glfw => { .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); @import("mach_glfw").link(mach_glfw_dep.builder, step);
}, },
@ -883,8 +924,8 @@ fn addDeps(
fn benchSteps( fn benchSteps(
b: *std.Build, b: *std.Build,
target: std.zig.CrossTarget, target: std.Build.ResolvedTarget,
optimize: std.builtin.Mode, optimize: std.builtin.OptimizeMode,
install: bool, install: bool,
) !void { ) !void {
// Open the directory ./src/bench // Open the directory ./src/bench
@ -916,7 +957,7 @@ fn benchSteps(
.root_source_file = .{ .path = path }, .root_source_file = .{ .path = path },
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.main_pkg_path = .{ .path = "./src" }, // .main_pkg_path = .{ .path = "./src" },
}); });
if (install) b.installArtifact(c_exe); if (install) b.installArtifact(c_exe);
_ = try addDeps(b, c_exe, true); _ = try addDeps(b, c_exe, true);
@ -925,10 +966,10 @@ fn benchSteps(
fn conformanceSteps( fn conformanceSteps(
b: *std.Build, b: *std.Build,
target: std.zig.CrossTarget, target: std.Build.ResolvedTarget,
optimize: std.builtin.Mode, optimize: std.builtin.Mode,
) !std.StringHashMap(*LibExeObjStep) { ) !std.StringHashMap(*CompileStep) {
var map = std.StringHashMap(*LibExeObjStep).init(b.allocator); var map = std.StringHashMap(*CompileStep).init(b.allocator);
// Open the directory ./conformance // Open the directory ./conformance
const c_dir_path = (comptime root()) ++ "/conformance"; const c_dir_path = (comptime root()) ++ "/conformance";

View File

@ -5,24 +5,24 @@
.dependencies = .{ .dependencies = .{
// Zig libs // Zig libs
.libxev = .{ .libxev = .{
.url = "https://github.com/mitchellh/libxev/archive/7eada4333c36b3e16f4dc2abad707149ef7b6de5.tar.gz", .url = "https://github.com/der-teufel-programming/libxev/archive/2bef0a64276df5f4f4a7f54e5757566502951a27.tar.gz",
.hash = "1220be2c7b3f3a07b9150720140c7038f454a9ce0cbc5d303767c1e4a50856ec1b01", .hash = "1220bfba76eaadfbee75acdd18a44df896252b1945280f69229b5b37ac1984ccccf1",
}, },
.mach_glfw = .{ .mach_glfw = .{
.url = "https://github.com/hexops/mach-glfw/archive/577220552e1b31c4496d2e0df2fb5fbc9287b966.tar.gz", .url = "https://github.com/der-teufel-programming/mach-glfw/archive/cf3a3fdfcbcdabe3529fa3ad6815ff5af7b38538.tar.gz",
.hash = "12204779ba2f14b46f569110f774d5c3f48b7a105b6717e668bc410710bceae62072", .hash = "12200ce85e5d72069d695fe4ac4f4dcc4686d89bb80e1d9a3308396dfac898255f0e",
}, },
.zig_objc = .{ .zig_objc = .{
.url = "https://github.com/mitchellh/zig-objc/archive/10e552bd37c2f61b9f570d5ceb145165c6f1854b.tar.gz", .url = "https://github.com/der-teufel-programming/zig-objc/archive/31298087bbb7b9346737a6dfd8c87e21db066152.tar.gz",
.hash = "122045926c2a90c61ca2ce907cc83a91ede0d49c989209fff2e2db421a88caf88e91", .hash = "122083bcd6341d2e7e2e34af42e86888a9f5e84516b28d2f61b1251c2fe054ee94d8",
}, },
.zig_js = .{ .zig_js = .{
.url = "https://github.com/mitchellh/zig-js/archive/60ac42ab137461cdba2b38cc6c5e16376470aae6.tar.gz", .url = "https://github.com/der-teufel-programming/zig-js/archive/bbb15f9ff39c5caaf64998d8c6d2483cd575787b.tar.gz",
.hash = "1220319b42fbc0116f3f198343256018e9f1da9483cef259201afe4ebab0ce0d8f6a", .hash = "1220ddc4e61d7bff3eab90661f0849dedeabc9840648084c994416bdd8ac4697d85b",
}, },
.ziglyph = .{ .ziglyph = .{
.url = "https://codeberg.org/dude_the_builder/ziglyph/archive/ef6a97e3e6d31786e4c5152abb8393f32ce52279.tar.gz", .url = "https://codeberg.org/dude_the_builder/ziglyph/archive/0e17bd36a4e882b194a87c283bd78562ea215116.tar.gz",
.hash = "1220847f934ea57e90ffb4d447a43e37ff4dce2aab23c84513dfff591376350ffd31", .hash = "12208553f3f47e51494e187f4c0e6f6b3844e3993436cad4a0e8c4db4e99645967b5",
}, },
// C libs // C libs

View File

@ -7,7 +7,7 @@ pub fn build(b: *std.Build) !void {
_ = optimize; _ = 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; _ = b;
@import("macos_sdk").addPaths(step); @import("macos_sdk").addPaths(step);
} }

View File

@ -3,8 +3,8 @@
.version = "0.1.0", .version = "0.1.0",
.dependencies = .{ .dependencies = .{
.macos_sdk = .{ .macos_sdk = .{
.url = "https://github.com/mitchellh/zig-build-macos-sdk/archive/7a7cb3816617dbaf87ecbc3fd90ad56a6f828275.tar.gz", .url = "https://github.com/der-teufel-programming/zig-build-macos-sdk/archive/51dc3ff03b6f103043ed12f7d4508d270475b569.tar.gz",
.hash = "1220a1dd91457d0131b50db15fb1bc51208ecadf1a23ad5dfa2d3a6bb3d1de5230c1", .hash = "12201f1da86d5de762253305b89775ca70c4f1c818695a128649b88f358ca7a4f61f",
}, },
}, },
} }

View File

@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); 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 imgui = b.dependency("imgui", .{});
const freetype = b.dependency("freetype", .{ const freetype = b.dependency("freetype", .{
@ -21,7 +21,7 @@ pub fn build(b: *std.Build) !void {
lib.linkLibC(); lib.linkLibC();
lib.linkLibCpp(); lib.linkLibCpp();
lib.linkLibrary(freetype.artifact("freetype")); lib.linkLibrary(freetype.artifact("freetype"));
if (target.isWindows()) { if (target.result.os.tag == .windows) {
lib.linkSystemLibrary("imm32"); lib.linkSystemLibrary("imm32");
} }
@ -34,7 +34,7 @@ pub fn build(b: *std.Build) !void {
"-DIMGUI_USE_WCHAR32=1", "-DIMGUI_USE_WCHAR32=1",
"-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1", "-DIMGUI_DISABLE_OBSOLETE_FUNCTIONS=1",
}); });
if (target.isWindows()) { if (target.result.os.tag == .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-DIMGUI_IMPL_API=extern\t\"C\"\t__declspec(dllexport)", "-DIMGUI_IMPL_API=extern\t\"C\"\t__declspec(dllexport)",
}); });
@ -57,8 +57,8 @@ pub fn build(b: *std.Build) !void {
.flags = flags.items, .flags = flags.items,
}); });
if (target.isDarwin()) { if (target.result.isDarwin()) {
if (!target.isNative()) try @import("apple_sdk").addPaths(b, lib); if (!target.query.isNative()) try @import("apple_sdk").addPaths(b, lib);
lib.addCSourceFile(.{ lib.addCSourceFile(.{
.file = imgui.path("backends/imgui_impl_metal.mm"), .file = imgui.path("backends/imgui_impl_metal.mm"),
.flags = flags.items, .flags = flags.items,

View File

@ -10,10 +10,10 @@ pub fn build(b: *std.Build) !void {
bool, bool,
"enable-libxml2-iconv", "enable-libxml2-iconv",
"Build libxml2 with 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; 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 upstream = b.dependency("fontconfig", .{});
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{
@ -22,7 +22,7 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
lib.linkLibC(); lib.linkLibC();
if (!target.isWindows()) { if (target.result.os.tag != .windows) {
lib.linkSystemLibrary("pthread"); lib.linkSystemLibrary("pthread");
} }
if (freetype_enabled) { if (freetype_enabled) {
@ -86,8 +86,8 @@ pub fn build(b: *std.Build) !void {
"-fno-sanitize=undefined", "-fno-sanitize=undefined",
"-fno-sanitize-trap=undefined", "-fno-sanitize-trap=undefined",
}); });
const target_info = try NativeTargetInfo.detect(target); // const target_info = try NativeTargetInfo.detect(target);
switch (target_info.target.ptrBitWidth()) { switch (target.result.ptrBitWidth()) {
32 => try flags.appendSlice(&.{ 32 => try flags.appendSlice(&.{
"-DSIZEOF_VOID_P=4", "-DSIZEOF_VOID_P=4",
"-DALIGNOF_VOID_P=4", "-DALIGNOF_VOID_P=4",
@ -100,7 +100,7 @@ pub fn build(b: *std.Build) !void {
else => @panic("unsupported arch"), else => @panic("unsupported arch"),
} }
if (target.isWindows()) { if (target.result.os.tag == .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-DFC_CACHEDIR=\"LOCAL_APPDATA_FONTCONFIG_CACHE\"", "-DFC_CACHEDIR=\"LOCAL_APPDATA_FONTCONFIG_CACHE\"",
"-DFC_TEMPLATEDIR=\"c:/share/fontconfig/conf.avail\"", "-DFC_TEMPLATEDIR=\"c:/share/fontconfig/conf.avail\"",
@ -133,7 +133,7 @@ pub fn build(b: *std.Build) !void {
"-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"", "-DCONFIGDIR=\"/usr/local/fontconfig/conf.d\"",
"-DFC_DEFAULT_FONTS=\"<dir>/usr/share/fonts</dir><dir>/usr/local/share/fonts</dir>\"", "-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(&.{ try flags.appendSlice(&.{
"-DHAVE_SYS_STATFS_H", "-DHAVE_SYS_STATFS_H",
"-DHAVE_SYS_VFS_H", "-DHAVE_SYS_VFS_H",
@ -146,7 +146,7 @@ pub fn build(b: *std.Build) !void {
"-DLIBXML_STATIC", "-DLIBXML_STATIC",
"-DLIBXML_PUSH_ENABLED", "-DLIBXML_PUSH_ENABLED",
}); });
if (target.isWindows()) { if (target.result.os.tag == .windows) {
// NOTE: this should be defined on all targets // NOTE: this should be defined on all targets
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-Werror=implicit-function-declaration", "-Werror=implicit-function-declaration",

View File

@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const libpng_enabled = b.option(bool, "enable-libpng", "Build libpng") orelse false; 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 upstream = b.dependency("freetype", .{});
const lib = b.addStaticLibrary(.{ 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(.{ .linux => lib.addCSourceFile(.{
.file = upstream.path("builds/unix/ftsystem.c"), .file = upstream.path("builds/unix/ftsystem.c"),
.flags = flags.items, .flags = flags.items,
@ -59,7 +59,7 @@ pub fn build(b: *std.Build) !void {
.flags = flags.items, .flags = flags.items,
}), }),
} }
switch (target.getOsTag()) { switch (target.result.os.tag) {
.windows => { .windows => {
lib.addCSourceFile(.{ lib.addCSourceFile(.{
.file = upstream.path("builds/windows/ftdebug.c"), .file = upstream.path("builds/windows/ftdebug.c"),

View File

@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); 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 upstream = b.dependency("glslang", .{});
const lib = try buildGlslang(b, upstream, target, optimize); const lib = try buildGlslang(b, upstream, target, optimize);
@ -30,7 +30,7 @@ pub fn build(b: *std.Build) !void {
fn buildGlslang( fn buildGlslang(
b: *std.Build, b: *std.Build,
upstream: *std.Build.Dependency, upstream: *std.Build.Dependency,
target: std.zig.CrossTarget, target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode, optimize: std.builtin.OptimizeMode,
) !*std.Build.Step.Compile { ) !*std.Build.Step.Compile {
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{
@ -108,7 +108,7 @@ fn buildGlslang(
}, },
}); });
if (!target.isWindows()) { if (target.result.os.tag != .windows) {
lib.addCSourceFiles(.{ lib.addCSourceFiles(.{
.dependency = upstream, .dependency = upstream,
.flags = flags.items, .flags = flags.items,

View File

@ -17,8 +17,8 @@ pub fn build(b: *std.Build) !void {
const upstream = b.dependency("harfbuzz", .{}); const upstream = b.dependency("harfbuzz", .{});
const module = b.addModule("harfbuzz", .{ const module = b.addModule("harfbuzz", .{
.source_file = .{ .path = "main.zig" }, .root_source_file = .{ .path = "main.zig" },
.dependencies = &.{ .imports = &.{
.{ .name = "freetype", .module = freetype.module("freetype") }, .{ .name = "freetype", .module = freetype.module("freetype") },
.{ .name = "macos", .module = macos.module("macos") }, .{ .name = "macos", .module = macos.module("macos") },
}, },
@ -41,7 +41,7 @@ pub fn build(b: *std.Build) !void {
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-DHAVE_STDBOOL_H", "-DHAVE_STDBOOL_H",
}); });
if (!target.isWindows()) { if (target.result.os.tag != .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-DHAVE_UNISTD_H", "-DHAVE_UNISTD_H",
"-DHAVE_SYS_MMAN_H", "-DHAVE_SYS_MMAN_H",
@ -85,8 +85,8 @@ pub fn build(b: *std.Build) !void {
}); });
test_exe.linkLibrary(lib); test_exe.linkLibrary(lib);
var it = module.dependencies.iterator(); var it = module.import_table.iterator();
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*); while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
test_exe.linkLibrary(freetype_dep.artifact("freetype")); test_exe.linkLibrary(freetype_dep.artifact("freetype"));
const tests_run = b.addRunArtifact(test_exe); const tests_run = b.addRunArtifact(test_exe);
const test_step = b.step("test", "Run tests"); const test_step = b.step("test", "Run tests");

View File

@ -12,7 +12,7 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
lib.linkLibC(); lib.linkLibC();
if (target.isLinux()) { if (target.result.os.tag == .linux) {
lib.linkSystemLibrary("m"); lib.linkSystemLibrary("m");
} }

View File

@ -15,7 +15,7 @@ pub fn build(b: *std.Build) !void {
lib.addIncludePath(upstream.path("include")); lib.addIncludePath(upstream.path("include"));
lib.addIncludePath(.{ .path = "override/include" }); lib.addIncludePath(.{ .path = "override/include" });
if (target.isWindows()) { if (target.result.os.tag == .windows) {
lib.addIncludePath(.{ .path = "override/config/win32" }); lib.addIncludePath(.{ .path = "override/config/win32" });
lib.linkSystemLibrary("ws2_32"); lib.linkSystemLibrary("ws2_32");
} else { } else {
@ -42,7 +42,7 @@ pub fn build(b: *std.Build) !void {
"-DLIBXML_AUTOMATA_ENABLED=1", "-DLIBXML_AUTOMATA_ENABLED=1",
"-DWITHOUT_TRIO=1", "-DWITHOUT_TRIO=1",
}); });
if (!target.isWindows()) { if (target.result.os.tag != .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-DHAVE_ARPA_INET_H=1", "-DHAVE_ARPA_INET_H=1",
"-DHAVE_ARPA_NAMESER_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 target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); 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(.{ const lib = b.addStaticLibrary(.{
.name = "macos", .name = "macos",
@ -29,7 +29,7 @@ pub fn build(b: *std.Build) !void {
lib.linkFramework("CoreGraphics"); lib.linkFramework("CoreGraphics");
lib.linkFramework("CoreText"); lib.linkFramework("CoreText");
lib.linkFramework("CoreVideo"); 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); b.installArtifact(lib);
@ -41,8 +41,8 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
test_exe.linkLibrary(lib); test_exe.linkLibrary(lib);
var it = module.dependencies.iterator(); var it = module.import_table.iterator();
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*); while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
const tests_run = b.addRunArtifact(test_exe); const tests_run = b.addRunArtifact(test_exe);
const test_step = b.step("test", "Run tests"); const test_step = b.step("test", "Run tests");

View File

@ -5,7 +5,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); 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 upstream = b.dependency("oniguruma", .{});
const lib = try buildOniguruma(b, upstream, target, optimize); const lib = try buildOniguruma(b, upstream, target, optimize);
@ -31,7 +31,7 @@ pub fn build(b: *std.Build) !void {
fn buildOniguruma( fn buildOniguruma(
b: *std.Build, b: *std.Build,
upstream: *std.Build.Dependency, upstream: *std.Build.Dependency,
target: std.zig.CrossTarget, target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode, optimize: std.builtin.OptimizeMode,
) !*std.Build.Step.Compile { ) !*std.Build.Step.Compile {
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{
@ -39,7 +39,7 @@ fn buildOniguruma(
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
const t = lib.target_info.target; const t = target.result;
lib.linkLibC(); lib.linkLibC();
lib.addIncludePath(upstream.path("src")); lib.addIncludePath(upstream.path("src"));

View File

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

View File

@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); 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 upstream = b.dependency("pixman", .{});
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{
@ -13,7 +13,7 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
lib.linkLibC(); lib.linkLibC();
if (!target.isWindows()) { if (!(target.result.os.tag == .windows)) {
lib.linkSystemLibrary("pthread"); lib.linkSystemLibrary("pthread");
} }
@ -42,7 +42,7 @@ pub fn build(b: *std.Build) !void {
"-fno-sanitize=undefined", "-fno-sanitize=undefined",
"-fno-sanitize-trap=undefined", "-fno-sanitize-trap=undefined",
}); });
if (!target.isWindows()) { if (!(target.result.os.tag == .windows)) {
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-DHAVE_PTHREADS=1", "-DHAVE_PTHREADS=1",
@ -75,8 +75,8 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
test_exe.linkLibrary(lib); test_exe.linkLibrary(lib);
var it = module.dependencies.iterator(); var it = module.import_table.iterator();
while (it.next()) |entry| test_exe.addModule(entry.key_ptr.*, entry.value_ptr.*); while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
const tests_run = b.addRunArtifact(test_exe); const tests_run = b.addRunArtifact(test_exe);
const test_step = b.step("test", "Run tests"); const test_step = b.step("test", "Run tests");

View File

@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); 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 upstream = b.dependency("spirv_cross", .{});
const lib = try buildSpirvCross(b, upstream, target, optimize); const lib = try buildSpirvCross(b, upstream, target, optimize);
@ -30,7 +30,7 @@ pub fn build(b: *std.Build) !void {
fn buildSpirvCross( fn buildSpirvCross(
b: *std.Build, b: *std.Build,
upstream: *std.Build.Dependency, upstream: *std.Build.Dependency,
target: std.zig.CrossTarget, target: std.Build.ResolvedTarget,
optimize: std.builtin.OptimizeMode, optimize: std.builtin.OptimizeMode,
) !*std.Build.Step.Compile { ) !*std.Build.Step.Compile {
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{

View File

@ -4,7 +4,7 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); 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 upstream = b.dependency("tracy", .{});
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{
@ -14,7 +14,7 @@ pub fn build(b: *std.Build) !void {
}); });
lib.linkLibC(); lib.linkLibC();
lib.linkLibCpp(); lib.linkLibCpp();
if (target.isWindows()) { if (target.result.os.tag == .windows) {
lib.linkSystemLibrary("Advapi32"); lib.linkSystemLibrary("Advapi32");
lib.linkSystemLibrary("User32"); lib.linkSystemLibrary("User32");
lib.linkSystemLibrary("Ws2_32"); lib.linkSystemLibrary("Ws2_32");
@ -29,7 +29,7 @@ pub fn build(b: *std.Build) !void {
"-DTRACY_ENABLE", "-DTRACY_ENABLE",
"-fno-sanitize=undefined", "-fno-sanitize=undefined",
}); });
if (target.isWindows()) { if (target.result.os.tag == .windows) {
try flags.appendSlice(&.{ try flags.appendSlice(&.{
"-D_WIN32_WINNT=0x601", "-D_WIN32_WINNT=0x601",
}); });

View File

@ -53,12 +53,12 @@ pub const Runtime = enum {
/// GTK-backed. Rich windowed application. GTK is dynamically linked. /// GTK-backed. Rich windowed application. GTK is dynamically linked.
gtk, 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. // 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 // 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 // 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 // build is opt-in because it is missing so many features compared

View File

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

View File

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