diff --git a/README.md b/README.md index c7deed71ff025489c48a7e73a8ecbca98c01383e..b99b01d2fb2b3893a24ca27a0ce55fb6df8d30ba 100644 --- a/README.md +++ b/README.md @@ -23,5 +23,18 @@ Cargo uses the `target` directory for storing build artifacts. In our case we ar Cargo identifies a build context by a unique hash in order to distinguish cashed compilation units between builds (under different configurations). To that end, we need to determine the current hash to determine the full path of the generated llvm ir (e.g. `target/thumbv7m-none-eabi/release/examples/hello1-f3268774e62977a5.ll`, `f3268774e62977a5` being the hash). While `Cargo` can be accessed as a library, it does not (AFAIK) provide a stable API. A pragmatic solotion is to parse the actual invocation parameters to `rustc` to determine the current hash (as identified by the `extra-filename` option). +### Multiple targets +An attempt to analyse multiple targets, e.g., +> cargo call-stack --examples --release + +Will render: + +``` text +error: extra arguments to `rustc` can only be passed to one target, consider filtering +the package by passing e.g. `--lib` or `--bin NAME` to specify a single target + +``` + +This is fine Since we are interested in analysing a single application. This error is reported directly by `rustc` (not by the `call-stack` command). diff --git a/src/main.rs b/src/main.rs index 2f1ba12f98596f5602a141a136f0bda46315e1f9..fa72331280661116e71732e9b9bf014faffe2913 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ struct Out { // we skip the last line (Finished ...) // and look for `--crate-name x`, `extra-filename=y` and `--out dir z` // -// Notice, the parsing is a bit of a hack, implemnting look ahead using flags. +// Notice, the parsing is a bit of a hack, implemnting look-ahead using flags. fn parse_out(out_str: &str) -> Out { let mut out = Out { hash: None, @@ -47,37 +47,6 @@ fn parse_out(out_str: &str) -> Out { out } -fn parse_output(output: &str) -> (Option<&str>, Option<&str>, Option<&str>) { - let mut suffix = None; - let mut crate_name = None; - let mut example = None; - - let output = str::from_utf8(output.as_bytes()).unwrap(); - println!("here ..."); - let mut i = output.lines().into_iter(); - i.next_back(); // skip last line - if let Some(line) = i.next_back() { - let mut b = false; - for part in line.split(' ') { - if b { - crate_name = Some(part); - b = false; - } else if part.starts_with("--crate-name") { - b = true; - println!("----- here ---------- {:?}", crate_name); - } else if part.starts_with("extra-filename=") { - suffix = part.split('=').nth(1); - println!("----- there ----------"); - } else if part.starts_with("example") { - example = part.split('/').nth(1); - println!("----- there ----------"); - }; - } - //} - } - (suffix, crate_name, example) -} - fn main() { println!("start sub command"); // first argument is the path to this binary; the second argument is always "call-stack" -- both can