fn link_executable_internal(
    link_dynamicly: bool,
    files: Vec<PathBuf>,
    lib: &Vec<String>,
    libpath: &Vec<String>,
    out: PathBuf
) -> PathBuf {
    info!("output as {:?}", out.as_path());

    let mut cc = Command::new(get_c_compiler());

    // external libs
    for path in libpath.iter() {
        cc.arg(format!("-L{}", path));
    }
    for l in lib.iter() {
        cc.arg(format!("-l{}", l));
    }

    if link_dynamicly {
        cc.arg(format!(
            "-L{}",
            get_path_under_zebu(if cfg!(debug_assertions) {
                "target/debug"
            } else {
                "target/release"
            }).to_str()
                .unwrap()
        ));
        cc.arg("-lmu");
    }
    // dylibs used for linux
    if cfg!(target_os = "linux") {
        cc.arg("-ldl");
        cc.arg("-lrt");
        cc.arg("-lm");
        cc.arg("-lpthread");
        cc.arg("-lz");
    } else if cfg!(target_os = "macos") {
        cc.arg("-liconv");
        cc.arg("-framework");
        cc.arg("Security");
        cc.arg("-framework");
        cc.arg("CoreFoundation");
        cc.arg("-lz");
        cc.arg("-lSystem");
        cc.arg("-lresolv");
        cc.arg("-lc");
        cc.arg("-lm");
    }
    // all the source code
    for file in files {
        info!("link with {:?}", file.as_path());
        cc.arg(file.as_path());
    }

    // flag to allow find symbols in the executable
    cc.arg("-rdynamic");

    // specified output
    cc.arg("-o");
    cc.arg(out.as_os_str());

    // execute and check results
    assert!(exec_cmd(cc).status.success(), "failed to link code");
    out
}
/// invokes the C compiler to link code into an executable
invokes the C compiler to link code into an executable
invokes the C compiler to link code into an executable
fn link_executable_internal(
    link_dynamicly: bool,
    files: Vec<PathBuf>,
    lib: &Vec<String>,
    libpath: &Vec<String>,
    out: PathBuf
) -> PathBuf {
    info!("output as {:?}", out.as_path());
    let mut cc = Command::new(get_c_compiler());
    // external libs
    for path in libpath.iter() {
        cc.arg(format!("-L{}", path));
    }
    for l in lib.iter() {
        cc.arg(format!("-l{}", l));
    }
    if link_dynamicly {
        cc.arg(format!(
            "-L{}",
            get_path_under_zebu(if cfg!(debug_assertions) {
                "target/debug"
            } else {
                "target/release"
            }).to_str()
                .unwrap()
        ));
        cc.arg("-lmu");
    }
    // dylibs used for linux
    if cfg!(target_os = "linux") {
        cc.arg("-ldl");
        cc.arg("-lrt");
        cc.arg("-lm");
        cc.arg("-lpthread");
        cc.arg("-lz");
    } else if cfg!(target_os = "macos") {
        cc.arg("-liconv");
        cc.arg("-framework");
        cc.arg("Security");
        cc.arg("-framework");
        cc.arg("CoreFoundation");
        cc.arg("-lz");
        cc.arg("-lSystem");
        cc.arg("-lresolv");
        cc.arg("-lc");
        cc.arg("-lm");
    }
    // all the source code
    for file in files {
        info!("link with {:?}", file.as_path());
        cc.arg(file.as_path());
    }
    // flag to allow find symbols in the executable
    cc.arg("-rdynamic");
    // specified output
    cc.arg("-o");
    cc.arg(out.as_os_str());
    // execute and check results
    assert!(exec_cmd(cc).status.success(), "failed to link code");
    out
}
fn link_executable_internal ( link_dynamicly : bool , files : Vec < PathBuf > , lib : & Vec < String > , libpath : & Vec < String > , out : PathBuf ) -> PathBuf { info ! ( " " out as_path ( ) ) ; let mut cc = Command :: new ( get_c_compiler ( ) ) ; // external libs for path in libpath . iter ( ) { cc . arg ( format ! ( " " path ) ) ; } for l in lib . iter ( ) { cc . arg ( format ! ( " " l ) ) ; } if link_dynamicly { cc . arg ( format ! ( " " get_path_under_zebu ( if cfg ( debug_assertions ) { " " } else { " " } ) to_str ( ) unwrap ( ) ) ) ; cc . arg ( " " ) ; } // dylibs used for linux if cfg ! ( target_os " " ) { cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; } else if cfg ! ( target_os " " ) { cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; cc . arg ( " " ) ; } // all the source code for file in files { info ! ( " " file as_path ( ) ) ; cc . arg ( file . as_path ( ) ) ; } // flag to allow find symbols in the executable cc . arg ( " " ) ; // specified output cc . arg ( " " ) ; cc . arg ( out . as_os_str ( ) ) ; // execute and check results assert ! ( exec_cmd ( cc ) status success ( ) " " ) ; out }
invokes the C compiler to link code into an executable
invokes the C compiler to link code into an executable
link_dynamicly
bool
files
Vec<PathBuf>
lib
&Vec<String>
libpath
&Vec<String>
out
PathBuf
link_dynamicly
bool
files
Vec<PathBuf>
lib
&Vec<String>
libpath
&Vec<String>
out
PathBuf