graphql-engine/v3/crates/engine/build.rs
Daniel Harvey bdd5d06437 Move all crates into a folder (#355)
<!-- Thank you for submitting this PR! :) -->

## Description

This moves all the crates into a `/crates` folder. Everything appears to
just work, thanks Cargo!

V3_GIT_ORIGIN_REV_ID: 8e3ef287b1a46cabdb4d919a50e813ab2cddf8b1
2024-03-19 18:07:14 +00:00

28 lines
1.0 KiB
Rust

fn main() -> Result<(), String> {
// Ensure that we rebuild if the version is specified.
println!("cargo:rerun-if-env-changed=RELEASE_VERSION");
// On release builds, use the Git commit as a backup if the version is not set.
// On debug builds, use "dev".
// If we fail to get the Git information, fail.
let build_profile = std::env::var("PROFILE").map_err(|err| err.to_string())?;
let release_version = if build_profile == "release" {
match option_env!("RELEASE_VERSION") {
Some(version) => version.to_string(),
None => {
let git_commit_ref = build_data::get_git_commit_short()?;
let git_dirty = build_data::get_git_dirty().unwrap_or(false);
if git_dirty {
format!("{git_commit_ref}-dirty")
} else {
git_commit_ref
}
}
}
} else {
"dev".to_string()
};
println!("cargo:rustc-env=CARGO_V3_ENGINE_VERSION={release_version}");
Ok(())
}