Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out capi targets: make separate freertos, staticlib, and cdylib crates as targets #1747

Merged
merged 14 commits into from
Mar 29, 2022
5 changes: 4 additions & 1 deletion ffi/diplomat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ skip_optional_dependencies = true
# Bench feature gets tested separately and is only relevant for CI.
# x86tiny is not relevant in normal environments,
# smaller_static gets tested on the FFI job anyway
denylist = ["bench", "x86tiny", "smaller_static"]
denylist = ["bench", "x86tiny", "smaller_static", "internal_all_features_hack"]

[lib]
crate-type = ["rlib"]
Expand All @@ -47,6 +47,9 @@ provider_static = ["icu_testdata"]
smaller_static = ["provider_static"]
# Enables size-optimized builds on x86_64
x86tiny = ["dlmalloc"]
# We can't exclude x86tiny from `--all-features` and it messes up the build for other crates
# Instead, we use this feature to detect when `--all-features` is occurring
internal_all_features_hack = []
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really have a good way to opt out of --all-features


[dependencies]
fixed_decimal = { path = "../../utils/fixed_decimal", features = ["ryu"] }
Expand Down
4 changes: 2 additions & 2 deletions ffi/diplomat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)]
#![allow(clippy::upper_case_acronyms)]
#![cfg_attr(
any(feature = "x86tiny", target_os = "none"),
all(feature = "x86tiny", not(feature = "internal_all_features_hack")),
feature(alloc_error_handler)
)]

Expand Down Expand Up @@ -54,5 +54,5 @@ pub mod segmenter_line;
#[cfg(target_arch = "wasm32")]
mod wasm_glue;

#[cfg(all(feature = "x86tiny", not(target_os = "none")))]
#[cfg(all(feature = "x86tiny", not(feature = "internal_all_features_hack")))]
mod x86tiny_glue;
42 changes: 26 additions & 16 deletions ffi/freertos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// https://github.com/unicode-org/icu4x/blob/main/docs/process/boilerplate.md#library-annotations
#![no_std]

#![cfg_attr(
not(test),
deny(
Expand All @@ -14,28 +15,37 @@
)
)]
#![allow(clippy::upper_case_acronyms)]
#![feature(alloc_error_handler)]

extern crate alloc;

#![cfg_attr(target_os = "none", feature(alloc_error_handler))]

// Necessary to for symbols to be linked in
extern crate icu_capi;

use alloc::alloc::Layout;
use core::panic::PanicInfo;
use cortex_m::asm;
use freertos_rust::FreeRtosAllocator;
// CFG it off so that it doesn't break the --all-features build due to needing unstable rust
#[cfg(target_os = "none")]
mod stuff {
extern crate alloc;

#[global_allocator]
static GLOBAL: FreeRtosAllocator = FreeRtosAllocator;

#[alloc_error_handler]
fn alloc_error(_layout: Layout) -> ! {
asm::bkpt();
loop {}
}
use alloc::alloc::Layout;
use core::panic::PanicInfo;
use cortex_m::asm;
use freertos_rust::FreeRtosAllocator;

#[global_allocator]
static GLOBAL: FreeRtosAllocator = FreeRtosAllocator;


#[alloc_error_handler]
fn alloc_error(_layout: Layout) -> ! {
asm::bkpt();
loop {}
}

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
#[cfg(target_os = "none")]
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
}