Skip to content

Commit

Permalink
Merge pull request #7 from diondokter/develop
Browse files Browse the repository at this point in the history
Update to 2.4.2 and improve build script
  • Loading branch information
diondokter authored Sep 6, 2023
2 parents 1bb0aec + 558a524 commit 2751088
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 60 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

env:
CARGO_TERM_COLOR: always

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt, llvm-tools-preview
targets: thumbv8m.main-none-eabihf

- run: cargo fmt -- --check
- run: cargo clippy --target thumbv8m.main-none-eabihf
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nrfxlib-sys"
version = "2.1.0"
version = "2.4.2"
authors = [
"Jonathan 'theJPster' Pallant <[email protected]>",
"42 Technology Ltd <[email protected]>",
Expand Down Expand Up @@ -36,9 +36,10 @@ include = [

[build-dependencies]
regex = "1"
bindgen = "0.63.0"
bindgen = "0.66.1"
llvm-tools = { version = "0.1.1", optional = true }

[features]
default = ["llvm-objcopy"]
arm-none-eabi-objcopy = []
llvm-objcopy = []
llvm-objcopy = ["dep:llvm-tools"]
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ nrfxlib-sys = "2.1"
Because the modem library has its debug sections compressed and Rust's tooling doesn't have support for
that by default, this crate either strips the debug sections or decompresses them.

By default the crate uses the `llvm-tools` that can be installed using `rustup component add llvm-tools-preview`.
By default the crate uses the `llvm-tools` that can be installed using `rustup component add llvm-tools`.
In this case the debug sections get stripped.

If you'd rather have the debug sections decompressed, then disable the default features on this crate and
Expand Down Expand Up @@ -65,9 +65,14 @@ without any additional terms or conditions.

## Changelog

### Unreleased Changes ([Source](https://github.com/nrf-rs/nrfxlib-sys/tree/master) | [Changes](https://github.com/nrf-rs/nrfxlib-sys/compare/v2.1.0...develop))
### Unreleased Changes ([Source](https://github.com/nrf-rs/nrfxlib-sys/tree/develop) | [Changes](https://github.com/nrf-rs/nrfxlib-sys/compare/v2.4.2...develop))

### v2.1.0 ([Source](https://github.com/nrf-rs/nrfxlib-sys/tree/master) | [Changes](https://github.com/nrf-rs/nrfxlib-sys/compare/v1.4.2...v2.1.0))
### v2.4.2 ([Source](https://github.com/nrf-rs/nrfxlib-sys/tree/v2.4.2) | [Changes](https://github.com/nrf-rs/nrfxlib-sys/compare/v2.1.0...v2.4.2))

* Updated to [nrfxlib v2.4.2](https://github.com/NordicPlayground/nrfxlib/tree/v2.4.2)
* Improved the way the build script searches for `llvm-objcopy`

### v2.1.0 ([Source](https://github.com/nrf-rs/nrfxlib-sys/tree/v2.1.0) | [Changes](https://github.com/nrf-rs/nrfxlib-sys/compare/v1.4.2...v2.1.0))

* Updated to [nrfxlib v2.1.0](https://github.com/NordicPlayground/nrfxlib/tree/v2.1.0)
* Added many oberon crypto functions
Expand Down
31 changes: 19 additions & 12 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ fn main() {
.clang_arg("-mfloat-abi=soft")
// We're no_std
.use_core()
// Use our own ctypes to save using libc
.ctypes_prefix("ctypes")
// Include only the useful stuff
.allowlist_function("nrf_.*")
.allowlist_function("ocrypto_.*")
Expand All @@ -43,7 +41,7 @@ fn main() {
.allowlist_var("BSD_.*")
.allowlist_var("OCRYPTO_.*")
// Format the output
.rustfmt_bindings(true)
.formatter(bindgen::Formatter::Rustfmt)
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.
Expand Down Expand Up @@ -82,12 +80,12 @@ fn main() {

let libmodem_original_path =
Path::new(&nrfxlib_path).join("nrf_modem/lib/cortex-m33/hard-float/libmodem.a");
let libmodem_changed_path =
PathBuf::from(env::var("OUT_DIR").unwrap()).join("libmodem.a");
let libmodem_changed_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("libmodem.a");

// The modem library now has compressed headers, but Rust cannot deal with that.
// If the appropriate features is active, we're gonna strip it or decompress it.
if cfg!(feature = "arm-none-eabi-objcopy") {
#[cfg(feature = "arm-none-eabi-objcopy")]
{
// We assume the arm-none-eabi-objcopy comes from the official arm website.
let child = std::process::Command::new("arm-none-eabi-objcopy")
.arg("--decompress-debug-sections")
Expand All @@ -100,15 +98,25 @@ fn main() {
if !child_result.status.success() {
panic!("Something went wrong with `arm-none-eabi-objcopy`.");
}
} else if cfg!(feature = "llvm-objcopy") {
}
#[cfg(feature = "llvm-objcopy")]
{
// We assume the llvm-objcopy comes from the rustup llvm-tools.
// This cannot do decompression, so we'll just strip the debug sections
let child = std::process::Command::new("llvm-objcopy")

let tool_error = "Could not find `llvm-objcopy`. Is it installed? Use `rustup component add llvm-tools` to install it or select the `arm-none-eabi-objcopy` feature if you have that tool installed.";
// It's not in our path, so we have to search for it
let path = llvm_tools::LlvmTools::new()
.expect(tool_error)
.tool(&llvm_tools::exe("llvm-objcopy"))
.expect(tool_error);

let child = std::process::Command::new(path)
.arg("--strip-debug")
.arg(&libmodem_original_path)
.arg(&libmodem_changed_path)
.spawn()
.expect("Could not start `llvm-objcopy`. Is it installed and available in your path? Use `rustup component add llvm-tools-preview` to install it or select the `arm-none-eabi-objcopy` feature if you have that tool installed.");
.expect(tool_error);

let child_result = child.wait_with_output().unwrap();
if !child_result.status.success() {
Expand All @@ -119,8 +127,7 @@ fn main() {
// Make sure we link against the libraries
println!(
"cargo:rustc-link-search={}",
libmodem_changed_path.parent().unwrap()
.display()
libmodem_changed_path.parent().unwrap().display()
);
println!(
"cargo:rustc-link-search={}",
Expand All @@ -129,5 +136,5 @@ fn main() {
.display()
);
println!("cargo:rustc-link-lib=static=modem");
println!("cargo:rustc-link-lib=static=oberon_3.0.12");
println!("cargo:rustc-link-lib=static=oberon_3.0.13");
}
24 changes: 1 addition & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]

pub mod ctypes {
pub type c_char = u8;
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_int = i32;
pub type c_uint = u32;
pub type c_long = i32;
pub type c_ulong = u32;
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type c_ushort = u16;
pub type c_short = i16;

#[repr(u8)]
pub enum c_void {
// Two dummy variants so the #[repr] attribute can be used.
#[doc(hidden)]
__variant1,
#[doc(hidden)]
__variant2,
}
}
#![allow(clippy::missing_safety_doc)]

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
2 changes: 1 addition & 1 deletion third_party/nordic/nrfxlib
Submodule nrfxlib updated 966 files
17 changes: 11 additions & 6 deletions wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
*/

/*
* libbsd headers
* libmodem headers
*/
#include "nrf_modem/include/nrf_modem.h"
#include "nrf_modem/include/nrf_modem_limits.h"
#include "nrf_modem/include/nrf_modem_full_dfu.h"
#include "nrf_modem/include/nrf_modem_os.h"
#include "nrf_modem/include/nrf_modem_platform.h"
#include "nrf_modem/include/nrf_errno.h"
#include "nrf_modem/include/nrf_socket.h"
#include "nrf_modem/include/nrf_modem_gnss.h"
#include "nrf_modem/include/nrf_modem_delta_dfu.h"
#include "nrf_modem/include/nrf_modem_at.h"
#include "nrf_modem/include/nrf_modem_bootloader.h"
#include "nrf_modem/include/nrf_modem_trace.h"
#include "nrf_modem/include/nrf_gai_errors.h"

/*
Expand Down Expand Up @@ -82,7 +81,6 @@
#include "crypto/nrf_oberon/include/ocrypto_aes_key.h"
#include "crypto/nrf_oberon/include/ocrypto_chacha20.h"
#include "crypto/nrf_oberon/include/ocrypto_chacha20_poly1305.h"
#include "crypto/nrf_oberon/include/ocrypto_chacha20_poly1305_inc.h"
#include "crypto/nrf_oberon/include/ocrypto_constant_time.h"
#include "crypto/nrf_oberon/include/ocrypto_curve_p224.h"
#include "crypto/nrf_oberon/include/ocrypto_curve_p256.h"
Expand All @@ -99,17 +97,24 @@
#include "crypto/nrf_oberon/include/ocrypto_hmac_sha1.h"
#include "crypto/nrf_oberon/include/ocrypto_hmac_sha256.h"
#include "crypto/nrf_oberon/include/ocrypto_hmac_sha512.h"
#include "crypto/nrf_oberon/include/ocrypto_pbkdf2.h"
#include "crypto/nrf_oberon/include/ocrypto_pbkdf2_cmac_prf128.h"
#include "crypto/nrf_oberon/include/ocrypto_pbkdf2_sha1.h"
#include "crypto/nrf_oberon/include/ocrypto_pbkdf2_sha256.h"
#include "crypto/nrf_oberon/include/ocrypto_poly1305.h"
#include "crypto/nrf_oberon/include/ocrypto_rsa.h"
#include "crypto/nrf_oberon/include/ocrypto_rsa_key.h"
#include "crypto/nrf_oberon/include/ocrypto_rsa_operations.h"
#include "crypto/nrf_oberon/include/ocrypto_rsa_padding.h"
#include "crypto/nrf_oberon/include/ocrypto_rsa_primitives.h"
#include "crypto/nrf_oberon/include/ocrypto_sc_p224.h"
#include "crypto/nrf_oberon/include/ocrypto_sc_p256.h"
#include "crypto/nrf_oberon/include/ocrypto_secp160r1.h"
#include "crypto/nrf_oberon/include/ocrypto_sha1.h"
#include "crypto/nrf_oberon/include/ocrypto_sha224.h"
#include "crypto/nrf_oberon/include/ocrypto_sha256.h"
#include "crypto/nrf_oberon/include/ocrypto_sha384.h"
#include "crypto/nrf_oberon/include/ocrypto_sha512.h"
#include "crypto/nrf_oberon/include/ocrypto_spake2p_p256.h"
#include "crypto/nrf_oberon/include/ocrypto_srp.h"
#include "crypto/nrf_oberon/include/ocrypto_srtp.h"
#include "crypto/nrf_oberon/include/ocrypto_types.h"
Expand Down

0 comments on commit 2751088

Please sign in to comment.