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;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub(crate) struct Config {
|
pub(crate) struct Config {
|
||||||
// TODO(nox): Use manifest dir instead.
|
|
||||||
pub(crate) pwd: PathBuf,
|
|
||||||
pub(crate) manifest_dir: PathBuf,
|
pub(crate) manifest_dir: PathBuf,
|
||||||
pub(crate) out_dir: PathBuf,
|
pub(crate) out_dir: PathBuf,
|
||||||
pub(crate) host: String,
|
pub(crate) host: String,
|
||||||
|
|
@ -38,8 +36,6 @@ pub(crate) struct Env {
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub(crate) fn from_env() -> Self {
|
pub(crate) fn from_env() -> Self {
|
||||||
let pwd = env::current_dir().unwrap();
|
|
||||||
|
|
||||||
let manifest_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap().into();
|
let manifest_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap().into();
|
||||||
let out_dir = env::var_os("OUT_DIR").unwrap().into();
|
let out_dir = env::var_os("OUT_DIR").unwrap().into();
|
||||||
let host = env::var("HOST").unwrap();
|
let host = env::var("HOST").unwrap();
|
||||||
|
|
@ -52,7 +48,6 @@ impl Config {
|
||||||
let env = Env::from_env();
|
let env = Env::from_env();
|
||||||
|
|
||||||
let config = Self {
|
let config = Self {
|
||||||
pwd,
|
|
||||||
manifest_dir,
|
manifest_dir,
|
||||||
out_dir,
|
out_dir,
|
||||||
host,
|
host,
|
||||||
|
|
|
||||||
|
|
@ -249,8 +249,10 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
|
||||||
"x86" => {
|
"x86" => {
|
||||||
boringssl_cmake.define(
|
boringssl_cmake.define(
|
||||||
"CMAKE_TOOLCHAIN_FILE",
|
"CMAKE_TOOLCHAIN_FILE",
|
||||||
|
// `src_path` can be a path relative to the manifest dir, but
|
||||||
|
// cmake hates that.
|
||||||
config
|
config
|
||||||
.pwd
|
.manifest_dir
|
||||||
.join(src_path)
|
.join(src_path)
|
||||||
.join("src/util/32-bit-toolchain.cmake")
|
.join("src/util/32-bit-toolchain.cmake")
|
||||||
.as_os_str(),
|
.as_os_str(),
|
||||||
|
|
@ -259,13 +261,19 @@ fn get_boringssl_cmake_config(config: &Config) -> cmake::Config {
|
||||||
"aarch64" => {
|
"aarch64" => {
|
||||||
boringssl_cmake.define(
|
boringssl_cmake.define(
|
||||||
"CMAKE_TOOLCHAIN_FILE",
|
"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" => {
|
"arm" => {
|
||||||
boringssl_cmake.define(
|
boringssl_cmake.define(
|
||||||
"CMAKE_TOOLCHAIN_FILE",
|
"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