Merge pull request #1305 from der-teufel-programming/better-build

Make addDeps cleaner, use addCSourceFiles instead of addCSourceFile in a loop
This commit is contained in:
Mitchell Hashimoto
2024-01-15 14:30:37 -08:00
committed by GitHub
5 changed files with 55 additions and 74 deletions

View File

@ -831,94 +831,78 @@ fn addDeps(
.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);
const target = step.root_module.resolved_target.?;
const optimize = step.root_module.optimize.?;
// Dependencies
const cimgui_dep = b.dependency("cimgui", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const js_dep = b.dependency("zig_js", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const libxev_dep = b.dependency("libxev", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const objc_dep = b.dependency("zig_objc", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const fontconfig_dep = b.dependency("fontconfig", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const freetype_dep = b.dependency("freetype", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
.@"enable-libpng" = true,
});
const glslang_dep = b.dependency("glslang", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const spirv_cross_dep = b.dependency("spirv_cross", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const mach_glfw_dep = b.dependency("mach_glfw", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const libpng_dep = b.dependency("libpng", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const macos_dep = b.dependency("macos", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const oniguruma_dep = b.dependency("oniguruma", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const opengl_dep = b.dependency("opengl", .{});
const pixman_dep = b.dependency("pixman", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const zlib_dep = b.dependency("zlib", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
const harfbuzz_dep = b.dependency("harfbuzz", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
.@"enable-freetype" = true,
.@"enable-coretext" = config.font_backend.hasCoretext(),
});
const ziglyph_dep = b.dependency("ziglyph", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
.target = target,
.optimize = optimize,
});
// Wasm we do manually since it is such a different build.

View File

@ -156,12 +156,11 @@ pub fn build(b: *std.Build) !void {
}
}
for (srcs) |src| {
lib.addCSourceFile(.{
.file = upstream.path(src),
lib.addCSourceFiles(.{
.dependency = upstream,
.files = srcs,
.flags = flags.items,
});
}
lib.installHeadersDirectoryOptions(.{
.source_dir = upstream.path("fontconfig"),

View File

@ -33,12 +33,12 @@ pub fn build(b: *std.Build) !void {
"-DPNG_INTEL_SSE_OPT=0",
"-DPNG_MIPS_MSA_OPT=0",
});
for (srcs) |src| {
lib.addCSourceFile(.{
.file = upstream.path(src),
lib.addCSourceFiles(.{
.dependency = upstream,
.files = srcs,
.flags = flags.items,
});
}
lib.installHeader("pnglibconf.h", "pnglibconf.h");
lib.installHeadersDirectoryOptions(.{

View File

@ -94,12 +94,11 @@ pub fn build(b: *std.Build) !void {
}
}
inline for (srcs) |src| {
lib.addCSourceFile(.{
.file = upstream.path(src),
lib.addCSourceFiles(.{
.dependency = upstream,
.files = srcs,
.flags = flags.items,
});
}
lib.installHeader("override/include/libxml/xmlversion.h", "libxml/xmlversion.h");
lib.installHeadersDirectoryOptions(.{

View File

@ -33,12 +33,11 @@ pub fn build(b: *std.Build) !void {
"-DHAVE_STDDEF_H",
"-DZ_HAVE_UNISTD_H",
});
for (srcs) |src| {
lib.addCSourceFile(.{
.file = upstream.path(src),
lib.addCSourceFiles(.{
.dependency = upstream,
.files = srcs,
.flags = flags.items,
});
}
b.installArtifact(lib);
}