Re: [PATCH RFC v2 1/7] meson: add infrastructure to build internal Rust library
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 8, 2025, 06:42 UTC
- Message-ID
- <aL56xRcJTCU2wttG@pks.im>
- In-Reply-To
- <CABPp-BGF9Ds=9bLKbWFEuatGmGycemwTMiyez_s3XMJR=M6xQw@mail.gmail.com>
On Sat, Sep 06, 2025 at 09:54:18PM -0700, Elijah Newren wrote:
Show 26 quoted lines
> On Fri, Sep 5, 2025 at 4:51 AM Patrick Steinhardt <ps@pks.im> wrote: > > > > Add the infrastructure into Meson to build an internal Rust library. > > Building the Rust parts of Git are for now entirely optional, as they > > are mostly intended as a test balloon for both Git developers, but also > > for distributors of Git. So for now, they may contain: > > > > - New features that are not mission critical to Git and that users can > > easily live without. > > > > - Alternative implementations of small subsystems. > > > > If these test balloons are successful, we will eventually make Rust a > > mandatory dependency for our build process in Git 3.0. > > Okay. > > > The availability of a Rust toolchain will be auto-detected by Meson at > > setup time. This behaviour can be tweaked via the `-Drust=` feature > > toggle. > > This goes against what you said above, because it turns it into > something other than a test balloon. As I've said elsewhere, I don't > think this part is helpful; it reduces the amount of notice that > distributors and platforms have about our intent to make Rust > mandatory.
See the BreakingChanges document later in this series, which talks about this. Makes me wonder whether I should reverse the order of patches so that the BreakingChanges are more prominent.
Show 24 quoted lines
> > diff --git a/src/meson.build b/src/meson.build
> > new file mode 100644
> > index 00000000000..eb752651d35
> > --- /dev/null
> > +++ b/src/meson.build
> > @@ -0,0 +1,15 @@
> > +libgit_rs = static_library('git_rs',
> > + sources: [
> > + 'lib.rs',
> > + ],
> > + rust_crate_type: 'staticlib',
> > +)
> > +libgit_libraries += libgit_rs
> > +
> > +# The 'rust' module was only introduced in Meson 1.0. Furthermore, the module
> > +# does not seem to work on macOS as expected right now. As such, we only
> > +# conditionally enable tests.
> > +if meson.version().version_compare('>=1.0.0') and host_machine.system() != 'darwin'
> > + rustmod = import('rust')
> > + rustmod.test('rust', libgit_rs)
> > +endif
>
> Would it make sense to invoke 'cargo test' as one step of 'meson test'
> on mac as an alternative, so that mac users also can run the tests?Maybe. I'll revisit the Meson code anyway to figure out how to get Cargo support in there natively.
Patrick