diff --git a/.travis.yml b/.travis.yml index e37ff6b203353f0bf0a68ca949a20f249210c5b8..1fce2aec53585e869b58bc7b9fcc6b37f1289855 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,9 @@ matrix: - os: linux env: TARGET=mips-unknown-linux-gnu rust: nightly-2015-09-08 + - os: linux + env: TARGET=DOX + rust: nightly addons: apt: packages: diff --git a/ci/dox.sh b/ci/dox.sh new file mode 100644 index 0000000000000000000000000000000000000000..ec13b062fb5557e9d577ec93c93aa878e0c0a931 --- /dev/null +++ b/ci/dox.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +set -e + +rm -rf target/doc +mkdir -p target/doc + +doc() { + local _target=$1 + echo documenting $_target + rustdoc -o target/doc/$_target --target $_target src/lib.rs --cfg dox +} + +doc x86_64-unknown-linux-gnu +doc i686-unknown-linux-gnu +doc x86_64-apple-darwin +doc i686-apple-darwin +doc x86_64-pc-windows-gnu +doc x86_64-pc-windows-msvc +doc i686-pc-windows-gnu +doc i686-pc-windows-msvc + +doc arm-unknown-linux-gnueabihf +doc mips-unknown-linux-gnu +doc arm-linux-androideabi +doc x86_64-unknown-linux-musl + +cp ci/landing-page.html target/doc/index.html + +if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "autotest" ]; then + pip install ghp-import --user $USER + $HOME/.local/bin/ghp-import -n target/doc + git push -qf https://${TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages +fi diff --git a/ci/run-travis.sh b/ci/run-travis.sh index 20aec65091c19cabb3c7d1fa790dcd15384c031c..bb45dca8eb8d2ec378db8b23c55de2ca3859d241 100644 --- a/ci/run-travis.sh +++ b/ci/run-travis.sh @@ -11,7 +11,9 @@ export HOST=$ARCH-$OS MAIN_TARGETS=https://static.rust-lang.org/dist EXTRA_TARGETS=https://people.mozilla.org/~acrichton/libc-test/2015-09-08 -if [ "$TARGET" = "arm-linux-androideabi" ]; then +if [ "$TARGET" = "DOX" ]; then + exec sh ci/dox.sh +elif [ "$TARGET" = "arm-linux-androideabi" ]; then # Pull a pre-built docker image for testing android, then run tests entirely # within that image. docker pull alexcrichton/rust-libc-test diff --git a/src/dox.rs b/src/dox.rs new file mode 100644 index 0000000000000000000000000000000000000000..92e3edacf87432b1a9bcd3b7645d4b67200bb26f --- /dev/null +++ b/src/dox.rs @@ -0,0 +1,105 @@ +pub use self::imp::*; + +#[cfg(not(dox))] +mod imp { + pub use std::option::Option; + pub use std::clone::Clone; + pub use std::marker::Copy; +} + +#[cfg(dox)] +mod imp { + pub enum Option<T> { + Some(T), + None, + } + + pub trait Clone { + fn clone(&self) -> Self; + } + + #[lang = "copy"] + pub trait Copy {} + + #[lang = "sized"] + pub trait Sized {} + + macro_rules! each_int { + ($mac:ident) => ( + $mac!(u8); + $mac!(u16); + $mac!(u32); + $mac!(u64); + $mac!(usize); + $mac!(i8); + $mac!(i16); + $mac!(i32); + $mac!(i64); + $mac!(isize); + ) + } + + #[lang = "shl"] + pub trait Shl<RHS> { + type Output; + fn shl(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_shl { + ($($i:ident)*) => ($( + impl Shl<$i> for $i { + type Output = $i; + fn shl(self, rhs: $i) -> $i { self << rhs } + } + )*) + } + each_int!(impl_shl); + + #[lang = "mul"] + pub trait Mul<RHS=Self> { + type Output; + fn mul(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_mul { + ($($i:ident)*) => ($( + impl Mul for $i { + type Output = $i; + fn mul(self, rhs: $i) -> $i { self * rhs } + } + )*) + } + each_int!(impl_mul); + + #[lang = "sub"] + pub trait Sub<RHS=Self> { + type Output; + fn sub(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_sub { + ($($i:ident)*) => ($( + impl Sub for $i { + type Output = $i; + fn sub(self, rhs: $i) -> $i { self - rhs } + } + )*) + } + each_int!(impl_sub); + + #[lang = "bitor"] + pub trait Bitor<RHS=Self> { + type Output; + fn bitor(self, rhs: RHS) -> Self::Output; + } + + macro_rules! impl_bitor { + ($($i:ident)*) => ($( + impl Bitor for $i { + type Output = $i; + fn bitor(self, rhs: $i) -> $i { self | rhs } + } + )*) + } + each_int!(impl_bitor); +} diff --git a/src/lib.rs b/src/lib.rs index ded1683d245d2b3a31c23c04ea4263a967f53991..cf2ba526bd4b8dbca30c8e638032b60f4ede02f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,8 +9,16 @@ // except according to those terms. #![allow(bad_style, raw_pointer_derive)] +#![cfg_attr(dox, feature(no_core, lang_items))] +#![cfg_attr(dox, no_core)] +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://doc.rust-lang.org/favicon.ico")] + +#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), + doc(html_root_url = "http://alexcrichton.com/libc/x86_64-unknown-linux-gnu"))] #[macro_use] mod macros; +mod dox; #[repr(u8)] pub enum c_void { diff --git a/src/macros.rs b/src/macros.rs index 0c58de5fd26e5e47b19964b68b10898697474bc2..bb5d9eeadd182cb8dea02f07c7b11f5aa66424e3 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -40,8 +40,8 @@ macro_rules! s { #[repr(C)] pub struct $i { $($field)* } } - impl Copy for $i {} - impl Clone for $i { + impl ::dox::Copy for $i {} + impl ::dox::Clone for $i { fn clone(&self) -> $i { *self } } )*) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index a96361a7c0938ab9ecf5d2405d674d2546b8ba3b..f05e6337cd5db551ad4cb136e22945a6abb1468d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -316,8 +316,8 @@ extern { pub fn freeifaddrs(ifa: *mut ifaddrs); pub fn glob(pattern: *const c_char, flags: c_int, - errfunc: Option<extern "C" fn(epath: *const c_char, - errno: c_int) -> c_int>, + errfunc: ::dox::Option<extern "C" fn(epath: *const c_char, + errno: c_int) -> c_int>, pglob: *mut glob_t); pub fn globfree(pglob: *mut glob_t);