aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-06-07 05:18:53 +0200
committerGitHub <[email protected]>2021-06-07 05:18:53 +0200
commitf752700df5a20703a3b4d746a524137ef0972b52 (patch)
tree81d77a250222dc1b239ea563951a0f0cdd9a2e01
parent2685dbfcf4446704cdd18afa7c83247c5fae36cb (diff)
parentb65c3c7160059d43a5535defa505a10b8523d851 (diff)
Merge pull request #229 from embassy-rs/buildrs-macrotables
Use macrotables from build.rs
-rw-r--r--embassy-stm32/Cargo.toml1
-rw-r--r--embassy-stm32/build.rs11
-rw-r--r--embassy-stm32/src/clock.rs2
-rw-r--r--stm32-metapac/Cargo.toml1
-rw-r--r--stm32-metapac/build.rs10
5 files changed, 9 insertions, 16 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index ee0ec1abf..a93fce41e 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -27,6 +27,7 @@ stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", features = ["rt"
27cfg-if = "1.0.0" 27cfg-if = "1.0.0"
28 28
29[build-dependencies] 29[build-dependencies]
30stm32-metapac = { version = "0.1.0", path = "../stm32-metapac", default-features = false }
30serde = { version = "1.0.123", features = [ "derive" ]} 31serde = { version = "1.0.123", features = [ "derive" ]}
31serde_yaml = "0.8.15" 32serde_yaml = "0.8.15"
32 33
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs
index ef60a855a..df8af660b 100644
--- a/embassy-stm32/build.rs
+++ b/embassy-stm32/build.rs
@@ -23,10 +23,13 @@ fn main() {
23 panic!("gen.py exited with {:?}", exit_code) 23 panic!("gen.py exited with {:?}", exit_code)
24 } 24 }
25 25
26 for s in env::var("DEP_STM32_METAPAC_V0.1_CFGS").unwrap().split(",") { 26 stm32_metapac::peripheral_versions!(
27 println!("cargo:rustc-cfg={}", s); 27 ($peri:ident, $version:ident) => {
28 } 28 println!("cargo:rustc-cfg={}", stringify!($peri));
29 println!("cargo:rerun-if-env-changed=DEP_STM32_METAPAC_V0.1_CFGS"); 29 println!("cargo:rustc-cfg={}_{}", stringify!($peri), stringify!($version));
30 };
31 );
32
30 println!("cargo:rerun-if-changed=build.rs"); 33 println!("cargo:rerun-if-changed=build.rs");
31 println!("cargo:rerun-if-changed=gen.py"); 34 println!("cargo:rerun-if-changed=gen.py");
32} 35}
diff --git a/embassy-stm32/src/clock.rs b/embassy-stm32/src/clock.rs
index 694ca666d..075b80118 100644
--- a/embassy-stm32/src/clock.rs
+++ b/embassy-stm32/src/clock.rs
@@ -79,7 +79,7 @@ impl<T: Instance> Clock<T> {
79 // TODO: Temporary until clock code generation is in place 79 // TODO: Temporary until clock code generation is in place
80 pub fn start_tim2(&'static self) { 80 pub fn start_tim2(&'static self) {
81 cfg_if::cfg_if! { 81 cfg_if::cfg_if! {
82 if #[cfg(stm32l0)] { 82 if #[cfg(rcc_l0)] {
83 unsafe { 83 unsafe {
84 let rcc = crate::pac::RCC; 84 let rcc = crate::pac::RCC;
85 rcc.apb1enr() 85 rcc.apb1enr()
diff --git a/stm32-metapac/Cargo.toml b/stm32-metapac/Cargo.toml
index 971d76956..e7f0b22e9 100644
--- a/stm32-metapac/Cargo.toml
+++ b/stm32-metapac/Cargo.toml
@@ -2,7 +2,6 @@
2name = "stm32-metapac" 2name = "stm32-metapac"
3version = "0.1.0" 3version = "0.1.0"
4edition = "2018" 4edition = "2018"
5links = "stm32-metapac-v0.1"
6resolver = "2" 5resolver = "2"
7 6
8[dependencies] 7[dependencies]
diff --git a/stm32-metapac/build.rs b/stm32-metapac/build.rs
index ef95f3313..083e06bfd 100644
--- a/stm32-metapac/build.rs
+++ b/stm32-metapac/build.rs
@@ -132,7 +132,6 @@ fn main() {
132 }; 132 };
133 133
134 let mut peripheral_versions: HashMap<String, String> = HashMap::new(); 134 let mut peripheral_versions: HashMap<String, String> = HashMap::new();
135 let mut cfgs: HashSet<String> = HashSet::new();
136 let mut pin_table: Vec<Vec<String>> = Vec::new(); 135 let mut pin_table: Vec<Vec<String>> = Vec::new();
137 let mut interrupt_table: Vec<Vec<String>> = Vec::new(); 136 let mut interrupt_table: Vec<Vec<String>> = Vec::new();
138 let mut peripherals_table: Vec<Vec<String>> = Vec::new(); 137 let mut peripherals_table: Vec<Vec<String>> = Vec::new();
@@ -148,8 +147,6 @@ fn main() {
148 let gpio_base = chip.peripherals.get(&"GPIOA".to_string()).unwrap().address; 147 let gpio_base = chip.peripherals.get(&"GPIOA".to_string()).unwrap().address;
149 let gpio_stride = 0x400; 148 let gpio_stride = 0x400;
150 149
151 cfgs.insert(chip.family.to_ascii_lowercase().replace("+", "plus"));
152
153 for (name, p) in &chip.peripherals { 150 for (name, p) in &chip.peripherals {
154 let mut ir_peri = ir::Peripheral { 151 let mut ir_peri = ir::Peripheral {
155 name: name.clone(), 152 name: name.clone(),
@@ -176,8 +173,6 @@ fn main() {
176 peripheral_pins_table.push(row); 173 peripheral_pins_table.push(row);
177 } 174 }
178 175
179 cfgs.insert(bi.module.clone());
180 cfgs.insert(format!("{}_{}", bi.module, bi.version));
181 let mut peripheral_row = Vec::new(); 176 let mut peripheral_row = Vec::new();
182 peripheral_row.push(bi.module.clone()); 177 peripheral_row.push(bi.module.clone());
183 peripheral_row.push(name.clone()); 178 peripheral_row.push(name.clone());
@@ -319,9 +314,4 @@ fn main() {
319 .unwrap(); 314 .unwrap();
320 println!("cargo:rustc-link-search={}", out.display()); 315 println!("cargo:rustc-link-search={}", out.display());
321 println!("cargo:rerun-if-changed=build.rs"); 316 println!("cargo:rerun-if-changed=build.rs");
322
323 println!(
324 "cargo:cfgs={}",
325 cfgs.into_iter().collect::<Vec<_>>().join(",")
326 );
327} 317}