From b9754e710871552b1144a6c59e137b63f73eebfa Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 28 Dec 2017 12:57:40 +0000 Subject: [PATCH] firmware: deduplicate libbuild_misoc and libbuild_artiq. --- artiq/firmware/Cargo.lock | 3 ++- artiq/firmware/ksupport/Cargo.toml | 2 +- artiq/firmware/ksupport/build.rs | 4 ++-- artiq/firmware/libboard_artiq/build.rs | 7 +++---- artiq/firmware/libbuild_artiq/lib.rs | 19 ++++--------------- artiq/firmware/runtime/Cargo.toml | 1 + artiq/firmware/runtime/build.rs | 3 ++- artiq/firmware/satman/Cargo.toml | 1 + artiq/firmware/satman/build.rs | 3 ++- 9 files changed, 18 insertions(+), 25 deletions(-) diff --git a/artiq/firmware/Cargo.lock b/artiq/firmware/Cargo.lock index a60de7ea9..794b0e2d3 100644 --- a/artiq/firmware/Cargo.lock +++ b/artiq/firmware/Cargo.lock @@ -126,7 +126,7 @@ dependencies = [ "alloc_stub 0.0.0", "amp 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)", "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)", @@ -185,6 +185,7 @@ dependencies = [ "board 0.0.0", "board_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)", "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)", diff --git a/artiq/firmware/ksupport/Cargo.toml b/artiq/firmware/ksupport/Cargo.toml index 1162a848c..b295c160c 100644 --- a/artiq/firmware/ksupport/Cargo.toml +++ b/artiq/firmware/ksupport/Cargo.toml @@ -10,7 +10,7 @@ path = "lib.rs" crate-type = ["staticlib"] [build-dependencies] -build_artiq = { path = "../libbuild_artiq" } +build_misoc = { path = "../libbuild_misoc" } [dependencies] byteorder = { version = "1.0", default-features = false } diff --git a/artiq/firmware/ksupport/build.rs b/artiq/firmware/ksupport/build.rs index 6f802af66..ab6acff39 100644 --- a/artiq/firmware/ksupport/build.rs +++ b/artiq/firmware/ksupport/build.rs @@ -1,6 +1,6 @@ -extern crate build_artiq; +extern crate build_misoc; fn main() { - build_artiq::misoc_cfg(); + build_misoc::cfg(); println!("cargo:rustc-cfg={}", "ksupport"); } diff --git a/artiq/firmware/libboard_artiq/build.rs b/artiq/firmware/libboard_artiq/build.rs index 225cf707a..508c9f935 100644 --- a/artiq/firmware/libboard_artiq/build.rs +++ b/artiq/firmware/libboard_artiq/build.rs @@ -1,10 +1,9 @@ extern crate build_misoc; -extern crate build_artiq; use std::env; use std::fs::File; use std::io::Write; -use std::path::PathBuf; +use std::path::Path; use std::process::Command; fn gen_hmc7043_writes() { @@ -19,8 +18,8 @@ fn gen_hmc7043_writes() { .ok() .and_then(|o| String::from_utf8(o.stdout).ok()) .unwrap(); - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - let mut f = File::create(out_dir.join("hmc7043_writes.rs")).unwrap(); + let out_dir = env::var("OUT_DIR").unwrap(); + let mut f = File::create(Path::new(&out_dir).join("hmc7043_writes.rs")).unwrap(); write!(f, "{}", hmc7043_writes).unwrap(); } diff --git a/artiq/firmware/libbuild_artiq/lib.rs b/artiq/firmware/libbuild_artiq/lib.rs index 2eb27a040..cd35a30a8 100644 --- a/artiq/firmware/libbuild_artiq/lib.rs +++ b/artiq/firmware/libbuild_artiq/lib.rs @@ -2,8 +2,8 @@ extern crate walkdir; use std::env; use std::fs::File; -use std::io::{Write, BufRead, BufReader}; -use std::path::{Path, PathBuf}; +use std::io::Write; +use std::path::Path; use std::process::Command; use walkdir::WalkDir; @@ -42,18 +42,7 @@ pub fn git_describe() { version = "unknown".to_owned(); } - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - let mut f = File::create(out_dir.join("git-describe")).unwrap(); + let out_dir = env::var("OUT_DIR").unwrap(); + let mut f = File::create(Path::new(&out_dir).join("git-describe")).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()); - } -} diff --git a/artiq/firmware/runtime/Cargo.toml b/artiq/firmware/runtime/Cargo.toml index 6753261cd..5802b84b2 100644 --- a/artiq/firmware/runtime/Cargo.toml +++ b/artiq/firmware/runtime/Cargo.toml @@ -10,6 +10,7 @@ crate-type = ["staticlib"] path = "main.rs" [build-dependencies] +build_misoc = { path = "../libbuild_misoc" } build_artiq = { path = "../libbuild_artiq" } [dependencies] diff --git a/artiq/firmware/runtime/build.rs b/artiq/firmware/runtime/build.rs index d9df648a6..64a84fcb8 100644 --- a/artiq/firmware/runtime/build.rs +++ b/artiq/firmware/runtime/build.rs @@ -1,6 +1,7 @@ +extern crate build_misoc; extern crate build_artiq; fn main() { + build_misoc::cfg(); build_artiq::git_describe(); - build_artiq::misoc_cfg(); } diff --git a/artiq/firmware/satman/Cargo.toml b/artiq/firmware/satman/Cargo.toml index be6abc55f..7cab6d4c1 100644 --- a/artiq/firmware/satman/Cargo.toml +++ b/artiq/firmware/satman/Cargo.toml @@ -10,6 +10,7 @@ crate-type = ["staticlib"] path = "main.rs" [build-dependencies] +build_misoc = { path = "../libbuild_misoc" } build_artiq = { path = "../libbuild_artiq" } [dependencies] diff --git a/artiq/firmware/satman/build.rs b/artiq/firmware/satman/build.rs index d9df648a6..64a84fcb8 100644 --- a/artiq/firmware/satman/build.rs +++ b/artiq/firmware/satman/build.rs @@ -1,6 +1,7 @@ +extern crate build_misoc; extern crate build_artiq; fn main() { + build_misoc::cfg(); build_artiq::git_describe(); - build_artiq::misoc_cfg(); }