From b7f6bfffeb73e1699a100605b19b04b7b2255a54 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 26 Jan 2017 17:40:18 +0000 Subject: [PATCH] firmware: fix embedding of software version during build. --- artiq/firmware/libbuild_artiq/lib.rs | 8 +++++++- artiq/firmware/runtime/lib.rs | 2 +- artiq/firmware/satman/lib.rs | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/artiq/firmware/libbuild_artiq/lib.rs b/artiq/firmware/libbuild_artiq/lib.rs index e47374610..da7133f26 100644 --- a/artiq/firmware/libbuild_artiq/lib.rs +++ b/artiq/firmware/libbuild_artiq/lib.rs @@ -2,7 +2,7 @@ extern crate walkdir; use std::env; use std::fs::File; -use std::io::{BufRead, BufReader}; +use std::io::{Write, BufRead, BufReader}; use std::path::Path; use std::process::Command; @@ -27,6 +27,12 @@ pub fn git_describe() { .unwrap(); let id = id.split("-").collect::>(); let id = format!("{}+{}.{}", id[0], id[1], id[2]); + + let out_dir = env::var("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("git-describe"); + let mut f = File::create(&dest_path).unwrap(); + f.write(id.as_bytes()).unwrap(); + println!("cargo:rust-cfg=git_describe={:?}", id); println!("cargo:rerun-if-changed=../../../.git/HEAD"); diff --git a/artiq/firmware/runtime/lib.rs b/artiq/firmware/runtime/lib.rs index 89e86c7e2..48a269348 100644 --- a/artiq/firmware/runtime/lib.rs +++ b/artiq/firmware/runtime/lib.rs @@ -60,7 +60,7 @@ mod analyzer; fn startup() { board::clock::init(); info!("ARTIQ runtime starting..."); - info!("software version {}", cfg!(git_describe)); + info!("software version {}", include_str!(concat!(env!("OUT_DIR"), "/git-describe"))); info!("gateware version {}", board::ident(&mut [0; 64])); let t = board::clock::get_ms(); diff --git a/artiq/firmware/satman/lib.rs b/artiq/firmware/satman/lib.rs index 0eafbf6e0..6f20ba017 100644 --- a/artiq/firmware/satman/lib.rs +++ b/artiq/firmware/satman/lib.rs @@ -11,7 +11,7 @@ extern crate board; fn startup() { board::clock::init(); info!("ARTIQ satellite manager starting..."); - info!("software version {}", cfg!(git_describe)); + info!("software version {}", include_str!(concat!(env!("OUT_DIR"), "/git-describe"))); info!("gateware version {}", board::ident(&mut [0; 64])); loop {}