run_make_support: move external deps to `external_deps` module

This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-07-15 10:00:18 +00:00
parent a02008edac
commit 288c572745
10 changed files with 49 additions and 24 deletions

View File

@ -1,5 +1,5 @@
use std::ffi::OsString;
use std::env;
use std::ffi::OsString;
#[track_caller]
#[must_use]

View File

@ -0,0 +1,14 @@
use crate::command::Command;
use crate::source_root;
use super::python::python_command;
/// `htmldocck` is a python script which is used for rustdoc test suites, it is assumed to be
/// available at `$SOURCE_ROOT/src/etc/htmldocck.py`.
#[track_caller]
#[must_use]
pub fn htmldocck() -> Command {
let mut python = python_command();
python.arg(source_root().join("src/etc/htmldocck.py"));
python
}

View File

@ -0,0 +1,10 @@
//! This module contains external tool dependencies that we assume are available in the environment,
//! such as `cc` or `python`.
pub mod cc;
pub mod clang;
pub mod htmldocck;
pub mod llvm;
pub mod python;
pub mod rustc;
pub mod rustdoc;

View File

@ -0,0 +1,11 @@
use crate::command::Command;
use crate::env_checked::env_var;
/// Obtain path of python as provided by the `PYTHON` environment variable. It is up to the caller
/// to document and check if the python version is compatible with its intended usage.
#[track_caller]
#[must_use]
pub fn python_command() -> Command {
let python_path = env_var("PYTHON");
Command::new(python_path)
}

View File

@ -3,17 +3,13 @@
//! notably is built via cargo: this means that if your test wants some non-trivial utility, such
//! as `object` or `wasmparser`, they can be re-exported and be made available through this library.
pub mod cc;
pub mod clang;
mod command;
pub mod diff;
pub mod env_checked;
pub mod external_deps;
pub mod fs_wrapper;
pub mod llvm;
mod macros;
pub mod run;
pub mod rustc;
pub mod rustdoc;
pub mod targets;
use std::fs;
@ -27,17 +23,26 @@ pub use object;
pub use regex;
pub use wasmparser;
// Re-exports of external dependencies.
pub use external_deps::{cc, clang, htmldocck, llvm, python, rustc, rustdoc};
pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
pub use clang::{clang, Clang};
pub use diff::{diff, Diff};
pub use env_checked::{env_var, env_var_os};
pub use htmldocck::htmldocck;
pub use llvm::{
llvm_ar, llvm_filecheck, llvm_objdump, llvm_profdata, llvm_readobj, LlvmAr, LlvmFilecheck,
LlvmObjdump, LlvmProfdata, LlvmReadobj,
};
pub use run::{cmd, run, run_fail, run_with_args};
pub use python::python_command;
pub use rustc::{aux_build, bare_rustc, rustc, Rustc};
pub use rustdoc::{bare_rustdoc, rustdoc, Rustdoc};
pub use diff::{diff, Diff};
pub use env_checked::{env_var, env_var_os};
pub use run::{cmd, run, run_fail, run_with_args};
pub use targets::{is_darwin, is_msvc, is_windows, target, uname};
use command::{Command, CompletedProcess};
@ -55,21 +60,6 @@ pub fn ar(inputs: &[impl AsRef<Path>], output_path: impl AsRef<Path>) {
}
}
#[track_caller]
#[must_use]
pub fn python_command() -> Command {
let python_path = env_var("PYTHON");
Command::new(python_path)
}
#[track_caller]
#[must_use]
pub fn htmldocck() -> Command {
let mut python = python_command();
python.arg(source_root().join("src/etc/htmldocck.py"));
python
}
/// Returns the path for a local test file.
pub fn path<P: AsRef<Path>>(p: P) -> PathBuf {
cwd().join(p.as_ref())