#build-script #build #print #cargo-build #log #error-message

build build-print

build-print is a crate that allows you to print non-warning messages from within rust build scripts

2 releases

0.1.1 Sep 27, 2024
0.1.0 Sep 27, 2024

#220 in Build Utils

Download history 257/week @ 2024-09-27 47/week @ 2024-10-04 48/week @ 2024-10-11 5/week @ 2024-10-18 11/week @ 2024-11-01 5/week @ 2024-11-08 17/week @ 2024-11-15 70/week @ 2024-11-22 33/week @ 2024-11-29

128 downloads per month
Used in libltc-rs

MIT license

81KB
79 lines

build-print

A simple set of macros that allow regular printing as well as properly formatted info, warnings, errors, and notes during build scripts.

Traditionally, there are only two ways to print to the console during a build script:

  • println!("cargo:warning=...") to print a somewhat annoyingly formatted warning message
  • panic!(..) to halt the build process and print an error message

Regular println! statements are not shown during the build process, so this crate hijacks the cargo:warning=... variant using ANSI escape sequences to produce a working println! macro as well as info!, warn!, error!, and note! macros that following the indentation and coloring of standard cargo diagnostic messages.

You can also define your own custom print messages using the custom_println! macro, which is also the basis for the other macros.

Example

// build.rs
use build_print::{println, *};

fn main() {
    println!("regular println works");
    info!("hello world");
    warn!("hello world");
    error!("hello world");
    note!("hello world");
    custom_println!("Documenting", green, "hello world");
}

No runtime deps