add cargo features for each of the arm/ar interrupt controllers
This commit is contained in:
parent
1a2e750313
commit
35a58297dd
|
@ -35,6 +35,11 @@ panic = "abort"
|
|||
lto = "on"
|
||||
debug = true
|
||||
|
||||
[features]
|
||||
hercules = []
|
||||
sitara-vim = []
|
||||
sitara-intc = []
|
||||
|
||||
[[example]]
|
||||
name = "donate"
|
||||
path = "rust/examples/donate.rs"
|
||||
|
|
|
@ -31,10 +31,34 @@ static PTHREAD_ARCH: Arch = Arch {
|
|||
static ARM_ARCH: Arch = Arch {
|
||||
name: "arm",
|
||||
sources: &["arm.c", "syscall.S", "task_entry.S"],
|
||||
flags: &["-fshort-enums"], // arm-none-eabi-gcc uses this by default, but clang/bindgen don't
|
||||
flags: &["-fshort-enums"], // arm-none-eabi-gcc and rustc use this by default, but clang/bindgen don't
|
||||
defs: &[],
|
||||
};
|
||||
|
||||
struct ArmArFeature<'a> {
|
||||
name: &'a str,
|
||||
path: &'a str,
|
||||
arch_patterns: &'a [&'a str],
|
||||
}
|
||||
|
||||
static ARM_AR_FEATURES: &[ArmArFeature] = &[
|
||||
ArmArFeature {
|
||||
name: "HERCULES",
|
||||
path: "hercules",
|
||||
arch_patterns: &["armebv7r", "armv7r"],
|
||||
},
|
||||
ArmArFeature {
|
||||
name: "SITARA_VIM",
|
||||
path: "sitara/vim",
|
||||
arch_patterns: &["armv7r"],
|
||||
},
|
||||
ArmArFeature {
|
||||
name: "SITARA_INTC",
|
||||
path: "sitara/intc",
|
||||
arch_patterns: &["armv7a"],
|
||||
},
|
||||
];
|
||||
|
||||
fn main() {
|
||||
let root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
|
@ -78,16 +102,16 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: Provide a better way to specify Cortex-A/R variants.
|
||||
if target.contains("armebv7r") {
|
||||
// Assume a big-endian armv7r is a Hercules.
|
||||
cc.include(arch_dir.join("ar/hercules"));
|
||||
} else if target.contains("armv7r") {
|
||||
// Assume a little-endian armv7r is a Sitara w/VIM.
|
||||
cc.include(arch_dir.join("ar/sitara/vim"));
|
||||
} else if target.contains("armv7a") {
|
||||
// Assume a little-endian armv7a is a Sitara w/INTC.
|
||||
cc.include(arch_dir.join("ar/sitara/intc"));
|
||||
let mut arm_ar_feature_already_set = false;
|
||||
for feat in ARM_AR_FEATURES {
|
||||
if env::var(format!("CARGO_FEATURE_{}", feat.name)).is_ok() {
|
||||
// Prevent multiple arm/ar features from being enabled.
|
||||
assert!(!arm_ar_feature_already_set);
|
||||
// Check that the architecture matches what the feature expects.
|
||||
assert!(feat.arch_patterns.iter().any(|pat| target.contains(pat)));
|
||||
cc.include(arch_dir.join("ar").join(feat.path));
|
||||
arm_ar_feature_already_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
cc.compile("rt");
|
||||
|
|
Loading…
Reference in New Issue