Set link type based on --lib flag

This commit is contained in:
Richard Feldman 2021-06-08 21:56:15 -04:00
parent cdc32aadd2
commit 9fcd339af9
2 changed files with 11 additions and 3 deletions

View file

@ -145,6 +145,12 @@ pub fn build(target: &Triple, matches: &ArgMatches, config: BuildConfig) -> io::
}; };
let emit_debug_info = matches.is_present(FLAG_DEBUG); let emit_debug_info = matches.is_present(FLAG_DEBUG);
let link_type = if matches.is_present(FLAG_LIB) {
LinkType::Dylib
} else {
LinkType::Executable
};
let path = Path::new(filename).canonicalize().unwrap(); let path = Path::new(filename).canonicalize().unwrap();
let src_dir = path.parent().unwrap().canonicalize().unwrap(); let src_dir = path.parent().unwrap().canonicalize().unwrap();
@ -174,7 +180,7 @@ pub fn build(target: &Triple, matches: &ArgMatches, config: BuildConfig) -> io::
path, path,
opt_level, opt_level,
emit_debug_info, emit_debug_info,
LinkType::Executable, link_type,
); );
match res_binary_path { match res_binary_path {

View file

@ -12,8 +12,10 @@ use target_lexicon::{Architecture, OperatingSystem, Triple};
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum LinkType { pub enum LinkType {
Executable, // These numbers correspond to the --lib flag; if it's present
Dylib, // (e.g. is_present returns `1 as bool`), this will be 1 as well.
Executable = 0,
Dylib = 1,
} }
/// input_paths can include the host as well as the app. e.g. &["host.o", "roc_app.o"] /// input_paths can include the host as well as the app. e.g. &["host.o", "roc_app.o"]