mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
pkg/wuffs: define build defines separately, not in defs.zig
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn build(b: *std.Build) void {
|
pub fn build(b: *std.Build) !void {
|
||||||
const target = b.standardTargetOptions(.{});
|
const target = b.standardTargetOptions(.{});
|
||||||
const optimize = b.standardOptimizeOption(.{});
|
const optimize = b.standardOptimizeOption(.{});
|
||||||
|
|
||||||
@ -13,18 +13,16 @@ pub fn build(b: *std.Build) void {
|
|||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
module.addIncludePath(wuffs.path("release/c"));
|
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||||
module.addCSourceFile(
|
defer flags.deinit();
|
||||||
.{
|
try flags.append("-DWUFFS_IMPLEMENTATION");
|
||||||
.file = wuffs.path("release/c/wuffs-v0.4.c"),
|
inline for (@import("src/c.zig").defines) |key| {
|
||||||
.flags = f: {
|
try flags.append("-D" ++ key);
|
||||||
const flags = @import("src/defs.zig").build;
|
|
||||||
var a: [flags.len][]const u8 = undefined;
|
|
||||||
inline for (flags, 0..) |flag, i| {
|
|
||||||
a[i] = "-D" ++ flag ++ "=1";
|
|
||||||
}
|
}
|
||||||
break :f &a;
|
|
||||||
},
|
module.addIncludePath(wuffs.path("release/c"));
|
||||||
},
|
module.addCSourceFile(.{
|
||||||
);
|
.file = wuffs.path("release/c/wuffs-v0.4.c"),
|
||||||
|
.flags = flags.items,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
pub const c = @cImport({
|
pub const c = @cImport({
|
||||||
for (@import("defs.zig").cimport) |d| {
|
for (defines) |d| @cDefine(d, "1");
|
||||||
@cDefine(d, "1");
|
|
||||||
}
|
|
||||||
@cInclude("wuffs-v0.4.c");
|
@cInclude("wuffs-v0.4.c");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// All the C macros defined so that the header matches the build.
|
||||||
|
pub const defines: []const []const u8 = &[_][]const u8{
|
||||||
|
"WUFFS_CONFIG__MODULES",
|
||||||
|
"WUFFS_CONFIG__MODULE__AUX__BASE",
|
||||||
|
"WUFFS_CONFIG__MODULE__AUX__IMAGE",
|
||||||
|
"WUFFS_CONFIG__MODULE__BASE",
|
||||||
|
"WUFFS_CONFIG__MODULE__ADLER32",
|
||||||
|
"WUFFS_CONFIG__MODULE__CRC32",
|
||||||
|
"WUFFS_CONFIG__MODULE__DEFLATE",
|
||||||
|
"WUFFS_CONFIG__MODULE__JPEG",
|
||||||
|
"WUFFS_CONFIG__MODULE__PNG",
|
||||||
|
"WUFFS_CONFIG__MODULE__ZLIB",
|
||||||
|
};
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
//! Define all of the C macros that WUFFS uses to configure itself here so
|
|
||||||
//! that the settings used to import the C "header" file stay in sync with the
|
|
||||||
//! settings used build the C "source" file.
|
|
||||||
|
|
||||||
pub const cimport = [_][]const u8{
|
|
||||||
"WUFFS_CONFIG__MODULES",
|
|
||||||
"WUFFS_CONFIG__MODULE__AUX__BASE",
|
|
||||||
"WUFFS_CONFIG__MODULE__AUX__IMAGE",
|
|
||||||
"WUFFS_CONFIG__MODULE__BASE",
|
|
||||||
"WUFFS_CONFIG__MODULE__ADLER32",
|
|
||||||
"WUFFS_CONFIG__MODULE__CRC32",
|
|
||||||
"WUFFS_CONFIG__MODULE__DEFLATE",
|
|
||||||
"WUFFS_CONFIG__MODULE__JPEG",
|
|
||||||
"WUFFS_CONFIG__MODULE__PNG",
|
|
||||||
"WUFFS_CONFIG__MODULE__ZLIB",
|
|
||||||
};
|
|
||||||
|
|
||||||
// The only difference should be that the "build" defines WUFFS_IMPLEMENTATION
|
|
||||||
pub const build = [_][]const u8{
|
|
||||||
"WUFFS_IMPLEMENTATION",
|
|
||||||
} ++ cimport;
|
|
Reference in New Issue
Block a user