Browse Source

Build ctype with header

Jeremy Soller 7 years ago
parent
commit
c4b88cc1e6
8 changed files with 121 additions and 76 deletions
  1. 9 0
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 11 0
      src/ctype/Cargo.toml
  4. 11 0
      src/ctype/build.rs
  5. 6 0
      src/ctype/cbindgen.toml
  6. 82 0
      src/ctype/src/lib.rs
  7. 1 0
      src/lib.rs
  8. 0 76
      src/todo/ctype/lib.rs

+ 9 - 0
Cargo.lock

@@ -62,6 +62,14 @@ dependencies = [
  "platform 0.1.0",
 ]
 
+[[package]]
+name = "ctype"
+version = "0.1.0"
+dependencies = [
+ "cbindgen 0.5.0",
+ "platform 0.1.0",
+]
+
 [[package]]
 name = "dtoa"
 version = "0.4.2"
@@ -212,6 +220,7 @@ name = "relibc"
 version = "0.1.0"
 dependencies = [
  "compiler_builtins 0.1.0 (git+https://github.com/rust-lang-nursery/compiler-builtins.git)",
+ "ctype 0.1.0",
  "fcntl 0.1.0",
  "platform 0.1.0",
  "stdio 0.1.0",

+ 1 - 0
Cargo.toml

@@ -13,6 +13,7 @@ members = ["crt0"]
 [dependencies]
 compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins.git", default-features = false, features = ["mem"] }
 platform = { path = "platform" }
+ctype = { path = "src/ctype" }
 fcntl = { path = "src/fcntl" }
 stdio = { path = "src/stdio" }
 stdlib = { path = "src/stdlib" }

+ 11 - 0
src/ctype/Cargo.toml

@@ -0,0 +1,11 @@
+[package]
+name = "ctype"
+version = "0.1.0"
+authors = ["Jeremy Soller <jackpot51@gmail.com>"]
+build = "build.rs"
+
+[build-dependencies]
+cbindgen = { path = "../../cbindgen" }
+
+[dependencies]
+platform = { path = "../../platform" }

+ 11 - 0
src/ctype/build.rs

@@ -0,0 +1,11 @@
+extern crate cbindgen;
+
+use std::{env, fs};
+
+fn main() {
+    let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
+    fs::create_dir_all("../../target/include").expect("failed to create include directory");
+    cbindgen::generate(crate_dir)
+      .expect("failed to generate bindings")
+      .write_to_file("../../target/include/ctype.h");
+}

+ 6 - 0
src/ctype/cbindgen.toml

@@ -0,0 +1,6 @@
+sys_includes = []
+include_guard = "_CTYPE_H"
+language = "C"
+
+[enum]
+prefix_with_name = true

+ 82 - 0
src/ctype/src/lib.rs

@@ -0,0 +1,82 @@
+//! ctype implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/ctype.h.html
+
+#![no_std]
+
+extern crate platform;
+
+use platform::types::*;
+
+#[no_mangle]
+pub extern "C" fn isalnum(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn isalpha(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn isascii(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn iscntrl(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn isdigit(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn isgraph(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn islower(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn isprint(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn ispunct(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn isspace(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn isupper(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn isxdigit(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn toascii(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn tolower(c: c_int) -> c_int {
+    unimplemented!();
+}
+
+#[no_mangle]
+pub extern "C" fn toupper(c: c_int) -> c_int {
+    unimplemented!();
+}

+ 1 - 0
src/lib.rs

@@ -4,6 +4,7 @@
 extern crate compiler_builtins;
 extern crate platform;
 
+extern crate ctype;
 extern crate fcntl;
 extern crate stdio;
 extern crate stdlib;

+ 0 - 76
src/todo/ctype/lib.rs

@@ -1,76 +0,0 @@
-/* automatically generated by rust-bindgen */
-
-#[no_mangle]
-pub extern "C" fn isalnum(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn isalpha(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn isascii(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn iscntrl(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn isdigit(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn isgraph(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn islower(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn isprint(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn ispunct(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn isspace(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn isupper(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn isxdigit(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn toascii(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn tolower(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}
-
-#[no_mangle]
-pub extern "C" fn toupper(c: libc::c_int) -> libc::c_int {
-    unimplemented!();
-}