commit 6d4e2a9171a2616f6a744f8f842fb4042b868fc8 (tree)
parent b8472db215a892754b7e834ce44b2d7f254ff60d
Author: mlugg <mlugg@mlugg.co.uk>
Date: Mon, 16 Dec 2024 15:18:07 +0000
test-cases: migrate from deprecated std.Build APIs
Diffstat:
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/test/src/Cases.zig b/test/src/Cases.zig
@@ -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.