From f59fce4f44f3790adf26d6be25a5917cb32793af Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 20 Jan 2021 11:44:30 +0100 Subject: [PATCH] Adding build script, further debug info --- README.md | 10 ++++++++++ build.rs | 40 ++++++++++++++++++++++++++++++++++++++++ src/serial_terminal.rs | 12 ++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 build.rs diff --git a/README.md b/README.md index 874c9b4e..eb70b976 100644 --- a/README.md +++ b/README.md @@ -232,3 +232,13 @@ Bootloader USB interface. ``` dfu-util -a 0 -s 0x08000000:leave --download booster.bin ``` + +# Generating Releases + +When a release is ready, `develop` must be merged into `master`. + +The corresponding merge commit is then tagged with the version in the form of `vX.Y.Z`, where X, Y, +and Z are the semantic version major, minor, and patch versions. The tag must be pushed using `git +push origin vX.Y.Z`. This will automatically trigger CI to generate the release. + +After the tag is generated, `master` must be merged back into `develop`. diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..5f8aeafc --- /dev/null +++ b/build.rs @@ -0,0 +1,40 @@ +//! Booster NGFW build script +//! +//! # Copyright +//! Copyright (C) 2020 QUARTIQ GmbH - All Rights Reserved +//! Unauthorized usage, editing, or copying is strictly prohibited. +//! Proprietary and confidential. +//! +//! # Note +//! This build script is run immediately before the build is completed and is used to inject +//! environment variables into the build. +use std::process::Command; + +fn main() { + // Inject the git revision into an environment variable for compilation. + let output = Command::new("git") + .args(&["rev-parse", "HEAD"]) + .output() + .unwrap(); + let revision = String::from_utf8(output.stdout).unwrap(); + println!("cargo:rustc-env=GIT_REVISION={}", revision); + + let output = Command::new("git") + .args(&["describe", "--tags"]) + .output() + .unwrap(); + let version = String::from_utf8(output.stdout).unwrap(); + println!("cargo:rustc-env=VERSION={}", version); + + // Collect all of the enabled features and inject them as an environment variable. + let mut features: Vec = Vec::new(); + for (key, _) in std::env::vars() { + let strings: Vec<&str> = key.split("CARGO_FEATURE_").collect(); + if strings.len() > 1 { + println!("{}", strings[1]); + features.push(String::from(strings[1])); + } + } + + println!("cargo:rustc-env=ALL_FEATURES={}", features.join(", ")); +} diff --git a/src/serial_terminal.rs b/src/serial_terminal.rs index e2297280..6ba85c32 100644 --- a/src/serial_terminal.rs +++ b/src/serial_terminal.rs @@ -173,6 +173,18 @@ impl SerialTerminal { // Reading the panic message above clears the panic message, so similarly, we // should also clear the watchdog once read. platform::clear_reset_flags(); + + self.write("Git revision: ".as_bytes()); + self.write(env!("GIT_REVISION").as_bytes()); + self.write("\n".as_bytes()); + + self.write("Features: ".as_bytes()); + self.write(env!("ALL_FEATURES").as_bytes()); + self.write("\n".as_bytes()); + + self.write("Version: ".as_bytes()); + self.write(env!("VERSION").as_bytes()); + self.write("\n".as_bytes()); } Request::WriteIpAddress(prop, addr) => match prop {