Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): Support build-finished message #42

Merged
merged 2 commits into from Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- next-header -->
## [Unreleased] - ReleaseDate

#### Features

* Support `build-finished` message

## [0.5.0] - 2019-04-08

#### Features
Expand Down
9 changes: 0 additions & 9 deletions README.md
Expand Up @@ -8,15 +8,6 @@
![License](https://img.shields.io/crates/l/escargot.svg)
[![Crates Status](https://img.shields.io/crates/v/escargot.svg)](https://crates.io/crates/escargot)

## Install

Add to your `Cargo.toml`:

```toml
[dependencies]
escargot = "0.5"
```

## Why escargot

Compared to depending on `cargo`:
Expand Down
11 changes: 11 additions & 0 deletions release.toml
@@ -0,0 +1,11 @@
pre-release-commit-message = "chore({{crate_name}}): Release {{version}}"
no-dev-version = true
tag-message = "{{tag_name}}"
tag-name = "{{prefix}}v{{version}}"
pre-release-replacements = [
{file="CHANGELOG.md", search="Unreleased", replace="{{version}}", min=1},
{file="CHANGELOG.md", search="\\.\\.\\.HEAD", replace="...{{tag_name}}", exactly=1},
{file="CHANGELOG.md", search="ReleaseDate", replace="{{date}}", min=1},
{file="CHANGELOG.md", search="<!-- next-header -->", replace="<!-- next-header -->\n## [Unreleased] - ReleaseDate\n", exactly=1},
{file="CHANGELOG.md", search="<!-- next-url -->", replace="<!-- next-url -->\n[Unreleased]: https://github.com/assert-rs/predicates-rs/compare/{{tag_name}}...HEAD", exactly=1},
]
19 changes: 19 additions & 0 deletions src/format/mod.rs
Expand Up @@ -15,6 +15,8 @@ type CowStr<'a> = borrow::Cow<'a, str>;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "reason", rename_all = "kebab-case")]
pub enum Message<'a> {
/// Build completed, all further output should not be parsed
BuildFinished(BuildFinished),
/// The compiler generated an artifact
#[serde(borrow)]
CompilerArtifact(Artifact<'a>),
Expand All @@ -30,6 +32,14 @@ pub enum Message<'a> {
Unknown,
}

/// Build completed, all further output should not be parsed
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct BuildFinished {
success: bool,
}

/// A compiler-generated file.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(feature = "strict_unstable", serde(deny_unknown_fields))]
Expand Down Expand Up @@ -77,6 +87,9 @@ pub struct Target<'a> {
/// Whether this is a doctest or not
#[serde(default)]
pub doctest: Option<bool>,
/// Whether this is a test file
#[serde(default)]
pub test: bool,

#[serde(default)]
#[serde(rename = "required-features")]
Expand Down Expand Up @@ -173,6 +186,9 @@ pub struct BuildScript<'a> {
#[cfg(not(feature = "print"))]
pub(crate) fn log_message(msg: &Message<'_>) {
match msg {
Message::BuildFinished(ref finished) => {
log::trace!("Build Finished: {:?}", finished.success);
}
Message::CompilerArtifact(ref art) => {
log::trace!("Building {:#?}", art.package_id,);
}
Expand Down Expand Up @@ -206,6 +222,9 @@ pub(crate) fn log_message(msg: &Message<'_>) {
#[cfg(feature = "print")]
pub(crate) fn log_message(msg: &Message<'_>) {
match msg {
Message::BuildFinished(ref finished) => {
println!("Build Finished: {:?}", finished.success);
}
Message::CompilerArtifact(ref art) => {
println!("Building {:#?}", art.package_id,);
}
Expand Down
9 changes: 1 addition & 8 deletions src/lib.rs
@@ -1,13 +1,6 @@
//! # Escargot: A Cargo API
//!
//! ## Install
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! escargot = "0.5"
//! ```
//! ## Features
//!
//! Features:
//! - `print` for logged output to be printed instead, generally for test writing.
Expand Down