mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-19 22:10:29 +00:00
pkg/highway
This commit is contained in:
110
pkg/highway/build.zig
Normal file
110
pkg/highway/build.zig
Normal file
@@ -0,0 +1,110 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const target = b.standardTargetOptions(.{});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const upstream = b.dependency("highway", .{});
|
||||
|
||||
const module = b.addModule("highway", .{
|
||||
.root_source_file = .{ .path = "main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "highway",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
lib.linkLibCpp();
|
||||
lib.addIncludePath(upstream.path(""));
|
||||
module.addIncludePath(upstream.path(""));
|
||||
|
||||
if (target.result.isDarwin()) {
|
||||
const apple_sdk = @import("apple_sdk");
|
||||
try apple_sdk.addPaths(b, &lib.root_module);
|
||||
try apple_sdk.addPaths(b, module);
|
||||
}
|
||||
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
try flags.appendSlice(&.{
|
||||
// Avoid changing binaries based on the current time and date.
|
||||
"-Wno-builtin-macro-redefined",
|
||||
"-D__DATE__=\"redacted\"",
|
||||
"-D__TIMESTAMP__=\"redacted\"",
|
||||
"-D__TIME__=\"redacted\"",
|
||||
|
||||
// Optimizations
|
||||
"-fmerge-all-constants",
|
||||
|
||||
// Warnings
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
|
||||
// These are not included in Wall nor Wextra:
|
||||
"-Wconversion",
|
||||
"-Wsign-conversion",
|
||||
"-Wvla",
|
||||
"-Wnon-virtual-dtor",
|
||||
|
||||
"-Wfloat-overflow-conversion",
|
||||
"-Wfloat-zero-conversion",
|
||||
"-Wfor-loop-analysis",
|
||||
"-Wgnu-redeclared-enum",
|
||||
"-Winfinite-recursion",
|
||||
"-Wself-assign",
|
||||
"-Wstring-conversion",
|
||||
"-Wtautological-overlap-compare",
|
||||
"-Wthread-safety-analysis",
|
||||
"-Wundefined-func-template",
|
||||
|
||||
"-fno-cxx-exceptions",
|
||||
"-fno-slp-vectorize",
|
||||
"-fno-vectorize",
|
||||
});
|
||||
if (target.result.os.tag != .windows) {
|
||||
try flags.appendSlice(&.{
|
||||
"-fmath-errno",
|
||||
"-fno-exceptions",
|
||||
});
|
||||
}
|
||||
|
||||
lib.addCSourceFiles(.{
|
||||
.dependency = upstream,
|
||||
.flags = flags.items,
|
||||
.files = &.{
|
||||
"hwy/aligned_allocator.cc",
|
||||
"hwy/nanobenchmark.cc",
|
||||
"hwy/per_target.cc",
|
||||
"hwy/print.cc",
|
||||
"hwy/targets.cc",
|
||||
"hwy/timer.cc",
|
||||
},
|
||||
});
|
||||
lib.installHeadersDirectoryOptions(.{
|
||||
.source_dir = upstream.path("hwy"),
|
||||
.install_dir = .header,
|
||||
.install_subdir = "hwy",
|
||||
.include_extensions = &.{".h"},
|
||||
});
|
||||
|
||||
b.installArtifact(lib);
|
||||
|
||||
{
|
||||
const test_exe = b.addTest(.{
|
||||
.name = "test",
|
||||
.root_source_file = .{ .path = "main.zig" },
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
test_exe.linkLibrary(lib);
|
||||
|
||||
var it = module.import_table.iterator();
|
||||
while (it.next()) |entry| test_exe.root_module.addImport(entry.key_ptr.*, entry.value_ptr.*);
|
||||
const tests_run = b.addRunArtifact(test_exe);
|
||||
const test_step = b.step("test", "Run tests");
|
||||
test_step.dependOn(&tests_run.step);
|
||||
}
|
||||
}
|
||||
13
pkg/highway/build.zig.zon
Normal file
13
pkg/highway/build.zig.zon
Normal file
@@ -0,0 +1,13 @@
|
||||
.{
|
||||
.name = "highway",
|
||||
.version = "1.0.7",
|
||||
.paths = .{""},
|
||||
.dependencies = .{
|
||||
.highway = .{
|
||||
.url = "https://github.com/google/highway/archive/refs/tags/1.0.7.tar.gz",
|
||||
.hash = "122060ea43a9403ad53b4a33e19416c0e9949fb3e175035791bd2b7462091079d5a2",
|
||||
},
|
||||
|
||||
.apple_sdk = .{ .path = "../apple-sdk" },
|
||||
},
|
||||
}
|
||||
0
pkg/highway/main.zig
Normal file
0
pkg/highway/main.zig
Normal file
Reference in New Issue
Block a user