On Wed, Aug 07, 2024 at 09:19:36PM +0100, James Le Cuirot wrote: > On Wed, 2024-08-07 at 19:39 +0200, Michał Górny wrote: > > On Wed, 2024-08-07 at 16:52 +0100, James Le Cuirot wrote: > > > The flags we set an a target-specific environment variable override any > > > generic [build] flags set by the project, requiring ebuilds to set these > > > themselves, which is undesirable. Work around this by using tomlq to > > > read the flags from the config files checked by Cargo and prepending > > > them to our environment variable. > > > > > > Signed-off-by: James Le Cuirot > > > --- > > > eclass/cargo.eclass | 28 +++++++++++++++++----------- > > > 1 file changed, 17 insertions(+), 11 deletions(-) > > > > > > diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass > > > index 6d4cf1b425eb..dea8c49e4585 100644 > > > --- a/eclass/cargo.eclass > > > +++ b/eclass/cargo.eclass > > > @@ -36,7 +36,8 @@ esac > > > > > > inherit flag-o-matic multiprocessing rust-toolchain toolchain-funcs > > > > > > -[[ ! ${CARGO_OPTIONAL} ]] && BDEPEND="${RUST_DEPEND}" > > > +# app-misc/yq is needed for tomlq. > > > +[[ ! ${CARGO_OPTIONAL} ]] && BDEPEND="${RUST_DEPEND} app-misc/yq" > > > > > > > Doesn't this imply that all ebuilds using CARGO_OPTIONAL will now have > > to explicitly depend on yq? > > Good catch, thanks. I can update the eclass docs accordingly. I count 23 > ebuilds across 8 packages, and this can be done without a revbump, so it's not > too bad. Even if it were missing, it would just continue without applying > these extra flags. Probably no reason to not just add it to RUST_DEPEND, some ebuilds already use that variable with OPTIONAL. Albeit yeah, it's not documented nor required to use it at the moment. > > I have also noticed that yq will need some keywording first. > > I considered some inline Python with just tomli instead, but then you get into > the mess of micro-managing the Python versions. I don't think there's a way to > say "use whatever Python tomli is installed for". If want to use python, I think simplest would the equivalent of meson.eclass' dev-build/meson-format-array. Then the ebuild could handle all the dependencies rather than the eclass. Could be handy to pull less dependencies, with >=python3.11 can use the stdlib's tomllib rather than tomli too, be very low footprint. But is it really worth it over just using yq? I don't know :) -- ionen