From: Stefan Reiter <s.reiter@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v3 proxmox-backup-qemu 2/3] return version via rust fn instead of header define
Date: Tue, 24 Nov 2020 16:41:21 +0100 [thread overview]
Message-ID: <20201124154122.22202-3-s.reiter@proxmox.com> (raw)
In-Reply-To: <20201124154122.22202-1-s.reiter@proxmox.com>
Otherwise the string gets included in the QEMU binary, not the library.
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
---
v3: added, applies as followup on top of already applied one
Makefile | 2 +-
build.rs | 6 +++---
current-api.h | 7 +++++--
src/lib.rs | 13 +++++++++++++
4 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/Makefile b/Makefile
index f799124..e3a3420 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ endif
all:
ifneq ($(BUILD_MODE), skip)
cargo build $(CARGO_BUILD_ARGS)
- diff -I 'PROXMOX_BACKUP_QEMU_VERSION' -up current-api.h proxmox-backup-qemu.h
+ diff -up current-api.h proxmox-backup-qemu.h
endif
# always re-create this dir
diff --git a/build.rs b/build.rs
index 274e935..6940d3f 100644
--- a/build.rs
+++ b/build.rs
@@ -12,8 +12,8 @@ fn main() {
Some(ver) if !ver.is_empty() => ver,
_ => "UNKNOWN",
};
- let version_define = format!(
- "\n#define PROXMOX_BACKUP_QEMU_VERSION \"{} ({})\"",
+ let version_string = format!(
+ "{} ({})",
crate_ver,
git_ver,
);
@@ -23,10 +23,10 @@ fn main() {
.with_crate(&crate_dir)
.with_header(header)
.with_include_guard("PROXMOX_BACKUP_QEMU_H")
- .with_after_include(version_define)
.generate()
.unwrap()
.write_to_file("proxmox-backup-qemu.h");
println!("cargo:rustc-cdylib-link-arg=-Wl,-soname,libproxmox_backup_qemu.so.0");
+ println!("cargo:rustc-env=PBS_LIB_VERSION={}", version_string);
}
diff --git a/current-api.h b/current-api.h
index cc4d0c1..abe7e89 100644
--- a/current-api.h
+++ b/current-api.h
@@ -32,8 +32,6 @@
#include <stdint.h>
#include <stdlib.h>
-#define PROXMOX_BACKUP_QEMU_VERSION "0.7.1 (dbb900ce4f524af2b59c59727203633588f32804)"
-
#define PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE ((1024 * 1024) * 4)
/**
@@ -183,6 +181,11 @@ ProxmoxBackupHandle *proxmox_backup_new(const char *repo,
const char *fingerprint,
char **error);
+/**
+ * Return a read-only pointer to a string containing the version of the library.
+ */
+const char *proxmox_backup_qemu_version(void);
+
/**
* Register a backup image (sync)
*/
diff --git a/src/lib.rs b/src/lib.rs
index 67c18fc..b755014 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -28,6 +28,19 @@ mod tools;
pub const PROXMOX_BACKUP_DEFAULT_CHUNK_SIZE: u64 = 1024*1024*4;
+use lazy_static::lazy_static;
+lazy_static!{
+ static ref VERSION_CSTR: CString = {
+ CString::new(env!("PBS_LIB_VERSION")).unwrap()
+ };
+}
+
+/// Return a read-only pointer to a string containing the version of the library.
+#[no_mangle]
+pub extern "C" fn proxmox_backup_qemu_version() -> *const c_char {
+ VERSION_CSTR.as_ptr()
+}
+
/// Free returned error messages
///
/// All calls can return error messages, but they are allocated using
--
2.20.1
next prev parent reply other threads:[~2020-11-24 15:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-24 15:41 [pve-devel] [PATCH v3 0/3] Add proxmox-backup-qemu version to VM status output Stefan Reiter
2020-11-24 15:41 ` [pve-devel] [PATCH v3 pve-qemu 1/3] update patches with squashed in 'include library version' Stefan Reiter
2020-11-25 10:59 ` [pve-devel] applied: " Fabian Grünbichler
2020-11-24 15:41 ` Stefan Reiter [this message]
2020-11-25 7:36 ` [pve-devel] applied: [PATCH v3 proxmox-backup-qemu 2/3] return version via rust fn instead of header define Dietmar Maurer
2020-11-24 15:41 ` [pve-devel] [PATCH v3 qemu-server 3/3] print query-proxmox-support result in 'full' status Stefan Reiter
2020-11-25 9:09 ` Fabian Grünbichler
2020-11-25 9:36 ` Stefan Reiter
2020-11-25 11:03 ` [pve-devel] applied: " Fabian Grünbichler
2020-11-24 16:29 ` [pve-devel] [PATCH v3 0/3] Add proxmox-backup-qemu version to VM status output Fabian Grünbichler
2020-11-24 18:27 ` Dietmar Maurer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201124154122.22202-3-s.reiter@proxmox.com \
--to=s.reiter@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox