make it compatible with no_std environment

This commit is contained in:
joseLuís 2020-08-10 10:57:11 +02:00
parent 8759572632
commit 2fe9e4c22b
5 changed files with 16 additions and 8 deletions

View File

@ -19,7 +19,12 @@ categories = [
keywords = ["tui", "cli", "terminal", "ncurses", "ffi"]
[dependencies]
libc = "0.2.74"
libc = {version = "0.2.74", default-features = false}
cty = "0.2.1"
# blocked by: https://github.com/Amanieu/cstr_core/issues/4
# cstr_core = "0.2"
cstr_core = {path = "../../../../_temp_clones/cstr_core"}
libc-print = "0.1.13"
[build-dependencies]
bindgen = ">= 0.52.0"

View File

@ -21,6 +21,8 @@ fn main() {
// The bindgen::Builder is the main entry point to bindgen, and lets you
// build up options for the resulting bindings.
let mut builder = bindgen::Builder::default()
.use_core()
.ctypes_prefix("cty")
.clang_arg("-D_XOPEN_SOURCE")
// The input header we would like to generate
// builder for.

View File

@ -26,7 +26,7 @@
// - ? gcluster (&str) > type alias?
// - ? attr (u32) > type alias?
use std::ffi::CString;
use cstr_core::CString;
use crate as ffi;
use crate::types::{ChannelPair, IntResult};
@ -101,7 +101,6 @@ pub fn cells_load_box(
// return -1;
// }
// static inline void
// cell_init(cell* c){
// memset(c, 0, sizeof(*c));

View File

@ -1,6 +1,7 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![no_std]
mod cells;
mod channels;
@ -15,9 +16,10 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
#[cfg(test)]
mod tests {
use std::ffi::{CStr, CString};
use std::ptr::{null, null_mut};
use core::ptr::{null, null_mut};
use cstr_core::{CStr, CString};
use libc_print::*;
use serial_test::serial; // serialize tests w/ ffi::notcurses_init()
use crate as ffi;
@ -31,7 +33,7 @@ mod tests {
CStr::from_ptr(s)
};
let r_str = c_str.to_str().unwrap();
println!("rust-bound notcurses v{}", r_str);
libc_println!("rust-bound notcurses v{}", r_str);
}
#[test]

View File

@ -5,8 +5,8 @@
// - ncplane_dim_x
// - ncplane_perimeter
use std::ffi::CString;
use std::ptr::null_mut;
use core::ptr::null_mut;
use cstr_core::CString;
use crate as ffi;
use ffi::types::IntResult;