]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_codegen_ssa/src/back/archive.rs
New upstream version 1.48.0~beta.8+dfsg1
[rustc.git] / compiler / rustc_codegen_ssa / src / back / archive.rs
1 use rustc_session::Session;
2 use rustc_span::symbol::Symbol;
3
4 use std::io;
5 use std::path::{Path, PathBuf};
6
7 pub fn find_library(name: Symbol, search_paths: &[PathBuf], sess: &Session) -> PathBuf {
8 // On Windows, static libraries sometimes show up as libfoo.a and other
9 // times show up as foo.lib
10 let oslibname = format!(
11 "{}{}{}",
12 sess.target.target.options.staticlib_prefix,
13 name,
14 sess.target.target.options.staticlib_suffix
15 );
16 let unixlibname = format!("lib{}.a", name);
17
18 for path in search_paths {
19 debug!("looking for {} inside {:?}", name, path);
20 let test = path.join(&oslibname);
21 if test.exists() {
22 return test;
23 }
24 if oslibname != unixlibname {
25 let test = path.join(&unixlibname);
26 if test.exists() {
27 return test;
28 }
29 }
30 }
31 sess.fatal(&format!(
32 "could not find native static library `{}`, \
33 perhaps an -L flag is missing?",
34 name
35 ));
36 }
37
38 pub trait ArchiveBuilder<'a> {
39 fn new(sess: &'a Session, output: &Path, input: Option<&Path>) -> Self;
40
41 fn add_file(&mut self, path: &Path);
42 fn remove_file(&mut self, name: &str);
43 fn src_files(&mut self) -> Vec<String>;
44
45 fn add_rlib(
46 &mut self,
47 path: &Path,
48 name: &str,
49 lto: bool,
50 skip_objects: bool,
51 ) -> io::Result<()>;
52 fn add_native_library(&mut self, name: Symbol);
53 fn update_symbols(&mut self);
54
55 fn build(self);
56 }