Skip to content

Commit a209247

Browse files
committed
ouip
Signed-off-by: Pierre Fenoll <[email protected]>
1 parent e9ecd71 commit a209247

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

rustcbuildx/src/main.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,17 @@ async fn do_wrap_rustc(
434434
// --mount=type=bind,source=Cargo.toml,target=Cargo.toml \
435435
// --mount=type=bind,source=Cargo.lock,target=Cargo.lock \
436436

437-
let cwd = Temp::new_dir().map_err(|e| anyhow!("Failed to create tmpdir 'cwd': {e}"))?;
437+
// let cwd = Temp::new_dir().map_err(|e| anyhow!("Failed to create tmpdir 'cwd': {e}"))?;
438+
let cwd = std::env::temp_dir().join(&metadata);
439+
std::fs::create_dir_all(&cwd).unwrap();
438440
let Some(cwd_path) = Utf8Path::from_path(cwd.as_path()) else {
439441
bail!("Path's UTF-8 encoding is corrupted: {cwd:?}")
440442
};
441443

442444
// TODO: use tmpfs when on *NIX
443445
// TODO: cache these folders
444446
if pwd.join(".git").is_dir() {
445-
log::info!(target: &krate, "copying all git files under {}", pwd.join(".git"));
447+
log::info!(target: &krate, "copying all git files under {pwd} to {cwd_path}");
446448
// TODO: rust git crate?
447449
// TODO: --mount=bind each file one by one => drop temp dir ctx
448450
let mut cmd = Command::new("git");
@@ -463,7 +465,7 @@ async fn do_wrap_rustc(
463465
copy_files(f, cwd_path)?;
464466
}
465467
} else {
466-
log::info!(target: &krate, "copying all files under {pwd}");
468+
log::info!(target: &krate, "copying all files under {pwd} to {cwd_path}");
467469
copy_files(&pwd, cwd_path)?;
468470
}
469471

@@ -478,6 +480,7 @@ async fn do_wrap_rustc(
478480
// 0 0s debug HEAD λ cat rustcbuildx.d
479481
// $target_dir/debug/rustcbuildx: $cwd/src/cli.rs $cwd/src/cratesio.rs $cwd/src/envs.rs $cwd/src/main.rs $cwd/src/md.rs $cwd/src/parse.rs $cwd/src/pops.rs $cwd/src/runner.rs $cwd/src/stage.rs
480482
rustc_block.push_str(&format!("WORKDIR {pwd}\n"));
483+
// rustc_block.push_str("COPY --from={rustc_stage} / .\n");
481484
rustc_block.push_str("COPY --from=cwd / .\n");
482485
rustc_block.push_str("RUN \\\n");
483486

@@ -494,13 +497,18 @@ async fn do_wrap_rustc(
494497
input_mount.and_then(|(name, src, target)| {
495498
src.is_none().then_some((name.to_string(), target.to_string()))
496499
}),
500+
// cwd.as_ref().map(|(_, cwd_path)| (rustc_stage.to_string(), cwd_path.to_string())),
497501
cwd.as_ref().map(|(_, cwd)| ("cwd".to_owned(), cwd.to_string())),
498502
crate_out.map(|crate_out| (crate_out_name(&crate_out), crate_out)),
499503
]
500504
.into_iter()
501505
.flatten()
502506
.map(|(name, uri)| BuildContext { name, uri })
503507
.collect();
508+
log::info!(target: &krate, "loading {} Docker contexts", md.contexts.len());
509+
for BuildContext { name, uri } in &md.contexts {
510+
log::info!(target: &krate, "loading {name:?}: {uri}");
511+
}
504512

505513
log::debug!(target: &krate, "all_externs = {all_externs:?}");
506514
if externs.len() > all_externs.len() {

0 commit comments

Comments
 (0)