test-cases: migrate from deprecated std.Build APIs

This commit is contained in:
mlugg 2024-12-16 15:18:07 +00:00 committed by Eric Joldasov
parent b8472db215
commit 6d4e2a9171
No known key found for this signature in database
GPG Key ID: 5C9C69060686B588

View File

@ -660,34 +660,37 @@ pub fn lowerToBuildSteps(
file_sources.put(file.path, writefiles.add(file.path, file.src)) catch @panic("OOM");
}
const artifact = if (case.is_test) b.addTest(.{
const mod = b.createModule(.{
.root_source_file = root_source_file,
.name = case.name,
.target = case.target,
.optimize = case.optimize_mode,
});
if (case.link_libc) mod.link_libc = true;
if (case.pic) |pic| mod.pic = pic;
for (case.deps.items) |dep| {
mod.addAnonymousImport(dep.name, .{
.root_source_file = file_sources.get(dep.path).?,
});
}
const artifact = if (case.is_test) b.addTest(.{
.name = case.name,
.root_module = mod,
}) else switch (case.output_mode) {
.Obj => b.addObject(.{
.root_source_file = root_source_file,
.name = case.name,
.target = case.target,
.optimize = case.optimize_mode,
.root_module = mod,
}),
.Lib => b.addStaticLibrary(.{
.root_source_file = root_source_file,
.name = case.name,
.target = case.target,
.optimize = case.optimize_mode,
.root_module = mod,
}),
.Exe => b.addExecutable(.{
.root_source_file = root_source_file,
.name = case.name,
.target = case.target,
.optimize = case.optimize_mode,
.root_module = mod,
}),
};
if (case.link_libc) artifact.linkLibC();
if (case.pic) |pic| artifact.root_module.pic = pic;
if (case.pie) |pie| artifact.pie = pie;
switch (case.backend) {
@ -701,12 +704,6 @@ pub fn lowerToBuildSteps(
},
}
for (case.deps.items) |dep| {
artifact.root_module.addAnonymousImport(dep.name, .{
.root_source_file = file_sources.get(dep.path).?,
});
}
switch (update.case) {
.Compile => {
// Force the binary to be emitted if requested.