@@ -52,7 +52,7 @@ pub struct CompilerArgs {
5252 pub parser_args : Vec < String > ,
5353}
5454
55- pub fn get_compiler_args ( path : & str , rescript_version : Option < String > ) -> String {
55+ pub fn get_compiler_args ( path : & str , rescript_version : Option < String > , bsc_path : Option < String > ) -> String {
5656 let filename = & helpers:: get_abs_path ( path) ;
5757 let package_root = helpers:: get_abs_path (
5858 & helpers:: get_nearest_bsconfig ( & std:: path:: PathBuf :: from ( path) ) . expect ( "Couldn't find package root" ) ,
@@ -64,7 +64,10 @@ pub fn get_compiler_args(path: &str, rescript_version: Option<String>) -> String
6464 let rescript_version = if let Some ( rescript_version) = rescript_version {
6565 rescript_version
6666 } else {
67- let bsc_path = helpers:: get_bsc ( & package_root, workspace_root. to_owned ( ) ) ;
67+ let bsc_path = match bsc_path {
68+ Some ( bsc_path) => bsc_path,
69+ None => helpers:: get_bsc ( & package_root, workspace_root. to_owned ( ) ) ,
70+ } ;
6871 helpers:: get_rescript_version ( & bsc_path)
6972 } ;
7073 // make PathBuf from package root and get the relative path for filename
@@ -134,10 +137,14 @@ pub fn initialize_build(
134137 default_timing : Option < Duration > ,
135138 filter : & Option < regex:: Regex > ,
136139 path : & str ,
140+ bsc_path : Option < String > ,
137141) -> Result < BuildState , InitializeBuildError > {
138142 let project_root = helpers:: get_abs_path ( path) ;
139143 let workspace_root = helpers:: get_workspace_root ( & project_root) ;
140- let bsc_path = helpers:: get_bsc ( & project_root, workspace_root. to_owned ( ) ) ;
144+ let bsc_path = match bsc_path {
145+ Some ( bsc_path) => bsc_path,
146+ None => helpers:: get_bsc ( & project_root, workspace_root. to_owned ( ) ) ,
147+ } ;
141148 let root_config_name = packages:: get_package_name ( & project_root) ;
142149 let rescript_version = helpers:: get_rescript_version ( & bsc_path) ;
143150
@@ -412,6 +419,7 @@ pub fn build(
412419 path : & str ,
413420 no_timing : bool ,
414421 create_sourcedirs : bool ,
422+ bsc_path : Option < String > ,
415423) -> Result < BuildState , BuildError > {
416424 let default_timing: Option < std:: time:: Duration > = if no_timing {
417425 Some ( std:: time:: Duration :: new ( 0.0 as u64 , 0.0 as u32 ) )
@@ -420,7 +428,7 @@ pub fn build(
420428 } ;
421429 let timing_total = Instant :: now ( ) ;
422430 let mut build_state =
423- initialize_build ( default_timing, filter, path) . map_err ( BuildError :: InitializeBuild ) ?;
431+ initialize_build ( default_timing, filter, path, bsc_path ) . map_err ( BuildError :: InitializeBuild ) ?;
424432
425433 match incremental_build ( & mut build_state, default_timing, true , false , create_sourcedirs) {
426434 Ok ( _) => {
0 commit comments