Skip to content

Commit 285144a

Browse files
Move NativeLibraryKind to rustc_session
1 parent f03d8f3 commit 285144a

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

src/librustc/middle/cstore.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_target::spec::Target;
2020
use rustc_data_structures::sync::{self, MetadataRef};
2121
use rustc_macros::HashStable;
2222

23+
pub use rustc_session::utils::NativeLibraryKind;
2324
pub use self::NativeLibraryKind::*;
2425

2526
// lonely orphan structs and enums looking for a better home
@@ -94,21 +95,6 @@ pub enum LinkagePreference {
9495
RequireStatic,
9596
}
9697

97-
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash,
98-
RustcEncodable, RustcDecodable, HashStable)]
99-
pub enum NativeLibraryKind {
100-
/// native static library (.a archive)
101-
NativeStatic,
102-
/// native static library, which doesn't get bundled into .rlibs
103-
NativeStaticNobundle,
104-
/// macOS-specific
105-
NativeFramework,
106-
/// Windows dynamic library without import library.
107-
NativeRawDylib,
108-
/// default way to specify a dynamic library
109-
NativeUnknown,
110-
}
111-
11298
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
11399
pub struct NativeLibrary {
114100
pub kind: NativeLibraryKind,

src/librustc/session/config.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! command-line options.
33
44
use rustc_session::lint;
5-
use crate::middle::cstore;
5+
use rustc_session::utils::NativeLibraryKind;
66
use crate::session::{early_error, early_warn, Session};
77
use crate::session::search_paths::SearchPath;
88

@@ -415,7 +415,7 @@ top_level_options!(
415415
describe_lints: bool [UNTRACKED],
416416
output_types: OutputTypes [TRACKED],
417417
search_paths: Vec<SearchPath> [UNTRACKED],
418-
libs: Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> [TRACKED],
418+
libs: Vec<(String, Option<String>, Option<NativeLibraryKind>)> [TRACKED],
419419
maybe_sysroot: Option<PathBuf> [UNTRACKED],
420420

421421
target_triple: TargetTriple [TRACKED],
@@ -2379,7 +2379,7 @@ fn select_debuginfo(
23792379
fn parse_libs(
23802380
matches: &getopts::Matches,
23812381
error_format: ErrorOutputType,
2382-
) -> Vec<(String, Option<String>, Option<cstore::NativeLibraryKind>)> {
2382+
) -> Vec<(String, Option<String>, Option<NativeLibraryKind>)> {
23832383
matches
23842384
.opt_strs("l")
23852385
.into_iter()
@@ -2390,10 +2390,12 @@ fn parse_libs(
23902390
let kind = parts.next().unwrap();
23912391
let (name, kind) = match (parts.next(), kind) {
23922392
(None, name) => (name, None),
2393-
(Some(name), "dylib") => (name, Some(cstore::NativeUnknown)),
2394-
(Some(name), "framework") => (name, Some(cstore::NativeFramework)),
2395-
(Some(name), "static") => (name, Some(cstore::NativeStatic)),
2396-
(Some(name), "static-nobundle") => (name, Some(cstore::NativeStaticNobundle)),
2393+
(Some(name), "dylib") => (name, Some(NativeLibraryKind::NativeUnknown)),
2394+
(Some(name), "framework") => (name, Some(NativeLibraryKind::NativeFramework)),
2395+
(Some(name), "static") => (name, Some(NativeLibraryKind::NativeStatic)),
2396+
(Some(name), "static-nobundle") => {
2397+
(name, Some(NativeLibraryKind::NativeStaticNobundle))
2398+
}
23972399
(_, s) => {
23982400
early_error(
23992401
error_format,
@@ -2405,7 +2407,8 @@ fn parse_libs(
24052407
);
24062408
}
24072409
};
2408-
if kind == Some(cstore::NativeStaticNobundle) && !nightly_options::is_nightly_build() {
2410+
if kind == Some(NativeLibraryKind::NativeStaticNobundle) &&
2411+
!nightly_options::is_nightly_build() {
24092412
early_error(
24102413
error_format,
24112414
&format!(
@@ -2855,7 +2858,7 @@ impl PpMode {
28552858
/// how the hash should be calculated when adding a new command-line argument.
28562859
mod dep_tracking {
28572860
use rustc_session::lint;
2858-
use crate::middle::cstore;
2861+
use rustc_session::utils::NativeLibraryKind;
28592862
use std::collections::BTreeMap;
28602863
use std::hash::Hash;
28612864
use std::path::PathBuf;
@@ -2913,7 +2916,7 @@ mod dep_tracking {
29132916
impl_dep_tracking_hash_via_hash!(Option<RelroLevel>);
29142917
impl_dep_tracking_hash_via_hash!(Option<lint::Level>);
29152918
impl_dep_tracking_hash_via_hash!(Option<PathBuf>);
2916-
impl_dep_tracking_hash_via_hash!(Option<cstore::NativeLibraryKind>);
2919+
impl_dep_tracking_hash_via_hash!(Option<NativeLibraryKind>);
29172920
impl_dep_tracking_hash_via_hash!(CrateType);
29182921
impl_dep_tracking_hash_via_hash!(MergeFunctions);
29192922
impl_dep_tracking_hash_via_hash!(PanicStrategy);
@@ -2924,7 +2927,7 @@ mod dep_tracking {
29242927
impl_dep_tracking_hash_via_hash!(DebugInfo);
29252928
impl_dep_tracking_hash_via_hash!(UnstableFeatures);
29262929
impl_dep_tracking_hash_via_hash!(OutputTypes);
2927-
impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind);
2930+
impl_dep_tracking_hash_via_hash!(NativeLibraryKind);
29282931
impl_dep_tracking_hash_via_hash!(Sanitizer);
29292932
impl_dep_tracking_hash_via_hash!(Option<Sanitizer>);
29302933
impl_dep_tracking_hash_via_hash!(TargetTriple);
@@ -2940,7 +2943,7 @@ mod dep_tracking {
29402943
impl_dep_tracking_hash_for_sortable_vec_of!((
29412944
String,
29422945
Option<String>,
2943-
Option<cstore::NativeLibraryKind>
2946+
Option<NativeLibraryKind>
29442947
));
29452948
impl_dep_tracking_hash_for_sortable_vec_of!((String, u64));
29462949
impl_dep_tracking_hash_for_sortable_vec_of!(Sanitizer);

src/librustc_session/utils.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,19 @@ pub fn duration_to_secs_str(dur: std::time::Duration) -> String {
77

88
format!("{:.3}", secs)
99
}
10+
11+
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
12+
pub enum NativeLibraryKind {
13+
/// native static library (.a archive)
14+
NativeStatic,
15+
/// native static library, which doesn't get bundled into .rlibs
16+
NativeStaticNobundle,
17+
/// macOS-specific
18+
NativeFramework,
19+
/// Windows dynamic library without import library.
20+
NativeRawDylib,
21+
/// default way to specify a dynamic library
22+
NativeUnknown,
23+
}
24+
25+
rustc_data_structures::impl_stable_hash_via_hash!(NativeLibraryKind);

0 commit comments

Comments
 (0)