Skip to content

Commit 5c21562

Browse files
committed
std: Move platform specific env code into sys
1 parent e6457bb commit 5c21562

File tree

5 files changed

+203
-183
lines changed

5 files changed

+203
-183
lines changed

src/libstd/env.rs

Lines changed: 9 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,8 @@ impl DoubleEndedIterator for ArgsOs {
649649
/// Constants associated with the current target
650650
#[stable(feature = "env", since = "1.0.0")]
651651
pub mod consts {
652+
use sys::env::os;
653+
652654
/// A string describing the architecture of the CPU that is currently
653655
/// in use.
654656
///
@@ -673,7 +675,7 @@ pub mod consts {
673675
/// - unix
674676
/// - windows
675677
#[stable(feature = "env", since = "1.0.0")]
676-
pub const FAMILY: &'static str = super::os::FAMILY;
678+
pub const FAMILY: &'static str = os::FAMILY;
677679

678680
/// A string describing the specific operating system in use.
679681
/// Example value is `linux`.
@@ -692,7 +694,7 @@ pub mod consts {
692694
/// - android
693695
/// - windows
694696
#[stable(feature = "env", since = "1.0.0")]
695-
pub const OS: &'static str = super::os::OS;
697+
pub const OS: &'static str = os::OS;
696698

697699
/// Specifies the filename prefix used for shared libraries on this
698700
/// platform. Example value is `lib`.
@@ -702,7 +704,7 @@ pub mod consts {
702704
/// - lib
703705
/// - `""` (an empty string)
704706
#[stable(feature = "env", since = "1.0.0")]
705-
pub const DLL_PREFIX: &'static str = super::os::DLL_PREFIX;
707+
pub const DLL_PREFIX: &'static str = os::DLL_PREFIX;
706708

707709
/// Specifies the filename suffix used for shared libraries on this
708710
/// platform. Example value is `.so`.
@@ -713,7 +715,7 @@ pub mod consts {
713715
/// - .dylib
714716
/// - .dll
715717
#[stable(feature = "env", since = "1.0.0")]
716-
pub const DLL_SUFFIX: &'static str = super::os::DLL_SUFFIX;
718+
pub const DLL_SUFFIX: &'static str = os::DLL_SUFFIX;
717719

718720
/// Specifies the file extension used for shared libraries on this
719721
/// platform that goes after the dot. Example value is `so`.
@@ -724,7 +726,7 @@ pub mod consts {
724726
/// - dylib
725727
/// - dll
726728
#[stable(feature = "env", since = "1.0.0")]
727-
pub const DLL_EXTENSION: &'static str = super::os::DLL_EXTENSION;
729+
pub const DLL_EXTENSION: &'static str = os::DLL_EXTENSION;
728730

729731
/// Specifies the filename suffix used for executable binaries on this
730732
/// platform. Example value is `.exe`.
@@ -736,7 +738,7 @@ pub mod consts {
736738
/// - .pexe
737739
/// - `""` (an empty string)
738740
#[stable(feature = "env", since = "1.0.0")]
739-
pub const EXE_SUFFIX: &'static str = super::os::EXE_SUFFIX;
741+
pub const EXE_SUFFIX: &'static str = os::EXE_SUFFIX;
740742

741743
/// Specifies the file extension, if any, used for executable binaries
742744
/// on this platform. Example value is `exe`.
@@ -746,183 +748,7 @@ pub mod consts {
746748
/// - exe
747749
/// - `""` (an empty string)
748750
#[stable(feature = "env", since = "1.0.0")]
749-
pub const EXE_EXTENSION: &'static str = super::os::EXE_EXTENSION;
750-
751-
}
752-
753-
#[cfg(target_os = "linux")]
754-
mod os {
755-
pub const FAMILY: &'static str = "unix";
756-
pub const OS: &'static str = "linux";
757-
pub const DLL_PREFIX: &'static str = "lib";
758-
pub const DLL_SUFFIX: &'static str = ".so";
759-
pub const DLL_EXTENSION: &'static str = "so";
760-
pub const EXE_SUFFIX: &'static str = "";
761-
pub const EXE_EXTENSION: &'static str = "";
762-
}
763-
764-
#[cfg(target_os = "macos")]
765-
mod os {
766-
pub const FAMILY: &'static str = "unix";
767-
pub const OS: &'static str = "macos";
768-
pub const DLL_PREFIX: &'static str = "lib";
769-
pub const DLL_SUFFIX: &'static str = ".dylib";
770-
pub const DLL_EXTENSION: &'static str = "dylib";
771-
pub const EXE_SUFFIX: &'static str = "";
772-
pub const EXE_EXTENSION: &'static str = "";
773-
}
774-
775-
#[cfg(target_os = "ios")]
776-
mod os {
777-
pub const FAMILY: &'static str = "unix";
778-
pub const OS: &'static str = "ios";
779-
pub const DLL_PREFIX: &'static str = "lib";
780-
pub const DLL_SUFFIX: &'static str = ".dylib";
781-
pub const DLL_EXTENSION: &'static str = "dylib";
782-
pub const EXE_SUFFIX: &'static str = "";
783-
pub const EXE_EXTENSION: &'static str = "";
784-
}
785-
786-
#[cfg(target_os = "freebsd")]
787-
mod os {
788-
pub const FAMILY: &'static str = "unix";
789-
pub const OS: &'static str = "freebsd";
790-
pub const DLL_PREFIX: &'static str = "lib";
791-
pub const DLL_SUFFIX: &'static str = ".so";
792-
pub const DLL_EXTENSION: &'static str = "so";
793-
pub const EXE_SUFFIX: &'static str = "";
794-
pub const EXE_EXTENSION: &'static str = "";
795-
}
796-
797-
#[cfg(target_os = "dragonfly")]
798-
mod os {
799-
pub const FAMILY: &'static str = "unix";
800-
pub const OS: &'static str = "dragonfly";
801-
pub const DLL_PREFIX: &'static str = "lib";
802-
pub const DLL_SUFFIX: &'static str = ".so";
803-
pub const DLL_EXTENSION: &'static str = "so";
804-
pub const EXE_SUFFIX: &'static str = "";
805-
pub const EXE_EXTENSION: &'static str = "";
806-
}
807-
808-
#[cfg(target_os = "bitrig")]
809-
mod os {
810-
pub const FAMILY: &'static str = "unix";
811-
pub const OS: &'static str = "bitrig";
812-
pub const DLL_PREFIX: &'static str = "lib";
813-
pub const DLL_SUFFIX: &'static str = ".so";
814-
pub const DLL_EXTENSION: &'static str = "so";
815-
pub const EXE_SUFFIX: &'static str = "";
816-
pub const EXE_EXTENSION: &'static str = "";
817-
}
818-
819-
#[cfg(target_os = "netbsd")]
820-
mod os {
821-
pub const FAMILY: &'static str = "unix";
822-
pub const OS: &'static str = "netbsd";
823-
pub const DLL_PREFIX: &'static str = "lib";
824-
pub const DLL_SUFFIX: &'static str = ".so";
825-
pub const DLL_EXTENSION: &'static str = "so";
826-
pub const EXE_SUFFIX: &'static str = "";
827-
pub const EXE_EXTENSION: &'static str = "";
828-
}
829-
830-
#[cfg(target_os = "openbsd")]
831-
mod os {
832-
pub const FAMILY: &'static str = "unix";
833-
pub const OS: &'static str = "openbsd";
834-
pub const DLL_PREFIX: &'static str = "lib";
835-
pub const DLL_SUFFIX: &'static str = ".so";
836-
pub const DLL_EXTENSION: &'static str = "so";
837-
pub const EXE_SUFFIX: &'static str = "";
838-
pub const EXE_EXTENSION: &'static str = "";
839-
}
840-
841-
#[cfg(target_os = "android")]
842-
mod os {
843-
pub const FAMILY: &'static str = "unix";
844-
pub const OS: &'static str = "android";
845-
pub const DLL_PREFIX: &'static str = "lib";
846-
pub const DLL_SUFFIX: &'static str = ".so";
847-
pub const DLL_EXTENSION: &'static str = "so";
848-
pub const EXE_SUFFIX: &'static str = "";
849-
pub const EXE_EXTENSION: &'static str = "";
850-
}
851-
852-
#[cfg(target_os = "solaris")]
853-
mod os {
854-
pub const FAMILY: &'static str = "unix";
855-
pub const OS: &'static str = "solaris";
856-
pub const DLL_PREFIX: &'static str = "lib";
857-
pub const DLL_SUFFIX: &'static str = ".so";
858-
pub const DLL_EXTENSION: &'static str = "so";
859-
pub const EXE_SUFFIX: &'static str = "";
860-
pub const EXE_EXTENSION: &'static str = "";
861-
}
862-
863-
#[cfg(target_os = "windows")]
864-
mod os {
865-
pub const FAMILY: &'static str = "windows";
866-
pub const OS: &'static str = "windows";
867-
pub const DLL_PREFIX: &'static str = "";
868-
pub const DLL_SUFFIX: &'static str = ".dll";
869-
pub const DLL_EXTENSION: &'static str = "dll";
870-
pub const EXE_SUFFIX: &'static str = ".exe";
871-
pub const EXE_EXTENSION: &'static str = "exe";
872-
}
873-
874-
#[cfg(all(target_os = "nacl", not(target_arch = "le32")))]
875-
mod os {
876-
pub const FAMILY: &'static str = "unix";
877-
pub const OS: &'static str = "nacl";
878-
pub const DLL_PREFIX: &'static str = "lib";
879-
pub const DLL_SUFFIX: &'static str = ".so";
880-
pub const DLL_EXTENSION: &'static str = "so";
881-
pub const EXE_SUFFIX: &'static str = ".nexe";
882-
pub const EXE_EXTENSION: &'static str = "nexe";
883-
}
884-
#[cfg(all(target_os = "nacl", target_arch = "le32"))]
885-
mod os {
886-
pub const FAMILY: &'static str = "unix";
887-
pub const OS: &'static str = "pnacl";
888-
pub const DLL_PREFIX: &'static str = "lib";
889-
pub const DLL_SUFFIX: &'static str = ".pso";
890-
pub const DLL_EXTENSION: &'static str = "pso";
891-
pub const EXE_SUFFIX: &'static str = ".pexe";
892-
pub const EXE_EXTENSION: &'static str = "pexe";
893-
}
894-
895-
#[cfg(all(target_os = "emscripten", target_arch = "asmjs"))]
896-
mod os {
897-
pub const FAMILY: &'static str = "unix";
898-
pub const OS: &'static str = "emscripten";
899-
pub const DLL_PREFIX: &'static str = "lib";
900-
pub const DLL_SUFFIX: &'static str = ".so";
901-
pub const DLL_EXTENSION: &'static str = "so";
902-
pub const EXE_SUFFIX: &'static str = ".js";
903-
pub const EXE_EXTENSION: &'static str = "js";
904-
}
905-
906-
#[cfg(all(target_os = "emscripten", target_arch = "wasm32"))]
907-
mod os {
908-
pub const FAMILY: &'static str = "unix";
909-
pub const OS: &'static str = "emscripten";
910-
pub const DLL_PREFIX: &'static str = "lib";
911-
pub const DLL_SUFFIX: &'static str = ".so";
912-
pub const DLL_EXTENSION: &'static str = "so";
913-
pub const EXE_SUFFIX: &'static str = ".js";
914-
pub const EXE_EXTENSION: &'static str = "js";
915-
}
916-
917-
#[cfg(target_os = "haiku")]
918-
mod os {
919-
pub const FAMILY: &'static str = "unix";
920-
pub const OS: &'static str = "haiku";
921-
pub const DLL_PREFIX: &'static str = "lib";
922-
pub const DLL_SUFFIX: &'static str = ".so";
923-
pub const DLL_EXTENSION: &'static str = "so";
924-
pub const EXE_SUFFIX: &'static str = "";
925-
pub const EXE_EXTENSION: &'static str = "";
751+
pub const EXE_EXTENSION: &'static str = os::EXE_EXTENSION;
926752
}
927753

928754
#[cfg(target_arch = "x86")]

0 commit comments

Comments
 (0)