Bunch of changes, like a lot

This commit is contained in:
Elias Wendland
2026-07-17 18:58:52 +02:00
parent f07f54d4c1
commit 3297f60f00
25 changed files with 566 additions and 285 deletions
+23 -7
View File
@@ -12,18 +12,34 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use std::process::Command;
use std::{path::Path, process::Command};
fn main() {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".to_owned());
let version = Command::new(rustc)
.arg("--version")
fn latest_engine_version(workspace: &Path) -> String {
if let Ok(version) = std::env::var("CONVERTIS_ENGINE_VERSION") {
return version;
}
Command::new("git")
.args(["describe", "--tags", "--abbrev=0", "--match", "v[0-9]*"])
.current_dir(workspace)
.output()
.ok()
.filter(|output| output.status.success())
.map(|output| String::from_utf8_lossy(&output.stdout).trim().to_owned())
.unwrap_or_else(|| "unknown".to_owned());
.filter(|version| !version.is_empty())
.map(|version| version.strip_prefix('v').unwrap_or(&version).to_owned())
.unwrap_or_else(|| "unknown".to_owned())
}
fn main() {
let manifest = std::env::var_os("CARGO_MANIFEST_DIR").expect("Cargo provides manifest dir");
let workspace = Path::new(&manifest).join("../..");
let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_owned());
println!("cargo:rustc-env=CONVERTIS_RUSTC_VERSION={version}");
let engine_version = latest_engine_version(&workspace);
println!("cargo:rerun-if-env-changed=CONVERTIS_ENGINE_VERSION");
println!(
"cargo:rerun-if-changed={}",
workspace.join(".git/HEAD").display()
);
println!("cargo:rustc-env=CONVERTIS_ENGINE_VERSION={engine_version}");
println!("cargo:rustc-env=CONVERTIS_TARGET={target}");
}