Skip to content

Commit 2bb2341

Browse files
committed
auto merge of #13697 : pongad/rust/consts, r=alexcrichton
I decided to put architecture constants in another mod. They are not used, so a part of me is thinking of just getting rid of them altogether. The rest should be similar to what @brson wants. Fixes #13536
2 parents 6648651 + 7c5d48a commit 2bb2341

File tree

4 files changed

+160
-189
lines changed

4 files changed

+160
-189
lines changed

src/librustc/back/link.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use lib::llvm::llvm;
1818
use lib::llvm::ModuleRef;
1919
use lib;
2020
use metadata::common::LinkMeta;
21-
use metadata::{encoder, cstore, filesearch, csearch};
21+
use metadata::{encoder, cstore, filesearch, csearch, loader};
2222
use middle::trans::context::CrateContext;
2323
use middle::trans::common::gensym_name;
2424
use middle::ty;
@@ -30,7 +30,6 @@ use std::c_str::{ToCStr, CString};
3030
use std::char;
3131
use std::io::{fs, TempDir, Process};
3232
use std::io;
33-
use std::os::consts::{macos, freebsd, linux, android, win32};
3433
use std::ptr;
3534
use std::str;
3635
use std::strbuf::StrBuf;
@@ -825,11 +824,11 @@ pub fn filename_for_input(sess: &Session, crate_type: session::CrateType,
825824
}
826825
session::CrateTypeDylib => {
827826
let (prefix, suffix) = match sess.targ_cfg.os {
828-
abi::OsWin32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
829-
abi::OsMacos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
830-
abi::OsLinux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
831-
abi::OsAndroid => (android::DLL_PREFIX, android::DLL_SUFFIX),
832-
abi::OsFreebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
827+
abi::OsWin32 => (loader::WIN32_DLL_PREFIX, loader::WIN32_DLL_SUFFIX),
828+
abi::OsMacos => (loader::MACOS_DLL_PREFIX, loader::MACOS_DLL_SUFFIX),
829+
abi::OsLinux => (loader::LINUX_DLL_PREFIX, loader::LINUX_DLL_SUFFIX),
830+
abi::OsAndroid => (loader::ANDROID_DLL_PREFIX, loader::ANDROID_DLL_SUFFIX),
831+
abi::OsFreebsd => (loader::FREEBSD_DLL_PREFIX, loader::FREEBSD_DLL_SUFFIX),
833832
};
834833
out_filename.with_filename(format!("{}{}{}", prefix, libname, suffix))
835834
}

src/librustc/metadata/loader.rs

+20-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use std::c_str::ToCStr;
2727
use std::cast;
2828
use std::cmp;
2929
use std::io;
30-
use std::os::consts::{macos, freebsd, linux, android, win32};
3130
use std::ptr;
3231
use std::slice;
3332
use std::str;
@@ -36,6 +35,21 @@ use collections::{HashMap, HashSet};
3635
use flate;
3736
use time;
3837

38+
pub static MACOS_DLL_PREFIX: &'static str = "lib";
39+
pub static MACOS_DLL_SUFFIX: &'static str = ".dylib";
40+
41+
pub static WIN32_DLL_PREFIX: &'static str = "";
42+
pub static WIN32_DLL_SUFFIX: &'static str = ".dll";
43+
44+
pub static LINUX_DLL_PREFIX: &'static str = "lib";
45+
pub static LINUX_DLL_SUFFIX: &'static str = ".so";
46+
47+
pub static FREEBSD_DLL_PREFIX: &'static str = "lib";
48+
pub static FREEBSD_DLL_SUFFIX: &'static str = ".so";
49+
50+
pub static ANDROID_DLL_PREFIX: &'static str = "lib";
51+
pub static ANDROID_DLL_SUFFIX: &'static str = ".so";
52+
3953
pub enum Os {
4054
OsMacos,
4155
OsWin32,
@@ -433,11 +447,11 @@ impl<'a> Context<'a> {
433447
// dynamic libraries
434448
fn dylibname(&self) -> (&'static str, &'static str) {
435449
match self.os {
436-
OsWin32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
437-
OsMacos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
438-
OsLinux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
439-
OsAndroid => (android::DLL_PREFIX, android::DLL_SUFFIX),
440-
OsFreebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
450+
OsWin32 => (WIN32_DLL_PREFIX, WIN32_DLL_SUFFIX),
451+
OsMacos => (MACOS_DLL_PREFIX, MACOS_DLL_SUFFIX),
452+
OsLinux => (LINUX_DLL_PREFIX, LINUX_DLL_SUFFIX),
453+
OsAndroid => (ANDROID_DLL_PREFIX, ANDROID_DLL_SUFFIX),
454+
OsFreebsd => (FREEBSD_DLL_PREFIX, FREEBSD_DLL_SUFFIX),
441455
}
442456
}
443457

0 commit comments

Comments
 (0)