Rust bindings: Use CARGO_MANIFEST_DIR in build.rs

When a rust crate uses the boringssl rust bindings like:

```Cargo.toml
[dependencies]
bssl-sys = { path = "./third_party/boringssl/build/rust" }
```

The working directory of `build.rs` is set to the the crate's
working directory so "." and ".." aren't relative to the bindings'
directory. Use CARGO_MANIFEST_DIR to specify link search paths.

Change-Id: Ieb49f4ab479f47390388dc5ace70561f593dc238
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/51645
Reviewed-by: David Drysdale <drysdale@google.com>
Reviewed-by: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/.gitignore b/.gitignore
index 6cbc9d2..1a27c89 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
 *.swo
 doc/*.html
 doc/doc.css
+rust/Cargo.lock
 rust/target
 
 util/bot/android_ndk
diff --git a/rust/build.rs b/rust/build.rs
index f6ce794..b029223 100644
--- a/rust/build.rs
+++ b/rust/build.rs
@@ -13,14 +13,27 @@
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+use std::env;
+use std::path::Path;
+
 fn main() {
+    let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+    let crate_path = Path::new(&dir);
+    let parent_path = crate_path.parent().unwrap();
+
     // Statically link libraries.
-    println!("cargo:rustc-link-search=native=../crypto");
+    println!(
+        "cargo:rustc-link-search=native={}",
+        parent_path.join("crypto").display()
+    );
     println!("cargo:rustc-link-lib=static=crypto");
 
-    println!("cargo:rustc-link-search=native=../ssl");
+    println!(
+        "cargo:rustc-link-search=native={}",
+        parent_path.join("ssl").display()
+    );
     println!("cargo:rustc-link-lib=static=ssl");
 
-    println!("cargo:rustc-link-search=native=.");
+    println!("cargo:rustc-link-search=native={}", crate_path.display());
     println!("cargo:rustc-link-lib=static=rust_wrapper");
 }