Crate build_data_writer[][src]

crates.io version license: Apache 2.0 unsafe forbidden pipeline status

build-data-writer

Functions to to write build-data.txt from your build.rs. Read the file with the build-data crate.

Features

  • Saves build-time data:
    • Timestamp
    • Date-time string
    • Hostname
    • git commit, branch, and dirtiness
    • rustc version
  • forbid(unsafe_code)
  • 100% test coverage

Alternatives

  • build-info
    • Mature & popular
    • Confusing API
    • Uses procedural macros

Example

See build-data crate docs.

Cargo Geiger Safety Report

Changelog

  • v0.1.2 - Support older versions of git when getting branch name.
  • v0.1.1 - Initial version

Happy Contributors 🙂

Fixing bugs and adding features is easy and fast. Send us a pull request and we intend to:

  • Always respond within 24 hours
  • Provide clear & concrete feedback
  • Immediately make a new release for your accepted change

Functions

escape_ascii

Converts a byte slice into a string using core::ascii::escape_default to escape each byte.

exec

Executes cmd with args as parameters, waits for it to exit, and returns its stdout, trimmed, and escaped with escape_ascii.

format_iso8601

Formats the time as an ISO-8601 or RFC-3339 string. Example: 2021-04-14T06:25:59+00:00

get_git_branch

Gets the current branch of the source code directory.

get_git_commit

Gets the latest git commit of the source code directory.

get_hostname

Gets the name of the current machine.

get_rustc_version

Gets the version of the Rust compiler used to build the build script.

get_seconds_since_epoch

Gets the number of seconds since 1970-01-01T00:00:00Z.

is_git_dirty

Returns true if the source directory contains uncommitted changes.

no_debug_rebuilds

Tells cargo not to rebuild build.rs during debug builds when other files change. This speeds up development builds.

write

Writes build-data.txt.