1 use crate::session::Session;
2 use rustc_data_structures::profiling::VerboseTimingGuard;
3 use std::path::{Path, PathBuf};
6 pub fn timer<'a>(&'a self, what: &'static str) -> VerboseTimingGuard<'a> {
7 self.prof.verbose_generic_activity(what)
9 pub fn time<R>(&self, what: &'static str, f: impl FnOnce() -> R) -> R {
10 self.prof.verbose_generic_activity(what).run(f)
14 #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
15 pub enum NativeLibKind {
16 /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) included
17 /// when linking a final binary, but not when archiving an rlib.
19 /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) included
20 /// when linking a final binary, but also included when archiving an rlib.
22 /// Dynamic library (e.g. `libfoo.so` on Linux)
23 /// or an import library corresponding to a dynamic library (e.g. `foo.lib` on Windows/MSVC).
25 /// Dynamic library (e.g. `foo.dll` on Windows) without a corresponding import library.
27 /// A macOS-specific kind of dynamic libraries.
29 /// The library kind wasn't specified, `Dylib` is currently used as a default.
33 rustc_data_structures::impl_stable_hash_via_hash!(NativeLibKind);
35 /// A path that has been canonicalized along with its original, non-canonicalized form
36 #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
37 pub struct CanonicalizedPath {
38 // Optional since canonicalization can sometimes fail
39 canonicalized: Option<PathBuf>,
43 impl CanonicalizedPath {
44 pub fn new(path: &Path) -> Self {
45 Self { original: path.to_owned(), canonicalized: std::fs::canonicalize(path).ok() }
48 pub fn canonicalized(&self) -> &PathBuf {
49 self.canonicalized.as_ref().unwrap_or(self.original())
52 pub fn original(&self) -> &PathBuf {