Load ngbv version in cargo build script

This commit is contained in:
Caelan Sayler
2023-12-23 20:57:35 +00:00
parent ace4cadeb9
commit 4ff8cfb351
5 changed files with 18 additions and 19 deletions

2
src/Rust/Cargo.lock generated
View File

@@ -226,7 +226,7 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
[[package]]
name = "clowd_squirrel"
version = "0.1.0"
version = "0.0.0-local"
dependencies = [
"anyhow",
"chrono",

View File

@@ -1,6 +1,6 @@
[package]
name = "clowd_squirrel"
version = "0.1.0"
version = "0.0.0-local"
edition = "2021"
[[bin]]

View File

@@ -1,18 +1,16 @@
use semver;
use std::process::Command;
extern crate winres;
fn main() {
// cc::Build::new()
// .cpp(true)
// .file("src/platform/windows/shortcuts.cpp")
// .define("UNICODE", None)
// .define("_UNICODE", None)
// .compile("lib_shortcuts");
// println!("cargo:rerun-if-changed=src/platform/windows/shortcuts.cpp");
let ver = env!("CARGO_PKG_VERSION");
let ver = semver::Version::parse(&ver).unwrap();
let ver_output = Command::new("nbgv").args(&["get-version", "-v", "NuGetPackageVersion"]).output().expect("Failed to execute nbgv get-version");
let version = String::from_utf8(ver_output.stdout).expect("Unable to convert ngbv output to string");
let version = version.trim();
let ver = semver::Version::parse(&version).expect("Unable to parse ngbv output as semver version");
let ver: u64 = ver.major << 48 | ver.minor << 32 | ver.patch << 16;
let desc = format!("Clowd.Squirrel {}", version);
println!("cargo:rustc-env=NGBV_VERSION={}", version);
let _ = winres::WindowsResource::new()
.set_manifest_file("app.manifest")
@@ -20,8 +18,9 @@ fn main() {
.set_version_info(winres::VersionInfo::FILEVERSION, ver)
.set("CompanyName", "Clowd.Squirrel")
.set("ProductName", "Clowd.Squirrel")
.set("FileDescription", "Clowd.Squirrel")
.set("ProductVersion", version)
.set("FileDescription", &desc)
.set("LegalCopyright", "Caelan Sayler (c) 2023")
.compile()
.unwrap();
}
}

View File

@@ -30,7 +30,7 @@ use winsafe::{self as w, co};
fn main() -> Result<()> {
let mut arg_config = Command::new("Setup")
.about(format!("Clowd.Squirrel Setup ({}) installs Squirrel applications.\nhttps://github.com/clowd/Clowd.Squirrel", env!("CARGO_PKG_VERSION")))
.about(format!("Clowd.Squirrel Setup ({}) installs Squirrel applications.\nhttps://github.com/clowd/Clowd.Squirrel", env!("NGBV_VERSION")))
.arg(arg!(-s --silent "Hides all dialogs and answers 'yes' to all prompts"))
.arg(arg!(-v --verbose "Print debug messages to console"))
.arg(arg!(-l --log <FILE> "Enable file logging and set location").required(false).value_parser(value_parser!(PathBuf)))
@@ -52,7 +52,7 @@ fn main() -> Result<()> {
platform::set_silent(silent);
util::setup_logging(logfile, true, verbose, nocolor)?;
info!("Starting Clowd.Squirrel Setup ({})", env!("CARGO_PKG_VERSION"));
info!("Starting Clowd.Squirrel Setup ({})", env!("NGBV_VERSION"));
info!(" Location: {:?}", std::env::current_exe()?);
info!(" Silent: {}", silent);
info!(" Verbose: {}", verbose);

View File

@@ -25,8 +25,8 @@ use crate::bundle::BundleInfo;
#[rustfmt::skip]
fn root_command() -> Command {
Command::new("Update")
.version(env!("CARGO_PKG_VERSION"))
.about(format!("Clowd.Squirrel Updater ({}) manages packages and installs updates for Squirrel applications.\nhttps://github.com/clowd/Clowd.Squirrel", env!("CARGO_PKG_VERSION")))
.version(env!("NGBV_VERSION"))
.about(format!("Clowd.Squirrel Updater ({}) manages packages and installs updates for Squirrel applications.\nhttps://github.com/clowd/Clowd.Squirrel", env!("NGBV_VERSION")))
.subcommand(Command::new("apply")
.about("Applies a staged / prepared update, installing prerequisite runtimes if necessary")
.arg(arg!(-r --restart "Restart the application after the update"))
@@ -83,7 +83,7 @@ fn main() -> Result<()> {
platform::set_silent(silent);
util::setup_logging(Some(&log_file), true, verbose, nocolor)?;
info!("Starting Clowd.Squirrel Updater ({})", env!("CARGO_PKG_VERSION"));
info!("Starting Clowd.Squirrel Updater ({})", env!("NGBV_VERSION"));
info!(" Location: {}", env::current_exe()?.to_string_lossy());
info!(" Verbose: {}", verbose);
info!(" Silent: {}", silent);