Skip to content

Commit e114878

Browse files
committed
s/all/take/g, s/_all/steal/g and tweak CI
1 parent d5c07e9 commit e114878

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ matrix:
4747
os: osx
4848

4949
install:
50-
- sh ci/install.sh
50+
- bash ci/install.sh
5151

5252
script:
5353
- bash ci/script.sh

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ keywords = [
1919
license = "MIT OR Apache-2.0"
2020
name = "svd2rust"
2121
repository = "https://github.com/japaric/svd2rust"
22-
version = "0.11.4"
22+
version = "0.12.0"
2323

2424
[[bin]]
2525
doc = false

ci/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set -ex
1+
set -euxo pipefail
22

33
main() {
44
local sort=

ci/script.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
set -ex
2-
set -o pipefail
1+
set -euxo pipefail
32

43
test_svd() {
54
(
@@ -15,7 +14,7 @@ test_svd() {
1514
}
1615

1716
main() {
18-
cross build --target $TARGET
17+
cross check --target $TARGET
1918

2019
if [ -z $VENDOR ]; then
2120
return
@@ -35,7 +34,7 @@ main() {
3534
# test crate
3635
cargo init --name foo $td
3736
echo 'bare-metal = "0.1.0"' >> $td/Cargo.toml
38-
echo 'cortex-m = "0.3.0"' >> $td/Cargo.toml
37+
echo 'cortex-m = { git = "https://github.com/japaric/cortex-m" }' >> $td/Cargo.toml
3938
echo 'cortex-m-rt = "0.3.0"' >> $td/Cargo.toml
4039
echo 'vcell = "0.1.0"' >> $td/Cargo.toml
4140

@@ -609,6 +608,6 @@ main() {
609608
rm -rf $td
610609
}
611610

612-
if [ -z $TRAVIS_TAG ]; then
611+
if [ -z ${TRAVIS_TAG-} ]; then
613612
main
614613
fi

src/generate.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,11 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
143143
}
144144

145145
items.push(quote! {
146+
// NOTE `no_mangle` is used here to prevent linking different minor versions of the device
147+
// crate as that would let you `take` the device peripherals more than once (one per minor
148+
// version)
146149
#[no_mangle]
147-
static mut PERIPHERALS: bool = false;
150+
static mut DEVICE_PERIPHERALS: bool = false;
148151

149152
/// All the peripherals
150153
#[allow(non_snake_case)]
@@ -154,21 +157,21 @@ pub fn device(d: &Device, target: &Target, items: &mut Vec<Tokens>) -> Result<()
154157

155158
impl Peripherals {
156159
/// Returns all the peripherals *once*
157-
pub fn all() -> Option<Self> {
160+
pub fn take() -> Option<Self> {
158161
cortex_m::interrupt::free(|_| {
159-
if unsafe { PERIPHERALS } {
162+
if unsafe { DEVICE_PERIPHERALS } {
160163
None
161164
} else {
162-
Some(unsafe { Peripherals::_all() })
165+
Some(unsafe { Peripherals::steal() })
163166
}
164167
})
165168
}
166169

167170
#[doc(hidden)]
168-
pub unsafe fn _all() -> Self {
169-
debug_assert!(!PERIPHERALS);
171+
pub unsafe fn steal() -> Self {
172+
debug_assert!(!DEVICE_PERIPHERALS);
170173

171-
PERIPHERALS = true;
174+
DEVICE_PERIPHERALS = true;
172175

173176
Peripherals {
174177
#(#exprs,)*

0 commit comments

Comments
 (0)