@@ -2,6 +2,7 @@ use std::env;
22use std:: fs;
33use std:: path:: { Path , PathBuf } ;
44
5+ /// Represents the configuration for building Luau artifacts.
56pub struct Build {
67 out_dir : Option < PathBuf > ,
78 target : Option < String > ,
@@ -16,6 +17,7 @@ pub struct Build {
1617 vector_size : usize ,
1718}
1819
20+ /// Represents the artifacts produced by the build process.
1921pub struct Artifacts {
2022 lib_dir : PathBuf ,
2123 libs : Vec < String > ,
@@ -37,48 +39,69 @@ impl Default for Build {
3739}
3840
3941impl Build {
42+ /// Creates a new `Build` instance with default settings.
4043 pub fn new ( ) -> Build {
4144 Build :: default ( )
4245 }
4346
47+ /// Sets the output directory for the build artifacts.
48+ ///
49+ /// Default is the environment variable `OUT_DIR`.
4450 pub fn out_dir < P : AsRef < Path > > ( & mut self , path : P ) -> & mut Build {
4551 self . out_dir = Some ( path. as_ref ( ) . to_path_buf ( ) ) ;
4652 self
4753 }
4854
49- #[ doc( hidden) ]
55+ /// Sets the target architecture for the build.
56+ ///
57+ /// Default is the environment variable `TARGET`.
5058 pub fn target ( & mut self , target : & str ) -> & mut Build {
5159 self . target = Some ( target. to_string ( ) ) ;
5260 self
5361 }
5462
55- #[ doc( hidden) ]
63+ /// Sets the host architecture for the build.
64+ ///
65+ /// Default is the environment variable `HOST`.
5666 pub fn host ( & mut self , host : & str ) -> & mut Build {
5767 self . host = Some ( host. to_string ( ) ) ;
5868 self
5969 }
6070
71+ /// Sets the maximum number of Lua stack slots that a C function can use.
72+ ///
73+ /// Default is 1,000,000.
6174 pub fn set_max_cstack_size ( & mut self , size : usize ) -> & mut Build {
6275 self . max_cstack_size = size;
6376 self
6477 }
6578
79+ /// Sets whether to use longjmp instead of C++ exceptions.
80+ ///
81+ /// Default is false.
6682 pub fn use_longjmp ( & mut self , r#use : bool ) -> & mut Build {
6783 self . use_longjmp = r#use;
6884 self
6985 }
7086
87+ /// Sets whether to enable the code generator (JIT).
88+ ///
89+ /// Default is false.
7190 pub fn enable_codegen ( & mut self , enable : bool ) -> & mut Build {
7291 self . enable_codegen = enable;
7392 self
7493 }
7594
95+ /// Sets the vector size (3 or 4).
96+ ///
97+ /// Default is 3.
7698 pub fn set_vector_size ( & mut self , size : usize ) -> & mut Build {
7799 assert ! ( size == 3 || size == 4 , "vector size must be 3 or 4" ) ;
78100 self . vector_size = size;
79101 self
80102 }
81103
104+ /// Builds the Lua artifacts for the specified version.
82105 pub fn build ( & mut self ) -> Artifacts {
83106 let target = & self . target . as_ref ( ) . expect ( "TARGET is not set" ) [ ..] ;
84107 let host = & self . host . as_ref ( ) . expect ( "HOST is not set" ) [ ..] ;
0 commit comments