Skip to content

Commit

Permalink
Use proper logging
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero committed Jun 26, 2019
1 parent 552c962 commit 26fbe2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ name = "cargo-cbuild"
path = "src/main.rs"

[dependencies]
log = "0.4"
pretty_env_logger = "0.3.0"
cargo_metadata = "0.7"
structopt = "0.2"
regex = "1"
Expand Down
19 changes: 6 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::path::PathBuf;

use cargo_metadata::{MetadataCommand, Package};
use structopt::StructOpt;
use log::*;

mod pkg_config_gen;
mod static_libs;
Expand Down Expand Up @@ -278,11 +279,9 @@ impl Config {

f.read_to_end(&mut s).ok()?;

println!("bi {}", std::str::from_utf8(&s).unwrap());

let t = toml::from_slice::<BuildInfo>(&s).unwrap();

println!("{}", t.hash);
info!("saved build hash {}", t.hash);

Some(t)
}
Expand Down Expand Up @@ -412,7 +411,7 @@ impl Config {
for line in self.shared_object_link_args() {
cmd.arg("-C").arg(&format!("link-arg={}", line));
}
println!("{:?}", cmd);
info!("build_library {:?}", cmd);

let out = cmd.output()?;

Expand All @@ -435,7 +434,7 @@ impl Config {
.map(|cap| cap.get(1).unwrap().as_str()).unwrap()
.to_owned();

println!("{}", hash);
info!("parsed hash {}", hash);

Ok(Some(BuildInfo { hash }))
} else {
Expand Down Expand Up @@ -487,8 +486,6 @@ impl Config {
let name = &self.name;
let ver = &self.pkg.version;

println!("destdir {}", self.destdir.display());

let install_path_lib = append_to_destdir(&self.destdir, &self.libdir);
let install_path_pc = install_path_lib.join("pkg-config");
let install_path_include = append_to_destdir(&self.destdir, &self.includedir).join(name);
Expand All @@ -497,14 +494,9 @@ impl Config {
fs::create_dir_all(&install_path_pc)?;
fs::create_dir_all(&install_path_include)?;

println!("{:?}", install_path_pc);

fs::copy(&build_targets.pc, install_path_pc.join(&format!("{}.pc", name)))?;
fs::copy(&build_targets.include, install_path_include.join(&format!("{}.h", name)))?;
println!("{:?}", build_targets.include);

fs::copy(&build_targets.static_lib, install_path_lib.join(&format!("lib{}.a", name)))?;
println!("{:?}", build_targets.static_lib);


let link_libs = |lib: &str, lib_with_major_ver: &str, lib_with_full_ver: &str| {
Expand Down Expand Up @@ -549,6 +541,7 @@ impl Config {
}

fn main() -> Result<(), std::io::Error> {
pretty_env_logger::init();
let opts = Opt::from_args();

match opts.cmd {
Expand All @@ -562,7 +555,7 @@ fn main() -> Result<(), std::io::Error> {
let info = cfg.build()?;
let build_targets = BuildTargets::new(&cfg, &info.hash);

println!("{:?}", build_targets);
info!("{:?}", build_targets);

cfg.install(build_targets)?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/static_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn get_static_libs_for_target<T: AsRef<std::ffi::OsStr>>(target: Option<T>,

let out = cmd.output()?;

println!("{:?} {:?}", cmd, out);
log::info!("native-static-libs check {:?} {:?}", cmd, out);

if out.status.success() {
let re = Regex::new(r"note: native-static-libs: (.+)").unwrap();
Expand Down

0 comments on commit 26fbe2f

Please sign in to comment.