mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-25 08:39:15 -05:00
build: add PYTHON envvar to specify your python binary (#1202)
This commit is contained in:
parent
8216c9e435
commit
af75d6d8a2
2 changed files with 22 additions and 5 deletions
|
@ -98,7 +98,9 @@ cargo build
|
|||
Use `V8_FROM_SOURCE=1 cargo build -vv` to build the crate completely from
|
||||
source.
|
||||
|
||||
The build scripts require Python 3 to be available as `python` in your `PATH`.
|
||||
The build scripts require Python 3 to be available as `python3` in your `PATH`.
|
||||
If you want to specify the exact binary of Python to use, you should use the
|
||||
`PYTHON` environment variable.
|
||||
|
||||
The build also requires `curl` to be installed on your system.
|
||||
|
||||
|
@ -109,6 +111,10 @@ install them.
|
|||
For Windows builds: the 64-bit toolchain needs to be used. 32-bit targets are
|
||||
not supported.
|
||||
|
||||
For Mac builds: You'll need Xcode and Xcode CLT installed. Recent macOS versions
|
||||
will also require you to pass PYTHON=python3 because macOS no longer ships with
|
||||
`python` simlinked to Python 3.
|
||||
|
||||
The build depends on several binary tools: `gn`, `ninja` and `clang`. The tools
|
||||
will automatically be downloaded, if they are not detected in the environment.
|
||||
|
||||
|
|
19
build.rs
19
build.rs
|
@ -34,6 +34,7 @@ fn main() {
|
|||
"SCCACHE",
|
||||
"V8_FORCE_DEBUG",
|
||||
"V8_FROM_SOURCE",
|
||||
"PYTHON",
|
||||
];
|
||||
for env in envs {
|
||||
println!("cargo:rerun-if-env-changed={}", env);
|
||||
|
@ -215,6 +216,7 @@ fn build_v8() {
|
|||
|
||||
fn print_gn_args(gn_out_dir: &Path) {
|
||||
assert!(Command::new(gn())
|
||||
.arg(format!("--script-executable={}", python()))
|
||||
.arg("args")
|
||||
.arg(gn_out_dir)
|
||||
.arg("--list")
|
||||
|
@ -239,7 +241,7 @@ fn maybe_clone_repo(dest: &str, repo: &str) {
|
|||
fn maybe_install_sysroot(arch: &str) {
|
||||
let sysroot_path = format!("build/linux/debian_sid_{}-sysroot", arch);
|
||||
if !PathBuf::from(sysroot_path).is_dir() {
|
||||
assert!(Command::new("python")
|
||||
assert!(Command::new(python())
|
||||
.arg("./build/linux/sysroot_scripts/install-sysroot.py")
|
||||
.arg(format!("--arch={}", arch))
|
||||
.status()
|
||||
|
@ -277,7 +279,7 @@ fn download_ninja_gn_binaries() {
|
|||
let ninja = ninja.with_extension("exe");
|
||||
|
||||
if !gn.exists() || !ninja.exists() {
|
||||
assert!(Command::new("python")
|
||||
assert!(Command::new(python())
|
||||
.arg("./tools/ninja_gn_binaries.py")
|
||||
.arg("--dir")
|
||||
.arg(&target_dir)
|
||||
|
@ -382,7 +384,7 @@ fn download_file(url: String, filename: PathBuf) {
|
|||
// Try downloading with python first. Python is a V8 build dependency,
|
||||
// so this saves us from adding a Rust HTTP client dependency.
|
||||
println!("Downloading {}", url);
|
||||
let status = Command::new("python")
|
||||
let status = Command::new(python())
|
||||
.arg("./tools/download_file.py")
|
||||
.arg("--url")
|
||||
.arg(&url)
|
||||
|
@ -531,7 +533,7 @@ fn find_compatible_system_clang() -> Option<PathBuf> {
|
|||
fn clang_download() -> PathBuf {
|
||||
let clang_base_path = build_dir().join("clang");
|
||||
println!("clang_base_path {}", clang_base_path.display());
|
||||
assert!(Command::new("python")
|
||||
assert!(Command::new(python())
|
||||
.arg("./tools/clang/scripts/update.py")
|
||||
.arg("--output-dir")
|
||||
.arg(&clang_base_path)
|
||||
|
@ -638,6 +640,14 @@ fn gn() -> String {
|
|||
env::var("GN").unwrap_or_else(|_| "gn".to_owned())
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the system's python binary - specified via the PYTHON environment
|
||||
* variable or defaulting to `python3`.
|
||||
*/
|
||||
fn python() -> String {
|
||||
env::var("PYTHON").unwrap_or_else(|_| "python3".to_owned())
|
||||
}
|
||||
|
||||
type NinjaEnv = Vec<(String, String)>;
|
||||
|
||||
fn ninja(gn_out_dir: &Path, maybe_env: Option<NinjaEnv>) -> Command {
|
||||
|
@ -671,6 +681,7 @@ pub fn maybe_gen(manifest_dir: &str, gn_args: GnArgs) -> PathBuf {
|
|||
);
|
||||
assert!(Command::new(gn())
|
||||
.arg(format!("--root={}", dirs.root.display()))
|
||||
.arg(format!("--script-executable={}", python()))
|
||||
.arg("gen")
|
||||
.arg(&gn_out_dir)
|
||||
.arg("--args=".to_owned() + &args)
|
||||
|
|
Loading…
Reference in a new issue