Skip to content

Commit

Permalink
Release 3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
quanshousio committed Aug 4, 2021
1 parent 8f0ebd9 commit f534426
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 44 deletions.
14 changes: 12 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. `cargo-comp

#### 3.x Releases

- `3.2.x` Releases - [3.2.0](#320)
- `3.2.x` Releases - [3.2.0](#320) | [3.2.1](#321)
- `3.1.x` Releases - [3.1.0](#310)
- `3.0.x` Releases - [3.0.0](#300) | [3.0.1](#301)

Expand All @@ -19,6 +19,16 @@ All notable changes to this project will be documented in this file. `cargo-comp

---

## [3.2.1](https://github.com/bitslab/cargo-compiler-interrupts/releases/tag/3.2.1)

Released on 2021-08-04.

#### Updated

- Documentation and dependencies.
- `cargo-build-ci`
- Progress indicator is more aware of terminal size changes.

## [3.2.0](https://github.com/bitslab/cargo-compiler-interrupts/releases/tag/3.2.0)

Released on 2021-07-31.
Expand All @@ -34,7 +44,7 @@ Released on 2021-07-31.

- Various path-related helper functions are renamed.
- `cargo-build-ci`
- Fix a race condition between integration threads and progress indicator threads when integration thread failed unexpectedly.
- Fix a race condition between integration threads and progress indicator thread when integration thread failed unexpectedly.
- Failed integration can now be run again without using `cargo clean`.
- `cargo-lib-ci`
- Fix wrong output formatting while the progress indicator is showing.
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ license = "MIT"
name = "cargo-compiler-interrupts"
readme = "README.md"
repository = "https://github.com/bitslab/cargo-compiler-interrupts"
version = "3.2.0"
version = "3.2.1"

[dependencies]
anyhow = "1.0"
cargo-util = {version = "0.1.0", path = "crates/cargo-util"}
cargo_metadata = "0.13"
chrono = "0.4"
clap = "3.0.0-beta.2"
colored = "2"
colored = "2.0"
crossbeam-utils = "0.8"
dirs = "3.0"
faccess = "0.2"
indicatif = "0.16"
indicatif = "0.17.0-beta.1"
md5 = "0.7"
num_cpus = "1.13"
serde = "1.0"
term_size = "1.0.0-beta.2"
terminal_size = "0.1"
thiserror = "1.0"
toml = "0.5"
tracing = "0.1"
Expand Down
6 changes: 3 additions & 3 deletions crates/cargo-util/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()>
.with_context(|| format!("failed to write `{}`", path.display()))
}

/// Equivalent to [`write`], but does not write anything if the file contents
/// Equivalent to [`write()`], but does not write anything if the file contents
/// are identical to the given contents.
pub fn write_if_changed<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) -> Result<()> {
(|| -> Result<()> {
Expand Down Expand Up @@ -635,7 +635,7 @@ pub fn create_dir_all_excluded_from_backups_atomic<P: AsRef<Path>>(p: P) -> Resu
let parent = path.parent().unwrap();
let base = path.file_name().unwrap();
create_dir_all(parent)?;
// We do this in two steps (first create a temporary directory and exlucde
// We do this in two steps (first create a temporary directory and exclude
// it from backups, then rename it to the desired name. If we created the
// directory directly where it should be and then excluded it from backups
// we would risk a situation where cargo is interrupted right after the directory
Expand All @@ -653,7 +653,7 @@ pub fn create_dir_all_excluded_from_backups_atomic<P: AsRef<Path>>(p: P) -> Resu
// here to create the directory directly and fs::create_dir_all() explicitly treats
// the directory being created concurrently by another thread or process as success,
// hence the check below to follow the existing behavior. If we get an error at
// rename() and suddently the directory (which didn't exist a moment earlier) exists
// rename() and suddenly the directory (which didn't exist a moment earlier) exists
// we can infer from it it's another cargo process doing work.
if let Err(e) = fs::rename(tempdir.path(), path) {
if !path.exists() {
Expand Down
36 changes: 30 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ pub enum CIError {
Path to the library: {0}\n\
Run `cargo lib-ci --update` to update the library if needed"
)]
LibraryAlreadyInstalled(String),
LibraryAlreadyInstalled(
/// Path to the library.
String,
),

/// LLVM version between Rust and LLVM toolchain does not match.
#[error(
"LLVM version from Rust toolchain ({0}) does not match with the\
LLVM version from LLVM toolchain ({1})"
)]
LLVMVersionNotMatch(String, String),
LLVMVersionNotMatch(
/// LLVM version from Rust toolchain.
String,
/// LLVM version from LLVM toolchain.
String,
),

/// LLVM toolchain is not installed.
#[error(
Expand All @@ -39,14 +47,24 @@ pub enum CIError {

/// LLVM version is not supported.
#[error("LLVM version {0} is not supported. Minimum supported LLVM version is {1}")]
LLVMNotSupported(String, String),
LLVMNotSupported(
/// LLVM version.
String,
/// Minimum supported LLVM version
String,
),

/// Binary is not available.
#[error(
"Failed to execute the binary '{0}'\n\
Available binaries: {1}"
)]
BinaryNotAvailable(String, String),
BinaryNotAvailable(
/// Name of the unavailable binary.
String,
/// List of available binaries.
String,
),

/// Package does not have any available binaries.
#[error("Package does not have any available binaries")]
Expand All @@ -58,9 +76,15 @@ pub enum CIError {
Run `cargo run-ci --bin <BINARY_NAME>` to specify a binary\n\
Available binaries: {0}"
)]
BinaryNotDetermine(String),
BinaryNotDetermine(
/// List of available binaries.
String,
),

/// Path is not a valid directory.
#[error("Given path is not a valid directory: {0}")]
PathNotDirectory(String),
PathNotDirectory(
/// Given path.
String,
),
}
62 changes: 33 additions & 29 deletions src/ops/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn _exec(config: &Config, opts: &BuildOpts) -> CIResult<()> {
let ar = &llvm_bins[2];
let nm = &llvm_bins[3];

// get binary names
// get all binary-type crate names, including examples
let mut crate_names = Vec::new();
let metadata = cargo_metadata()?;
for package in metadata.packages {
Expand Down Expand Up @@ -237,42 +237,32 @@ fn _exec(config: &Config, opts: &BuildOpts) -> CIResult<()> {
});
}

let term_size = term_size::dimensions().unwrap_or((80, 24));
debug!("term_size: {:?}", term_size);

// progress bar
// total length of the process bar
let len = ll_files.len() * 2 + linkers.len() + 1;
let pb = if opts.verbose == 0 {
ProgressBar::new(len as u64)
} else {
ProgressBar::hidden()
};
pb.set_style(
ProgressStyle::default_bar()
.template(if term_size.0 > 80 {
"{prefix:>12.cyan.bold} [{bar:27}] {pos}/{len}: {wide_msg}"
} else {
"{prefix:>12.cyan.bold} {pos}/{len}: {wide_msg}"
})
.progress_chars("=> "),
);
pb.set_prefix("Building");

let opts = &opts;
let config = &config;
let crate_names = &crate_names;
let deps_path = &deps_path;

let num_cpus = num_cpus::get();

let ll_iter = Arc::new(Mutex::new(ll_files.iter()));
let lk_iter = Arc::new(Mutex::new(linkers.iter_mut()));

thread::scope(move |s| -> CIResult<()> {
// communication between the progress bar thread and integration threads
let (tx, rx) = mpsc::channel::<IntegrationCx>();

// number of threads based on number of logical cores in CPU
let num_cpus = num_cpus::get();

// handle progress bar rendering
let pb_thread = s.spawn(move |_| {
// progress bar
let pb = if opts.verbose == 0 {
ProgressBar::new(len as u64)
} else {
ProgressBar::hidden()
};
pb.set_prefix("Building");

let mut names: Vec<String> = Vec::new();
let mut error = false;

Expand Down Expand Up @@ -345,9 +335,16 @@ fn _exec(config: &Config, opts: &BuildOpts) -> CIResult<()> {
}
}

// processing crates message
let term_size = term_size::dimensions().unwrap_or((80, 24));
// progress bar message
let term_size = terminal_size::terminal_size()
.map(|(w, h)| (w.0.into(), h.0.into()))
.unwrap_or((80, 24));
let prefix_size = if term_size.0 > 80 { 50 } else { 20 };
let template = if term_size.0 > 80 {
"{prefix:>12.cyan.bold} [{bar:27}] {pos}/{len}: {wide_msg}"
} else {
"{prefix:>12.cyan.bold} {pos}/{len}: {wide_msg}"
};
let mut msg = String::new();
let mut iter = names.iter();
let first = match iter.next() {
Expand All @@ -365,6 +362,11 @@ fn _exec(config: &Config, opts: &BuildOpts) -> CIResult<()> {
break;
}
}
pb.set_style(
ProgressStyle::default_bar()
.template(template)
.progress_chars("=> "),
);
pb.set_message(msg);
}

Expand Down Expand Up @@ -496,7 +498,7 @@ fn _exec(config: &Config, opts: &BuildOpts) -> CIResult<()> {
let iter = Arc::clone(&lk_iter);
let thread = s.spawn(move |_| -> CIResult<()> {
loop {
let linker = iter.lock().expect("mutex failed").next();
let linker = iter.lock().expect("failed to acquire lock").next();
if let Some(linker) = linker {
let crate_name = Arc::new(crate_name(&linker.bin_path));
info!("linking: {}", crate_name);
Expand All @@ -515,7 +517,7 @@ fn _exec(config: &Config, opts: &BuildOpts) -> CIResult<()> {
if stdout.contains("__rust_alloc") {
debug!("found allocator shim: {}", file);
} else {
*file = util::append_suffix(&file, "ci").display().to_string();
*file = util::path_to_string(util::append_suffix(&file, "ci"));
}
}
let deps_rlib_files = linker
Expand Down Expand Up @@ -651,10 +653,12 @@ fn handle_output<P: AsRef<Path>>(
// take last few output lines to not polluting the terminal
let mut desc = proc_err.desc.lines().rev().take(10).collect::<Vec<_>>();
desc.reverse();
out.push("(truncated)");
out.append(&mut desc);
let msg = if debug {
// set log file name
let desc = &proc_err.desc;

// set log file name
let digest = md5::compute(desc.as_bytes());
let date = chrono::Local::now().format("%y%m%dT%H%M%S").to_string();
let mut path = util::config_path()?;
Expand Down

0 comments on commit f534426

Please sign in to comment.