This moves the Rust sources out of rust_src/ and into the top level.
Running the bcachefs executable out of the development tree is now:
$ ./target/release/bcachefs command
or
$ cargo run --profile release -- command
instead of "./bcachefs command".
Building and installing is still:
$ make && make install
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
uuid-dev zlib1g-dev valgrind libudev-dev python3-docutils libclang-dev
- name: Extract MSRV
run: |
- MSRV=$(cargo metadata --format-version 1 --no-deps --manifest-path rust-src/Cargo.toml |
+ MSRV=$(cargo metadata --format-version 1 --no-deps |
jq -r '.packages[] | select(.name == "bcachefs-tools") | .rust_version')
echo "MSRV=$MSRV" >> $GITHUB_ENV
- name: Install Rust ${{ env.MSRV }} toolchain
!.editorconfig
bcachefs-principles-of-operation.*
+
+# will have compiled files and executables
+debug/
+target/
+
+# These are backup files generated by rustfmt
+**/*.rs.bk
+
+# MSVC Windows builds of rustc generate these, which store debugging information
+*.pdb
-Wno-deprecated-declarations \
-fno-strict-aliasing \
-fno-delete-null-pointer-checks \
- -I. -Iinclude -Iraid \
+ -Ic_src -Ic_src/include \
-D_FILE_OFFSET_BITS=64 \
-D_GNU_SOURCE \
-D_LGPL_SOURCE \
CARGO=cargo $(CARGO_ARGS)
CARGO_PROFILE=release
# CARGO_PROFILE=debug
-CARGO_MANIFEST=--manifest-path rust-src/Cargo.toml
CARGO_BUILD_ARGS=--$(CARGO_PROFILE)
-CARGO_BUILD=$(CARGO) build $(CARGO_BUILD_ARGS) $(CARGO_MANIFEST)
+CARGO_BUILD=$(CARGO) build $(CARGO_BUILD_ARGS)
-CARGO_CLEAN=$(CARGO) clean $(CARGO_CLEAN_ARGS) $(CARGO_MANIFEST)
+CARGO_CLEAN=$(CARGO) clean $(CARGO_CLEAN_ARGS)
include Makefile.compiler
@echo " [CC] $@"
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
-BCACHEFS_DEPS=libbcachefs.a
-RUST_SRCS:=$(shell find rust-src/src rust-src/bch_bindgen/src -type f -iname '*.rs')
+BCACHEFS_DEPS=c_src/libbcachefs.a
+RUST_SRCS:=$(shell find src bch_bindgen/src -type f -iname '*.rs')
bcachefs: $(BCACHEFS_DEPS) $(RUST_SRCS)
- $(CARGO_BUILD)
+ $(Q)$(CARGO_BUILD)
-libbcachefs.a: $(filter-out ./tests/%.o, $(OBJS))
+c_src/libbcachefs.a: $(filter-out ./tests/%.o, $(OBJS))
@echo " [AR] $@"
$(Q)ar -rc $@ $+
install: INITRAMFS_HOOK=$(INITRAMFS_DIR)/hooks/bcachefs
install: INITRAMFS_SCRIPT=$(INITRAMFS_DIR)/scripts/local-premount/bcachefs
install: bcachefs $(optional_install)
- $(INSTALL) -m0755 -D rust-src/target/release/bcachefs -t $(DESTDIR)$(ROOT_SBINDIR)
+ $(INSTALL) -m0755 -D target/release/bcachefs -t $(DESTDIR)$(ROOT_SBINDIR)
$(INSTALL) -m0644 -D bcachefs.8 -t $(DESTDIR)$(PREFIX)/share/man/man8/
$(INSTALL) -m0755 -D initramfs/script $(DESTDIR)$(INITRAMFS_SCRIPT)
$(INSTALL) -m0755 -D initramfs/hook $(DESTDIR)$(INITRAMFS_HOOK)
.PHONY: clean
clean:
@echo "Cleaning all"
- $(Q)$(RM) libbcachefs.a tests/test_helper .version *.tar.xz $(OBJS) $(DEPS) $(DOCGENERATED)
+ $(Q)$(RM) c_src/libbcachefs.a tests/test_helper .version *.tar.xz $(OBJS) $(DEPS) $(DOCGENERATED)
$(Q)$(CARGO_CLEAN)
$(Q)$(RM) -f $(built_scripts)
.PHONY: cargo-update-msrv
cargo-update-msrv:
- cargo +nightly generate-lockfile --manifest-path rust-src/Cargo.toml -Zmsrv-policy
- cargo +nightly generate-lockfile --manifest-path rust-src/bch_bindgen/Cargo.toml -Zmsrv-policy
+ cargo +nightly generate-lockfile -Zmsrv-policy
+ cargo +nightly generate-lockfile --manifest-path bch_bindgen/Cargo.toml -Zmsrv-policy
.PHONY: update-bcachefs-sources
update-bcachefs-sources:
.expect("ENV Var 'CARGO_MANIFEST_DIR' Expected")
.into();
- let libbcachefs_inc_dir = std::path::Path::new("../..");
+ let libbcachefs_inc_dir = std::path::Path::new("../c_src");
- let _libbcachefs_dir = top_dir.join("libbcachefs").join("libbcachefs");
let bindings = bindgen::builder()
.header(
top_dir
--- /dev/null
+#include "libbcachefs/super-io.h"
+#include "libbcachefs/checksum.h"
+#include "libbcachefs/bcachefs_format.h"
+#include "libbcachefs/btree_cache.h"
+#include "libbcachefs/btree_iter.h"
+#include "libbcachefs/debug.h"
+#include "libbcachefs/errcode.h"
+#include "libbcachefs/error.h"
+#include "libbcachefs/opts.h"
+#include "libbcachefs.h"
+#include "crypto.h"
+#include "include/linux/bio.h"
+#include "include/linux/blkdev.h"
+#include "cmds.h"
+#include "raid/raid.h"
+
+
+#define MARK_FIX_753(req_name) const blk_mode_t Fix753_##req_name = req_name;
+
+MARK_FIX_753(BLK_OPEN_READ);
+MARK_FIX_753(BLK_OPEN_WRITE);
+MARK_FIX_753(BLK_OPEN_EXCL);
BCACHEFS_FUSE = if fuseSupport then "1" else "";
- cargoRoot = "rust-src";
+ cargoRoot = ".";
# when git-based crates are updated, run:
# nix run github:Mic92/nix-update -- --version=skip --flake default
# to update the hashes
cargoDeps = rustPlatform.importCargoLock {
- lockFile = "${src}/rust-src/Cargo.lock";
+ lockFile = "${src}/Cargo.lock";
outputHashes = {
"bindgen-0.64.0" = "sha256-GNG8as33HLRYJGYe0nw6qBzq86aHiGonyynEM7gaEE4=";
};
fn main() {
- println!("cargo:rustc-link-search=..");
- println!("cargo:rerun-if-changed=../libbcachefs.a");
+ println!("cargo:rustc-link-search=c_src");
+ println!("cargo:rerun-if-changed=c_src/libbcachefs.a");
println!("cargo:rustc-link-lib=static:+whole-archive=bcachefs");
println!("cargo:rustc-link-lib=urcu");
git checkout v$version
git clean -xfd
-(cd rust-src; cargo license) > COPYING.rust-dependencies
+cargo license > COPYING.rust-dependencies
git ls-files|
tar --create --file bcachefs-tools-$version.tar -T - \
scp bcachefs-tools-$version.tar.asc evilpiepirate.org:/var/www/htdocs/bcachefs-tools/
scp bcachefs-tools-$version.tar.sign evilpiepirate.org:/var/www/htdocs/bcachefs-tools/
-cargo vendor --manifest-path rust-src/Cargo.toml
+cargo vendor
mkdir .cargo
cat > .cargo/config.toml <<-ZZ
+++ /dev/null
-# Generated by Cargo
-# will have compiled files and executables
-debug/
-target/
-
-# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
-# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
-# Needed by nix
-# Cargo.lock
-
-# These are backup files generated by rustfmt
-**/*.rs.bk
-
-# MSVC Windows builds of rustc generate these, which store debugging information
-*.pdb
+++ /dev/null
-Usage
-=====
-
-```
-bcachefs-mount 0.1.0
-Mount a bcachefs filesystem by its UUID
-
-USAGE:
- bcachefs-mount [OPTIONS] <uuid> <mountpoint>
-
-FLAGS:
- -h, --help
- Prints help information
-
- -V, --version
- Prints version information
-
-
-OPTIONS:
- -o <options>
- Mount options [default: ]
-
- -p, --password <password>
- Where the password would be loaded from.
-
- Possible values are: "fail" - don't ask for password, fail if filesystem is encrypted; "wait" - wait for
- password to become available before mounting; "ask" - prompt the user for password; [default: fail]
-
-ARGS:
- <uuid>
- External UUID of the bcachefs filesystem
-
- <mountpoint>
- Where the filesystem should be mounted
-```
-
-Caveats
-=======
-
-* `--password ask` is not yet implemented, but you can use `--password wait`, and load the key with `bcachefs unlock`.
-
-Build
-=====
-
-```sh
-$ git submodule update --init --recursive
-$ cargo build --release
-```
-
-Binary will be built in `target/release/bcachefs-mount`
-
-Dependencies:
-
-* rust
-* blkid
-* uuid
-* liburcu
-* libsodium
-* zlib
-* liblz4
-* libzstd
-* libkeyutils
+++ /dev/null
-#include "../libbcachefs/super-io.h"
-#include "../libbcachefs/checksum.h"
-#include "../libbcachefs/bcachefs_format.h"
-#include "../libbcachefs/btree_cache.h"
-#include "../libbcachefs/btree_iter.h"
-#include "../libbcachefs/debug.h"
-#include "../libbcachefs/errcode.h"
-#include "../libbcachefs/error.h"
-#include "../libbcachefs/opts.h"
-#include "../libbcachefs.h"
-#include "../crypto.h"
-#include "../include/linux/bio.h"
-#include "../include/linux/blkdev.h"
-#include "../cmds.h"
-#include "../raid/raid.h"
-
-
-#define MARK_FIX_753(req_name) const blk_mode_t Fix753_##req_name = req_name;
-
-MARK_FIX_753(BLK_OPEN_READ);
-MARK_FIX_753(BLK_OPEN_WRITE);
-MARK_FIX_753(BLK_OPEN_EXCL);
from pathlib import Path
BASE_PATH= os.path.dirname(__file__)
-BCH_PATH = os.path.abspath(os.path.join(BASE_PATH, '../rust-src/target/release', 'bcachefs'))
+BCH_PATH = os.path.abspath(os.path.join(BASE_PATH, '../target/release', 'bcachefs'))
VALGRIND_PATH= os.path.abspath(os.path.join(BASE_PATH,
'valgrind-suppressions.txt'))