mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-30 11:03:55 +00:00
move stb to src/stb, add stb_image for png decoding
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
/// Directories with our includes.
|
||||
const root = thisDir();
|
||||
pub const include_paths = [_][]const u8{
|
||||
root,
|
||||
};
|
||||
|
||||
pub fn module(b: *std.Build) *std.build.Module {
|
||||
return b.createModule(.{
|
||||
.source_file = .{ .path = (comptime thisDir()) ++ "/main.zig" },
|
||||
});
|
||||
}
|
||||
|
||||
fn thisDir() []const u8 {
|
||||
return std.fs.path.dirname(@src().file) orelse ".";
|
||||
}
|
||||
|
||||
pub const Options = struct {};
|
||||
|
||||
pub fn link(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
const lib = try buildStbImageResize(b, step, opt);
|
||||
step.linkLibrary(lib);
|
||||
inline for (include_paths) |path| step.addIncludePath(.{ .path = path });
|
||||
return lib;
|
||||
}
|
||||
|
||||
pub fn buildStbImageResize(
|
||||
b: *std.Build,
|
||||
step: *std.build.LibExeObjStep,
|
||||
opt: Options,
|
||||
) !*std.build.LibExeObjStep {
|
||||
_ = opt;
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "stb_image_resize",
|
||||
.target = step.target,
|
||||
.optimize = step.optimize,
|
||||
});
|
||||
|
||||
// Include
|
||||
inline for (include_paths) |path| lib.addIncludePath(.{ .path = path });
|
||||
|
||||
// Link
|
||||
lib.linkLibC();
|
||||
|
||||
// Compile
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
defer flags.deinit();
|
||||
try flags.appendSlice(&.{
|
||||
//"-fno-sanitize=undefined",
|
||||
});
|
||||
|
||||
// C files
|
||||
lib.addCSourceFile(.{
|
||||
.file = .{ .path = root ++ "/stb_image_resize.c" },
|
||||
.flags = flags.items,
|
||||
});
|
||||
|
||||
return lib;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
pub usingnamespace @cImport({
|
||||
@cInclude("stb_image_resize.h");
|
||||
});
|
||||
|
||||
test {
|
||||
// Needed to not crash on test
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
#define STB_IMAGE_RESIZE_IMPLEMENTATION
|
||||
#include <stb_image_resize.h>
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user