build-system: Replace deprecated usages of addStaticLibrary with addLibrary (#8029)

Hi there, this is just a low-hanging fruit and it also prepares the way
for the future 0.15, which removes addStaticLibrary.
Please, let me know what to do on the `// TODO` comments.
This commit is contained in:
Jayson Reis
2025-07-22 23:47:18 +02:00
committed by GitHub
parent c903754b70
commit acc2ea724f
19 changed files with 110 additions and 55 deletions

View File

@ -4,10 +4,13 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "breakpad", .name = "breakpad",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibCpp(); lib.linkLibCpp();
lib.addIncludePath(b.path("vendor")); lib.addIncludePath(b.path("vendor"));

View File

@ -12,10 +12,13 @@ pub fn build(b: *std.Build) !void {
}); });
const imgui = b.dependency("imgui", .{}); const imgui = b.dependency("imgui", .{});
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "cimgui", .name = "cimgui",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
lib.linkLibCpp(); lib.linkLibCpp();

View File

@ -64,10 +64,13 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
const libxml2_iconv_enabled = options.libxml2_iconv_enabled; const libxml2_iconv_enabled = options.libxml2_iconv_enabled;
const freetype_enabled = options.freetype_enabled; const freetype_enabled = options.freetype_enabled;
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "fontconfig", .name = "fontconfig",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
if (target.result.os.tag != .windows) { if (target.result.os.tag != .windows) {

View File

@ -61,10 +61,13 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
const libpng_enabled = options.libpng_enabled; const libpng_enabled = options.libpng_enabled;
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "freetype", .name = "freetype",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
if (target.result.os.tag.isDarwin()) { if (target.result.os.tag.isDarwin()) {

View File

@ -40,10 +40,13 @@ fn buildGlslang(
target: std.Build.ResolvedTarget, 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.addLibrary(.{
.name = "glslang", .name = "glslang",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
lib.linkLibCpp(); lib.linkLibCpp();

View File

@ -92,10 +92,13 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
.@"enable-libpng" = true, .@"enable-libpng" = true,
}); });
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "harfbuzz", .name = "harfbuzz",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
lib.linkLibCpp(); lib.linkLibCpp();

View File

@ -12,10 +12,13 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "highway", .name = "highway",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibCpp(); lib.linkLibCpp();
lib.addIncludePath(upstream.path("")); lib.addIncludePath(upstream.path(""));

View File

@ -30,10 +30,13 @@ pub fn build(b: *std.Build) !void {
}); });
{ {
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "intl", .name = "intl",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
lib.addIncludePath(b.path("")); lib.addIncludePath(b.path(""));

View File

@ -4,10 +4,13 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "png", .name = "png",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
if (target.result.os.tag == .linux) { if (target.result.os.tag == .linux) {

View File

@ -6,10 +6,13 @@ pub fn build(b: *std.Build) !void {
const upstream = b.dependency("libxml2", .{}); const upstream = b.dependency("libxml2", .{});
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "xml2", .name = "xml2",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();

View File

@ -12,10 +12,13 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "macos", .name = "macos",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.addCSourceFile(.{ lib.addCSourceFile(.{

View File

@ -57,10 +57,13 @@ fn buildLib(b: *std.Build, module: *std.Build.Module, options: anytype) !*std.Bu
const target = options.target; const target = options.target;
const optimize = options.optimize; const optimize = options.optimize;
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "oniguruma", .name = "oniguruma",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
const t = target.result; const t = target.result;
lib.linkLibC(); lib.linkLibC();

View File

@ -12,10 +12,13 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize, .optimize = optimize,
}); });
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "sentry", .name = "sentry",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
if (target.result.os.tag.isDarwin()) { if (target.result.os.tag.isDarwin()) {

View File

@ -4,10 +4,13 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "simdutf", .name = "simdutf",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibCpp(); lib.linkLibCpp();
lib.addIncludePath(b.path("vendor")); lib.addIncludePath(b.path("vendor"));

View File

@ -35,10 +35,13 @@ fn buildSpirvCross(
target: std.Build.ResolvedTarget, 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.addLibrary(.{
.name = "spirv_cross", .name = "spirv_cross",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
lib.linkLibCpp(); lib.linkLibCpp();

View File

@ -7,10 +7,13 @@ pub fn build(b: *std.Build) !void {
const module = b.addModule("utf8proc", .{ .root_source_file = .{ .path = "main.zig" } }); const module = b.addModule("utf8proc", .{ .root_source_file = .{ .path = "main.zig" } });
const upstream = b.dependency("utf8proc", .{}); const upstream = b.dependency("utf8proc", .{});
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "utf8proc", .name = "utf8proc",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();

View File

@ -4,10 +4,13 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "utfcpp", .name = "utfcpp",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibCpp(); lib.linkLibCpp();

View File

@ -4,10 +4,13 @@ pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "z", .name = "z",
.target = target, .root_module = b.createModule(.{
.optimize = optimize, .target = target,
.optimize = optimize,
}),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();
if (target.result.os.tag.isDarwin()) { if (target.result.os.tag.isDarwin()) {

View File

@ -18,7 +18,7 @@ pub fn initStatic(
b: *std.Build, b: *std.Build,
deps: *const SharedDeps, deps: *const SharedDeps,
) !GhosttyLib { ) !GhosttyLib {
const lib = b.addStaticLibrary(.{ const lib = b.addLibrary(.{
.name = "ghostty", .name = "ghostty",
.root_module = b.createModule(.{ .root_module = b.createModule(.{
.root_source_file = b.path("src/main_c.zig"), .root_source_file = b.path("src/main_c.zig"),
@ -28,6 +28,7 @@ pub fn initStatic(
.omit_frame_pointer = deps.config.strip, .omit_frame_pointer = deps.config.strip,
.unwind_tables = if (deps.config.strip) .none else .sync, .unwind_tables = if (deps.config.strip) .none else .sync,
}), }),
.linkage = .static,
}); });
lib.linkLibC(); lib.linkLibC();