Add an environmental variable for the zircon build directory

These are intended to be used by build.rs scripts when not building with gn to allow them to find static libraries they need.

Also remove some obsolete environmental variables.

Change-Id: Ie06959763388c87912b2efd1b04b88b689644128
diff --git a/README.md b/README.md
index 83004fc..7ac9eac 100644
--- a/README.md
+++ b/README.md
@@ -128,6 +128,22 @@
 To change this behavior, set the environmental variables `FARGO_CARGO` and `FARGO_RUSTC` before
 running fargo.
 
+## Environmental variables set by fargo
+
+CARGO\_TARGET\_[X86\_64|AARCH64]\_UNKNOWN\_FUCHSIA\_RUNNER - set to the fargo binary to run remotely on simulator or device.
+
+CARGO\_TARGET\_[X86\_64|AARCH64]\_UNKNOWN\_FUCHSIA\_RUSTFLAGS - set to provide linker flags
+
+CARGO\_TARGET\_[X86\_64|AARCH64]\_UNKNOWN\_FUCHSIA\_LINKER - set to specify the linker
+
+RUSTC - set to cause cargo to use the copy of rustc in buildtools
+
+RUSTDOC - set to cause cargo to use the copy of rustdoc in buildtools
+
+FUCHSIA\_SHARED\_ROOT - set to the directory containing shared libraries for the current selected architecture. Useful for build scripts.
+
+ZIRCON\_BUILD\_ROOT - set to the zircon build directory for the current architecture. Useful for build scripts.
+
 ## Using crates that link with native libraries
 
 Some crates are wrappers around libraries written in other languages. An
diff --git a/src/lib.rs b/src/lib.rs
index e2b2f3c..4ae9f80 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -25,9 +25,8 @@
 use failure::{err_msg, Error, ResultExt};
 pub use sdk::TargetOptions;
 use sdk::{cargo_out_dir, cargo_path, clang_archiver_path, clang_c_compiler_path,
-          clang_cpp_compiler_path, clang_linker_path, clang_ranlib_path, fidl2_target_gen_dir,
-          rustc_path, rustdoc_path, shared_libraries_path, sysroot_path, target_gen_dir,
-          FuchsiaConfig};
+          clang_cpp_compiler_path, clang_linker_path, clang_ranlib_path, rustc_path, rustdoc_path,
+          shared_libraries_path, sysroot_path, zircon_build_path, FuchsiaConfig};
 use std::fs;
 use std::path::PathBuf;
 use std::process::Command;
@@ -217,7 +216,7 @@
 }
 
 fn build_doc(
-    run_cargo_options: RunCargoOptions, target_options: &TargetOptions, no_deps: bool, open: bool
+    run_cargo_options: RunCargoOptions, target_options: &TargetOptions, no_deps: bool, open: bool,
 ) -> Result<(), Error> {
     let mut args = vec![];
     if no_deps {
@@ -444,8 +443,11 @@
         )
         .env("RUSTC", rustc_path(target_options)?.to_str().unwrap())
         .env("RUSTDOC", rustdoc_path(target_options)?.to_str().unwrap())
-        .env("FUCHSIA_GEN_ROOT", target_gen_dir(target_options)?)
-        .env("FIDL_GEN_ROOT", fidl2_target_gen_dir(target_options)?)
+        .env(
+            "FUCHSIA_SHARED_ROOT",
+            shared_libraries_path(target_options)?,
+        )
+        .env("ZIRCON_BUILD_ROOT", zircon_build_path(target_options)?)
         .arg(subcommand)
         .args(target_args)
         .args(args);
diff --git a/src/sdk.rs b/src/sdk.rs
index cf1aebe..0220801 100644
--- a/src/sdk.rs
+++ b/src/sdk.rs
@@ -116,16 +116,6 @@
     possible_target_out_dir(&fuchsia_dir, options)
 }
 
-pub fn target_gen_dir(options: &TargetOptions) -> Result<PathBuf, Error> {
-    let target_out_dir = target_out_dir(options)?;
-    Ok(target_out_dir.join("gen"))
-}
-
-pub fn fidl2_target_gen_dir(options: &TargetOptions) -> Result<PathBuf, Error> {
-    let target_out_dir = target_out_dir(options)?;
-    Ok(target_out_dir.join("fidling/gen"))
-}
-
 pub fn cargo_out_dir(options: &TargetOptions) -> Result<PathBuf, Error> {
     let fuchsia_dir = fuchsia_dir(options)?;
     let target_triple = format!("{}-unknown-fuchsia", options.target_cpu_linker);
@@ -147,6 +137,20 @@
         .join("sysroot"))
 }
 
+pub fn zircon_build_path(options: &TargetOptions) -> Result<PathBuf, Error> {
+    let fuchsia_dir = fuchsia_dir(options)?;
+    let build_name = if options.target_cpu == X64 {
+        "build-x64"
+    } else {
+        "build-arm64"
+    };
+    let zircon_build = fuchsia_dir
+        .join("out")
+        .join("build-zircon")
+        .join(build_name);
+    Ok(zircon_build)
+}
+
 pub fn shared_libraries_path(options: &TargetOptions) -> Result<PathBuf, Error> {
     let shared_name = if options.target_cpu == X64 {
         "x64-shared"