@@ -382,13 +382,8 @@ fn dup2(src: c_int, dst: c_int) -> c_int {
382
382
383
383
384
384
pub fn dll_filename ( base : & str ) -> ~str {
385
- return pre ( ) + str:: from_slice ( base) + dll_suffix ( ) ;
386
-
387
- #[ cfg( unix) ]
388
- fn pre ( ) -> ~str { ~"lib" }
389
-
390
- #[ cfg( windows) ]
391
- fn pre ( ) -> ~str { ~"" }
385
+ return str:: from_slice ( DLL_PREFIX ) + str:: from_slice ( base) +
386
+ str:: from_slice ( DLL_SUFFIX )
392
387
}
393
388
394
389
@@ -878,48 +873,83 @@ extern {
878
873
pub fn _NSGetArgv ( ) -> * * * c_char ;
879
874
}
880
875
881
- #[ cfg( unix) ]
882
- pub fn family ( ) -> ~str { ~"unix" }
876
+ mod consts {
883
877
884
- #[ cfg( windows ) ]
885
- pub fn family ( ) -> ~ str { ~"windows" }
878
+ #[ cfg( unix ) ]
879
+ use os :: consts :: unix :: * ;
886
880
887
- #[ cfg( target_os = "macos" ) ]
888
- mod consts {
889
- pub fn sysname ( ) -> ~str { ~"macos" }
890
- pub fn exe_suffix ( ) -> ~str { ~"" }
891
- pub fn dll_suffix ( ) -> ~str { ~". dylib" }
892
- }
881
+ #[ cfg( windows) ]
882
+ use os:: consts:: windows:: * ;
893
883
894
- #[ cfg( target_os = "freebsd" ) ]
895
- mod consts {
896
- pub fn sysname ( ) -> ~str { ~"freebsd" }
897
- pub fn exe_suffix ( ) -> ~str { ~"" }
898
- pub fn dll_suffix ( ) -> ~str { ~". so" }
899
- }
884
+ pub mod unix {
885
+ pub const FAMILY : & str = "unix" ;
886
+ }
900
887
901
- #[ cfg( target_os = "linux" ) ]
902
- mod consts {
903
- pub fn sysname ( ) -> ~str { ~"linux" }
904
- pub fn exe_suffix ( ) -> ~str { ~"" }
905
- pub fn dll_suffix ( ) -> ~str { ~". so" }
906
- }
888
+ pub mod windows {
889
+ pub const FAMILY : & str = "windows" ;
890
+ }
907
891
908
- #[ cfg( target_os = "win32" ) ]
909
- mod consts {
910
- pub fn sysname ( ) -> ~str { ~"win32" }
911
- pub fn exe_suffix ( ) -> ~str { ~". exe" }
912
- pub fn dll_suffix ( ) -> ~str { ~". dll" }
913
- }
914
892
915
- #[ cfg( target_arch = "x86" ) ]
916
- pub fn arch ( ) -> ~str { ~"x86" }
893
+ #[ cfg( target_os = "macos" ) ]
894
+ use os:: consts:: macos:: * ;
895
+
896
+ #[ cfg( target_os = "freebsd" ) ]
897
+ use os:: consts:: freebsd:: * ;
898
+
899
+ #[ cfg( target_os = "linux" ) ]
900
+ use os:: consts:: linux:: * ;
901
+
902
+ #[ cfg( target_os = "win32" ) ]
903
+ use os:: consts:: win32:: * ;
917
904
918
- #[ cfg( target_arch = "x86_64" ) ]
919
- pub fn arch ( ) -> ~str { ~"x86_64" }
905
+ pub mod macos {
906
+ pub const SYSNAME : & str = "macos" ;
907
+ pub const DLL_PREFIX : & str = "lib" ;
908
+ pub const DLL_SUFFIX : & str = ".dylib" ;
909
+ pub const EXE_SUFFIX : & str = "" ;
910
+ }
911
+
912
+ pub mod freebsd {
913
+ pub const SYSNAME : & str = "freebsd" ;
914
+ pub const DLL_PREFIX : & str = "lib" ;
915
+ pub const DLL_SUFFIX : & str = ".so" ;
916
+ pub const EXE_SUFFIX : & str = "" ;
917
+ }
918
+
919
+ pub mod linux {
920
+ pub const SYSNAME : & str = "linux" ;
921
+ pub const DLL_PREFIX : & str = "lib" ;
922
+ pub const DLL_SUFFIX : & str = ".so" ;
923
+ pub const EXE_SUFFIX : & str = "" ;
924
+ }
920
925
921
- #[ cfg( target_arch = "arm" ) ]
922
- pub fn arch ( ) -> str { ~"arm" }
926
+ pub mod win32 {
927
+ pub const SYSNAME : & str = "win32" ;
928
+ pub const DLL_PREFIX : & str = "" ;
929
+ pub const DLL_SUFFIX : & str = ".dll" ;
930
+ pub const EXE_SUFFIX : & str = ".exe" ;
931
+ }
932
+
933
+
934
+ #[ cfg( target_arch = "x86" ) ]
935
+ use os:: consts:: x86:: * ;
936
+
937
+ #[ cfg( target_arch = "x86_64" ) ]
938
+ use os:: consts:: x86_64:: * ;
939
+
940
+ #[ cfg( target_arch = "arm" ) ]
941
+ use os:: consts:: arm:: * ;
942
+
943
+ pub mod x86 {
944
+ pub const ARCH : & str = "x86" ;
945
+ }
946
+ pub mod x86_64 {
947
+ pub const ARCH : & str = "x86_64" ;
948
+ }
949
+ pub mod arm {
950
+ pub const ARCH : & str = "arm" ;
951
+ }
952
+ }
923
953
924
954
#[ cfg( test) ]
925
955
#[ allow( non_implicitly_copyable_typarams) ]
0 commit comments