forked from M-Labs/artiq
firmware: factor out build scripts from runtime/satman.
This commit is contained in:
parent
4d05c70dfa
commit
5604d9bb55
|
@ -17,6 +17,13 @@ dependencies = [
|
|||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "build_artiq"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"walkdir 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.0.0"
|
||||
|
@ -75,13 +82,13 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"alloc_artiq 0.0.0",
|
||||
"board 0.0.0",
|
||||
"build_artiq 0.0.0",
|
||||
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fringe 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smoltcp 0.2.0 (git+https://github.com/m-labs/smoltcp?rev=b90495f)",
|
||||
"std_artiq 0.0.0",
|
||||
"walkdir 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -90,10 +97,10 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"alloc_artiq 0.0.0",
|
||||
"board 0.0.0",
|
||||
"build_artiq 0.0.0",
|
||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log_buffer 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"std_artiq 0.0.0",
|
||||
"walkdir 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
authors = ["M-Labs"]
|
||||
name = "build_artiq"
|
||||
version = "0.0.0"
|
||||
|
||||
[lib]
|
||||
name = "build_artiq"
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
walkdir = "1.0"
|
|
@ -0,0 +1,48 @@
|
|||
extern crate walkdir;
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use walkdir::WalkDir;
|
||||
|
||||
pub fn git_describe() {
|
||||
let id =
|
||||
Command::new("git")
|
||||
.arg("describe")
|
||||
.arg("--tags")
|
||||
.arg("--dirty")
|
||||
.arg("--always")
|
||||
.arg("--long")
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||
.map(|mut s| {
|
||||
let len = s.trim_right().len();
|
||||
s.truncate(len);
|
||||
s
|
||||
})
|
||||
.unwrap();
|
||||
let id = id.split("-").collect::<Vec<_>>();
|
||||
let id = format!("{}+{}.{}", id[0], id[1], id[2]);
|
||||
println!("cargo:rust-cfg=git_describe={:?}", id);
|
||||
|
||||
println!("cargo:rerun-if-changed=../../../.git/HEAD");
|
||||
for entry in WalkDir::new("../../../.git/refs") {
|
||||
let entry = entry.unwrap();
|
||||
println!("cargo:rerun-if-changed={}", entry.path().display());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn misoc_registers() {
|
||||
let out_dir = env::var("BUILDINC_DIRECTORY").unwrap();
|
||||
let cfg_path = Path::new(&out_dir).join("generated").join("rust-cfg");
|
||||
println!("cargo:rerun-if-changed={}", cfg_path.to_str().unwrap());
|
||||
|
||||
let f = BufReader::new(File::open(&cfg_path).unwrap());
|
||||
for line in f.lines() {
|
||||
println!("cargo:rustc-cfg={}", line.unwrap());
|
||||
}
|
||||
}
|
|
@ -4,14 +4,14 @@ name = "runtime"
|
|||
version = "0.0.0"
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
walkdir = "1.0"
|
||||
|
||||
[lib]
|
||||
name = "runtime"
|
||||
crate-type = ["staticlib"]
|
||||
path = "lib.rs"
|
||||
|
||||
[build-dependencies]
|
||||
build_artiq = { path = "../libbuild_artiq" }
|
||||
|
||||
[dependencies]
|
||||
alloc_artiq = { path = "../liballoc_artiq" }
|
||||
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
||||
|
|
|
@ -1,53 +1,6 @@
|
|||
extern crate walkdir;
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{Write, BufRead, BufReader};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use walkdir::WalkDir;
|
||||
extern crate build_artiq;
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("BUILDINC_DIRECTORY").unwrap();
|
||||
let cfg_path = Path::new(&out_dir).join("generated").join("rust-cfg");
|
||||
println!("cargo:rerun-if-changed={}", cfg_path.to_str().unwrap());
|
||||
|
||||
let f = BufReader::new(File::open(&cfg_path).unwrap());
|
||||
for line in f.lines() {
|
||||
println!("cargo:rustc-cfg={}", line.unwrap());
|
||||
}
|
||||
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let dest_path = Path::new(&out_dir).join("git_info.rs");
|
||||
let mut f = File::create(&dest_path).unwrap();
|
||||
|
||||
let id = git_describe().unwrap();
|
||||
let id = id.split("-").collect::<Vec<_>>();
|
||||
let id = format!("{}+{}.{}", id[0], id[1], id[2]);
|
||||
writeln!(f, "const GIT_COMMIT: &'static str = {:?};", id).unwrap();
|
||||
|
||||
println!("cargo:rerun-if-changed=../../../.git/HEAD");
|
||||
for entry in WalkDir::new("../../../.git/refs") {
|
||||
let entry = entry.unwrap();
|
||||
println!("cargo:rerun-if-changed={}", entry.path().display());
|
||||
}
|
||||
}
|
||||
|
||||
// Returns `None` if git is not available.
|
||||
fn git_describe() -> Option<String> {
|
||||
Command::new("git")
|
||||
.arg("describe")
|
||||
.arg("--tags")
|
||||
.arg("--dirty")
|
||||
.arg("--always")
|
||||
.arg("--long")
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||
.map(|mut s| {
|
||||
let len = s.trim_right().len();
|
||||
s.truncate(len);
|
||||
s
|
||||
})
|
||||
build_artiq::git_describe();
|
||||
build_artiq::misoc_registers();
|
||||
}
|
||||
|
|
|
@ -93,13 +93,11 @@ mod moninj;
|
|||
#[cfg(has_rtio_analyzer)]
|
||||
mod analyzer;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/git_info.rs"));
|
||||
|
||||
fn startup() {
|
||||
board::uart::set_speed(921600);
|
||||
board::clock::init();
|
||||
info!("booting ARTIQ");
|
||||
info!("software version {}", GIT_COMMIT);
|
||||
info!("software version {}", cfg!(git_describe));
|
||||
info!("gateware version {}", board::ident(&mut [0; 64]));
|
||||
|
||||
let t = board::clock::get_ms();
|
||||
|
|
|
@ -4,14 +4,14 @@ name = "satman"
|
|||
version = "0.0.0"
|
||||
build = "build.rs"
|
||||
|
||||
[build-dependencies]
|
||||
walkdir = "1.0"
|
||||
|
||||
[lib]
|
||||
name = "satman"
|
||||
crate-type = ["staticlib"]
|
||||
path = "lib.rs"
|
||||
|
||||
[build-dependencies]
|
||||
build_artiq = { path = "../libbuild_artiq" }
|
||||
|
||||
[dependencies]
|
||||
alloc_artiq = { path = "../liballoc_artiq" }
|
||||
std_artiq = { path = "../libstd_artiq", features = ["alloc"] }
|
||||
|
|
|
@ -1,53 +1,6 @@
|
|||
extern crate walkdir;
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{Write, BufRead, BufReader};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use walkdir::WalkDir;
|
||||
extern crate artiq_build;
|
||||
|
||||
fn main() {
|
||||
let out_dir = env::var("BUILDINC_DIRECTORY").unwrap();
|
||||
let cfg_path = Path::new(&out_dir).join("generated").join("rust-cfg");
|
||||
println!("cargo:rerun-if-changed={}", cfg_path.to_str().unwrap());
|
||||
|
||||
let f = BufReader::new(File::open(&cfg_path).unwrap());
|
||||
for line in f.lines() {
|
||||
println!("cargo:rustc-cfg={}", line.unwrap());
|
||||
}
|
||||
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let dest_path = Path::new(&out_dir).join("git_info.rs");
|
||||
let mut f = File::create(&dest_path).unwrap();
|
||||
|
||||
let id = git_describe().unwrap();
|
||||
let id = id.split("-").collect::<Vec<_>>();
|
||||
let id = format!("{}+{}.{}", id[0], id[1], id[2]);
|
||||
writeln!(f, "const GIT_COMMIT: &'static str = {:?};", id).unwrap();
|
||||
|
||||
println!("cargo:rerun-if-changed=../../../.git/HEAD");
|
||||
for entry in WalkDir::new("../../../.git/refs") {
|
||||
let entry = entry.unwrap();
|
||||
println!("cargo:rerun-if-changed={}", entry.path().display());
|
||||
}
|
||||
}
|
||||
|
||||
// Returns `None` if git is not available.
|
||||
fn git_describe() -> Option<String> {
|
||||
Command::new("git")
|
||||
.arg("describe")
|
||||
.arg("--tags")
|
||||
.arg("--dirty")
|
||||
.arg("--always")
|
||||
.arg("--long")
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|o| String::from_utf8(o.stdout).ok())
|
||||
.map(|mut s| {
|
||||
let len = s.trim_right().len();
|
||||
s.truncate(len);
|
||||
s
|
||||
})
|
||||
artiq_build::git_describe();
|
||||
artiq_build::misoc_registers();
|
||||
}
|
||||
|
|
|
@ -56,8 +56,6 @@ pub extern fn panic_fmt(args: self::core::fmt::Arguments, file: &'static str, li
|
|||
|
||||
mod logger;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/git_info.rs"));
|
||||
|
||||
// Allow linking with crates that are built as -Cpanic=unwind even if we use -Cpanic=abort.
|
||||
// This is never called.
|
||||
#[allow(non_snake_case)]
|
||||
|
@ -73,7 +71,7 @@ pub unsafe extern fn rust_main() {
|
|||
.register(move || {
|
||||
board::clock::init();
|
||||
info!("ARTIQ satellite manager starting...");
|
||||
info!("software version {}", GIT_COMMIT);
|
||||
info!("software version {}", cfg!(git_describe));
|
||||
info!("gateware version {}", board::ident(&mut [0; 64]));
|
||||
|
||||
loop {
|
||||
|
|
Loading…
Reference in New Issue