| ... | @@ -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 | } |
| 662 | | 662 | |
| 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 | }; |
| 688 | | 693 | |
| 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; |
| 692 | | 695 | |
| 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 | } |
| 703 | | 706 | |
| 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. |