@@ -29,36 +29,7 @@ pub const Builder = Build;
29
29
pub const InstallDirectoryOptions = Step .InstallDir .Options ;
30
30
31
31
pub const Step = @import ("Build/Step.zig" );
32
- /// deprecated: use `Step.CheckFile`.
33
- pub const CheckFileStep = @import ("Build/Step/CheckFile.zig" );
34
- /// deprecated: use `Step.CheckObject`.
35
- pub const CheckObjectStep = @import ("Build/Step/CheckObject.zig" );
36
- /// deprecated: use `Step.ConfigHeader`.
37
- pub const ConfigHeaderStep = @import ("Build/Step/ConfigHeader.zig" );
38
- /// deprecated: use `Step.Fmt`.
39
- pub const FmtStep = @import ("Build/Step/Fmt.zig" );
40
- /// deprecated: use `Step.InstallArtifact`.
41
- pub const InstallArtifactStep = @import ("Build/Step/InstallArtifact.zig" );
42
- /// deprecated: use `Step.InstallDir`.
43
- pub const InstallDirStep = @import ("Build/Step/InstallDir.zig" );
44
- /// deprecated: use `Step.InstallFile`.
45
- pub const InstallFileStep = @import ("Build/Step/InstallFile.zig" );
46
- /// deprecated: use `Step.ObjCopy`.
47
- pub const ObjCopyStep = @import ("Build/Step/ObjCopy.zig" );
48
- /// deprecated: use `Step.Compile`.
49
- pub const CompileStep = @import ("Build/Step/Compile.zig" );
50
- /// deprecated: use `Step.Options`.
51
- pub const OptionsStep = @import ("Build/Step/Options.zig" );
52
- /// deprecated: use `Step.RemoveDir`.
53
- pub const RemoveDirStep = @import ("Build/Step/RemoveDir.zig" );
54
- /// deprecated: use `Step.Run`.
55
- pub const RunStep = @import ("Build/Step/Run.zig" );
56
- /// deprecated: use `Step.TranslateC`.
57
- pub const TranslateCStep = @import ("Build/Step/TranslateC.zig" );
58
- /// deprecated: use `Step.WriteFile`.
59
- pub const WriteFileStep = @import ("Build/Step/WriteFile.zig" );
60
- /// deprecated: use `LazyPath`.
61
- pub const FileSource = LazyPath ;
32
+ pub const Module = @import ("Build/Module.zig" );
62
33
63
34
install_tls : TopLevelStep ,
64
35
uninstall_tls : TopLevelStep ,
@@ -634,34 +605,31 @@ pub const ExecutableOptions = struct {
634
605
use_llvm : ? bool = null ,
635
606
use_lld : ? bool = null ,
636
607
zig_lib_dir : ? LazyPath = null ,
637
- main_mod_path : ? LazyPath = null ,
638
608
/// Embed a `.manifest` file in the compilation if the object format supports it.
639
609
/// https://learn.microsoft.com/en-us/windows/win32/sbscs/manifest-files-reference
640
610
/// Manifest files must have the extension `.manifest`.
641
611
/// Can be set regardless of target. The `.manifest` file will be ignored
642
612
/// if the target object format does not support embedded manifests.
643
613
win32_manifest : ? LazyPath = null ,
644
-
645
- /// Deprecated; use `main_mod_path`.
646
- main_pkg_path : ? LazyPath = null ,
647
614
};
648
615
649
616
pub fn addExecutable (b : * Build , options : ExecutableOptions ) * Step.Compile {
650
617
return Step .Compile .create (b , .{
651
618
.name = options .name ,
652
- .root_source_file = options .root_source_file ,
619
+ .root_module = .{
620
+ .root_source_file = options .root_source_file ,
621
+ .target = options .target ,
622
+ .optimize = options .optimize ,
623
+ .link_libc = options .link_libc ,
624
+ .single_threaded = options .single_threaded ,
625
+ },
653
626
.version = options .version ,
654
- .target = options .target ,
655
- .optimize = options .optimize ,
656
627
.kind = .exe ,
657
628
.linkage = options .linkage ,
658
629
.max_rss = options .max_rss ,
659
- .link_libc = options .link_libc ,
660
- .single_threaded = options .single_threaded ,
661
630
.use_llvm = options .use_llvm ,
662
631
.use_lld = options .use_lld ,
663
632
.zig_lib_dir = options .zig_lib_dir orelse b .zig_lib_dir ,
664
- .main_mod_path = options .main_mod_path orelse options .main_pkg_path ,
665
633
.win32_manifest = options .win32_manifest ,
666
634
});
667
635
}
@@ -677,26 +645,23 @@ pub const ObjectOptions = struct {
677
645
use_llvm : ? bool = null ,
678
646
use_lld : ? bool = null ,
679
647
zig_lib_dir : ? LazyPath = null ,
680
- main_mod_path : ? LazyPath = null ,
681
-
682
- /// Deprecated; use `main_mod_path`.
683
- main_pkg_path : ? LazyPath = null ,
684
648
};
685
649
686
650
pub fn addObject (b : * Build , options : ObjectOptions ) * Step.Compile {
687
651
return Step .Compile .create (b , .{
688
652
.name = options .name ,
689
- .root_source_file = options .root_source_file ,
690
- .target = options .target ,
691
- .optimize = options .optimize ,
653
+ .root_module = .{
654
+ .root_source_file = options .root_source_file ,
655
+ .target = options .target ,
656
+ .optimize = options .optimize ,
657
+ .link_libc = options .link_libc ,
658
+ .single_threaded = options .single_threaded ,
659
+ },
692
660
.kind = .obj ,
693
661
.max_rss = options .max_rss ,
694
- .link_libc = options .link_libc ,
695
- .single_threaded = options .single_threaded ,
696
662
.use_llvm = options .use_llvm ,
697
663
.use_lld = options .use_lld ,
698
664
.zig_lib_dir = options .zig_lib_dir orelse b .zig_lib_dir ,
699
- .main_mod_path = options .main_mod_path orelse options .main_pkg_path ,
700
665
});
701
666
}
702
667
@@ -712,34 +677,31 @@ pub const SharedLibraryOptions = struct {
712
677
use_llvm : ? bool = null ,
713
678
use_lld : ? bool = null ,
714
679
zig_lib_dir : ? LazyPath = null ,
715
- main_mod_path : ? LazyPath = null ,
716
680
/// Embed a `.manifest` file in the compilation if the object format supports it.
717
681
/// https://learn.microsoft.com/en-us/windows/win32/sbscs/manifest-files-reference
718
682
/// Manifest files must have the extension `.manifest`.
719
683
/// Can be set regardless of target. The `.manifest` file will be ignored
720
684
/// if the target object format does not support embedded manifests.
721
685
win32_manifest : ? LazyPath = null ,
722
-
723
- /// Deprecated; use `main_mod_path`.
724
- main_pkg_path : ? LazyPath = null ,
725
686
};
726
687
727
688
pub fn addSharedLibrary (b : * Build , options : SharedLibraryOptions ) * Step.Compile {
728
689
return Step .Compile .create (b , .{
729
690
.name = options .name ,
730
- .root_source_file = options .root_source_file ,
691
+ .root_module = .{
692
+ .target = options .target ,
693
+ .optimize = options .optimize ,
694
+ .root_source_file = options .root_source_file ,
695
+ .link_libc = options .link_libc ,
696
+ .single_threaded = options .single_threaded ,
697
+ },
731
698
.kind = .lib ,
732
699
.linkage = .dynamic ,
733
700
.version = options .version ,
734
- .target = options .target ,
735
- .optimize = options .optimize ,
736
701
.max_rss = options .max_rss ,
737
- .link_libc = options .link_libc ,
738
- .single_threaded = options .single_threaded ,
739
702
.use_llvm = options .use_llvm ,
740
703
.use_lld = options .use_lld ,
741
704
.zig_lib_dir = options .zig_lib_dir orelse b .zig_lib_dir ,
742
- .main_mod_path = options .main_mod_path orelse options .main_pkg_path ,
743
705
.win32_manifest = options .win32_manifest ,
744
706
});
745
707
}
@@ -756,28 +718,25 @@ pub const StaticLibraryOptions = struct {
756
718
use_llvm : ? bool = null ,
757
719
use_lld : ? bool = null ,
758
720
zig_lib_dir : ? LazyPath = null ,
759
- main_mod_path : ? LazyPath = null ,
760
-
761
- /// Deprecated; use `main_mod_path`.
762
- main_pkg_path : ? LazyPath = null ,
763
721
};
764
722
765
723
pub fn addStaticLibrary (b : * Build , options : StaticLibraryOptions ) * Step.Compile {
766
724
return Step .Compile .create (b , .{
767
725
.name = options .name ,
768
- .root_source_file = options .root_source_file ,
726
+ .root_module = .{
727
+ .target = options .target ,
728
+ .optimize = options .optimize ,
729
+ .root_source_file = options .root_source_file ,
730
+ .link_libc = options .link_libc ,
731
+ .single_threaded = options .single_threaded ,
732
+ },
769
733
.kind = .lib ,
770
734
.linkage = .static ,
771
735
.version = options .version ,
772
- .target = options .target ,
773
- .optimize = options .optimize ,
774
736
.max_rss = options .max_rss ,
775
- .link_libc = options .link_libc ,
776
- .single_threaded = options .single_threaded ,
777
737
.use_llvm = options .use_llvm ,
778
738
.use_lld = options .use_lld ,
779
739
.zig_lib_dir = options .zig_lib_dir orelse b .zig_lib_dir ,
780
- .main_mod_path = options .main_mod_path orelse options .main_pkg_path ,
781
740
});
782
741
}
783
742
@@ -795,28 +754,25 @@ pub const TestOptions = struct {
795
754
use_llvm : ? bool = null ,
796
755
use_lld : ? bool = null ,
797
756
zig_lib_dir : ? LazyPath = null ,
798
- main_mod_path : ? LazyPath = null ,
799
-
800
- /// Deprecated; use `main_mod_path`.
801
- main_pkg_path : ? LazyPath = null ,
802
757
};
803
758
804
759
pub fn addTest (b : * Build , options : TestOptions ) * Step.Compile {
805
760
return Step .Compile .create (b , .{
806
761
.name = options .name ,
807
762
.kind = .@"test" ,
808
- .root_source_file = options .root_source_file ,
809
- .target = options .target ,
810
- .optimize = options .optimize ,
763
+ .root_module = .{
764
+ .root_source_file = options .root_source_file ,
765
+ .target = options .target ,
766
+ .optimize = options .optimize ,
767
+ .link_libc = options .link_libc ,
768
+ .single_threaded = options .single_threaded ,
769
+ },
811
770
.max_rss = options .max_rss ,
812
771
.filter = options .filter ,
813
772
.test_runner = options .test_runner ,
814
- .link_libc = options .link_libc ,
815
- .single_threaded = options .single_threaded ,
816
773
.use_llvm = options .use_llvm ,
817
774
.use_lld = options .use_lld ,
818
775
.zig_lib_dir = options .zig_lib_dir orelse b .zig_lib_dir ,
819
- .main_mod_path = options .main_mod_path orelse options .main_pkg_path ,
820
776
});
821
777
}
822
778
@@ -833,9 +789,10 @@ pub fn addAssembly(b: *Build, options: AssemblyOptions) *Step.Compile {
833
789
const obj_step = Step .Compile .create (b , .{
834
790
.name = options .name ,
835
791
.kind = .obj ,
836
- .root_source_file = null ,
837
- .target = options .target ,
838
- .optimize = options .optimize ,
792
+ .root_module = .{
793
+ .target = options .target ,
794
+ .optimize = options .optimize ,
795
+ },
839
796
.max_rss = options .max_rss ,
840
797
.zig_lib_dir = options .zig_lib_dir orelse b .zig_lib_dir ,
841
798
});
@@ -846,41 +803,17 @@ pub fn addAssembly(b: *Build, options: AssemblyOptions) *Step.Compile {
846
803
/// This function creates a module and adds it to the package's module set, making
847
804
/// it available to other packages which depend on this one.
848
805
/// `createModule` can be used instead to create a private module.
849
- pub fn addModule (b : * Build , name : []const u8 , options : CreateModuleOptions ) * Module {
850
- const module = b . createModule ( options );
806
+ pub fn addModule (b : * Build , name : []const u8 , options : Module.CreateOptions ) * Module {
807
+ const module = Module . create ( b , options );
851
808
b .modules .put (b .dupe (name ), module ) catch @panic ("OOM" );
852
809
return module ;
853
810
}
854
811
855
- pub const ModuleDependency = struct {
856
- name : []const u8 ,
857
- module : * Module ,
858
- };
859
-
860
- pub const CreateModuleOptions = struct {
861
- source_file : LazyPath ,
862
- dependencies : []const ModuleDependency = &.{},
863
- };
864
-
865
812
/// This function creates a private module, to be used by the current package,
866
813
/// but not exposed to other packages depending on this one.
867
814
/// `addModule` can be used instead to create a public module.
868
- pub fn createModule (b : * Build , options : CreateModuleOptions ) * Module {
869
- const module = b .allocator .create (Module ) catch @panic ("OOM" );
870
- module .* = .{
871
- .builder = b ,
872
- .source_file = options .source_file .dupe (b ),
873
- .dependencies = moduleDependenciesToArrayHashMap (b .allocator , options .dependencies ),
874
- };
875
- return module ;
876
- }
877
-
878
- fn moduleDependenciesToArrayHashMap (arena : Allocator , deps : []const ModuleDependency ) std.StringArrayHashMap (* Module ) {
879
- var result = std .StringArrayHashMap (* Module ).init (arena );
880
- for (deps ) | dep | {
881
- result .put (dep .name , dep .module ) catch @panic ("OOM" );
882
- }
883
- return result ;
815
+ pub fn createModule (b : * Build , options : Module.CreateOptions ) * Module {
816
+ return Module .create (b , options );
884
817
}
885
818
886
819
/// Initializes a `Step.Run` with argv, which must at least have the path to the
@@ -1885,15 +1818,6 @@ pub fn runBuild(b: *Build, build_zig: anytype) anyerror!void {
1885
1818
}
1886
1819
}
1887
1820
1888
- pub const Module = struct {
1889
- builder : * Build ,
1890
- /// This could either be a generated file, in which case the module
1891
- /// contains exactly one file, or it could be a path to the root source
1892
- /// file of directory of files which constitute the module.
1893
- source_file : LazyPath ,
1894
- dependencies : std .StringArrayHashMap (* Module ),
1895
- };
1896
-
1897
1821
/// A file that is generated by a build step.
1898
1822
/// This struct is an interface that is meant to be used with `@fieldParentPtr` to implement the actual path logic.
1899
1823
pub const GeneratedFile = struct {
0 commit comments