Skip to content

Commit

Permalink
support bsc-path arg also in clean and compiler args
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrolich committed May 24, 2024
1 parent f406559 commit add09eb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct CompilerArgs {
pub parser_args: Vec<String>,
}

pub fn get_compiler_args(path: &str, rescript_version: Option<String>) -> String {
pub fn get_compiler_args(path: &str, rescript_version: Option<String>, bsc_path: Option<String>) -> String {
let filename = &helpers::get_abs_path(path);
let package_root = helpers::get_abs_path(
&helpers::get_nearest_bsconfig(&std::path::PathBuf::from(path)).expect("Couldn't find package root"),
Expand All @@ -64,7 +64,10 @@ pub fn get_compiler_args(path: &str, rescript_version: Option<String>) -> String
let rescript_version = if let Some(rescript_version) = rescript_version {
rescript_version
} else {
let bsc_path = helpers::get_bsc(&package_root, workspace_root.to_owned());
let bsc_path = match bsc_path {
Some(bsc_path) => bsc_path,
None => helpers::get_bsc(&package_root, workspace_root.to_owned()),
};
helpers::get_rescript_version(&bsc_path)
};
// make PathBuf from package root and get the relative path for filename
Expand Down
8 changes: 6 additions & 2 deletions src/build/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,16 @@ pub fn cleanup_after_build(build_state: &BuildState) {
});
}

pub fn clean(path: &str) {
pub fn clean(path: &str, bsc_path: Option<String>) {
let project_root = helpers::get_abs_path(path);
let workspace_root = helpers::get_workspace_root(&project_root);
let packages = packages::make(&None, &project_root, &workspace_root);
let root_config_name = packages::get_package_name(&project_root);
let bsc_path = helpers::get_bsc(&project_root, workspace_root.to_owned());
let bsc_path = match bsc_path {
Some(bsc_path) => bsc_path,
None => helpers::get_bsc(&project_root, workspace_root.to_owned()),
};

let rescript_version = helpers::get_rescript_version(&bsc_path);

let timing_clean_compiler_assets = Instant::now();
Expand Down
7 changes: 5 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ fn main() {
match args.compiler_args {
None => (),
Some(path) => {
println!("{}", build::get_compiler_args(&path, args.rescript_version));
println!(
"{}",
build::get_compiler_args(&path, args.rescript_version, args.bsc_path)
);
std::process::exit(0);
}
}
Expand All @@ -76,7 +79,7 @@ fn main() {
std::process::exit(1)
}
lock::Lock::Aquired(_) => match command {
Command::Clean => build::clean::clean(&folder),
Command::Clean => build::clean::clean(&folder, args.bsc_path),
Command::Build => {
match build::build(
&filter,
Expand Down

0 comments on commit add09eb

Please sign in to comment.