From: Thomas Bertschinger <tahbertschinger@gmail.com>
To: rust-for-linux@vger.kernel.org, linux-bcachefs@vger.kernel.org,
linux-fsdevel@vger.kernel.org, kent.overstreet@linux.dev,
bfoster@redhat.com, ojeda@kernel.org, alex.gaynor@gmail.com,
wedsonaf@gmail.com
Cc: Thomas Bertschinger <tahbertschinger@gmail.com>
Subject: [PATCH RFC 2/3] bcachefs: create framework for Rust bindings
Date: Tue, 6 Feb 2024 22:58:18 -0700 [thread overview]
Message-ID: <20240207055818.611679-1-tahbertschinger@gmail.com> (raw)
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
reply other threads:[~2024-02-07 5:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240207055818.611679-1-tahbertschinger@gmail.com \
--to=tahbertschinger@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=bfoster@redhat.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).