Skip to content

Commit

Permalink
add bsc-path argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrolich committed May 24, 2024
1 parent d1efa2f commit cc5ea6b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,14 @@ pub fn initialize_build(
default_timing: Option<Duration>,
filter: &Option<regex::Regex>,
path: &str,
bsc_path: Option<String>,
) -> Result<BuildState, InitializeBuildError> {
let project_root = helpers::get_abs_path(path);
let workspace_root = helpers::get_workspace_root(&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 root_config_name = packages::get_package_name(&project_root);
let rescript_version = helpers::get_rescript_version(&bsc_path);

Expand Down Expand Up @@ -412,6 +416,7 @@ pub fn build(
path: &str,
no_timing: bool,
create_sourcedirs: bool,
bsc_path: Option<String>,
) -> Result<BuildState, BuildError> {
let default_timing: Option<std::time::Duration> = if no_timing {
Some(std::time::Duration::new(0.0 as u64, 0.0 as u32))
Expand All @@ -420,7 +425,7 @@ pub fn build(
};
let timing_total = Instant::now();
let mut build_state =
initialize_build(default_timing, filter, path).map_err(BuildError::InitializeBuild)?;
initialize_build(default_timing, filter, path, bsc_path).map_err(BuildError::InitializeBuild)?;

match incremental_build(&mut build_state, default_timing, true, false, create_sourcedirs) {
Ok(_) => {
Expand Down
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ struct Args {

#[arg(long)]
rescript_version: Option<String>,

#[arg(long)]
bsc_path: Option<String>,
}

fn main() {
Expand Down Expand Up @@ -83,6 +86,7 @@ fn main() {
&folder,
args.no_timing.unwrap_or(false),
args.create_sourcedirs.unwrap_or(false),
args.bsc_path,
) {
Err(e) => {
eprintln!("Error Building: {e}");
Expand Down
5 changes: 3 additions & 2 deletions src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn async_watch(
after_build: Option<String>,
create_sourcedirs: bool,
) -> notify::Result<()> {
let mut build_state = build::initialize_build(None, filter, path).expect("Can't initialize build");
let mut build_state = build::initialize_build(None, filter, path, None).expect("Can't initialize build");
let mut needs_compile_type = CompileType::Incremental;
// create a mutex to capture if ctrl-c was pressed
let ctrlc_pressed = Arc::new(Mutex::new(false));
Expand Down Expand Up @@ -205,7 +205,8 @@ async fn async_watch(
}
CompileType::Full => {
let timing_total = Instant::now();
build_state = build::initialize_build(None, filter, path).expect("Can't initialize build");
build_state =
build::initialize_build(None, filter, path, None).expect("Can't initialize build");
let _ =
build::incremental_build(&mut build_state, None, initial_build, false, create_sourcedirs);
if let Some(a) = after_build.clone() {
Expand Down

0 comments on commit cc5ea6b

Please sign in to comment.