diff options
| author | bors <bors@rust-lang.org> | 2017-11-25 19:00:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-25 19:00:45 +0000 |
| commit | e97ba83287a6f0f85cc9cc7a51ab309487e17038 (patch) | |
| tree | 33ac3daabb387d2ebd128d5f2ae6e9637318a752 /src/libstd | |
| parent | 2f47a9eb80bc3474b6e89637269ef1f92cfccb7f (diff) | |
| parent | 48996f9e759912140ccc98072e9e55fa6480a9d7 (diff) | |
| download | rust-e97ba83287a6f0f85cc9cc7a51ab309487e17038.tar.gz rust-e97ba83287a6f0f85cc9cc7a51ab309487e17038.zip | |
Auto merge of #46115 - alexcrichton:add-wasm-target, r=kennytm
rustbuild: Enable WebAssembly backend by default This commit alters how we compile LLVM by default enabling the WebAssembly backend. This then also adds the wasm32-unknown-unknown target to get compiled on the `cross` builder and distributed through rustup. Tests are not yet enabled for this target but that should hopefully be coming soon!
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/os/mod.rs | 78 | ||||
| -rw-r--r-- | src/libstd/sys/mod.rs | 109 |
2 files changed, 111 insertions, 76 deletions
diff --git a/src/libstd/os/mod.rs b/src/libstd/os/mod.rs index 122f15d1d4c..ac7809451d1 100644 --- a/src/libstd/os/mod.rs +++ b/src/libstd/os/mod.rs @@ -13,35 +13,53 @@ #![stable(feature = "os", since = "1.0.0")] #![allow(missing_docs, bad_style, missing_debug_implementations)] -#[cfg(all(not(dox), any(target_os = "redox", unix)))] -#[stable(feature = "rust1", since = "1.0.0")] -pub use sys::ext as unix; -#[cfg(all(not(dox), windows))] -#[stable(feature = "rust1", since = "1.0.0")] -pub use sys::ext as windows; - -#[cfg(dox)] -#[stable(feature = "rust1", since = "1.0.0")] -pub use sys::unix_ext as unix; -#[cfg(dox)] -#[stable(feature = "rust1", since = "1.0.0")] -pub use sys::windows_ext as windows; - -#[cfg(any(dox, target_os = "linux", target_os = "l4re"))] -#[doc(cfg(target_os = "linux"))] -pub mod linux; - -#[cfg(all(not(dox), target_os = "android"))] pub mod android; -#[cfg(all(not(dox), target_os = "bitrig"))] pub mod bitrig; -#[cfg(all(not(dox), target_os = "dragonfly"))] pub mod dragonfly; -#[cfg(all(not(dox), target_os = "freebsd"))] pub mod freebsd; -#[cfg(all(not(dox), target_os = "haiku"))] pub mod haiku; -#[cfg(all(not(dox), target_os = "ios"))] pub mod ios; -#[cfg(all(not(dox), target_os = "macos"))] pub mod macos; -#[cfg(all(not(dox), target_os = "netbsd"))] pub mod netbsd; -#[cfg(all(not(dox), target_os = "openbsd"))] pub mod openbsd; -#[cfg(all(not(dox), target_os = "solaris"))] pub mod solaris; -#[cfg(all(not(dox), target_os = "emscripten"))] pub mod emscripten; -#[cfg(all(not(dox), target_os = "fuchsia"))] pub mod fuchsia; +cfg_if! { + if #[cfg(dox)] { + + // When documenting libstd we want to show unix/windows/linux modules as + // these are the "main modules" that are used across platforms. This + // should help show platform-specific functionality in a hopefully + // cross-platform way in the documentation + + #[stable(feature = "rust1", since = "1.0.0")] + pub use sys::unix_ext as unix; + + #[stable(feature = "rust1", since = "1.0.0")] + pub use sys::windows_ext as windows; + + #[doc(cfg(target_os = "linux"))] + pub mod linux; + + } else { + + // If we're not documenting libstd then we just expose everything as we + // otherwise would. + + #[cfg(target_os = "android")] pub mod android; + #[cfg(target_os = "bitrig")] pub mod bitrig; + #[cfg(target_os = "dragonfly")] pub mod dragonfly; + #[cfg(target_os = "freebsd")] pub mod freebsd; + #[cfg(target_os = "haiku")] pub mod haiku; + #[cfg(target_os = "ios")] pub mod ios; + #[cfg(target_os = "macos")] pub mod macos; + #[cfg(target_os = "netbsd")] pub mod netbsd; + #[cfg(target_os = "openbsd")] pub mod openbsd; + #[cfg(target_os = "solaris")] pub mod solaris; + #[cfg(target_os = "emscripten")] pub mod emscripten; + #[cfg(target_os = "fuchsia")] pub mod fuchsia; + + #[cfg(any(target_os = "redox", unix))] + #[stable(feature = "rust1", since = "1.0.0")] + pub use sys::ext as unix; + + #[cfg(windows)] + #[stable(feature = "rust1", since = "1.0.0")] + pub use sys::ext as windows; + + #[cfg(any(target_os = "linux", target_os = "l4re"))] + pub mod linux; + + } +} pub mod raw; diff --git a/src/libstd/sys/mod.rs b/src/libstd/sys/mod.rs index 27d6433b329..be8cb88416b 100644 --- a/src/libstd/sys/mod.rs +++ b/src/libstd/sys/mod.rs @@ -32,49 +32,66 @@ #![allow(missing_debug_implementations)] -pub use self::imp::*; - -#[cfg(unix)] -#[path = "unix/mod.rs"] -mod imp; - -#[cfg(windows)] -#[path = "windows/mod.rs"] -mod imp; - -#[cfg(target_os = "redox")] -#[path = "redox/mod.rs"] -mod imp; - -#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] -#[path = "wasm/mod.rs"] -mod imp; - -// Import essential modules from both platforms when documenting. - -#[cfg(all(dox, not(unix)))] -use os::linux as platform; - -#[cfg(all(dox, not(any(unix, target_os = "redox"))))] -#[path = "unix/ext/mod.rs"] -pub mod unix_ext; - -#[cfg(all(dox, any(unix, target_os = "redox")))] -pub use self::ext as unix_ext; - - -#[cfg(all(dox, not(windows)))] -#[macro_use] -#[path = "windows/compat.rs"] -mod compat; - -#[cfg(all(dox, not(windows)))] -#[path = "windows/c.rs"] -mod c; - -#[cfg(all(dox, not(windows)))] -#[path = "windows/ext/mod.rs"] -pub mod windows_ext; - -#[cfg(all(dox, windows))] -pub use self::ext as windows_ext; +cfg_if! { + if #[cfg(unix)] { + mod unix; + pub use self::unix::*; + } else if #[cfg(windows)] { + mod windows; + pub use self::windows::*; + } else if #[cfg(target_os = "redox")] { + mod redox; + pub use self::redox::*; + } else if #[cfg(target_arch = "wasm32")] { + mod wasm; + pub use self::wasm::*; + } else { + compile_error!("libstd doesn't compile for this platform yet"); + } +} + +// Import essential modules from both platforms when documenting. These are +// then later used in the `std::os` module when documenting, for example, +// Windows when we're compiling for Linux. + +#[cfg(dox)] +cfg_if! { + if #[cfg(any(unix, target_os = "redox"))] { + // On unix we'll document what's already available + pub use self::ext as unix_ext; + } else if #[cfg(target_arch = "wasm32")] { + // On wasm right now the module below doesn't compile (missing things + // in `libc` which is empty) so just omit everything with an empty module + #[unstable(issue = "0", feature = "std_internals")] + pub mod unix_ext {} + } else { + // On other platforms like Windows document the bare bones of unix + use os::linux as platform; + #[path = "unix/ext/mod.rs"] + pub mod unix_ext; + } +} + +#[cfg(dox)] +cfg_if! { + if #[cfg(windows)] { + // On windows we'll just be documenting what's already available + pub use self::ext as windows_ext; + } else if #[cfg(target_arch = "wasm32")] { + // On wasm right now the shim below doesn't compile, so just omit it + #[unstable(issue = "0", feature = "std_internals")] + pub mod windows_ext {} + } else { + // On all other platforms (aka linux/osx/etc) then pull in a "minimal" + // amount of windows goop which ends up compiling + #[macro_use] + #[path = "windows/compat.rs"] + mod compat; + + #[path = "windows/c.rs"] + mod c; + + #[path = "windows/ext/mod.rs"] + pub mod windows_ext; + } +} |
