about summary refs log tree commit diff
path: root/library/std/src/sys/pal/unix/env.rs
diff options
context:
space:
mode:
authorThalia Archibald <thalia@archibald.dev>2025-04-15 05:29:38 -0700
committerThalia Archibald <thalia@archibald.dev>2025-04-18 16:35:26 -0700
commite0d9244472b50631f07af8a425c1dbed65161d25 (patch)
treeaa4769274f1231b0e8255b5191152f71590107f1 /library/std/src/sys/pal/unix/env.rs
parentf433fa46b0fd27d35219357ad75f54d294081bc4 (diff)
downloadrust-e0d9244472b50631f07af8a425c1dbed65161d25.tar.gz
rust-e0d9244472b50631f07af8a425c1dbed65161d25.zip
Sort Unix env constants alphabetically by target_os
They were roughly grouped into Linux, Apple, BSD, and everything else,
roughly in alphabetical order. Alphabetically order them to make it
easier to maintain and discard the Unix-specific groups to generalize it
to all platforms.
Diffstat (limited to 'library/std/src/sys/pal/unix/env.rs')
-rw-r--r--library/std/src/sys/pal/unix/env.rs198
1 files changed, 100 insertions, 98 deletions
diff --git a/library/std/src/sys/pal/unix/env.rs b/library/std/src/sys/pal/unix/env.rs
index c6609298f4b..1a5e23f06b8 100644
--- a/library/std/src/sys/pal/unix/env.rs
+++ b/library/std/src/sys/pal/unix/env.rs
@@ -1,73 +1,64 @@
-#[cfg(target_os = "linux")]
-pub mod os {
-    pub const FAMILY: &str = "unix";
-    pub const OS: &str = "linux";
-    pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".so";
-    pub const DLL_EXTENSION: &str = "so";
-    pub const EXE_SUFFIX: &str = "";
-    pub const EXE_EXTENSION: &str = "";
-}
+// Keep entries sorted alphabetically.
 
-#[cfg(target_os = "macos")]
+#[cfg(target_os = "aix")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "macos";
+    pub const OS: &str = "aix";
     pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".dylib";
-    pub const DLL_EXTENSION: &str = "dylib";
+    pub const DLL_SUFFIX: &str = ".a";
+    pub const DLL_EXTENSION: &str = "a";
     pub const EXE_SUFFIX: &str = "";
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "ios")]
+#[cfg(target_os = "android")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "ios";
+    pub const OS: &str = "android";
     pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".dylib";
-    pub const DLL_EXTENSION: &str = "dylib";
+    pub const DLL_SUFFIX: &str = ".so";
+    pub const DLL_EXTENSION: &str = "so";
     pub const EXE_SUFFIX: &str = "";
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "tvos")]
+#[cfg(target_os = "cygwin")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "tvos";
-    pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".dylib";
-    pub const DLL_EXTENSION: &str = "dylib";
-    pub const EXE_SUFFIX: &str = "";
-    pub const EXE_EXTENSION: &str = "";
+    pub const OS: &str = "cygwin";
+    pub const DLL_PREFIX: &str = "";
+    pub const DLL_SUFFIX: &str = ".dll";
+    pub const DLL_EXTENSION: &str = "dll";
+    pub const EXE_SUFFIX: &str = ".exe";
+    pub const EXE_EXTENSION: &str = "exe";
 }
 
-#[cfg(target_os = "watchos")]
+#[cfg(target_os = "dragonfly")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "watchos";
+    pub const OS: &str = "dragonfly";
     pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".dylib";
-    pub const DLL_EXTENSION: &str = "dylib";
+    pub const DLL_SUFFIX: &str = ".so";
+    pub const DLL_EXTENSION: &str = "so";
     pub const EXE_SUFFIX: &str = "";
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "visionos")]
+#[cfg(all(target_os = "emscripten", target_arch = "wasm32"))]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "visionos";
+    pub const OS: &str = "emscripten";
     pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".dylib";
-    pub const DLL_EXTENSION: &str = "dylib";
-    pub const EXE_SUFFIX: &str = "";
-    pub const EXE_EXTENSION: &str = "";
+    pub const DLL_SUFFIX: &str = ".so";
+    pub const DLL_EXTENSION: &str = "so";
+    pub const EXE_SUFFIX: &str = ".js";
+    pub const EXE_EXTENSION: &str = "js";
 }
 
-#[cfg(target_os = "freebsd")]
+#[cfg(target_os = "espidf")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "freebsd";
+    pub const OS: &str = "espidf";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -75,10 +66,10 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "dragonfly")]
+#[cfg(target_os = "freebsd")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "dragonfly";
+    pub const OS: &str = "freebsd";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -86,10 +77,10 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "netbsd")]
+#[cfg(target_os = "fuchsia")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "netbsd";
+    pub const OS: &str = "fuchsia";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -97,10 +88,10 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "openbsd")]
+#[cfg(target_os = "haiku")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "openbsd";
+    pub const OS: &str = "haiku";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -108,32 +99,21 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "cygwin")]
-pub mod os {
-    pub const FAMILY: &str = "unix";
-    pub const OS: &str = "cygwin";
-    pub const DLL_PREFIX: &str = "";
-    pub const DLL_SUFFIX: &str = ".dll";
-    pub const DLL_EXTENSION: &str = "dll";
-    pub const EXE_SUFFIX: &str = ".exe";
-    pub const EXE_EXTENSION: &str = "exe";
-}
-
-#[cfg(target_os = "android")]
+#[cfg(target_os = "horizon")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "android";
+    pub const OS: &str = "horizon";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
-    pub const EXE_SUFFIX: &str = "";
-    pub const EXE_EXTENSION: &str = "";
+    pub const EXE_SUFFIX: &str = ".elf";
+    pub const EXE_EXTENSION: &str = "elf";
 }
 
-#[cfg(target_os = "solaris")]
+#[cfg(target_os = "hurd")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "solaris";
+    pub const OS: &str = "hurd";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -152,32 +132,32 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "haiku")]
+#[cfg(target_os = "ios")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "haiku";
+    pub const OS: &str = "ios";
     pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".so";
-    pub const DLL_EXTENSION: &str = "so";
+    pub const DLL_SUFFIX: &str = ".dylib";
+    pub const DLL_EXTENSION: &str = "dylib";
     pub const EXE_SUFFIX: &str = "";
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "horizon")]
+#[cfg(target_os = "l4re")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "horizon";
+    pub const OS: &str = "l4re";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
-    pub const EXE_SUFFIX: &str = ".elf";
-    pub const EXE_EXTENSION: &str = "elf";
+    pub const EXE_SUFFIX: &str = "";
+    pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "hurd")]
+#[cfg(target_os = "linux")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "hurd";
+    pub const OS: &str = "linux";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -185,32 +165,32 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "vita")]
+#[cfg(target_os = "macos")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "vita";
+    pub const OS: &str = "macos";
     pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".so";
-    pub const DLL_EXTENSION: &str = "so";
-    pub const EXE_SUFFIX: &str = ".elf";
-    pub const EXE_EXTENSION: &str = "elf";
+    pub const DLL_SUFFIX: &str = ".dylib";
+    pub const DLL_EXTENSION: &str = "dylib";
+    pub const EXE_SUFFIX: &str = "";
+    pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(all(target_os = "emscripten", target_arch = "wasm32"))]
+#[cfg(target_os = "netbsd")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "emscripten";
+    pub const OS: &str = "netbsd";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
-    pub const EXE_SUFFIX: &str = ".js";
-    pub const EXE_EXTENSION: &str = "js";
+    pub const EXE_SUFFIX: &str = "";
+    pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "fuchsia")]
+#[cfg(target_os = "nto")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "fuchsia";
+    pub const OS: &str = "nto";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -218,10 +198,10 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "l4re")]
+#[cfg(target_os = "nuttx")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "l4re";
+    pub const OS: &str = "nuttx";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -229,10 +209,10 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "nto")]
+#[cfg(target_os = "openbsd")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "nto";
+    pub const OS: &str = "openbsd";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -262,10 +242,10 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "vxworks")]
+#[cfg(target_os = "solaris")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "vxworks";
+    pub const OS: &str = "solaris";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
@@ -273,35 +253,57 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "espidf")]
+#[cfg(target_os = "tvos")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "espidf";
+    pub const OS: &str = "tvos";
     pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".so";
-    pub const DLL_EXTENSION: &str = "so";
+    pub const DLL_SUFFIX: &str = ".dylib";
+    pub const DLL_EXTENSION: &str = "dylib";
     pub const EXE_SUFFIX: &str = "";
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "aix")]
+#[cfg(target_os = "visionos")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "aix";
+    pub const OS: &str = "visionos";
     pub const DLL_PREFIX: &str = "lib";
-    pub const DLL_SUFFIX: &str = ".a";
-    pub const DLL_EXTENSION: &str = "a";
+    pub const DLL_SUFFIX: &str = ".dylib";
+    pub const DLL_EXTENSION: &str = "dylib";
     pub const EXE_SUFFIX: &str = "";
     pub const EXE_EXTENSION: &str = "";
 }
 
-#[cfg(target_os = "nuttx")]
+#[cfg(target_os = "vita")]
 pub mod os {
     pub const FAMILY: &str = "unix";
-    pub const OS: &str = "nuttx";
+    pub const OS: &str = "vita";
+    pub const DLL_PREFIX: &str = "lib";
+    pub const DLL_SUFFIX: &str = ".so";
+    pub const DLL_EXTENSION: &str = "so";
+    pub const EXE_SUFFIX: &str = ".elf";
+    pub const EXE_EXTENSION: &str = "elf";
+}
+
+#[cfg(target_os = "vxworks")]
+pub mod os {
+    pub const FAMILY: &str = "unix";
+    pub const OS: &str = "vxworks";
     pub const DLL_PREFIX: &str = "lib";
     pub const DLL_SUFFIX: &str = ".so";
     pub const DLL_EXTENSION: &str = "so";
     pub const EXE_SUFFIX: &str = "";
     pub const EXE_EXTENSION: &str = "";
 }
+
+#[cfg(target_os = "watchos")]
+pub mod os {
+    pub const FAMILY: &str = "unix";
+    pub const OS: &str = "watchos";
+    pub const DLL_PREFIX: &str = "lib";
+    pub const DLL_SUFFIX: &str = ".dylib";
+    pub const DLL_EXTENSION: &str = "dylib";
+    pub const EXE_SUFFIX: &str = "";
+    pub const EXE_EXTENSION: &str = "";
+}