Skip to content

Commit

Permalink
internal: add raw_target_dir in Package
Browse files Browse the repository at this point in the history
  • Loading branch information
lijunchen committed Sep 13, 2024
1 parent 80feb23 commit 9a57730
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 18 deletions.
5 changes: 3 additions & 2 deletions crates/moon/src/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn run_build_internal(
cli.quiet,
)?;

let original_target_dir = target_dir;
let raw_target_dir = target_dir;
let mut moonc_opt = super::get_compiler_flags(source_dir, &cmd.build_flags)?;
moonc_opt.build_opt.deny_warn = cmd.build_flags.deny_warn;
let run_mode = RunMode::Build;
Expand All @@ -125,6 +125,7 @@ fn run_build_internal(

let moonbuild_opt = MoonbuildOpt {
source_dir: source_dir.to_path_buf(),
raw_target_dir: raw_target_dir.to_path_buf(),
target_dir,
sort_input,
run_mode,
Expand Down Expand Up @@ -172,7 +173,7 @@ fn run_build_internal(
&moonbuild_opt,
&reg_cfg,
&module,
original_target_dir,
raw_target_dir,
)
} else {
entry::run_build(&moonc_opt, &moonbuild_opt, &module)
Expand Down
2 changes: 2 additions & 0 deletions crates/moon/src/cli/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ fn run_bundle_internal(
let run_mode = RunMode::Bundle;
let sort_input = cmd.build_flags.sort_input;

let raw_target_dir = target_dir.to_path_buf();
let target_dir = mk_arch_mode_dir(source_dir, target_dir, &moonc_opt, run_mode)?;
let _lock = FileLock::lock(&target_dir)?;

let moonbuild_opt = MoonbuildOpt {
source_dir: source_dir.to_path_buf(),
raw_target_dir,
target_dir,
sort_input,
run_mode,
Expand Down
5 changes: 3 additions & 2 deletions crates/moon/src/cli/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ fn run_check_internal(
cli.quiet,
)?;

let original_target_dir = target_dir;
let raw_target_dir = target_dir;
let mut moonc_opt = get_compiler_flags(source_dir, &cmd.build_flags)?;
moonc_opt.build_opt.deny_warn = cmd.build_flags.deny_warn;
let run_mode = RunMode::Check;
Expand All @@ -143,6 +143,7 @@ fn run_check_internal(

let moonbuild_opt = MoonbuildOpt {
source_dir: source_dir.to_path_buf(),
raw_target_dir: raw_target_dir.to_path_buf(),
target_dir: target_dir.clone(),
sort_input,
run_mode,
Expand Down Expand Up @@ -190,7 +191,7 @@ fn run_check_internal(
&moonbuild_opt,
&reg_cfg,
&module,
original_target_dir,
raw_target_dir,
)
} else {
let pid_path = target_dir.join(MOON_PID_NAME);
Expand Down
2 changes: 2 additions & 0 deletions crates/moon/src/cli/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ pub fn run_doc(cli: UniversalFlags, cmd: DocSubcommand) -> anyhow::Result<i32> {
)?;

let run_mode = RunMode::Check;
let raw_target_dir = target_dir.to_path_buf();
let target_dir = mk_arch_mode_dir(&source_dir, &target_dir, &moonc_opt, run_mode)?;
let moonbuild_opt = MoonbuildOpt {
source_dir: source_dir.clone(),
raw_target_dir,
target_dir,
sort_input: true,
run_mode,
Expand Down
2 changes: 2 additions & 0 deletions crates/moon/src/cli/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub fn run_fmt(cli: &UniversalFlags, cmd: FmtSubcommand) -> anyhow::Result<i32>

let moonc_opt = MooncOpt::default();
let run_mode = RunMode::Format;
let raw_target_dir = target_dir.to_path_buf();
let target_dir = mk_arch_mode_dir(&source_dir, &target_dir, &moonc_opt, run_mode)?;
let _lock = FileLock::lock(&target_dir)?;

Expand All @@ -59,6 +60,7 @@ pub fn run_fmt(cli: &UniversalFlags, cmd: FmtSubcommand) -> anyhow::Result<i32>

let moonbuild_opt = MoonbuildOpt {
source_dir,
raw_target_dir,
target_dir: target_dir.clone(),
sort_input: cmd.sort_input,
run_mode,
Expand Down
2 changes: 2 additions & 0 deletions crates/moon/src/cli/generate_test_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ pub fn generate_test_driver(
&RegistryConfig::load(),
cli.quiet,
)?;
let raw_target_dir = target_dir.to_path_buf();

let moonbuild_opt = MoonbuildOpt {
source_dir,
raw_target_dir,
target_dir: target_dir.clone(),
test_opt: Some(TestOpt {
filter_package: filter_package.clone(),
Expand Down
17 changes: 3 additions & 14 deletions crates/moon/src/cli/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pub fn run_info(cli: UniversalFlags, cmd: InfoSubcommand) -> anyhow::Result<i32>
})?;
let module_name = &mod_desc.name;
let mut moonc_opt = MooncOpt::default();
let raw_target_dir = target_dir.to_path_buf();
let target_dir = mk_arch_mode_dir(
source_dir.as_path(),
target_dir.as_path(),
Expand All @@ -82,6 +83,7 @@ pub fn run_info(cli: UniversalFlags, cmd: InfoSubcommand) -> anyhow::Result<i32>
}
let moonbuild_opt = MoonbuildOpt {
source_dir: source_dir.clone(),
raw_target_dir,
target_dir: target_dir.clone(),
sort_input: false,
run_mode: RunMode::Check,
Expand Down Expand Up @@ -114,20 +116,7 @@ pub fn run_info(cli: UniversalFlags, cmd: InfoSubcommand) -> anyhow::Result<i32>
&resolved_env,
&dir_sync_result,
&moonc_opt,
&MoonbuildOpt {
source_dir: source_dir.clone(),
target_dir,
sort_input: false,
run_mode: RunMode::Check,
test_opt: None,
fmt_opt: None,
args: vec![],
verbose: cli.verbose,
quiet: cli.quiet,
output_json: false,
no_parallelize: false,
build_graph: false,
},
&moonbuild_opt,
)?;

let runtime = tokio::runtime::Runtime::new()?;
Expand Down
2 changes: 2 additions & 0 deletions crates/moon/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ pub fn run_run_internal(cli: &UniversalFlags, cmd: RunSubcommand) -> anyhow::Res

let mut moonc_opt = super::get_compiler_flags(&source_dir, &cmd.build_flags)?;
let run_mode = RunMode::Run;
let raw_target_dir = target_dir.to_path_buf();
let target_dir = mk_arch_mode_dir(&source_dir, &target_dir, &moonc_opt, run_mode)?;
let _lock = FileLock::lock(&target_dir)?;

Expand Down Expand Up @@ -260,6 +261,7 @@ pub fn run_run_internal(cli: &UniversalFlags, cmd: RunSubcommand) -> anyhow::Res
}
let moonbuild_opt = MoonbuildOpt {
source_dir,
raw_target_dir,
target_dir,
sort_input,
run_mode,
Expand Down
2 changes: 2 additions & 0 deletions crates/moon/src/cli/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ fn run_test_internal(
moonc_opt.link_opt.debug_flag = !cmd.release;

let run_mode = RunMode::Test;
let raw_target_dir = target_dir.to_path_buf();
let target_dir = mk_arch_mode_dir(source_dir, target_dir, &moonc_opt, run_mode)?;
let _lock = FileLock::lock(&target_dir)?;

Expand All @@ -180,6 +181,7 @@ fn run_test_internal(
let filter_index = cmd.index;
let moonbuild_opt = MoonbuildOpt {
source_dir: source_dir.to_path_buf(),
raw_target_dir,
target_dir: target_dir.clone(),
test_opt: Some(TestOpt {
filter_package: filter_package.clone(),
Expand Down
1 change: 1 addition & 0 deletions crates/moonutil/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ impl LinkCoreFlags {
#[derive(Debug, Clone)]
pub struct MoonbuildOpt {
pub source_dir: PathBuf,
pub raw_target_dir: PathBuf,
pub target_dir: PathBuf,
pub test_opt: Option<TestOpt>,
pub sort_input: bool,
Expand Down

0 comments on commit 9a57730

Please sign in to comment.