Don't use env::current_dir in build script
The current directory from a build script executed by cargo is always the manifest dir, so we may as well only use the manifest dir.
This commit is contained in:
parent
0d25d74cd6
commit
6b52c1e93c
|
|
@ -3,8 +3,6 @@ use std::ffi::OsString;
|
|||
use std::path::PathBuf;
|
||||
|
||||
pub(crate) struct Config {
|
||||
// TODO(nox): Use manifest dir instead.
|
||||
pub(crate) pwd: PathBuf,
|
||||
pub(crate) manifest_dir: PathBuf,
|
||||
pub(crate) out_dir: PathBuf,
|
||||
pub(crate) host: String,
|
||||
|
|
@ -38,8 +36,6 @@ pub(crate) struct Env {
|
|||
|
||||
impl Config {
|
||||
pub(crate) fn from_env() -> Self {
|
||||
let pwd = env::current_dir().unwrap();
|
||||
|
||||
let manifest_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap().into();
|
||||
let out_dir = env::var_os("OUT_DIR").unwrap().into();
|
||||
let host = env::var("HOST").unwrap();
|
||||
|
|
@ -52,7 +48,6 @@ impl Config {
|
|||
let env = Env::from_env();
|
||||
|
||||
let config = Self {
|
||||
pwd,
|
||||
manifest_dir,
|
||||
out_dir,
|
||||
host,
|
||||
|
|
|
|||
|
|
@ -249,8 +249,10 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
|
|||
"x86" => {
|
||||
boringssl_cmake.define(
|
||||
"CMAKE_TOOLCHAIN_FILE",
|
||||
// `src_path` can be a path relative to the manifest dir, but
|
||||
// cmake hates that.
|
||||
config
|
||||
.pwd
|
||||
.manifest_dir
|
||||
.join(src_path)
|
||||
.join("src/util/32-bit-toolchain.cmake")
|
||||
.as_os_str(),
|
||||
|
|
@ -259,13 +261,19 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
|
|||
"aarch64" => {
|
||||
boringssl_cmake.define(
|
||||
"CMAKE_TOOLCHAIN_FILE",
|
||||
config.pwd.join("cmake/aarch64-linux.cmake").as_os_str(),
|
||||
config
|
||||
.manifest_dir
|
||||
.join("cmake/aarch64-linux.cmake")
|
||||
.as_os_str(),
|
||||
);
|
||||
}
|
||||
"arm" => {
|
||||
boringssl_cmake.define(
|
||||
"CMAKE_TOOLCHAIN_FILE",
|
||||
config.pwd.join("cmake/armv7-linux.cmake").as_os_str(),
|
||||
config
|
||||
.manifest_dir
|
||||
.join("cmake/armv7-linux.cmake")
|
||||
.as_os_str(),
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue