authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-12-16 15:18:07+00:00
committergravatar for bratishkaerik@landless-city.netEric Joldasov <bratishkaerik@landless-city.net> 2024-12-18 01:49:00+05:00
log6d4e2a9171a2616f6a744f8f842fb4042b868fc8
tree30fba794c92bed2f7cd50fe7ff7dd4520538da42
parentb8472db215a892754b7e834ce44b2d7f254ff60d
signaturelock-open Commit is signed but in an unrecognized format.

test-cases: migrate from deprecated std.Build APIs


1 files changed, 16 insertions(+), 19 deletions(-)

test/src/Cases.zig+16-19
...@@ -660,34 +660,37 @@ pub fn lowerToBuildSteps(...@@ -660,34 +660,37 @@ pub fn lowerToBuildSteps(
660 file_sources.put(file.path, writefiles.add(file.path, file.src)) catch @panic("OOM");660 file_sources.put(file.path, writefiles.add(file.path, file.src)) catch @panic("OOM");
661 }661 }
662662
663 const artifact = if (case.is_test) b.addTest(.{663 const mod = b.createModule(.{
664 .root_source_file = root_source_file,664 .root_source_file = root_source_file,
665 .name = case.name,
666 .target = case.target,665 .target = case.target,
667 .optimize = case.optimize_mode,666 .optimize = case.optimize_mode,
667 });
668 if (case.link_libc) mod.link_libc = true;
669 if (case.pic) |pic| mod.pic = pic;
670 for (case.deps.items) |dep| {
671 mod.addAnonymousImport(dep.name, .{
672 .root_source_file = file_sources.get(dep.path).?,
673 });
674 }
675
676 const artifact = if (case.is_test) b.addTest(.{
677 .name = case.name,
678 .root_module = mod,
668 }) else switch (case.output_mode) {679 }) else switch (case.output_mode) {
669 .Obj => b.addObject(.{680 .Obj => b.addObject(.{
670 .root_source_file = root_source_file,
671 .name = case.name,681 .name = case.name,
672 .target = case.target,682 .root_module = mod,
673 .optimize = case.optimize_mode,
674 }),683 }),
675 .Lib => b.addStaticLibrary(.{684 .Lib => b.addStaticLibrary(.{
676 .root_source_file = root_source_file,
677 .name = case.name,685 .name = case.name,
678 .target = case.target,686 .root_module = mod,
679 .optimize = case.optimize_mode,
680 }),687 }),
681 .Exe => b.addExecutable(.{688 .Exe => b.addExecutable(.{
682 .root_source_file = root_source_file,
683 .name = case.name,689 .name = case.name,
684 .target = case.target,690 .root_module = mod,
685 .optimize = case.optimize_mode,
686 }),691 }),
687 };692 };
688693
689 if (case.link_libc) artifact.linkLibC();
690 if (case.pic) |pic| artifact.root_module.pic = pic;
691 if (case.pie) |pie| artifact.pie = pie;694 if (case.pie) |pie| artifact.pie = pie;
692695
693 switch (case.backend) {696 switch (case.backend) {
...@@ -701,12 +704,6 @@ pub fn lowerToBuildSteps(...@@ -701,12 +704,6 @@ pub fn lowerToBuildSteps(
701 },704 },
702 }705 }
703706
704 for (case.deps.items) |dep| {
705 artifact.root_module.addAnonymousImport(dep.name, .{
706 .root_source_file = file_sources.get(dep.path).?,
707 });
708 }
709
710 switch (update.case) {707 switch (update.case) {
711 .Compile => {708 .Compile => {
712 // Force the binary to be emitted if requested.709 // Force the binary to be emitted if requested.