Skip to content

Commit

Permalink
Adding build script, further debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-summers committed Jan 20, 2021
1 parent b29ec9a commit f59fce4
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
40 changes: 40 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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<String> = 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(", "));
}
12 changes: 12 additions & 0 deletions src/serial_terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f59fce4

Please sign in to comment.