commit 387ba0e5b8876decdaed97f2333f033f5707e52b
parent d59c00bf5c8ac23ee4eb4b01c2e7fdbed7822c76
Author: Antoine A <>
Date: Sat, 18 Apr 2026 12:39:18 +0200
build: improve build version logic
Diffstat:
7 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
@@ -32,9 +32,6 @@ install-nobuild-files:
install -m 644 -D -t $(share_dir)/taler-apns-relay/sql taler-apns-relay/db/apns-relay*.sql
install -m 644 -D -t $(man_dir)/man1 doc/prebuilt/man/taler-apns-relay.1
install -m 644 -D -t $(man_dir)/man5 doc/prebuilt/man/taler-apns-relay.conf.5
-
-.PHONY: install
-install: build install-nobuild-files
install -D -t $(bin_dir) contrib/taler-magnet-bank-dbconfig
install -D -t $(bin_dir) target/release/taler-magnet-bank
install -D -t $(bin_dir) contrib/taler-cyclos-dbconfig
@@ -42,8 +39,11 @@ install: build install-nobuild-files
install -D -t $(bin_dir) contrib/taler-apns-relay-dbconfig
install -D -t $(bin_dir) target/release/taler-apns-relay
+.PHONY: install
+install: build install-nobuild-files
+
.PHONY: check
-check: install
+check: install-nobuild-files
cargo clippy --all-targets
cargo test
diff --git a/common/taler-build/src/lib.rs b/common/taler-build/src/lib.rs
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2025 Taler Systems SA
+ Copyright (C) 2025, 2026 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free Software
@@ -14,8 +14,10 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
+use std::sync::LazyLock;
+
/// Taler component version format
-pub fn long_version() -> &'static str {
+static LONG_VERSION: LazyLock<String> = LazyLock::new(|| {
let version = env!("CARGO_PKG_VERSION");
let git_hash = option_env!("GIT_HASH");
if let Some(hash) = git_hash {
@@ -23,5 +25,9 @@ pub fn long_version() -> &'static str {
} else {
format!("v{version}")
}
- .leak()
+});
+
+/// Taler component version format
+pub fn long_version() -> &'static str {
+ &LONG_VERSION
}
diff --git a/common/taler-common/src/types/amount.rs b/common/taler-common/src/types/amount.rs
@@ -37,6 +37,8 @@ pub const FRAC_BASE_NB_DIGITS: u8 = 8;
/** The fraction part of an amount represents which fraction of the value */
pub const FRAC_BASE: u32 = 10u32.pow(FRAC_BASE_NB_DIGITS as u32);
+const CENT_FRACTION: u32 = 10u32.pow((FRAC_BASE_NB_DIGITS - 2) as u32);
+
#[derive(
Clone, Copy, PartialEq, Eq, serde_with::DeserializeFromStr, serde_with::SerializeDisplay,
)]
@@ -310,6 +312,11 @@ impl Amount {
self.decimal() == Decimal::zero()
}
+ /* Check is amount has fractional amount < 0.01 */
+ pub fn is_sub_cent(&self) -> bool {
+ !self.frac.is_multiple_of(CENT_FRACTION)
+ }
+
pub const fn decimal(&self) -> Decimal {
Decimal {
val: self.val,
diff --git a/common/taler-common/src/types/payto.rs b/common/taler-common/src/types/payto.rs
@@ -35,15 +35,6 @@ pub fn payto(url: impl AsRef<str>) -> PaytoURI {
url.as_ref().parse().expect("invalid payto")
}
-/// Generate an iban payto URI, panic if malformed
-pub fn iban_payto(iban: impl AsRef<str>, name: impl AsRef<str>) -> PaytoURI {
- IbanPayto::new(BankID {
- iban: iban.as_ref().parse().expect("invalid IBAN"),
- bic: None,
- })
- .as_full_payto(name.as_ref())
-}
-
pub trait PaytoImpl: Sized {
fn as_payto(&self) -> PaytoURI;
fn as_full_payto(&self, name: &str) -> PaytoURI {
@@ -157,6 +148,7 @@ impl FromStr for PaytoURI {
pub type IbanPayto = Payto<BankID>;
pub type FullIbanPayto = FullPayto<BankID>;
+pub type TransferIbanPayto = TransferPayto<BankID>;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BankID {
diff --git a/common/taler-common/src/types/utils.rs b/common/taler-common/src/types/utils.rs
@@ -16,7 +16,11 @@
use std::{fmt::Debug, ops::Deref};
-use jiff::{Timestamp, civil::Date, tz::TimeZone};
+use jiff::{
+ Timestamp,
+ civil::{Date, DateTime},
+ tz::TimeZone,
+};
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct InlineStr<const LEN: usize> {
@@ -96,6 +100,11 @@ pub fn date_to_utc_ts(date: &Date) -> Timestamp {
date.to_zoned(TimeZone::UTC).unwrap().timestamp()
}
+/** Convert a date time to a UTC timestamp */
+pub fn date_time_to_utc_ts(date: &DateTime) -> Timestamp {
+ date.to_zoned(TimeZone::UTC).unwrap().timestamp()
+}
+
/** Get current timestamp truncated to micros precision */
pub fn now_sql_stable_ts() -> Timestamp {
Timestamp::from_microsecond(Timestamp::now().as_microsecond()).unwrap()
diff --git a/common/taler-enum-meta/src/lib.rs b/common/taler-enum-meta/src/lib.rs
@@ -70,6 +70,7 @@ pub fn derive_domain_code(input: TokenStream) -> TokenStream {
})
};
+ let mut entries = Vec::new();
let mut description_arms = Vec::new();
let mut code_arms = Vec::new();
let mut from_str_arms = Vec::new();
@@ -120,9 +121,15 @@ pub fn derive_domain_code(input: TokenStream) -> TokenStream {
if enabled_str {
as_ref_arms.push(quote! { Self::#v_ident => #v_str });
}
+ entries.push(quote! { Self::#v_ident, });
}
- let mut expanded = quote! {};
+ let mut expanded = quote! {
+ impl #name {
+ /// Returns a slice of all enum variants.
+ pub const entries: &'static [Self] = &[#(#entries)*];
+ }
+ };
if enabled_doc {
expanded.extend(quote! {
diff --git a/common/taler-test-utils/src/lib.rs b/common/taler-test-utils/src/lib.rs
@@ -22,6 +22,6 @@ pub mod json;
pub mod routine;
pub mod server;
-fn setup_tracing() {
+pub fn setup_tracing() {
taler_logger(None).try_init().ok();
}