Skip to content

Commit 94d0d24

Browse files
committed
Fix how we report version numbers.
Now matches the BMC.
1 parent 65691aa commit 94d0d24

File tree

5 files changed

+30
-40
lines changed

5 files changed

+30
-40
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
uses: actions/checkout@v3
1414
with:
1515
submodules: true
16+
fetch-depth: 0
1617

1718
- name: Install Rust
1819
uses: actions-rs/toolchain@v1
@@ -23,25 +24,8 @@ jobs:
2324
target: thumbv6m-none-eabi
2425

2526
- name: Build Code
26-
run: cargo build --release --verbose
27-
28-
- name: Get Branch Name
29-
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
30-
id: branch_name
3127
run: |
32-
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
33-
34-
- name: Create Release
35-
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')
36-
id: create_release
37-
uses: actions/create-release@v1
38-
env:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
with:
41-
tag_name: ${{ github.ref }}
42-
release_name: Release ${{ steps.branch_name.outputs.SOURCE_TAG }}
43-
draft: false
44-
prerelease: false
28+
cargo build --release --verbose
4529
4630
- name: Upload files to Release
4731
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/')

.github/workflows/clippy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ jobs:
1111
steps:
1212
- name: Checkout Code
1313
uses: actions/checkout@v3
14+
with:
15+
submodules: true
16+
fetch-depth: 0
1417

1518
- name: Install Rust
1619
uses: actions-rs/toolchain@v1

.github/workflows/format.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ jobs:
88
steps:
99
- name: Checkout Code
1010
uses: actions/checkout@v3
11+
with:
12+
submodules: true
13+
fetch-depth: 0
1114

1215
- name: Install Rust
1316
uses: actions-rs/toolchain@v1

build.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,21 @@ fn main() {
2929
// `memory.x` is changed.
3030
println!("cargo:rerun-if-changed=memory.x");
3131

32-
// Get git version
33-
if let Ok(cmd_output) = std::process::Command::new("git")
34-
.arg("describe")
35-
.arg("--all")
36-
.arg("--dirty")
37-
.arg("--long")
32+
// Generate a file containing the firmware version
33+
let version_output = std::process::Command::new("git")
34+
.current_dir(env::var_os("CARGO_MANIFEST_DIR").unwrap())
35+
.args(["describe", "--long", "--dirty"])
3836
.output()
39-
{
40-
let git_version = std::str::from_utf8(&cmd_output.stdout).unwrap();
41-
println!(
42-
"cargo:rustc-env=BIOS_VERSION={} (git:{})",
43-
env!("CARGO_PKG_VERSION"),
44-
git_version.trim()
45-
);
46-
} else {
47-
println!("cargo:rustc-env=BIOS_VERSION={}", env!("CARGO_PKG_VERSION"));
48-
}
37+
.expect("running git-describe");
38+
assert!(version_output.status.success());
39+
40+
// Remove the trailing newline
41+
let mut output = version_output.stdout;
42+
output.pop();
43+
44+
// Add a null
45+
output.push(0);
46+
47+
// Write the file
48+
std::fs::write(out.join("version.txt"), output).expect("writing version file");
4949
}

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ struct Pins {
154154
// Static and Const Data
155155
// -----------------------------------------------------------------------------
156156

157-
/// The BIOS version string
158-
static BIOS_VERSION: &str = concat!("Neotron Pico BIOS version ", env!("BIOS_VERSION"), "\0");
157+
/// Version string auto-generated by git.
158+
static VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/version.txt"));
159159

160160
/// Ensures we always send a unique read request
161161
static USE_ALT: UseAlt = UseAlt::new();
@@ -261,8 +261,8 @@ fn main() -> ! {
261261
// Needed by the clock setup
262262
let mut watchdog = hal::watchdog::Watchdog::new(pp.WATCHDOG);
263263

264-
// BIOS_VERSION has a trailing `\0` as that is what the BIOS/OS API requires.
265-
info!("{} starting...", &BIOS_VERSION[0..BIOS_VERSION.len() - 1]);
264+
// VERSION has a trailing `\0` as that is what the BIOS/OS API requires.
265+
info!("Neotron BIOS {} starting...", VERSION.trim_matches('\0'));
266266

267267
// Run at 126 MHz SYS_PLL, 48 MHz, USB_PLL. This is important, we as clock
268268
// the PIO at ÷ 5, to give 25.2 MHz (which is close enough to the 25.175
@@ -827,7 +827,7 @@ fn sign_on() {
827827

828828
tc.move_to(0, 0);
829829

830-
writeln!(&tc, "{}", &BIOS_VERSION[0..BIOS_VERSION.len() - 1]).unwrap();
830+
writeln!(&tc, "Neotron Pico BIOS {}", VERSION.trim_matches('\0')).unwrap();
831831
write!(&tc, "{}", LICENCE_TEXT).unwrap();
832832

833833
let bmc_ver = critical_section::with(|cs| {
@@ -879,7 +879,7 @@ pub extern "C" fn api_version_get() -> common::Version {
879879
/// a Rust string. It is unspecified as to whether the string is located
880880
/// in Flash ROM or RAM (but it's likely to be Flash ROM).
881881
pub extern "C" fn bios_version_get() -> common::ApiString<'static> {
882-
common::ApiString::new(BIOS_VERSION)
882+
common::ApiString::new(VERSION)
883883
}
884884

885885
/// Get information about the Serial ports in the system.

0 commit comments

Comments
 (0)