firmware: deduplicate libbuild_misoc and libbuild_artiq.

This commit is contained in:
whitequark 2017-12-28 12:57:40 +00:00
parent 8153cfa88f
commit b9754e7108
9 changed files with 18 additions and 25 deletions

View File

@ -126,7 +126,7 @@ dependencies = [
"alloc_stub 0.0.0", "alloc_stub 0.0.0",
"amp 0.0.0", "amp 0.0.0",
"board 0.0.0", "board 0.0.0",
"build_artiq 0.0.0", "build_misoc 0.0.0",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.0 (git+https://github.com/m-labs/compiler-builtins?rev=97916b1)", "compiler_builtins 0.1.0 (git+https://github.com/m-labs/compiler-builtins?rev=97916b1)",
"cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -185,6 +185,7 @@ dependencies = [
"board 0.0.0", "board 0.0.0",
"board_artiq 0.0.0", "board_artiq 0.0.0",
"build_artiq 0.0.0", "build_artiq 0.0.0",
"build_misoc 0.0.0",
"byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"compiler_builtins 0.1.0 (git+https://github.com/m-labs/compiler-builtins?rev=97916b1)", "compiler_builtins 0.1.0 (git+https://github.com/m-labs/compiler-builtins?rev=97916b1)",
"cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "cslice 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -10,7 +10,7 @@ path = "lib.rs"
crate-type = ["staticlib"] crate-type = ["staticlib"]
[build-dependencies] [build-dependencies]
build_artiq = { path = "../libbuild_artiq" } build_misoc = { path = "../libbuild_misoc" }
[dependencies] [dependencies]
byteorder = { version = "1.0", default-features = false } byteorder = { version = "1.0", default-features = false }

View File

@ -1,6 +1,6 @@
extern crate build_artiq; extern crate build_misoc;
fn main() { fn main() {
build_artiq::misoc_cfg(); build_misoc::cfg();
println!("cargo:rustc-cfg={}", "ksupport"); println!("cargo:rustc-cfg={}", "ksupport");
} }

View File

@ -1,10 +1,9 @@
extern crate build_misoc; extern crate build_misoc;
extern crate build_artiq;
use std::env; use std::env;
use std::fs::File; use std::fs::File;
use std::io::Write; use std::io::Write;
use std::path::PathBuf; use std::path::Path;
use std::process::Command; use std::process::Command;
fn gen_hmc7043_writes() { fn gen_hmc7043_writes() {
@ -19,8 +18,8 @@ fn gen_hmc7043_writes() {
.ok() .ok()
.and_then(|o| String::from_utf8(o.stdout).ok()) .and_then(|o| String::from_utf8(o.stdout).ok())
.unwrap(); .unwrap();
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let out_dir = env::var("OUT_DIR").unwrap();
let mut f = File::create(out_dir.join("hmc7043_writes.rs")).unwrap(); let mut f = File::create(Path::new(&out_dir).join("hmc7043_writes.rs")).unwrap();
write!(f, "{}", hmc7043_writes).unwrap(); write!(f, "{}", hmc7043_writes).unwrap();
} }

View File

@ -2,8 +2,8 @@ extern crate walkdir;
use std::env; use std::env;
use std::fs::File; use std::fs::File;
use std::io::{Write, BufRead, BufReader}; use std::io::Write;
use std::path::{Path, PathBuf}; use std::path::Path;
use std::process::Command; use std::process::Command;
use walkdir::WalkDir; use walkdir::WalkDir;
@ -42,18 +42,7 @@ pub fn git_describe() {
version = "unknown".to_owned(); version = "unknown".to_owned();
} }
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let out_dir = env::var("OUT_DIR").unwrap();
let mut f = File::create(out_dir.join("git-describe")).unwrap(); let mut f = File::create(Path::new(&out_dir).join("git-describe")).unwrap();
write!(f, "{}", version).unwrap(); write!(f, "{}", version).unwrap();
} }
pub fn misoc_cfg() {
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());
}
}

View File

@ -10,6 +10,7 @@ crate-type = ["staticlib"]
path = "main.rs" path = "main.rs"
[build-dependencies] [build-dependencies]
build_misoc = { path = "../libbuild_misoc" }
build_artiq = { path = "../libbuild_artiq" } build_artiq = { path = "../libbuild_artiq" }
[dependencies] [dependencies]

View File

@ -1,6 +1,7 @@
extern crate build_misoc;
extern crate build_artiq; extern crate build_artiq;
fn main() { fn main() {
build_misoc::cfg();
build_artiq::git_describe(); build_artiq::git_describe();
build_artiq::misoc_cfg();
} }

View File

@ -10,6 +10,7 @@ crate-type = ["staticlib"]
path = "main.rs" path = "main.rs"
[build-dependencies] [build-dependencies]
build_misoc = { path = "../libbuild_misoc" }
build_artiq = { path = "../libbuild_artiq" } build_artiq = { path = "../libbuild_artiq" }
[dependencies] [dependencies]

View File

@ -1,6 +1,7 @@
extern crate build_misoc;
extern crate build_artiq; extern crate build_artiq;
fn main() { fn main() {
build_misoc::cfg();
build_artiq::git_describe(); build_artiq::git_describe();
build_artiq::misoc_cfg();
} }