From 4d51eeecc840d9fc1a9ac60d423767e8d20f1659 Mon Sep 17 00:00:00 2001
From: Per Lindgren <per.lindgren@ltu.se>
Date: Thu, 15 Nov 2018 14:21:50 +0100
Subject: [PATCH] polish

---
 README.md   | 13 +++++++++++++
 src/main.rs | 33 +--------------------------------
 2 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/README.md b/README.md
index c7deed7..b99b01d 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 2f1ba12..fa72331 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
-- 
GitLab