Convert manifest path to absolute

Since the working directory changes between the initial invocation of fargo and
when it is invoked with run-on-target.

Change-Id: If0e3c65107b6489289e970f5a6da2132e90237c9
Testing: manual
Reviewed-on: https://fuchsia-review.googlesource.com/c/fargo/+/463736
Reviewed-by: Marc Khouri <mnck@google.com>
diff --git a/src/lib.rs b/src/lib.rs
index 6e4f473..dd8c2c8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -389,6 +389,14 @@
     Ok(rust_flags.join(" "))
 }
 
+fn make_absolute(path: &Path) -> Result<PathBuf, Error> {
+    if path.is_absolute() {
+        Ok(path.to_path_buf())
+    } else {
+        Ok(std::env::current_dir()?.join(path))
+    }
+}
+
 fn make_fargo_command(
     runner: Option<PathBuf>,
     options: &RunCargoOptions,
@@ -404,6 +412,7 @@
         options.get_story_name(),
         options.get_mod_name()
     );
+    let manifest_path_absolute;
     let manifest_path_string;
     let cmx_arg = format!("--{}", CMX_PATH);
     let app_dir_arg = format!("--{}", APP_DIR);
@@ -426,7 +435,8 @@
     }
 
     if let Some(manifest_path) = options.manifest_path.as_ref() {
-        manifest_path_string = manifest_path.to_string_lossy();
+        manifest_path_absolute = make_absolute(manifest_path)?;
+        manifest_path_string = manifest_path_absolute.to_string_lossy();
         runner_args.push("--manifest-path");
         runner_args.push(&manifest_path_string);
     }