mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
format utralib
formatting of generated files is suppressed with a `rustfmt::skip` directive on the `mod` import. HOWEVER, if a change is made to the file and saved, it may still be formatted automatically until the files are updated with codegens that put a format suppression directive at the top
This commit is contained in:
parent
c86df3eae8
commit
01853a500d
2 changed files with 46 additions and 45 deletions
|
|
@ -1,13 +1,11 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::OpenOptions;
|
use std::fs::OpenOptions;
|
||||||
use std::io::Write;
|
|
||||||
#[cfg(not(feature = "hosted"))]
|
#[cfg(not(feature = "hosted"))]
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
use std::io::Write;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn out_dir() -> PathBuf {
|
fn out_dir() -> PathBuf { PathBuf::from(env::var_os("OUT_DIR").unwrap()) }
|
||||||
PathBuf::from(env::var_os("OUT_DIR").unwrap())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Helper macro that returns a constant number of features enabled among specified list.
|
/// Helper macro that returns a constant number of features enabled among specified list.
|
||||||
macro_rules! count_enabled_features {
|
macro_rules! count_enabled_features {
|
||||||
|
|
@ -85,14 +83,17 @@ fn main() {
|
||||||
// This script retains the use of an explicit "hosted" flag because we want to catch
|
// This script retains the use of an explicit "hosted" flag because we want to catch
|
||||||
// unintentional build system misconfigurations that meant to build for a target other
|
// unintentional build system misconfigurations that meant to build for a target other
|
||||||
// than "hosted", rather than just falling back silently to defaults.
|
// than "hosted", rather than just falling back silently to defaults.
|
||||||
allow_single_target_feature!("precursor", "hosted", "renode", "atsama5d27", "cramium-soc", "cramium-fpga");
|
allow_single_target_feature!(
|
||||||
|
"precursor",
|
||||||
|
"hosted",
|
||||||
|
"renode",
|
||||||
|
"atsama5d27",
|
||||||
|
"cramium-soc",
|
||||||
|
"cramium-fpga"
|
||||||
|
);
|
||||||
|
|
||||||
#[cfg(feature = "precursor")]
|
#[cfg(feature = "precursor")]
|
||||||
allow_single_gitrev_feature!(
|
allow_single_gitrev_feature!("precursor-perflib", "precursor-dvt", "precursor-pvt");
|
||||||
"precursor-perflib",
|
|
||||||
"precursor-dvt",
|
|
||||||
"precursor-pvt"
|
|
||||||
);
|
|
||||||
|
|
||||||
// ----- select an SVD file based on a specific revision -----
|
// ----- select an SVD file based on a specific revision -----
|
||||||
#[cfg(feature = "precursor-perflib")]
|
#[cfg(feature = "precursor-perflib")]
|
||||||
|
|
@ -141,10 +142,7 @@ fn main() {
|
||||||
let mut svd_files = Vec::new();
|
let mut svd_files = Vec::new();
|
||||||
for svd in svd_filenames.iter() {
|
for svd in svd_filenames.iter() {
|
||||||
let svd_file_path = std::path::Path::new(&svd);
|
let svd_file_path = std::path::Path::new(&svd);
|
||||||
println!(
|
println!("cargo:rerun-if-changed={}", svd_file_path.canonicalize().unwrap().display());
|
||||||
"cargo:rerun-if-changed={}",
|
|
||||||
svd_file_path.canonicalize().unwrap().display()
|
|
||||||
);
|
|
||||||
svd_files.push(std::fs::File::open(svd_file_path).unwrap());
|
svd_files.push(std::fs::File::open(svd_file_path).unwrap());
|
||||||
}
|
}
|
||||||
// Regenerate the utra file in RAM.
|
// Regenerate the utra file in RAM.
|
||||||
|
|
@ -156,17 +154,16 @@ fn main() {
|
||||||
// If the file doesn't exist, or if it's different, write out a new utra file.
|
// If the file doesn't exist, or if it's different, write out a new utra file.
|
||||||
let should_write = if let Ok(mut existing_file) = std::fs::File::open(generated_filename) {
|
let should_write = if let Ok(mut existing_file) = std::fs::File::open(generated_filename) {
|
||||||
let mut existing_file_contents = vec![];
|
let mut existing_file_contents = vec![];
|
||||||
existing_file.read_to_end(&mut existing_file_contents).expect("couldn't read existing utra generated file");
|
existing_file
|
||||||
|
.read_to_end(&mut existing_file_contents)
|
||||||
|
.expect("couldn't read existing utra generated file");
|
||||||
existing_file_contents != dest_vec
|
existing_file_contents != dest_vec
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
if should_write {
|
if should_write {
|
||||||
let mut dest_file =
|
let mut dest_file = std::fs::File::create(generated_filename).expect("couldn't open dest file");
|
||||||
std::fs::File::create(generated_filename).expect("couldn't open dest file");
|
dest_file.write_all(&dest_vec).expect("couldn't write contents to utra file");
|
||||||
dest_file
|
|
||||||
.write_all(&dest_vec)
|
|
||||||
.expect("couldn't write contents to utra file");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- feedback SVD path to build framework -----
|
// ----- feedback SVD path to build framework -----
|
||||||
|
|
@ -178,12 +175,7 @@ fn main() {
|
||||||
// decode their addresses (this would be in anticipation of potential hardware bugs; ideally
|
// decode their addresses (this would be in anticipation of potential hardware bugs; ideally
|
||||||
// this isn't ever a problem).
|
// this isn't ever a problem).
|
||||||
let svd_path = out_dir().join("../../SVD_PATH");
|
let svd_path = out_dir().join("../../SVD_PATH");
|
||||||
let mut svd_file = OpenOptions::new()
|
let mut svd_file = OpenOptions::new().create(true).write(true).truncate(true).open(svd_path).unwrap();
|
||||||
.create(true)
|
|
||||||
.write(true)
|
|
||||||
.truncate(true)
|
|
||||||
.open(svd_path)
|
|
||||||
.unwrap();
|
|
||||||
for svd in svd_filenames.iter() {
|
for svd in svd_filenames.iter() {
|
||||||
writeln!(svd_file, "utralib/{}", svd).unwrap();
|
writeln!(svd_file, "utralib/{}", svd).unwrap();
|
||||||
}
|
}
|
||||||
|
|
@ -191,12 +183,7 @@ fn main() {
|
||||||
#[cfg(feature = "hosted")]
|
#[cfg(feature = "hosted")]
|
||||||
{
|
{
|
||||||
let svd_path = out_dir().join("../../SVD_PATH");
|
let svd_path = out_dir().join("../../SVD_PATH");
|
||||||
let mut svd_file = OpenOptions::new()
|
let mut svd_file = OpenOptions::new().create(true).write(true).truncate(true).open(svd_path).unwrap();
|
||||||
.create(true)
|
|
||||||
.write(true)
|
|
||||||
.truncate(true)
|
|
||||||
.open(svd_path)
|
|
||||||
.unwrap();
|
|
||||||
write!(svd_file, "").unwrap(); // there is no SVD file for hosted mode
|
write!(svd_file, "").unwrap(); // there is no SVD file for hosted mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,53 @@
|
||||||
// Feature flags are checked inside build.rs for sanity, so we
|
// Feature flags are checked inside build.rs for sanity, so we
|
||||||
// can use them here assuming all targets are mutually exclusive.
|
// can use them here assuming all targets are mutually exclusive.
|
||||||
|
|
||||||
#[cfg(feature="precursor-perflib")]
|
#[cfg(feature = "precursor-perflib")]
|
||||||
|
#[rustfmt::skip]
|
||||||
mod precursor_perf;
|
mod precursor_perf;
|
||||||
#[cfg(feature="precursor-perflib")]
|
#[cfg(feature = "precursor-perflib")]
|
||||||
|
#[rustfmt::skip]
|
||||||
pub use precursor_perf::*;
|
pub use precursor_perf::*;
|
||||||
|
|
||||||
#[cfg(feature="precursor-dvt")]
|
#[cfg(feature = "precursor-dvt")]
|
||||||
|
#[rustfmt::skip]
|
||||||
mod precursor_dvt;
|
mod precursor_dvt;
|
||||||
#[cfg(feature="precursor-dvt")]
|
#[cfg(feature = "precursor-dvt")]
|
||||||
|
#[rustfmt::skip]
|
||||||
pub use precursor_dvt::*;
|
pub use precursor_dvt::*;
|
||||||
|
|
||||||
#[cfg(feature="renode")]
|
#[cfg(feature = "renode")]
|
||||||
|
#[rustfmt::skip]
|
||||||
mod renode;
|
mod renode;
|
||||||
#[cfg(feature="renode")]
|
#[cfg(feature = "renode")]
|
||||||
|
#[rustfmt::skip]
|
||||||
pub use renode::*;
|
pub use renode::*;
|
||||||
|
|
||||||
#[cfg(feature="precursor-pvt")]
|
#[cfg(feature = "precursor-pvt")]
|
||||||
|
#[rustfmt::skip]
|
||||||
mod precursor_pvt;
|
mod precursor_pvt;
|
||||||
#[cfg(feature="precursor-pvt")]
|
#[cfg(feature = "precursor-pvt")]
|
||||||
|
#[rustfmt::skip]
|
||||||
pub use precursor_pvt::*;
|
pub use precursor_pvt::*;
|
||||||
|
|
||||||
#[cfg(feature = "atsama5d27")]
|
#[cfg(feature = "atsama5d27")]
|
||||||
|
#[rustfmt::skip]
|
||||||
mod atsama5d27;
|
mod atsama5d27;
|
||||||
#[cfg(feature = "atsama5d27")]
|
#[cfg(feature = "atsama5d27")]
|
||||||
|
#[rustfmt::skip]
|
||||||
pub use atsama5d27::*;
|
pub use atsama5d27::*;
|
||||||
|
|
||||||
#[cfg(feature="cramium-soc")]
|
#[cfg(feature = "cramium-soc")]
|
||||||
|
#[rustfmt::skip]
|
||||||
mod cramium_soc;
|
mod cramium_soc;
|
||||||
#[cfg(feature="cramium-soc")]
|
#[cfg(feature = "cramium-soc")]
|
||||||
|
#[rustfmt::skip]
|
||||||
pub use cramium_soc::*;
|
pub use cramium_soc::*;
|
||||||
|
|
||||||
#[cfg(feature="cramium-fpga")]
|
#[cfg(feature = "cramium-fpga")]
|
||||||
|
#[rustfmt::skip]
|
||||||
mod cramium_fpga;
|
mod cramium_fpga;
|
||||||
#[cfg(feature="cramium-fpga")]
|
#[cfg(feature = "cramium-fpga")]
|
||||||
|
#[rustfmt::skip]
|
||||||
pub use cramium_fpga::*;
|
pub use cramium_fpga::*;
|
||||||
|
|
||||||
// Hosted mode includes nothing, as it relies on the abstract host
|
// Hosted mode includes nothing, as it relies on the abstract host
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue