jamesmunns / nrf52dk-sys

A Rust Crate to develop on the Nordic nRF52-DK
MIT License
85 stars 19 forks source link

Refactor build.rs and sdk configuration, update bindgen #9

Closed anxiousmodernman closed 6 years ago

anxiousmodernman commented 6 years ago

Changes to build.rs and related:

We now crawl dirs to find things to add into the build. The moves us closer to being able to easily swap newer versions of the SDK published by Nordic.

Some C source files are removed that cannot compile due to missing external deps on things that aren't already bundled in the repo.

Generate app_config.h and add feature configuration via Cargo.

The extract-features.py script extracts a set of configuration names from the sdk_config.h header file and emits feature definitions that are intended to replace the features section at the bottom of Cargo.toml. We can check good defaults in, and keep the python script around for reference.

This enables building the library to suit the nRF board you have:

xargo build --example blinky --release --features TWI

Users of our crate can also specify features for our crate in Cargo.toml

UPGRADE BINDGEN

Upgrade bindgen to 0.31.3 and bump our version to 0.2.0

Changes to generated code yield breaking changes in our library, so we must bump versions.

We blacklist IRQn_Type and provide our own implementation

IRQn_Type is an enum in components/device/nrf52.h

We need the members to be Rust i8, but this conflicts with bindgen's requirement to get the enum's type from ctypes::c_schar a u8.

Changing our c_schar to i8 breaks a lot of stuff, so we can provide our own type alias to an i8, and all the constants.

Other changes: