File tree Expand file tree Collapse file tree 3 files changed +35
-7
lines changed
Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ use std::fmt;
2222use std:: fs:: File ;
2323use std:: io:: { stdout, Write } ;
2424use std:: path:: PathBuf ;
25+ use std:: process:: Stdio ;
2526use std:: time:: { Duration , Instant } ;
2627
2728use self :: compile:: compiler_args;
@@ -506,3 +507,18 @@ pub fn build(
506507 }
507508 }
508509}
510+
511+ pub fn pass_through_legacy ( args : Vec < String > ) -> i32 {
512+ let project_root = helpers:: get_abs_path ( "." ) ;
513+ let workspace_root = helpers:: get_workspace_root ( & project_root) ;
514+
515+ let bsb_path = helpers:: get_rescript_legacy ( & project_root, workspace_root) ;
516+
517+ let status = std:: process:: Command :: new ( bsb_path)
518+ . args ( args)
519+ . stdout ( Stdio :: inherit ( ) )
520+ . stderr ( Stdio :: inherit ( ) )
521+ . status ( ) ;
522+
523+ status. map ( |s| s. code ( ) . unwrap_or ( 1 ) ) . unwrap_or ( 1 )
524+ }
Original file line number Diff line number Diff line change @@ -146,6 +146,21 @@ pub fn create_build_path(build_path: &str) {
146146 . unwrap ( ) ;
147147}
148148
149+ pub fn get_rescript_legacy ( root_path : & str , workspace_root : Option < String > ) -> String {
150+ match (
151+ PathBuf :: from ( format ! ( "{}/node_modules/rescript/rescript" , root_path) ) . canonicalize ( ) ,
152+ workspace_root. map ( |workspace_root| {
153+ PathBuf :: from ( format ! ( "{}/node_modules/rescript/rescript" , workspace_root) ) . canonicalize ( )
154+ } ) ,
155+ ) {
156+ ( Ok ( path) , _) => path,
157+ ( _, Some ( Ok ( path) ) ) => path,
158+ _ => panic ! ( "Could not find rescript" ) ,
159+ }
160+ . to_string_lossy ( )
161+ . to_string ( )
162+ }
163+
149164pub fn get_bsc ( root_path : & str , workspace_root : Option < String > ) -> String {
150165 let subfolder = match ( std:: env:: consts:: OS , std:: env:: consts:: ARCH ) {
151166 ( "macos" , "aarch64" ) => "darwinarm64" ,
Original file line number Diff line number Diff line change @@ -89,18 +89,15 @@ struct Args {
8989 ///
9090 /// After this flag is encountered, the rest of the command line arguments are passed to the legacy build system.
9191 #[ arg( long, allow_hyphen_values = true , num_args = 0 ..) ]
92- legacy : Vec < String > ,
92+ legacy : Option < Vec < String > > ,
9393}
9494
9595fn main ( ) -> Result < ( ) > {
9696 let args = Args :: parse ( ) ;
9797
98- if !args. legacy . is_empty ( ) {
99- let s = std:: env:: args ( ) . collect :: < Vec < String > > ( ) . join ( " " ) ;
100-
101- println ! ( "Using legacy build system" ) ;
102- println ! ( "Running: {s}" ) ;
103- std:: process:: exit ( 0 ) ;
98+ if let Some ( legacy_args) = args. legacy {
99+ let code = build:: pass_through_legacy ( legacy_args) ;
100+ std:: process:: exit ( code) ;
104101 }
105102
106103 let log_level_filter = args. verbose . log_level_filter ( ) ;
You can’t perform that action at this time.
0 commit comments