mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
Merge pull request #1248 from der-teufel-programming/main
WIP: Update Ghostty to use the new build system API
This commit is contained in:
245
build.zig
245
build.zig
@ -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");
|
||||||
@ -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
|
// but we liberally update it. In the future, we'll be more careful about
|
||||||
// using released versions so that package managers can integrate better.
|
// using released versions so that package managers can integrate better.
|
||||||
comptime {
|
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 current_zig = builtin.zig_version;
|
||||||
const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable;
|
const min_zig = std.SemanticVersion.parse(required_zig) catch unreachable;
|
||||||
if (current_zig.order(min_zig) == .lt) {
|
if (current_zig.order(min_zig) == .lt) {
|
||||||
@ -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) {
|
||||||
@ -253,7 +253,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
|
|
||||||
// Building with LTO on Windows is broken.
|
// Building with LTO on Windows is broken.
|
||||||
// https://github.com/ziglang/zig/issues/15958
|
// 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
|
// If we're installing, we get the install step so we can add
|
||||||
// additional dependencies to it.
|
// additional dependencies to it.
|
||||||
@ -277,7 +277,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",
|
||||||
@ -298,7 +298,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 = .{
|
||||||
@ -321,7 +321,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 = .{
|
||||||
@ -345,7 +345,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",
|
||||||
@ -356,17 +356,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",
|
||||||
@ -376,11 +376,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
|
||||||
@ -390,15 +390,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(©_step.step);
|
b.getInstallStep().dependOn(©_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}),
|
||||||
);
|
);
|
||||||
@ -421,7 +421,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
|
||||||
@ -445,21 +445,21 @@ pub fn build(b: *std.Build) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// On Mac we can build the embedding library.
|
// 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 static_lib_aarch64 = lib: {
|
||||||
const lib = b.addStaticLibrary(.{
|
const lib = b.addStaticLibrary(.{
|
||||||
.name = "ghostty",
|
.name = "ghostty",
|
||||||
.root_source_file = .{ .path = "src/main_c.zig" },
|
.root_source_file = .{ .path = "src/main_c.zig" },
|
||||||
.target = .{
|
.target = b.resolveTargetQuery(.{
|
||||||
.cpu_arch = .aarch64,
|
.cpu_arch = .aarch64,
|
||||||
.os_tag = .macos,
|
.os_tag = .macos,
|
||||||
.os_version_min = target.os_version_min,
|
.os_version_min = target.query.os_version_min,
|
||||||
},
|
}),
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
lib.bundle_compiler_rt = true;
|
lib.bundle_compiler_rt = true;
|
||||||
lib.linkLibC();
|
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
|
// Create a single static lib with all our dependencies merged
|
||||||
var lib_list = try addDeps(b, lib, true);
|
var lib_list = try addDeps(b, lib, true);
|
||||||
@ -479,16 +479,16 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const lib = b.addStaticLibrary(.{
|
const lib = b.addStaticLibrary(.{
|
||||||
.name = "ghostty",
|
.name = "ghostty",
|
||||||
.root_source_file = .{ .path = "src/main_c.zig" },
|
.root_source_file = .{ .path = "src/main_c.zig" },
|
||||||
.target = .{
|
.target = b.resolveTargetQuery(.{
|
||||||
.cpu_arch = .x86_64,
|
.cpu_arch = .x86_64,
|
||||||
.os_tag = .macos,
|
.os_tag = .macos,
|
||||||
.os_version_min = target.os_version_min,
|
.os_version_min = target.query.os_version_min,
|
||||||
},
|
}),
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
lib.bundle_compiler_rt = true;
|
lib.bundle_compiler_rt = true;
|
||||||
lib.linkLibC();
|
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
|
// Create a single static lib with all our dependencies merged
|
||||||
var lib_list = try addDeps(b, lib, true);
|
var lib_list = try addDeps(b, lib, true);
|
||||||
@ -542,7 +542,7 @@ 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.Query = .{
|
||||||
.cpu_arch = .wasm32,
|
.cpu_arch = .wasm32,
|
||||||
.os_tag = .freestanding,
|
.os_tag = .freestanding,
|
||||||
.cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp },
|
.cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp },
|
||||||
@ -570,10 +570,10 @@ 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 = b.resolveTargetQuery(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;
|
||||||
@ -582,7 +582,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);
|
||||||
@ -601,9 +601,9 @@ 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 = 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);
|
_ = try addDeps(b, main_test, true);
|
||||||
test_step.dependOn(&main_test.step);
|
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);
|
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);
|
||||||
@ -650,94 +650,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;
|
||||||
}
|
}
|
||||||
@ -745,8 +776,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}) });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -760,42 +791,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());
|
||||||
@ -871,7 +902,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);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -887,8 +918,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
|
||||||
@ -920,7 +951,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);
|
||||||
@ -929,10 +960,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";
|
||||||
|
@ -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/mitchellh/libxev/archive/74bc7aea4a8f88210f0ad4215108613ab7e7af1a.tar.gz",
|
||||||
.hash = "1220be2c7b3f3a07b9150720140c7038f454a9ce0cbc5d303767c1e4a50856ec1b01",
|
.hash = "122029743e5d96aa1b57a1b99ff58bf13ff9ed6d8f624ac3ae8074062feb91c5bd8d",
|
||||||
},
|
},
|
||||||
.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/fe077f52e51c4eb7e4ff6bbe8d3ee3ecd9cc743d.tar.gz",
|
||||||
.hash = "12204779ba2f14b46f569110f774d5c3f48b7a105b6717e668bc410710bceae62072",
|
.hash = "1220838cb1781e328a0218facaa7e92ae97fd5bbcd81dd0429ac43c5b36fe70c1990",
|
||||||
},
|
},
|
||||||
.zig_objc = .{
|
.zig_objc = .{
|
||||||
.url = "https://github.com/mitchellh/zig-objc/archive/10e552bd37c2f61b9f570d5ceb145165c6f1854b.tar.gz",
|
.url = "https://github.com/mitchellh/zig-objc/archive/294e0f3765a96613b45ff7dd594bf99e22409e96.tar.gz",
|
||||||
.hash = "122045926c2a90c61ca2ce907cc83a91ede0d49c989209fff2e2db421a88caf88e91",
|
.hash = "1220ae28cc6af7600c6f23db1573b33ca3b8accd15e60a1fe1a2c979c20868f151fa",
|
||||||
},
|
},
|
||||||
.zig_js = .{
|
.zig_js = .{
|
||||||
.url = "https://github.com/mitchellh/zig-js/archive/60ac42ab137461cdba2b38cc6c5e16376470aae6.tar.gz",
|
.url = "https://github.com/mitchellh/zig-js/archive/d4edb682733aef8dc3933683272bdf7c8b9fe658.tar.gz",
|
||||||
.hash = "1220319b42fbc0116f3f198343256018e9f1da9483cef259201afe4ebab0ce0d8f6a",
|
.hash = "1220df81f0e65cc9ccd3628572c611e6f267a71f1bff1be19d50f4ac49ee2a83c324",
|
||||||
},
|
},
|
||||||
.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
|
||||||
|
12
flake.lock
generated
12
flake.lock
generated
@ -147,11 +147,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-zig-0-12": {
|
"nixpkgs-zig-0-12": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1703276979,
|
"lastModified": 1704663772,
|
||||||
"narHash": "sha256-WD3FdpkPRLm0PJC26bZT/cSoPNgKANHq14U5O+CfLqI=",
|
"narHash": "sha256-BIDaFQlRhjhrFk+UE7OsV3Jfo/9cbWAWwdjmdy1Hn34=",
|
||||||
"owner": "vancluever",
|
"owner": "vancluever",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d81c22905455c896e79db93fdace8771db1bd995",
|
"rev": "4f7ae324049ecdf3a84db0bb59d2442bb080304f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -194,11 +194,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1702850407,
|
"lastModified": 1704542888,
|
||||||
"narHash": "sha256-dG9eKPJXgZNcXkNJwBdx/7byx08Z3ppXU1E54EY1/t0=",
|
"narHash": "sha256-Fb8tc4cXUkWw+Fva6JKbjkFFpZwu4c+ictSAQGEYjIM=",
|
||||||
"owner": "mitchellh",
|
"owner": "mitchellh",
|
||||||
"repo": "zig-overlay",
|
"repo": "zig-overlay",
|
||||||
"rev": "f5d3c30b3f36ec5d3d5dd81fad850f5523767e5d",
|
"rev": "112cfb72e47cb85d17fc8075a4d70ab56964453d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -10,7 +10,7 @@ help() {
|
|||||||
echo "To fix, please (manually) re-run the script from the repository root,"
|
echo "To fix, please (manually) re-run the script from the repository root,"
|
||||||
echo "commit, and push the update:"
|
echo "commit, and push the update:"
|
||||||
echo ""
|
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 add nix/zigCacheHash.nix"
|
||||||
echo " git commit -m \"nix: update Zig cache hash\""
|
echo " git commit -m \"nix: update Zig cache hash\""
|
||||||
echo " git push"
|
echo " git push"
|
||||||
@ -52,7 +52,7 @@ fi
|
|||||||
|
|
||||||
# Write out the cache file
|
# Write out the cache file
|
||||||
cat > "${CACHE_HASH_FILE}" <<EOS
|
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.
|
# more details.
|
||||||
"${ZIG_CACHE_HASH}"
|
"${ZIG_CACHE_HASH}"
|
||||||
EOS
|
EOS
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# This file is auto-generated! check build-support/check-zig-cache-hash.sh for
|
# This file is auto-generated! check build-support/check-zig-cache-hash.sh for
|
||||||
# more details.
|
# more details.
|
||||||
"sha256-Dn9KRvSteFvHWy6ULEQbRIQZf+bVfpVYWsImGm32qeI="
|
"sha256-iRXzPgzOkt+TTcqPCRQubP3dN6lS+Wvn17l+0I/pDGg="
|
||||||
|
@ -7,7 +7,12 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn addPathsModule(b: *std.Build, m: *std.Build.Module) !void {
|
||||||
|
_ = b;
|
||||||
|
@import("macos_sdk").addPathsModule(m);
|
||||||
|
}
|
||||||
|
@ -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/mitchellh/zig-build-macos-sdk/archive/ee70f27c08680307fa35ada92e6b2c36e0ff84c6.tar.gz",
|
||||||
.hash = "1220a1dd91457d0131b50db15fb1bc51208ecadf1a23ad5dfa2d3a6bb3d1de5230c1",
|
.hash = "1220b415f529f1c04ed876c2b481e9f8119d353d4e3d4d7c8607ee302d2142e13eca",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -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" } });
|
const module = 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,11 +21,12 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
lib.addIncludePath(imgui.path(""));
|
lib.addIncludePath(imgui.path(""));
|
||||||
|
module.addIncludePath(.{ .path = "vendor" });
|
||||||
|
|
||||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
defer flags.deinit();
|
defer flags.deinit();
|
||||||
@ -34,7 +35,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 +58,11 @@ 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);
|
||||||
|
try @import("apple_sdk").addPathsModule(b, module);
|
||||||
|
}
|
||||||
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,
|
||||||
|
@ -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" } });
|
const module = 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) {
|
||||||
@ -40,6 +40,8 @@ pub fn build(b: *std.Build) !void {
|
|||||||
|
|
||||||
lib.addIncludePath(upstream.path(""));
|
lib.addIncludePath(upstream.path(""));
|
||||||
lib.addIncludePath(.{ .path = "override/include" });
|
lib.addIncludePath(.{ .path = "override/include" });
|
||||||
|
module.addIncludePath(upstream.path(""));
|
||||||
|
module.addIncludePath(.{ .path = "override/include" });
|
||||||
|
|
||||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
defer flags.deinit();
|
defer flags.deinit();
|
||||||
@ -86,8 +88,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);
|
|
||||||
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 +102,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 +135,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 +148,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",
|
||||||
|
@ -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" } });
|
const module = 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(.{
|
||||||
@ -15,6 +15,8 @@ pub fn build(b: *std.Build) !void {
|
|||||||
});
|
});
|
||||||
lib.linkLibC();
|
lib.linkLibC();
|
||||||
lib.addIncludePath(upstream.path("include"));
|
lib.addIncludePath(upstream.path("include"));
|
||||||
|
module.addIncludePath(upstream.path("include"));
|
||||||
|
module.addIncludePath(.{ .path = "" });
|
||||||
|
|
||||||
// Dependencies
|
// Dependencies
|
||||||
const zlib_dep = b.dependency("zlib", .{ .target = target, .optimize = optimize });
|
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");
|
if (libpng_enabled) try flags.append("-DFT_CONFIG_OPTION_USE_PNG=1");
|
||||||
|
|
||||||
for (srcs) |src| {
|
lib.addCSourceFiles(.{
|
||||||
lib.addCSourceFile(.{
|
.dependency = upstream,
|
||||||
.file = upstream.path(src),
|
.files = srcs,
|
||||||
.flags = flags.items,
|
.flags = flags.items,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
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 +60,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"),
|
||||||
|
@ -4,12 +4,15 @@ 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" } });
|
const module = 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);
|
||||||
b.installArtifact(lib);
|
b.installArtifact(lib);
|
||||||
|
|
||||||
|
module.addIncludePath(upstream.path(""));
|
||||||
|
module.addIncludePath(.{ .path = "override" });
|
||||||
|
|
||||||
{
|
{
|
||||||
const test_exe = b.addTest(.{
|
const test_exe = b.addTest(.{
|
||||||
.name = "test",
|
.name = "test",
|
||||||
@ -30,7 +33,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 +111,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,
|
||||||
|
@ -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") },
|
||||||
},
|
},
|
||||||
@ -32,16 +32,18 @@ pub fn build(b: *std.Build) !void {
|
|||||||
lib.linkLibC();
|
lib.linkLibC();
|
||||||
lib.linkLibCpp();
|
lib.linkLibCpp();
|
||||||
lib.addIncludePath(upstream.path("src"));
|
lib.addIncludePath(upstream.path("src"));
|
||||||
|
module.addIncludePath(upstream.path("src"));
|
||||||
|
|
||||||
const freetype_dep = b.dependency("freetype", .{ .target = target, .optimize = optimize });
|
const freetype_dep = b.dependency("freetype", .{ .target = target, .optimize = optimize });
|
||||||
lib.linkLibrary(freetype_dep.artifact("freetype"));
|
lib.linkLibrary(freetype_dep.artifact("freetype"));
|
||||||
|
module.addIncludePath(freetype_dep.builder.dependency("freetype", .{}).path("include"));
|
||||||
|
|
||||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
defer flags.deinit();
|
defer flags.deinit();
|
||||||
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",
|
||||||
@ -60,7 +62,9 @@ pub fn build(b: *std.Build) !void {
|
|||||||
if (coretext_enabled) {
|
if (coretext_enabled) {
|
||||||
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"});
|
try flags.appendSlice(&.{"-DHAVE_CORETEXT=1"});
|
||||||
try apple_sdk.addPaths(b, lib);
|
try apple_sdk.addPaths(b, lib);
|
||||||
|
try apple_sdk.addPathsModule(b, module);
|
||||||
lib.linkFramework("ApplicationServices");
|
lib.linkFramework("ApplicationServices");
|
||||||
|
module.linkFramework("ApplicationServices", .{});
|
||||||
}
|
}
|
||||||
|
|
||||||
lib.addCSourceFile(.{
|
lib.addCSourceFile(.{
|
||||||
@ -85,8 +89,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");
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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",
|
||||||
|
@ -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,8 +29,19 @@ 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.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);
|
b.installArtifact(lib);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -41,8 +52,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");
|
||||||
|
@ -5,10 +5,11 @@ 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" } });
|
const module = 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);
|
||||||
|
module.addIncludePath(upstream.path("src"));
|
||||||
b.installArtifact(lib);
|
b.installArtifact(lib);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -31,7 +32,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 +40,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"));
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
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" } });
|
const module = b.addModule("opengl", .{ .root_source_file = .{ .path = "main.zig" } });
|
||||||
|
module.addIncludePath(.{ .path = "../../vendor/glad/include" });
|
||||||
}
|
}
|
||||||
|
@ -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,12 +13,14 @@ 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");
|
||||||
}
|
}
|
||||||
|
|
||||||
lib.addIncludePath(upstream.path(""));
|
lib.addIncludePath(upstream.path(""));
|
||||||
lib.addIncludePath(.{ .path = "" });
|
lib.addIncludePath(.{ .path = "" });
|
||||||
|
module.addIncludePath(upstream.path("pixman"));
|
||||||
|
module.addIncludePath(.{ .path = "" });
|
||||||
|
|
||||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
defer flags.deinit();
|
defer flags.deinit();
|
||||||
@ -42,7 +44,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",
|
||||||
|
|
||||||
@ -50,12 +52,11 @@ pub fn build(b: *std.Build) !void {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (srcs) |src| {
|
lib.addCSourceFiles(.{
|
||||||
lib.addCSourceFile(.{
|
.dependency = upstream,
|
||||||
.file = upstream.path(src),
|
.files = srcs,
|
||||||
.flags = flags.items,
|
.flags = flags.items,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
lib.installHeader("pixman-version.h", "pixman-version.h");
|
lib.installHeader("pixman-version.h", "pixman-version.h");
|
||||||
lib.installHeadersDirectoryOptions(.{
|
lib.installHeadersDirectoryOptions(.{
|
||||||
@ -75,8 +76,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");
|
||||||
|
@ -4,9 +4,11 @@ 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" } });
|
|
||||||
|
|
||||||
const upstream = b.dependency("spirv_cross", .{});
|
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);
|
const lib = try buildSpirvCross(b, upstream, target, optimize);
|
||||||
b.installArtifact(lib);
|
b.installArtifact(lib);
|
||||||
|
|
||||||
@ -30,7 +32,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(.{
|
||||||
|
@ -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",
|
||||||
});
|
});
|
||||||
|
@ -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
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
const LibtoolStep = @This();
|
const LibtoolStep = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Step = std.build.Step;
|
const Step = std.Build.Step;
|
||||||
const RunStep = std.build.RunStep;
|
const RunStep = std.Build.Step.Run;
|
||||||
const FileSource = std.build.FileSource;
|
const LazyPath = std.Build.LazyPath;
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
/// The name of this step.
|
/// The name of this step.
|
||||||
@ -16,14 +16,14 @@ pub const Options = struct {
|
|||||||
out_name: []const u8,
|
out_name: []const u8,
|
||||||
|
|
||||||
/// Library files (.a) to combine.
|
/// Library files (.a) to combine.
|
||||||
sources: []FileSource,
|
sources: []LazyPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The step to depend on.
|
/// The step to depend on.
|
||||||
step: *Step,
|
step: *Step,
|
||||||
|
|
||||||
/// The output file from the libtool run.
|
/// The output file from the libtool run.
|
||||||
output: FileSource,
|
output: LazyPath,
|
||||||
|
|
||||||
/// Run libtool against a list of library files to combine into a single
|
/// Run libtool against a list of library files to combine into a single
|
||||||
/// static library.
|
/// 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}));
|
const run_step = RunStep.create(b, b.fmt("libtool {s}", .{opts.name}));
|
||||||
run_step.addArgs(&.{ "libtool", "-static", "-o" });
|
run_step.addArgs(&.{ "libtool", "-static", "-o" });
|
||||||
const output = run_step.addOutputFileArg(opts.out_name);
|
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.* = .{
|
self.* = .{
|
||||||
.step = &run_step.step,
|
.step = &run_step.step,
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
const LipoStep = @This();
|
const LipoStep = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Step = std.build.Step;
|
const Step = std.Build.Step;
|
||||||
const RunStep = std.build.RunStep;
|
const RunStep = std.Build.Step.Run;
|
||||||
const FileSource = std.build.FileSource;
|
const LazyPath = std.Build.LazyPath;
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
/// The name of the xcframework to create.
|
/// The name of the xcframework to create.
|
||||||
@ -15,14 +15,14 @@ pub const Options = struct {
|
|||||||
out_name: []const u8,
|
out_name: []const u8,
|
||||||
|
|
||||||
/// Library file (dylib, a) to package.
|
/// Library file (dylib, a) to package.
|
||||||
input_a: FileSource,
|
input_a: LazyPath,
|
||||||
input_b: FileSource,
|
input_b: LazyPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
step: *Step,
|
step: *Step,
|
||||||
|
|
||||||
/// Resulting binary
|
/// Resulting binary
|
||||||
output: FileSource,
|
output: LazyPath,
|
||||||
|
|
||||||
pub fn create(b: *std.Build, opts: Options) *LipoStep {
|
pub fn create(b: *std.Build, opts: Options) *LipoStep {
|
||||||
const self = b.allocator.create(LipoStep) catch @panic("OOM");
|
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}));
|
const run_step = RunStep.create(b, b.fmt("lipo {s}", .{opts.name}));
|
||||||
run_step.addArgs(&.{ "lipo", "-create", "-output" });
|
run_step.addArgs(&.{ "lipo", "-create", "-output" });
|
||||||
const output = run_step.addOutputFileArg(opts.out_name);
|
const output = run_step.addOutputFileArg(opts.out_name);
|
||||||
run_step.addFileSourceArg(opts.input_a);
|
run_step.addFileArg(opts.input_a);
|
||||||
run_step.addFileSourceArg(opts.input_b);
|
run_step.addFileArg(opts.input_b);
|
||||||
|
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.step = &run_step.step,
|
.step = &run_step.step,
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
const XCFrameworkStep = @This();
|
const XCFrameworkStep = @This();
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Step = std.build.Step;
|
const Step = std.Build.Step;
|
||||||
const RunStep = std.build.RunStep;
|
const RunStep = std.Build.Step.Run;
|
||||||
const FileSource = std.build.FileSource;
|
const LazyPath = std.Build.LazyPath;
|
||||||
|
|
||||||
pub const Options = struct {
|
pub const Options = struct {
|
||||||
/// The name of the xcframework to create.
|
/// The name of the xcframework to create.
|
||||||
@ -16,10 +16,10 @@ pub const Options = struct {
|
|||||||
out_path: []const u8,
|
out_path: []const u8,
|
||||||
|
|
||||||
/// Library file (dylib, a) to package.
|
/// Library file (dylib, a) to package.
|
||||||
library: std.build.FileSource,
|
library: LazyPath,
|
||||||
|
|
||||||
/// Path to a directory with the headers.
|
/// Path to a directory with the headers.
|
||||||
headers: std.build.FileSource,
|
headers: LazyPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
step: *Step,
|
step: *Step,
|
||||||
@ -42,9 +42,9 @@ pub fn create(b: *std.Build, opts: Options) *XCFrameworkStep {
|
|||||||
run.has_side_effects = true;
|
run.has_side_effects = true;
|
||||||
run.addArgs(&.{ "xcodebuild", "-create-xcframework" });
|
run.addArgs(&.{ "xcodebuild", "-create-xcframework" });
|
||||||
run.addArg("-library");
|
run.addArg("-library");
|
||||||
run.addFileSourceArg(opts.library);
|
run.addFileArg(opts.library);
|
||||||
run.addArg("-headers");
|
run.addArg("-headers");
|
||||||
run.addFileSourceArg(opts.headers);
|
run.addFileArg(opts.headers);
|
||||||
run.addArg("-output");
|
run.addArg("-output");
|
||||||
run.addArg(opts.out_path);
|
run.addArg(opts.out_path);
|
||||||
break :run run;
|
break :run run;
|
||||||
|
@ -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,
|
||||||
};
|
};
|
||||||
|
@ -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,
|
||||||
};
|
};
|
||||||
|
@ -161,7 +161,7 @@ test "Padding balanced on zero" {
|
|||||||
const cell: CellSize = .{ .width = 10, .height = 20 };
|
const cell: CellSize = .{ .width = 10, .height = 20 };
|
||||||
const screen: ScreenSize = .{ .width = 0, .height = 0 };
|
const screen: ScreenSize = .{ .width = 0, .height = 0 };
|
||||||
const padding = Padding.balanced(screen, grid, cell);
|
const padding = Padding.balanced(screen, grid, cell);
|
||||||
try testing.expectEqual(padding, .{});
|
try testing.expectEqual(Padding{}, padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "GridSize update exact" {
|
test "GridSize update exact" {
|
||||||
|
@ -1209,7 +1209,7 @@ test "OSC: get palette color" {
|
|||||||
|
|
||||||
const cmd = p.end('\x1b').?;
|
const cmd = p.end('\x1b').?;
|
||||||
try testing.expect(cmd == .report_color);
|
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);
|
try testing.expectEqual(cmd.report_color.terminator, .st);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1223,7 +1223,7 @@ test "OSC: set palette color" {
|
|||||||
|
|
||||||
const cmd = p.end('\x1b').?;
|
const cmd = p.end('\x1b').?;
|
||||||
try testing.expect(cmd == .set_color);
|
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");
|
try testing.expectEqualStrings(cmd.set_color.value, "rgb:aa/bb/cc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user