Re: [PATCH v5] move rust gitcore crate to a different subdirectory
From: Mike Hommey <hidden>
Date: 2026-09-18 15:02:59
On Fri, Sep 18, 2026 at 01:20:51AM -0700, Junio C Hamano wrote:
It would have been a friendly thing to do to describe what base was chosen, especially with a few other topics in flight that touch the build procedure for Rust part of the system recently, here below the three-dash line. It seems that this patch is designed to apply cleanly on top of Git 2.56-rc1, which already has these topics merged, so I do not have to worry about conflicts with them when queueing this patch, which is good.
I must admit I hadn't given much thought about where this would be applied, but it was based off master at the time of refreshing the patch, which was, indeed, v2.56.0-rc1.
So things in src/ move to either rust/ directory or rust/src/ directory.
Correct. Mostly rs files (except build.rs) move to rust/src/, and the rest to rust/.
quoted
-$(RUST_LIB): Cargo.toml $(RUST_SOURCES) $(LIB_FILE) - $(QUIET_CARGO)cargo build $(CARGO_ARGS) +$(RUST_LIB): rust/Cargo.toml $(RUST_SOURCES) $(LIB_FILE) + $(QUIET_CARGO)cargo build --manifest-path rust/Cargo.toml $(CARGO_ARGS) ... -RUST_MEMBER_LIBS = $(foreach target,$(RUST_TARGETS),target/$(target)/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)) -$(RUST_MEMBER_LIBS): target/%/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME): Cargo.toml $(RUST_SOURCES) $(LIB_FILE) - $(QUIET_CARGO)cargo build $(CARGO_ARGS) --target $* +RUST_MEMBER_LIBS = $(foreach target,$(RUST_TARGETS),rust/target/$(target)/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)) +$(RUST_MEMBER_LIBS): rust/target/%/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME): rust/Cargo.toml $(RUST_SOURCES) $(LIB_FILE) + $(QUIET_CARGO)cargo build --manifest-path rust/Cargo.toml $(CARGO_ARGS) --target $*Is the reason why we now need to sprinkle --manifest-path all over is because rust/Cargo.toml is a non-standard place for cargo tool? Not complaining, but am wondering if it is simpler to set and export CARGO_MANIFEST_DIR from the Makefile.
It's non-standard in the sense that it's not Cargo.toml is $PWD. An alternative could be to `cd rust` before running cargo commands.
quoted
diff --git a/meson.build b/meson.build index 0a95d90d21..432e306b21 100644 --- a/meson.build +++ b/meson.build@@ -1795,7 +1795,7 @@ libgit_sources += version_def_h rust_option = get_option('rust') if rust_option.allowed() - subdir('src') + subdir('rust')Not 'rust/src'? Just double-checking.
Not rust/src because the rust meson.build was moved to rust/, not rust/src. It felt like it was in src/ along the .rs files just because there was no other place for it in the first place.
quoted
@@ -13,7 +13,7 @@ libgit_rs_sources = [ cargo_command = [ shell, meson.current_source_dir() / 'cargo-meson.sh', - meson.project_source_root(), + meson.current_source_dir(), meson.current_build_dir(), ]What is this change about?
IIRC project_source_root is the git top-level directory, and current_source_dir is the one containing meson.build. Keeping project_source_root would put the target directory at the git top-level, which would be different from what the Makefile does (since it doesn't pass a --target-dir) Mike