[gn] Make boringssl-sys Rust crate usable on host
Change-Id: Ie91972c98cac95e64165957ff1ab024ba8747305
diff --git a/rust/boringssl-sys/BUILD.gn b/rust/boringssl-sys/BUILD.gn
index b951c0d..ce0d04b 100644
--- a/rust/boringssl-sys/BUILD.gn
+++ b/rust/boringssl-sys/BUILD.gn
@@ -14,4 +14,14 @@
# only depend on libcrypto until we actually use the SSL bits
"//third_party/boringssl:crypto",
]
+
+ if (current_toolchain == host_toolchain) {
+ # Unspeakable kludge to get the all wrong and completely fragile
+ # linking semantics for non_rust_deps to squeak through for the
+ # static libcrypto from boringssl.
+ crypto_out_dir = get_label_info(non_rust_deps[0], "target_out_dir")
+ static_libcrypto = rebase_path("$crypto_out_dir/libcrypto.a")
+ shlib_out_dir = get_label_info(":any($shlib_toolchain)", "root_out_dir")
+ write_file("$shlib_out_dir/libcrypto.so", [ "INPUT($static_libcrypto)" ])
+ }
}