Some checks failed
ci / test (beta, ubuntu-latest, beta) (pull_request) Has been cancelled
ci / test (macos, macos-latest, nightly) (pull_request) Has been cancelled
ci / test (nightly, ubuntu-latest, nightly) (pull_request) Has been cancelled
ci / test (pinned, ubuntu-latest, 1.85.0) (pull_request) Has been cancelled
ci / test (stable, ubuntu-latest, stable) (pull_request) Has been cancelled
ci / test (stable-aarch64, ubuntu-latest, stable, aarch64-unknown-linux-gnu) (pull_request) Has been cancelled
ci / test (stable-arm-gnueabihf, ubuntu-latest, stable, armv7-unknown-linux-gnueabihf) (pull_request) Has been cancelled
ci / test (stable-arm-musleabi, ubuntu-latest, stable, armv7-unknown-linux-musleabi) (pull_request) Has been cancelled
ci / test (stable-arm-musleabihf, ubuntu-latest, stable, armv7-unknown-linux-musleabihf) (pull_request) Has been cancelled
ci / test (stable-musl, ubuntu-latest, stable, x86_64-unknown-linux-musl) (pull_request) Has been cancelled
ci / test (stable-powerpc64, ubuntu-latest, stable, powerpc64-unknown-linux-gnu) (pull_request) Has been cancelled
ci / test (stable-riscv64, ubuntu-latest, stable, riscv64gc-unknown-linux-gnu) (pull_request) Has been cancelled
ci / test (stable-s390x, ubuntu-latest, stable, s390x-unknown-linux-gnu) (pull_request) Has been cancelled
ci / test (stable-x86, ubuntu-latest, stable, i686-unknown-linux-gnu) (pull_request) Has been cancelled
ci / test (win-gnu, windows-latest, nightly-x86_64-gnu) (pull_request) Has been cancelled
ci / test (win-msvc, windows-latest, nightly) (pull_request) Has been cancelled
ci / test (winaarch64-msvc, windows-11-arm, nightly) (pull_request) Has been cancelled
ci / wasm (pull_request) Has been cancelled
ci / rustfmt (pull_request) Has been cancelled
ci / docs (pull_request) Has been cancelled
ci / Compile Fuzz Test Targets (pull_request) Has been cancelled
62 lines
2.2 KiB
Rust
62 lines
2.2 KiB
Rust
fn main() {
|
|
set_git_revision_hash();
|
|
set_windows_exe_options();
|
|
}
|
|
|
|
/// Embed a Windows manifest and set some linker options.
|
|
///
|
|
/// The main reason for this is to enable long path support on Windows. This
|
|
/// still, I believe, requires enabling long path support in the registry. But
|
|
/// if that's enabled, then this will let ripgrep use C:\... style paths that
|
|
/// are longer than 260 characters.
|
|
fn set_windows_exe_options() {
|
|
static MANIFEST: &str = "pkg/windows/Manifest.xml";
|
|
|
|
let Ok(target_os) = std::env::var("CARGO_CFG_TARGET_OS") else { return };
|
|
let Ok(target_env) = std::env::var("CARGO_CFG_TARGET_ENV") else { return };
|
|
if !(target_os == "windows" && target_env == "msvc") {
|
|
return;
|
|
}
|
|
|
|
let Ok(mut manifest) = std::env::current_dir() else { return };
|
|
manifest.push(MANIFEST);
|
|
let Some(manifest) = manifest.to_str() else { return };
|
|
|
|
println!("cargo:rerun-if-changed={MANIFEST}");
|
|
// Embed the Windows application manifest file.
|
|
println!("cargo:rustc-link-arg-bin=rgs=/MANIFEST:EMBED");
|
|
println!("cargo:rustc-link-arg-bin=rgs=/MANIFESTINPUT:{manifest}");
|
|
// Turn linker warnings into errors. Helps debugging, otherwise the
|
|
// warnings get squashed (I believe).
|
|
println!("cargo:rustc-link-arg-bin=rgs=/WX");
|
|
}
|
|
|
|
/// Make the current git hash available to the build as the environment
|
|
/// variable `RIPGREP_BUILD_GIT_HASH`.
|
|
fn set_git_revision_hash() {
|
|
use std::process::Command;
|
|
|
|
let args = &["rev-parse", "--short=10", "HEAD"];
|
|
let output = Command::new("git").args(args).output();
|
|
match output {
|
|
Ok(output) => {
|
|
let rev =
|
|
String::from_utf8_lossy(&output.stdout).trim().to_string();
|
|
if rev.is_empty() {
|
|
println!(
|
|
"cargo:warning=output from `git rev-parse` is empty, \
|
|
so skipping embedding of commit hash"
|
|
);
|
|
return;
|
|
}
|
|
println!("cargo:rustc-env=RIPGREP_BUILD_GIT_HASH={rev}");
|
|
}
|
|
Err(e) => {
|
|
println!(
|
|
"cargo:warning=failed to run `git rev-parse`, \
|
|
so skipping embedding of commit hash: {e}"
|
|
);
|
|
}
|
|
}
|
|
}
|