Commit 6d4e2a9171
Changed files (1)
test
src
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.