Re: [PATCH v5] move rust gitcore crate to a different subdirectory
- From
Mike Hommey <mh@glandium.org>
- Date
- Sep 18, 2026, 15:02 UTC
- Message-ID
- <yc4bgjoyxnm6o7q4gwols4d6zvdrq3ydw2c65wjdwof3hjyde6@2osv37jtuxx3>
- In-Reply-To
- <xmqqfqz7otr0.fsf@gitster.g>
On Fri, Sep 18, 2026 at 01:20:51AM -0700, Junio C Hamano wrote:
Show 9 quoted lines
> 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/.
Show 16 quoted lines
> > -$(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.
Show 12 quoted lines
> > 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.
Show 10 quoted lines
> > @@ -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