about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2017-11-20 06:22:17 -0800
committerAlex Crichton <alex@alexcrichton.com>2017-11-25 06:44:35 -0800
commit48996f9e759912140ccc98072e9e55fa6480a9d7 (patch)
tree9ee7d07b394b806138cd00cb1ca2cbed86448183 /src/libstd/sys
parentcc6b88ccb2fd10c2ad04a30ba648a1e9abf7ba4b (diff)
downloadrust-48996f9e759912140ccc98072e9e55fa6480a9d7.tar.gz
rust-48996f9e759912140ccc98072e9e55fa6480a9d7.zip
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/sys')
-rw-r--r--src/libstd/sys/mod.rs109
1 files changed, 63 insertions, 46 deletions
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;
+    }
+}