@@ -10,6 +10,14 @@ pub struct Build {
1010 max_stack_size : Option < usize > ,
1111 // Use longjmp instead of C++ exceptions
1212 use_longjmp : Option < bool > ,
13+ // Disable bytecode loading
14+ disable_bytecode : Option < bool > ,
15+ // Disable filesystem access
16+ disable_fs : Option < bool > ,
17+ // Disable os.os.execute and io.popen
18+ disable_os_exec : Option < bool > ,
19+ // Disable loading any C modules or shared libraries
20+ disable_binaries : Option < bool > ,
1321}
1422
1523pub struct Artifacts {
@@ -27,6 +35,10 @@ impl Build {
2735 host : env:: var ( "HOST" ) . ok ( ) ,
2836 max_stack_size : None ,
2937 use_longjmp : None ,
38+ disable_bytecode : None ,
39+ disable_fs : None ,
40+ disable_os_exec : None ,
41+ disable_binaries : None ,
3042 }
3143 }
3244
@@ -55,6 +67,30 @@ impl Build {
5567 self
5668 }
5769
70+ // Controls `PLUTO_DISABLE_COMPILED` define
71+ pub fn disable_bytecode ( & mut self , disable : bool ) -> & mut Build {
72+ self . disable_bytecode = Some ( disable) ;
73+ self
74+ }
75+
76+ // Controls `PLUTO_NO_FILESYSTEM` define
77+ pub fn disable_fs ( & mut self , disable : bool ) -> & mut Build {
78+ self . disable_fs = Some ( disable) ;
79+ self
80+ }
81+
82+ // Controls `PLUTO_NO_OS_EXECUTE` define
83+ pub fn disable_os_exec ( & mut self , disable : bool ) -> & mut Build {
84+ self . disable_os_exec = Some ( disable) ;
85+ self
86+ }
87+
88+ // Controls `PLUTO_NO_BINARIES` define
89+ pub fn disable_binaries ( & mut self , disable : bool ) -> & mut Build {
90+ self . disable_binaries = Some ( disable) ;
91+ self
92+ }
93+
5894 pub fn build ( & mut self ) -> Artifacts {
5995 let target = & self . target . as_ref ( ) . expect ( "TARGET not set" ) [ ..] ;
6096 let host = & self . host . as_ref ( ) . expect ( "HOST not set" ) [ ..] ;
@@ -81,14 +117,6 @@ impl Build {
81117 . flag_if_supported ( "-Wno-multichar" )
82118 . cpp ( true ) ;
83119
84- if let Some ( max_stack_size) = self . max_stack_size {
85- config. define ( "LUAI_MAXSTACK" , & * max_stack_size. to_string ( ) ) ;
86- }
87-
88- if let Some ( true ) = self . use_longjmp {
89- config. define ( "LUA_USE_LONGJMP" , "1" ) ;
90- }
91-
92120 if cfg ! ( debug_assertions) {
93121 config. define ( "LUA_USE_APICHECK" , None ) ;
94122 } else {
@@ -124,6 +152,30 @@ impl Build {
124152 }
125153 soup_config. out_dir ( out_dir) . compile ( soup_lib_name) ;
126154
155+ if let Some ( max_stack_size) = self . max_stack_size {
156+ config. define ( "LUAI_MAXSTACK" , & * max_stack_size. to_string ( ) ) ;
157+ }
158+
159+ if let Some ( true ) = self . use_longjmp {
160+ config. define ( "LUA_USE_LONGJMP" , None ) ;
161+ }
162+
163+ if let Some ( true ) = self . disable_bytecode {
164+ config. define ( "PLUTO_DISABLE_COMPILED" , None ) ;
165+ }
166+
167+ if let Some ( true ) = self . disable_fs {
168+ config. define ( "PLUTO_NO_FILESYSTEM" , None ) ;
169+ }
170+
171+ if let Some ( true ) = self . disable_os_exec {
172+ config. define ( "PLUTO_NO_OS_EXECUTE" , None ) ;
173+ }
174+
175+ if let Some ( true ) = self . disable_binaries {
176+ config. define ( "PLUTO_NO_BINARIES" , None ) ;
177+ }
178+
127179 // Build Pluto
128180 let pluto_lib_name = "pluto" ;
129181 config
0 commit comments