File tree Expand file tree Collapse file tree 3 files changed +39
-7
lines changed Expand file tree Collapse file tree 3 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ use serde::Serialize;
21
21
use std:: fmt;
22
22
use std:: fs:: File ;
23
23
use std:: io:: { stdout, Write } ;
24
+ use std:: os:: unix:: process:: ExitStatusExt ;
24
25
use std:: path:: PathBuf ;
26
+ use std:: process:: Stdio ;
25
27
use std:: time:: { Duration , Instant } ;
26
28
27
29
use self :: compile:: compiler_args;
@@ -506,3 +508,21 @@ pub fn build(
506
508
}
507
509
}
508
510
}
511
+
512
+ pub fn pass_through_legacy ( args : Vec < String > ) -> i32 {
513
+ let project_root = helpers:: get_abs_path ( "." ) ;
514
+ let workspace_root = helpers:: get_workspace_root ( & project_root) ;
515
+
516
+ let bsb_path = helpers:: get_rescript_legacy ( & project_root, workspace_root) ;
517
+
518
+ let status = std:: process:: Command :: new ( bsb_path)
519
+ . args ( args)
520
+ . stdout ( Stdio :: inherit ( ) )
521
+ . stderr ( Stdio :: inherit ( ) )
522
+ . status ( ) ;
523
+
524
+ status
525
+ . unwrap_or ( std:: process:: ExitStatus :: from_raw ( 1 ) )
526
+ . code ( )
527
+ . unwrap_or ( 1 )
528
+ }
Original file line number Diff line number Diff line change @@ -146,6 +146,21 @@ pub fn create_build_path(build_path: &str) {
146
146
. unwrap ( ) ;
147
147
}
148
148
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
+
149
164
pub fn get_bsc ( root_path : & str , workspace_root : Option < String > ) -> String {
150
165
let subfolder = match ( std:: env:: consts:: OS , std:: env:: consts:: ARCH ) {
151
166
( "macos" , "aarch64" ) => "darwinarm64" ,
Original file line number Diff line number Diff line change @@ -89,18 +89,15 @@ struct Args {
89
89
///
90
90
/// After this flag is encountered, the rest of the command line arguments are passed to the legacy build system.
91
91
#[ arg( long, allow_hyphen_values = true , num_args = 0 ..) ]
92
- legacy : Vec < String > ,
92
+ legacy : Option < Vec < String > > ,
93
93
}
94
94
95
95
fn main ( ) -> Result < ( ) > {
96
96
let args = Args :: parse ( ) ;
97
97
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) ;
104
101
}
105
102
106
103
let log_level_filter = args. verbose . log_level_filter ( ) ;
You can’t perform that action at this time.
0 commit comments