Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Fix a few more bugs
Browse files Browse the repository at this point in the history
  - Avoid recursively copying a lib dir if it's the same as the
    package dir

  - Follow symbolic links for source files

  - Don't print unnecessary newlines
  • Loading branch information
David Cao committed Apr 11, 2019
1 parent 3ed3ad7 commit 21a555a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/lib/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ pub fn compile_lib(

let src_walker = source
.meta()
.list_files(source.path(), &src_path, |_| true)?
.filter(|x| valid_file(&x));
.list_files(source.path(), &src_path, |x| {
x.path() != &layout.build
})?;

clear_dir(&layout.build.join("lib"))?;
copy_dir_iter(src_walker, &src_path, &layout.build.join("lib"))?;
Expand Down
12 changes: 0 additions & 12 deletions src/lib/cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ pub fn test(
threads: ctx.threads,
};

ctx.shell.println_empty(Verbosity::Normal);
ctx.shell.println(
style("[2/3]").dim().bold(),
"Building targets...",
Expand Down Expand Up @@ -124,7 +123,6 @@ pub fn test(
let q = JobQueue::new(sources, &root, Some(layout), &bctx, &ctx.logger, ctx.shell)?;
q.exec(&bctx)?;

ctx.shell.println_empty(Verbosity::Normal);
ctx.shell.println(
style("[3/3]").dim().bold(),
"Running tests...",
Expand Down Expand Up @@ -182,7 +180,6 @@ pub fn test(
// pb.finish_and_clear();
});

ctx.shell.println_empty(Verbosity::Normal);
let mut errs = 0;
while let Some(res) = results.try_pop() {
match res {
Expand Down Expand Up @@ -261,7 +258,6 @@ pub fn install(
threads: ctx.threads,
};

ctx.shell.println_empty(Verbosity::Normal);
ctx.shell.println(
style("[2/3]").dim().bold(),
"Building targets...",
Expand All @@ -277,7 +273,6 @@ pub fn install(
let bins = q.exec(&bctx)?.1;
let binc = bins.len();

ctx.shell.println_empty(Verbosity::Normal);
ctx.shell.println(
style("[3/3]").dim().bold(),
"Installing binaries...",
Expand Down Expand Up @@ -392,7 +387,6 @@ pub fn repl(
threads: ctx.threads,
};

ctx.shell.println_empty(Verbosity::Normal);
ctx.shell.println(
style("[2/3]").dim().bold(),
"Building targets...",
Expand All @@ -410,13 +404,11 @@ pub fn repl(

// From here, we basically manually build a CompileInvocation, but tailor-made for the
// repl command.
ctx.shell.println_empty(Verbosity::Normal);
ctx.shell.println(
style("[3/3]").dim().bold(),
"Launching REPL...",
Verbosity::Quiet,
);
ctx.shell.println_empty(Verbosity::Quiet);

if bctx.compiler.flavor().is_idris2() {
bail!("The Idris 2 compiler doesn't currently support custom source paths, needed for the REPL.")
Expand Down Expand Up @@ -511,7 +503,6 @@ pub fn doc(ctx: &BuildCtx, project: &Path) -> Res<String> {
threads: ctx.threads,
};

ctx.shell.println_empty(Verbosity::Normal);
ctx.shell.println(
style("[2/2]").dim().bold(),
"Building targets + root docs...",
Expand Down Expand Up @@ -605,7 +596,6 @@ pub fn build(
threads: ctx.threads,
};

ctx.shell.println_empty(Verbosity::Normal);
ctx.shell.println(
style("[2/2]").dim().bold(),
"Building targets...",
Expand Down Expand Up @@ -867,8 +857,6 @@ pub fn solve_remote<F: FnMut(&Cache, Retriever, Graph<Summary>) -> Res<String>>(
);
let solve = Resolver::new(&retriever.logger.clone(), &mut retriever).solve()?;

ctx.shell.println_empty(Verbosity::Normal);

f(&cache, retriever, solve)
}

Expand Down
1 change: 1 addition & 0 deletions src/lib/package/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl Manifest {
.with_context(|e| format_err!("invalid excludes: {}", e))?;

let walker = WalkDir::new(search_root)
.follow_links(true)
.into_iter()
.filter_entry(move |x| {
!excludes
Expand Down
1 change: 1 addition & 0 deletions src/lib/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub fn copy_dir_iter(walker: impl Iterator<Item = DirEntry>, from: &Path, to: &P

pub fn copy_dir(from: &Path, to: &Path, gitless: bool) -> Res<()> {
let walker = WalkDir::new(from)
.follow_links(true)
.into_iter()
.filter_entry(|x| x.path() != to && (!gitless || x.file_name() != ".git"))
.filter_map(|x| {
Expand Down
6 changes: 6 additions & 0 deletions src/lib/util/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ impl Shell {
}
}

pub fn print_plain(self, message: impl Display, min_verbosity: Verbosity) {
if self.verbosity >= min_verbosity {
print!("{}", message);
}
}

pub fn println_empty(self, min_verbosity: Verbosity) {
if self.verbosity >= min_verbosity {
println!();
Expand Down

0 comments on commit 21a555a

Please sign in to comment.