@@ -194,6 +194,7 @@ impl MoonBitComponent {
194194 name : format ! ( "{moonbit_root_package}/ffi" ) ,
195195 mbt_files : vec ! [ Utf8Path :: new( "ffi" ) . join( "top.mbt" ) ] ,
196196 warning_control : vec ! [ WarningControl :: Disable ( Warning :: Specific ( 44 ) ) ] ,
197+ alert_control : vec ! [ ] ,
197198 output : Utf8Path :: new ( "target" )
198199 . join ( "wasm" )
199200 . join ( "release" )
@@ -226,6 +227,7 @@ impl MoonBitComponent {
226227 . join( "stub.mbt" ) ,
227228 ] ,
228229 warning_control : vec ! [ ] ,
230+ alert_control : vec ! [ ] ,
229231 output : Utf8Path :: new ( "target" )
230232 . join ( "wasm" )
231233 . join ( "release" )
@@ -278,6 +280,7 @@ impl MoonBitComponent {
278280 name : name. clone ( ) ,
279281 mbt_files : vec ! [ src. join( "top.mbt" ) , src. join( "ffi.mbt" ) ] ,
280282 warning_control : vec ! [ ] ,
283+ alert_control : vec ! [ ] ,
281284 output : output. join ( format ! ( "{interface_name}.core" ) ) ,
282285 dependencies : vec ! [ ffi_dep. clone( ) ] ,
283286 package_sources : vec ! [ ( name, src) ] ,
@@ -311,6 +314,7 @@ impl MoonBitComponent {
311314 name : name. clone ( ) ,
312315 mbt_files : vec ! [ src. join( "top.mbt" ) , src. join( "stub.mbt" ) ] ,
313316 warning_control : vec ! [ ] ,
317+ alert_control : vec ! [ ] ,
314318 output : output. join ( format ! ( "{interface_name}.core" ) ) ,
315319
316320 dependencies : vec ! [ ] ,
@@ -330,6 +334,7 @@ impl MoonBitComponent {
330334 name : format ! ( "{moonbit_root_package}/gen" ) ,
331335 mbt_files : gen_mbt_files,
332336 warning_control : vec ! [ ] ,
337+ alert_control : vec ! [ ] ,
333338 output : Utf8Path :: new ( "target" )
334339 . join ( "wasm" )
335340 . join ( "release" )
@@ -359,6 +364,19 @@ impl MoonBitComponent {
359364 Ok ( ( ) )
360365 }
361366
367+ pub fn set_alert_control (
368+ & mut self ,
369+ package_name : & str ,
370+ alert_control : Vec < WarningControl > ,
371+ ) -> anyhow:: Result < ( ) > {
372+ let package = self
373+ . packages
374+ . get_mut ( package_name)
375+ . ok_or_else ( || anyhow:: anyhow!( "Package '{package_name}' not found" ) ) ?;
376+ package. alert_control = alert_control;
377+ Ok ( ( ) )
378+ }
379+
362380 /// Defines a custom MoonBit package
363381 pub fn define_package ( & mut self , package : MoonBitPackage ) {
364382 debug ! ( "Adding MoonBit package: {}" , package. name) ;
@@ -485,6 +503,7 @@ impl MoonBitComponent {
485503 self . build_package (
486504 & package. mbt_files ,
487505 & package. warning_control ,
506+ & package. alert_control ,
488507 & package. output ,
489508 & package. name ,
490509 & package. dependencies ,
@@ -556,13 +575,35 @@ impl MoonBitComponent {
556575 & self ,
557576 mbt_files : & [ Utf8PathBuf ] ,
558577 warning_control : & [ WarningControl ] ,
578+ alert_control : & [ WarningControl ] ,
559579 output : & Utf8Path ,
560580 package : & str ,
561581 dependencies : & [ ( Utf8PathBuf , String ) ] ,
562582 package_sources : & [ ( String , Utf8PathBuf ) ] ,
563583 ) -> anyhow:: Result < ( ) > {
564584 info ! ( "Building MoonBit package: {package}" ) ;
565585
586+ for mbt_file in mbt_files {
587+ let abs = self . dir . join ( mbt_file) ;
588+ if !abs. exists ( ) {
589+ return Err ( anyhow ! ( "MBT file does not exist at {abs}" ) ) ;
590+ }
591+ }
592+ for ( path, name) in dependencies {
593+ let abs = self . dir . join ( path) ;
594+ if !abs. exists ( ) {
595+ return Err ( anyhow ! ( "Dependency {name} does not exist at {abs}" ) ) ;
596+ }
597+ }
598+ for ( source_name, source_path) in package_sources {
599+ let abs = self . dir . join ( source_path) ;
600+ if !abs. exists ( ) {
601+ return Err ( anyhow ! (
602+ "Package source {source_name} does not exist at {abs}"
603+ ) ) ;
604+ }
605+ }
606+
566607 let mut args = vec ! [ "build-package" . to_string( ) ] ;
567608 for file in mbt_files {
568609 let full_path = self . dir . join ( file) ;
@@ -572,6 +613,10 @@ impl MoonBitComponent {
572613 args. push ( "-w" . to_string ( ) ) ;
573614 args. push ( w. to_string ( ) ) ;
574615 }
616+ for a in alert_control {
617+ args. push ( "-alert" . to_string ( ) ) ;
618+ args. push ( a. to_string ( ) ) ;
619+ }
575620 args. push ( "-o" . to_string ( ) ) ;
576621 args. push ( self . dir . join ( output) . to_string ( ) ) ;
577622 args. push ( "-pkg" . to_string ( ) ) ;
@@ -588,6 +633,12 @@ impl MoonBitComponent {
588633 args. push ( "wasm" . to_string ( ) ) ;
589634
590635 MOONC . run ( args) ?;
636+
637+ let abs = self . dir . join ( output) ;
638+ if !abs. exists ( ) {
639+ return Err ( anyhow ! ( "Output does not exist at {abs}" ) ) ;
640+ }
641+
591642 Ok ( ( ) )
592643 }
593644
@@ -894,6 +945,7 @@ pub struct MoonBitPackage {
894945 pub name : String ,
895946 pub mbt_files : Vec < Utf8PathBuf > ,
896947 pub warning_control : Vec < WarningControl > ,
948+ pub alert_control : Vec < WarningControl > ,
897949 pub output : Utf8PathBuf ,
898950 pub dependencies : Vec < ( Utf8PathBuf , String ) > ,
899951 pub package_sources : Vec < ( String , Utf8PathBuf ) > ,
0 commit comments