From: Junio C Hamano <gitster@pobox.com>
To: Mike Hommey <mh@glandium.org>
Cc: git@vger.kernel.org, ps@pks.im, sandals@crustytoothpaste.net
Subject: Re: [PATCH v5] move rust gitcore crate to a different subdirectory
Date: Fri, 18 Sep 2026 01:20:51 -0700 [thread overview]
Message-ID: <xmqqfqz7otr0.fsf@gitster.g> (raw)
In-Reply-To: <20260917060415.2986259-1-mh@glandium.org> (Mike Hommey's message of "Thu, 17 Sep 2026 15:04:15 +0900")
Mike Hommey <mh@glandium.org> writes:
> Having `Cargo.toml` at the top-level of the repository implies that one
> can run `cargo build` directly, but this doesn't produce anything useful
> on its own.
>
> Additionally, when including the git source as a submodule of a Rust
> project, it prevents the git source from being included at all in the
> crate package because cargo skips directories that contain a Cargo.toml,
> assuming that everything in the directory is relevant to the crate.
>
> Move all Rust-specific files into a dedicated `rust/` subdirectory.
>
> Signed-off-by: Mike Hommey <mh@glandium.org>
> ---
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.
> .gitignore | 4 ++--
> Makefile | 24 ++++++++++++------------
> ci/run-rust-checks.sh | 6 +++---
> meson.build | 2 +-
> Cargo.toml => rust/Cargo.toml | 0
> build.rs => rust/build.rs | 0
> {src => rust}/cargo-meson.sh | 0
> {src => rust}/meson.build | 16 ++++++++--------
> {src => rust/src}/csum_file.rs | 0
> {src => rust/src}/hash.rs | 0
> {src => rust/src}/lib.rs | 0
> {src => rust/src}/loose.rs | 0
> {src => rust/src}/varint.rs | 0
> 13 files changed, 26 insertions(+), 26 deletions(-)
> rename Cargo.toml => rust/Cargo.toml (100%)
> rename build.rs => rust/build.rs (100%)
> rename {src => rust}/cargo-meson.sh (100%)
> rename {src => rust}/meson.build (81%)
> rename {src => rust/src}/csum_file.rs (100%)
> rename {src => rust/src}/hash.rs (100%)
> rename {src => rust/src}/lib.rs (100%)
> rename {src => rust/src}/loose.rs (100%)
> rename {src => rust/src}/varint.rs (100%)
So things in src/ move to either rust/ directory or rust/src/
directory.
> diff --git a/Makefile b/Makefile
> index c649c93c51..67e74c30cc 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -959,7 +959,7 @@ RUST_LIB_NAME = gitcore.lib
> else
> RUST_LIB_NAME = libgitcore.a
> endif
> -RUST_LIB = target$(if $(CARGO_BUILD_TARGET),/$(CARGO_BUILD_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)
> +RUST_LIB = rust/target$(if $(CARGO_BUILD_TARGET),/$(CARGO_BUILD_TARGET))/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)
> endif
This part was touched by a few topics in the recent past and I
didn't want to resolve conflicts there. This patch being on top of
these two topics makes my life easier and is very much appreciated.
> @@ -1571,11 +1571,11 @@ CLAR_TEST_OBJS += $(UNIT_TEST_DIR)/unit-test.o
>
> UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o
>
> -RUST_SOURCES += src/csum_file.rs
> -RUST_SOURCES += src/hash.rs
> -RUST_SOURCES += src/lib.rs
> -RUST_SOURCES += src/loose.rs
> -RUST_SOURCES += src/varint.rs
> +RUST_SOURCES += rust/src/csum_file.rs
> +RUST_SOURCES += rust/src/hash.rs
> +RUST_SOURCES += rust/src/lib.rs
> +RUST_SOURCES += rust/src/loose.rs
> +RUST_SOURCES += rust/src/varint.rs
So the sources are all in rust/src/ directory now.
> -$(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.
> 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.
> @@ -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?
next prev parent reply other threads:[~2026-09-18 8:20 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 23:22 [RFC PATCH] Move rust gitcore crate to a different subdirectory Mike Hommey
2026-02-05 0:10 ` brian m. carlson
2026-02-05 1:45 ` Mike Hommey
2026-02-05 2:06 ` brian m. carlson
2026-02-05 4:55 ` Mike Hommey
2026-02-09 22:48 ` [PATCH v2] " Mike Hommey
2026-09-09 1:38 ` [PATCH v3] " Mike Hommey
2026-09-09 19:54 ` Junio C Hamano
2026-09-10 12:09 ` Mike Hommey
2026-09-09 21:13 ` brian m. carlson
2026-09-10 12:05 ` Mike Hommey
2026-09-10 6:27 ` Tuomas Ahola
2026-09-10 12:21 ` Junio C Hamano
2026-09-10 12:10 ` [PATCH v4] " Mike Hommey
2026-09-10 17:45 ` Junio C Hamano
2026-09-17 6:04 ` [PATCH v5] move " Mike Hommey
2026-09-18 8:20 ` Junio C Hamano [this message]
2026-09-18 15:02 ` Mike Hommey
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=xmqqfqz7otr0.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mh@glandium.org \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
/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