* [PATCH RFC 2/3] bcachefs: create framework for Rust bindings
@ 2024-02-07 5:58 Thomas Bertschinger
0 siblings, 0 replies; only message in thread
From: Thomas Bertschinger @ 2024-02-07 5:58 UTC (permalink / raw)
To: rust-for-linux, linux-bcachefs, linux-fsdevel, kent.overstreet,
bfoster, ojeda, alex.gaynor, wedsonaf
Cc: Thomas Bertschinger
This adds infrastructure for Rust bindings, generated by bindgen, for
bcachefs internal use. The Rust code is only enabled when a new config
option, BCACHEFS_RUST, is defined. This option depends on RUST.
This change does not generate any bindings; future patches will use the
framework introduced here to add Rust code to bcachefs.
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
---
fs/bcachefs/.gitignore | 3 +++
fs/bcachefs/Kconfig | 6 ++++++
fs/bcachefs/Makefile | 9 +++++++++
fs/bcachefs/bindgen_parameters | 5 +++++
fs/bcachefs/bindings/bindings_helper.h | 3 +++
fs/bcachefs/bindings/mod.rs | 3 +++
6 files changed, 29 insertions(+)
create mode 100644 fs/bcachefs/.gitignore
create mode 100644 fs/bcachefs/bindgen_parameters
create mode 100644 fs/bcachefs/bindings/bindings_helper.h
create mode 100644 fs/bcachefs/bindings/mod.rs
diff --git a/fs/bcachefs/.gitignore b/fs/bcachefs/.gitignore
new file mode 100644
index 000000000000..35be43f02195
--- /dev/null
+++ b/fs/bcachefs/.gitignore
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+
+bcachefs_generated.rs
diff --git a/fs/bcachefs/Kconfig b/fs/bcachefs/Kconfig
index 5cdfef3b551a..6d40669dca00 100644
--- a/fs/bcachefs/Kconfig
+++ b/fs/bcachefs/Kconfig
@@ -33,6 +33,12 @@ config BCACHEFS_QUOTA
depends on BCACHEFS_FS
select QUOTACTL
+config BCACHEFS_RUST
+ bool "bcachefs Rust support"
+ depends on BCACHEFS_FS && RUST
+ help
+ This enables the internal Rust bindings for bcachefs.
+
config BCACHEFS_ERASURE_CODING
bool "bcachefs erasure coding (RAID5/6) support (EXPERIMENTAL)"
depends on BCACHEFS_FS
diff --git a/fs/bcachefs/Makefile b/fs/bcachefs/Makefile
index 1a05cecda7cc..3f209511149c 100644
--- a/fs/bcachefs/Makefile
+++ b/fs/bcachefs/Makefile
@@ -89,4 +89,13 @@ bcachefs-y := \
varint.o \
xattr.o
+always-$(CONFIG_BCACHEFS_RUST) += bindings/bcachefs_generated.rs
+
+$(obj)/bindings/bcachefs_generated.rs: private bindgen_target_flags = \
+ $(shell grep -Ev '^#|^$$' $(srctree)/$(src)/bindgen_parameters)
+
+$(obj)/bindings/bcachefs_generated.rs: $(src)/bindings/bindings_helper.h \
+ $(src)/bindgen_parameters FORCE
+ $(call if_changed_dep,bindgen)
+
obj-$(CONFIG_MEAN_AND_VARIANCE_UNIT_TEST) += mean_and_variance_test.o
diff --git a/fs/bcachefs/bindgen_parameters b/fs/bcachefs/bindgen_parameters
new file mode 100644
index 000000000000..547212bebd6e
--- /dev/null
+++ b/fs/bcachefs/bindgen_parameters
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
+--allowlist-function ''
+--allowlist-type ''
+--allowlist-var ''
diff --git a/fs/bcachefs/bindings/bindings_helper.h b/fs/bcachefs/bindings/bindings_helper.h
new file mode 100644
index 000000000000..f8bef3676f71
--- /dev/null
+++ b/fs/bcachefs/bindings/bindings_helper.h
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include "../bcachefs.h"
diff --git a/fs/bcachefs/bindings/mod.rs b/fs/bcachefs/bindings/mod.rs
new file mode 100644
index 000000000000..19a3ae3c63c6
--- /dev/null
+++ b/fs/bcachefs/bindings/mod.rs
@@ -0,0 +1,3 @@
+// SPDX-License-Identifier: GPL-2.0
+
+include!("bcachefs_generated.rs");
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-07 5:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-07 5:58 [PATCH RFC 2/3] bcachefs: create framework for Rust bindings Thomas Bertschinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).