Mailing List Archive

[PATCH] cargo.eclass: use verbose cargo invocations
Default output just prints crate name.
With -vv we can see all cargo options and rustc args.

Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
---
eclass/cargo.eclass | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
index 5b6d1f050f1..13dd5c355fb 100644
--- a/eclass/cargo.eclass
+++ b/eclass/cargo.eclass
@@ -146,7 +146,7 @@ cargo_src_compile() {

export CARGO_HOME="${ECARGO_HOME}"

- cargo build -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
+ cargo build -vv -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
|| die "cargo build failed"
}

@@ -156,7 +156,7 @@ cargo_src_compile() {
cargo_src_install() {
debug-print-function ${FUNCNAME} "$@"

- cargo install -j $(makeopts_jobs) --root="${ED}/usr" $(usex debug --debug "") "$@" \
+ cargo install -vv -j $(makeopts_jobs) --root="${ED}/usr" $(usex debug --debug "") "$@" \
|| die "cargo install failed"
rm -f "${ED}/usr/.crates.toml"

@@ -169,7 +169,7 @@ cargo_src_install() {
cargo_src_test() {
debug-print-function ${FUNCNAME} "$@"

- cargo test -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
+ cargo test -vv -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
|| die "cargo test failed"
}

--
2.23.0
Re: [PATCH] cargo.eclass: use verbose cargo invocations [ In reply to ]
On Fri, 6 Dec 2019 12:09:31 -0800
Georgy Yakovlev <gyakovlev@gentoo.org> wrote:

> Default output just prints crate name.
> With -vv we can see all cargo options and rustc args.
>
> Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
> ---

Looks good!

I had to do an equivalent locally at least a few times.

While at it I also suggest adding equivalent of
econf's/emake's ${EXTRA_ECONF} and ${EXTRA_EMAKE}
to allow users to inject arbitrary stuff. For example
to sneak in '-Z' options globally.

Say, ${CARGO_BUILD_EXTRA}, ${CARGO_INSTALL_EXTRA},
${CARGO_TEST_EXTRA}.

> eclass/cargo.eclass | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/eclass/cargo.eclass b/eclass/cargo.eclass
> index 5b6d1f050f1..13dd5c355fb 100644
> --- a/eclass/cargo.eclass
> +++ b/eclass/cargo.eclass
> @@ -146,7 +146,7 @@ cargo_src_compile() {
>
> export CARGO_HOME="${ECARGO_HOME}"
>
> - cargo build -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
> + cargo build -vv -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
> || die "cargo build failed"
> }
>
> @@ -156,7 +156,7 @@ cargo_src_compile() {
> cargo_src_install() {
> debug-print-function ${FUNCNAME} "$@"
>
> - cargo install -j $(makeopts_jobs) --root="${ED}/usr" $(usex debug --debug "") "$@" \
> + cargo install -vv -j $(makeopts_jobs) --root="${ED}/usr" $(usex debug --debug "") "$@" \
> || die "cargo install failed"
> rm -f "${ED}/usr/.crates.toml"
>
> @@ -169,7 +169,7 @@ cargo_src_install() {
> cargo_src_test() {
> debug-print-function ${FUNCNAME} "$@"
>
> - cargo test -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
> + cargo test -vv -j $(makeopts_jobs) $(usex debug "" --release) "$@" \
> || die "cargo test failed"
> }
>
> --
> 2.23.0
>
>


--

Sergei
Re: [PATCH] cargo.eclass: use verbose cargo invocations [ In reply to ]
On Friday, December 6, 2019 3:44:38 PM PST Sergei Trofimovich wrote:
> On Fri, 6 Dec 2019 12:09:31 -0800
>
> Georgy Yakovlev <gyakovlev@gentoo.org> wrote:
> > Default output just prints crate name.
> > With -vv we can see all cargo options and rustc args.
> >
> > Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
> > ---
>
> Looks good!
>
> I had to do an equivalent locally at least a few times.
Pushed!
>
> While at it I also suggest adding equivalent of
> econf's/emake's ${EXTRA_ECONF} and ${EXTRA_EMAKE}
> to allow users to inject arbitrary stuff. For example
> to sneak in '-Z' options globally.
>
> Say, ${CARGO_BUILD_EXTRA}, ${CARGO_INSTALL_EXTRA},
> ${CARGO_TEST_EXTRA}.
>

Yeah, it's on my to-do list for this eclass.
1 question tho, should it come after "$@" or before? Do you use it?
I know cargo can be picky about order and some ebuilds rely on passing params
in phase funcs.
Re: [PATCH] cargo.eclass: use verbose cargo invocations [ In reply to ]
[2019-12-06 16:16:32-0800] Georgy Yakovlev:
> On Friday, December 6, 2019 3:44:38 PM PST Sergei Trofimovich wrote:
> > On Fri, 6 Dec 2019 12:09:31 -0800
> > Georgy Yakovlev <gyakovlev@gentoo.org> wrote:
> > > Default output just prints crate name.
> > > With -vv we can see all cargo options and rustc args.
> > >
> > > Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
> > > ---
> >
> > While at it I also suggest adding equivalent of
> > econf's/emake's ${EXTRA_ECONF} and ${EXTRA_EMAKE}
> > to allow users to inject arbitrary stuff. For example
> > to sneak in '-Z' options globally.
> >
> > Say, ${CARGO_BUILD_EXTRA}, ${CARGO_INSTALL_EXTRA},
> > ${CARGO_TEST_EXTRA}.
> >
>
> Yeah, it's on my to-do list for this eclass.
> 1 question tho, should it come after "$@" or before? Do you use it?
> I know cargo can be picky about order and some ebuilds rely on passing params
> in phase funcs.

I think it should go after `cargo {build,install,test}` and before any
non-option argument, similar to how POSIX getopt(3) behaves (but that GNU
breaks without setting POSIXLY_CORRECT=1).
Re: [PATCH] cargo.eclass: use verbose cargo invocations [ In reply to ]
On Fri, 06 Dec 2019 16:16:32 -0800
Georgy Yakovlev <gyakovlev@gentoo.org> wrote:

> On Friday, December 6, 2019 3:44:38 PM PST Sergei Trofimovich wrote:
> > On Fri, 6 Dec 2019 12:09:31 -0800
> >
> > Georgy Yakovlev <gyakovlev@gentoo.org> wrote:
> > > Default output just prints crate name.
> > > With -vv we can see all cargo options and rustc args.
> > >
> > > Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
> > > ---
> >
> > Looks good!
> >
> > I had to do an equivalent locally at least a few times.
> Pushed!
> >
> > While at it I also suggest adding equivalent of
> > econf's/emake's ${EXTRA_ECONF} and ${EXTRA_EMAKE}
> > to allow users to inject arbitrary stuff. For example
> > to sneak in '-Z' options globally.
> >
> > Say, ${CARGO_BUILD_EXTRA}, ${CARGO_INSTALL_EXTRA},
> > ${CARGO_TEST_EXTRA}.
> >
>
> Yeah, it's on my to-do list for this eclass.
> 1 question tho, should it come after "$@" or before? Do you use it?
> I know cargo can be picky about order and some ebuilds rely on passing params
> in phase funcs.

I don't use it frequently for carge.eclass but use it extensively for
./configure and haskell-cabal.eclass. I'd say variables are designed to
override everything else (eclass defaults and ebuild values) and thus
should come after "$@":
econf() { ... "$@" "${EXTRA_ECONF[@]}" }
${MAKE:-make} ${MAKEOPTS} "$@" ${EXTRA_EMAKE}

--

Sergei
Re: [PATCH] cargo.eclass: use verbose cargo invocations [ In reply to ]
On Fri, 6 Dec 2019 12:09:31 -0800
Georgy Yakovlev <gyakovlev@gentoo.org> wrote:

> Default output just prints crate name.
> With -vv we can see all cargo options and rustc args.

On the overlay with rust-crate.eclass, I've not found the verbose
output very helpful for anything.

I would probably ask for a knob to tweak that disabled this.



...

ECARGO_OPTS=(
-j $(makeopts_jobs)
"${ECARGO_OPTS[@]}"
)
if [ "${ECARGO_VERBOSE:-1}" == 1 ]; then
ECARGO_OPTS+=( -vv )
fi

...

cargo build "${ECARGO_OPTS[@]}" ...


or something along those lines.

I've also (often) had to invoke stuff like:

src_test() {
RUSTFLAGS="${RUSTFLAGS} --cap-lints warn" rust-crate_src_test
}

Because well, upstream.

But I'm not entirely fond of that syntax.