Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,34 @@ repository = "https://github.com/thejpster/tinyrlibc"

[build-dependencies]
cc = "1.0"

[features]
default = ["all"]
all = [
"abs",
"strcmp",
"strncmp",
"strcpy",
"strncpy",
"strlen",
"strtol",
"strtoul",
"strstr",
"strchr",
"atoi",
"itoa",
"snprintf",
]
abs = []
strcmp = []
strncmp = []
strcpy = []
strncpy = []
strlen = []
strtol = []
strtoul = []
strstr = []
strchr = []
atoi = []
itoa = []
snprintf = []
16 changes: 9 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
fn main() {
// Build our snprintf substitute (which has to be C as Rust doesn't do varargs)
cc::Build::new()
.warnings(true)
.extra_warnings(true)
.flag("-std=c99")
.file("./src/snprintf.c")
.compile("clocal");
if cfg!(feature = "snprintf") {
// Build our snprintf substitute (which has to be C as Rust doesn't do varargs)
cc::Build::new()
.warnings(true)
.extra_warnings(true)
.flag("-std=c99")
.file("./src/snprintf.c")
.compile("clocal");
}
}
25 changes: 25 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,67 @@
#[allow(unused_imports)]
use std as core;

#[cfg(feature = "abs")]
mod abs;
#[cfg(feature = "abs")]
pub use self::abs::abs;

#[cfg(feature = "strcmp")]
mod strcmp;
#[cfg(feature = "strcmp")]
pub use self::strcmp::strcmp;

#[cfg(feature = "strncmp")]
mod strncmp;
#[cfg(feature = "strncmp")]
pub use self::strncmp::strncmp;

#[cfg(feature = "strcpy")]
mod strcpy;
#[cfg(feature = "strcpy")]
pub use self::strcpy::strcpy;

#[cfg(feature = "strncpy")]
mod strncpy;
#[cfg(feature = "strncpy")]
pub use self::strncpy::strncpy;

#[cfg(feature = "strlen")]
mod strlen;
#[cfg(feature = "strlen")]
pub use self::strlen::strlen;

#[cfg(feature = "strtol")]
mod strtol;
#[cfg(feature = "strtol")]
pub use self::strtol::strtol;

#[cfg(feature = "strtoul")]
mod strtoul;
#[cfg(feature = "strtoul")]
pub use self::strtoul::strtoul;

#[cfg(feature = "strstr")]
mod strstr;
#[cfg(feature = "strstr")]
pub use self::strstr::strstr;

#[cfg(feature = "strchr")]
mod strchr;
#[cfg(feature = "strchr")]
pub use self::strchr::strchr;

#[cfg(feature = "atoi")]
mod atoi;
#[cfg(feature = "atoi")]
pub use self::atoi::atoi;

#[cfg(feature = "itoa")]
mod itoa;
#[cfg(feature = "itoa")]
pub use self::itoa::itoa;

#[cfg(feature = "snprintf")]
mod snprintf;

/// `long long int`
Expand Down