mirror of
https://github.com/samba-team/samba.git
synced 2025-08-26 01:49:31 +03:00
Add Samba versioning
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
This commit is contained in:
@ -30,11 +30,14 @@ serde = "1.0.204"
|
||||
idmap = { workspace = true }
|
||||
libc = "0.2.155"
|
||||
|
||||
[build-dependencies]
|
||||
version = { path = "version" }
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"chelps", "dbg", "idmap",
|
||||
"nss", "ntstatus_gen",
|
||||
"param", "sock", "tdb",
|
||||
"param", "sock", "tdb", "version",
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
|
@ -15,4 +15,20 @@ fn main() {
|
||||
);
|
||||
}
|
||||
println!("cargo:rerun-if-changed-env=TARGET");
|
||||
|
||||
if let Some(vers) = version::samba_version_string() {
|
||||
println!("cargo:rustc-env=CARGO_PKG_VERSION={}", vers);
|
||||
}
|
||||
println!(
|
||||
"cargo:rustc-env=CARGO_PKG_VERSION_MAJOR={}",
|
||||
version::SAMBA_VERSION_MAJOR
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=CARGO_PKG_VERSION_MINOR={}",
|
||||
version::SAMBA_VERSION_MINOR
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=CARGO_PKG_VERSION_PATCH={}",
|
||||
version::SAMBA_VERSION_RELEASE
|
||||
);
|
||||
}
|
||||
|
@ -16,3 +16,6 @@ libnss = "0.8.0"
|
||||
ntstatus_gen.workspace = true
|
||||
param = { workspace = true }
|
||||
sock = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
version = { path = "../version" }
|
||||
|
17
himmelblaud/nss/build.rs
Normal file
17
himmelblaud/nss/build.rs
Normal file
@ -0,0 +1,17 @@
|
||||
fn main() {
|
||||
if let Some(vers) = version::samba_version_string() {
|
||||
println!("cargo:rustc-env=CARGO_PKG_VERSION={}", vers);
|
||||
}
|
||||
println!(
|
||||
"cargo:rustc-env=CARGO_PKG_VERSION_MAJOR={}",
|
||||
version::SAMBA_VERSION_MAJOR
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=CARGO_PKG_VERSION_MINOR={}",
|
||||
version::SAMBA_VERSION_MINOR
|
||||
);
|
||||
println!(
|
||||
"cargo:rustc-env=CARGO_PKG_VERSION_PATCH={}",
|
||||
version::SAMBA_VERSION_RELEASE
|
||||
);
|
||||
}
|
18
himmelblaud/version/Cargo.toml
Normal file
18
himmelblaud/version/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "version"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
homepage.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[lib]
|
||||
name = "version"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
chelps.workspace = true
|
||||
libc = "0.2.153"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0.97"
|
||||
bindgen = "0.69.4"
|
29
himmelblaud/version/build.rs
Normal file
29
himmelblaud/version/build.rs
Normal file
@ -0,0 +1,29 @@
|
||||
use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
fn main() {
|
||||
cc::Build::new()
|
||||
.file("../../source3/lib/version.c")
|
||||
.include(Path::new("../../bin/default"))
|
||||
.include(Path::new("./include")) // for the empty includes.h
|
||||
.warnings(false)
|
||||
.compile("version");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.blocklist_function("qgcvt")
|
||||
.blocklist_function("qgcvt_r")
|
||||
.blocklist_function("qfcvt")
|
||||
.blocklist_function("qfcvt_r")
|
||||
.blocklist_function("qecvt")
|
||||
.blocklist_function("qecvt_r")
|
||||
.blocklist_function("strtold")
|
||||
.header("../../bin/default/version.h")
|
||||
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||
.generate()
|
||||
.expect("Unable to generate bindings");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
0
himmelblaud/version/include/includes.h
Normal file
0
himmelblaud/version/include/includes.h
Normal file
40
himmelblaud/version/src/lib.rs
Normal file
40
himmelblaud/version/src/lib.rs
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
Unix SMB/CIFS implementation.
|
||||
Samba Version functions
|
||||
|
||||
Copyright (C) David Mulder 2024
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
use std::str;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
|
||||
|
||||
pub fn samba_version_string() -> Option<String> {
|
||||
let null_trimmed_vers =
|
||||
&SAMBA_VERSION_STRING[..SAMBA_VERSION_STRING.len() - 1];
|
||||
match str::from_utf8(null_trimmed_vers) {
|
||||
Ok(vers) => Some(vers.to_string()),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn samba_copyright_string() -> Option<String> {
|
||||
let null_trimmed_copy =
|
||||
&SAMBA_COPYRIGHT_STRING[..SAMBA_COPYRIGHT_STRING.len() - 1];
|
||||
match str::from_utf8(null_trimmed_copy) {
|
||||
Ok(copy) => Some(copy.to_string()),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user