]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Add build config for proper TDB build linkage
authorDavid Mulder <dmulder@samba.org>
Thu, 8 Aug 2024 16:51:02 +0000 (10:51 -0600)
committerDavid Mulder <dmulder@samba.org>
Wed, 23 Oct 2024 14:21:33 +0000 (14:21 +0000)
The tdb build needs to know whether Samba is
building with TDB bundled or not, otherwise
linking will fail.

Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
rust/Cargo.toml
rust/config/Cargo.toml [new file with mode: 0644]
rust/config/additions.h [new file with mode: 0644]
rust/config/build.rs [new file with mode: 0644]
rust/config/src/lib.rs [new file with mode: 0644]
rust/param/build.rs
rust/tdb/Cargo.toml
rust/tdb/build.rs

index 5c9e3107faac899f2e6fff8c6e859da0547e7bac..91d0ccbd9c8ea74ed9f4309f4b4d080f34514a47 100644 (file)
@@ -7,7 +7,7 @@ version = "4.21.0"
 [workspace]
 resolver = "2"
 members = [
-  "chelps", "dbg", "himmelblaud", "idmap",
+  "chelps", "config", "dbg", "himmelblaud", "idmap",
   "nss", "ntstatus_gen", "pam",
   "param", "sock", "tdb", "version",
 ]
@@ -21,3 +21,4 @@ ntstatus_gen = { path = "ntstatus_gen" }
 tdb = { path = "tdb" }
 idmap = { path = "idmap" }
 libc = "0.2.155"
+config = { path = "config" }
diff --git a/rust/config/Cargo.toml b/rust/config/Cargo.toml
new file mode 100644 (file)
index 0000000..e61ab95
--- /dev/null
@@ -0,0 +1,12 @@
+[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"
diff --git a/rust/config/additions.h b/rust/config/additions.h
new file mode 100644 (file)
index 0000000..c956134
--- /dev/null
@@ -0,0 +1,4 @@
+#include "../../bin/default/include/config.h"
+#ifndef USING_SYSTEM_TDB
+#define USING_SYSTEM_TDB 0
+#endif
diff --git a/rust/config/build.rs b/rust/config/build.rs
new file mode 100644 (file)
index 0000000..b1c1549
--- /dev/null
@@ -0,0 +1,20 @@
+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!");
+}
diff --git a/rust/config/src/lib.rs b/rust/config/src/lib.rs
new file mode 100644 (file)
index 0000000..be5724b
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+   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"));
index d2fa9df87534758d367d88c403462d8ff9472830..8fe81e1091b460ef968a055239d4eeaefadce3da 100644 (file)
@@ -13,6 +13,7 @@ fn main() {
         .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")
index ef96e76c5e12a54d28279500d883d4968ccefc36..aad1c727d112f87dc2e7ecd8a175c17ea31984c1 100644 (file)
@@ -13,3 +13,4 @@ ntstatus_gen.workspace = true
 
 [build-dependencies]
 bindgen = "0.69.4"
+config.workspace = true
index 7a9923cf78693413ac29ea66b2cec67f8d977fb8..57ee90aa8d4213fa094d2991b6b834067aa563e4 100644 (file)
@@ -23,7 +23,11 @@ fn main() {
 
     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()