[workspace]
resolver = "2"
members = [
- "chelps", "dbg", "himmelblaud", "idmap",
+ "chelps", "config", "dbg", "himmelblaud", "idmap",
"nss", "ntstatus_gen", "pam",
"param", "sock", "tdb", "version",
]
tdb = { path = "tdb" }
idmap = { path = "idmap" }
libc = "0.2.155"
+config = { path = "config" }
--- /dev/null
+[package]
+name = "config"
+edition.workspace = true
+license.workspace = true
+homepage.workspace = true
+version.workspace = true
+
+[dependencies]
+libc.workspace = true
+
+[build-dependencies]
+bindgen = "0.69.4"
--- /dev/null
+#include "../../bin/default/include/config.h"
+#ifndef USING_SYSTEM_TDB
+#define USING_SYSTEM_TDB 0
+#endif
--- /dev/null
+use std::env;
+use std::path::PathBuf;
+
+fn main() {
+ let header = "../../bin/default/include/config.h";
+ println!("cargo:rerun-if-changed={}", header);
+ let additions_header = "./additions.h";
+ println!("cargo:rerun-if-changed={}", additions_header);
+
+ let bindings = bindgen::Builder::default()
+ .header(additions_header)
+ .header(header)
+ .generate()
+ .expect("Failed generating config 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!");
+}
--- /dev/null
+/*
+ Unix SMB/CIFS implementation.
+
+ Samba config imported into Rust
+
+ 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/>.
+*/
+
+#![allow(non_upper_case_globals)]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+#![allow(dead_code)]
+#![allow(clippy::upper_case_acronyms)]
+include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
.clang_arg("-Dbool=int")
.clang_arg("-Doffset_t=loff_t")
.clang_arg("-I../../bin/default")
+ .clang_arg("-I../../lib/talloc")
.clang_arg("-includestdint.h")
.header("../../lib/param/param.h")
.header("../../lib/param/loadparm.h")
[build-dependencies]
bindgen = "0.69.4"
+config.workspace = true
let mut src_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
src_dir.push("../../bin/default/lib/tdb");
- println!("cargo:rustc-link-lib=tdb");
+ if config::USING_SYSTEM_TDB == 1 {
+ println!("cargo:rustc-link-lib=tdb");
+ } else {
+ println!("cargo:rustc-link-lib=tdb-private-samba");
+ }
println!(
"cargo:rustc-link-search=native={}",
src_dir.to_str().unwrap()