* [gentoo-dev] [PATCH] meson.eclass: allow disabling verbose compilation
@ 2023-07-17 14:51 Matt Turner
2023-07-17 14:56 ` Adrian Schollmeyer
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Matt Turner @ 2023-07-17 14:51 UTC (permalink / raw
To: gentoo-dev; +Cc: Jonas Rakebrandt, Matt Turner
From: Jonas Rakebrandt <xarblu@protonmail.com>
This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
Closes: https://github.com/gentoo/gentoo/pull/28942
Signed-off-by: Jonas Rakebrandt <xarblu@protonmail.com>
Signed-off-by: Matt Turner <mattst88@gentoo.org>
---
eclass/meson.eclass | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/eclass/meson.eclass b/eclass/meson.eclass
index 2c274b213191..1acdee9325b2 100644
--- a/eclass/meson.eclass
+++ b/eclass/meson.eclass
@@ -55,6 +55,12 @@ BDEPEND=">=dev-util/meson-0.62.2
# Build directory, location where all generated files should be placed.
# If this isn't set, it defaults to ${WORKDIR}/${P}-build.
+# @ECLASS_VARIABLE: MESON_QUIET
+# @USER_VARIABLE
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Disables verbose messages during compilation if non-empty.
+
# @ECLASS_VARIABLE: EMESON_BUILDTYPE
# @DESCRIPTION:
# The buildtype value to pass to meson setup.
@@ -385,10 +391,14 @@ meson_src_compile() {
-C "${BUILD_DIR}"
--jobs "$(makeopts_jobs "${MAKEOPTS}" 0)"
--load-average "$(makeopts_loadavg "${MAKEOPTS}" 0)"
- --verbose
- "$@"
)
+ if [[ -z ${MESON_QUIET} ]]; then
+ mesoncompileargs+=( --verbose )
+ fi
+
+ mesoncompileargs+=( "$@" )
+
set -- meson compile "${mesoncompileargs[@]}"
echo "$@" >&2
"$@" || die "compile failed"
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH] meson.eclass: allow disabling verbose compilation
2023-07-17 14:51 [gentoo-dev] [PATCH] meson.eclass: allow disabling verbose compilation Matt Turner
@ 2023-07-17 14:56 ` Adrian Schollmeyer
2023-07-17 15:24 ` Matt Turner
2023-07-17 15:23 ` [gentoo-dev] " Matt Turner
2023-07-18 16:44 ` [gentoo-dev] [PATCH v2] " Matt Turner
2 siblings, 1 reply; 13+ messages in thread
From: Adrian Schollmeyer @ 2023-07-17 14:56 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 325 bytes --]
Hi,
Am Montag, dem 17.07.2023 um 10:51 -0400 schrieb Matt Turner:
> This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
Why not use MESON_VERBOSE as well? Avoids double negation in the code
(not unset -> verbose vs. MESON_VERBOSE == true -> verbose) and keeps
the variable naming similar to cmake.eclass.
nex
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* [gentoo-dev] Re: [PATCH] meson.eclass: allow disabling verbose compilation
2023-07-17 14:51 [gentoo-dev] [PATCH] meson.eclass: allow disabling verbose compilation Matt Turner
2023-07-17 14:56 ` Adrian Schollmeyer
@ 2023-07-17 15:23 ` Matt Turner
2023-07-18 16:44 ` [gentoo-dev] [PATCH v2] " Matt Turner
2 siblings, 0 replies; 13+ messages in thread
From: Matt Turner @ 2023-07-17 15:23 UTC (permalink / raw
To: gentoo-dev; +Cc: Jonas Rakebrandt, Michał Górny
On Mon, Jul 17, 2023 at 10:51 AM Matt Turner <mattst88@gentoo.org> wrote:
>
> From: Jonas Rakebrandt <xarblu@protonmail.com>
>
> This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
... except that it's _QUIET, rather than _VERBOSE.
I've sent patches to add NINJA_VERBOSE to ninja-utils.eclass and
another to support CMAKE_VERBOSE with ninja.
This makes me think we should keep things consistent here by switching
this to MESON_VERBOSE.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH] meson.eclass: allow disabling verbose compilation
2023-07-17 14:56 ` Adrian Schollmeyer
@ 2023-07-17 15:24 ` Matt Turner
0 siblings, 0 replies; 13+ messages in thread
From: Matt Turner @ 2023-07-17 15:24 UTC (permalink / raw
To: gentoo-dev
On Mon, Jul 17, 2023 at 10:56 AM Adrian Schollmeyer <nex@nexadn.de> wrote:
> Am Montag, dem 17.07.2023 um 10:51 -0400 schrieb Matt Turner:
> > This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
>
> Why not use MESON_VERBOSE as well? Avoids double negation in the code
> (not unset -> verbose vs. MESON_VERBOSE == true -> verbose) and keeps
> the variable naming similar to cmake.eclass.
>
> nex
I personally agree -- I was just sending the patch as-is from GitHub.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-17 14:51 [gentoo-dev] [PATCH] meson.eclass: allow disabling verbose compilation Matt Turner
2023-07-17 14:56 ` Adrian Schollmeyer
2023-07-17 15:23 ` [gentoo-dev] " Matt Turner
@ 2023-07-18 16:44 ` Matt Turner
2023-07-19 7:23 ` Florian Schmaus
2 siblings, 1 reply; 13+ messages in thread
From: Matt Turner @ 2023-07-18 16:44 UTC (permalink / raw
To: gentoo-dev; +Cc: Jonas Rakebrandt, Matt Turner
From: Jonas Rakebrandt <xarblu@protonmail.com>
This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
Closes: https://github.com/gentoo/gentoo/pull/28942
Signed-off-by: Jonas Rakebrandt <xarblu@protonmail.com>
Signed-off-by: Matt Turner <mattst88@gentoo.org>
---
eclass/meson.eclass | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/eclass/meson.eclass b/eclass/meson.eclass
index 2c274b213191..3b30f66bf30a 100644
--- a/eclass/meson.eclass
+++ b/eclass/meson.eclass
@@ -55,6 +55,12 @@ BDEPEND=">=dev-util/meson-0.62.2
# Build directory, location where all generated files should be placed.
# If this isn't set, it defaults to ${WORKDIR}/${P}-build.
+# @ECLASS_VARIABLE: MESON_VERBOSE
+# @USER_VARIABLE
+# @DESCRIPTION:
+# Set to OFF to disable verbose messages during compilation
+: "${MESON_VERBOSE:=ON}"
+
# @ECLASS_VARIABLE: EMESON_BUILDTYPE
# @DESCRIPTION:
# The buildtype value to pass to meson setup.
@@ -385,10 +391,15 @@ meson_src_compile() {
-C "${BUILD_DIR}"
--jobs "$(makeopts_jobs "${MAKEOPTS}" 0)"
--load-average "$(makeopts_loadavg "${MAKEOPTS}" 0)"
- --verbose
- "$@"
)
+ case ${MESON_VERBOSE} in
+ OFF) ;;
+ *) mesoncompileargs+=( --verbose ) ;;
+ esac
+
+ mesoncompileargs+=( "$@" )
+
set -- meson compile "${mesoncompileargs[@]}"
echo "$@" >&2
"$@" || die "compile failed"
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-18 16:44 ` [gentoo-dev] [PATCH v2] " Matt Turner
@ 2023-07-19 7:23 ` Florian Schmaus
2023-07-20 15:00 ` Matt Turner
0 siblings, 1 reply; 13+ messages in thread
From: Florian Schmaus @ 2023-07-19 7:23 UTC (permalink / raw
To: gentoo-dev, Matt Turner
[-- Attachment #1.1.1: Type: text/plain, Size: 1670 bytes --]
On 18/07/2023 18.44, Matt Turner wrote:
> From: Jonas Rakebrandt <xarblu@protonmail.com>
>
> This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
>
> Closes: https://github.com/gentoo/gentoo/pull/28942
> Signed-off-by: Jonas Rakebrandt <xarblu@protonmail.com>
> Signed-off-by: Matt Turner <mattst88@gentoo.org>
> ---
> eclass/meson.eclass | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/eclass/meson.eclass b/eclass/meson.eclass
> index 2c274b213191..3b30f66bf30a 100644
> --- a/eclass/meson.eclass
> +++ b/eclass/meson.eclass
> @@ -55,6 +55,12 @@ BDEPEND=">=dev-util/meson-0.62.2
> # Build directory, location where all generated files should be placed.
> # If this isn't set, it defaults to ${WORKDIR}/${P}-build.
>
> +# @ECLASS_VARIABLE: MESON_VERBOSE
> +# @USER_VARIABLE
> +# @DESCRIPTION:
> +# Set to OFF to disable verbose messages during compilation
> +: "${MESON_VERBOSE:=ON}"
> +
> # @ECLASS_VARIABLE: EMESON_BUILDTYPE
> # @DESCRIPTION:
> # The buildtype value to pass to meson setup.
> @@ -385,10 +391,15 @@ meson_src_compile() {
> -C "${BUILD_DIR}"
> --jobs "$(makeopts_jobs "${MAKEOPTS}" 0)"
> --load-average "$(makeopts_loadavg "${MAKEOPTS}" 0)"
> - --verbose
> - "$@"
> )
>
> + case ${MESON_VERBOSE} in
> + OFF) ;;
> + *) mesoncompileargs+=( --verbose ) ;;
> + esac
No strong opinion, just to educate myself, but is there an advantage of
using case/easc over if/fi here?
That is
if [[ ${MESON_VERBOSE} != off ]]; then
mesoncompileargs+=( --verbose )
fi
or even the shell-style short idiom using ||.
- Flow
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 17273 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 618 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-19 7:23 ` Florian Schmaus
@ 2023-07-20 15:00 ` Matt Turner
2023-07-20 15:06 ` Florian Schmaus
0 siblings, 1 reply; 13+ messages in thread
From: Matt Turner @ 2023-07-20 15:00 UTC (permalink / raw
To: Florian Schmaus; +Cc: gentoo-dev
On Wed, Jul 19, 2023 at 3:23 AM Florian Schmaus <flow@gentoo.org> wrote:
>
> On 18/07/2023 18.44, Matt Turner wrote:
> > From: Jonas Rakebrandt <xarblu@protonmail.com>
> >
> > This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
> >
> > Closes: https://github.com/gentoo/gentoo/pull/28942
> > Signed-off-by: Jonas Rakebrandt <xarblu@protonmail.com>
> > Signed-off-by: Matt Turner <mattst88@gentoo.org>
> > ---
> > eclass/meson.eclass | 15 +++++++++++++--
> > 1 file changed, 13 insertions(+), 2 deletions(-)
> >
> > diff --git a/eclass/meson.eclass b/eclass/meson.eclass
> > index 2c274b213191..3b30f66bf30a 100644
> > --- a/eclass/meson.eclass
> > +++ b/eclass/meson.eclass
> > @@ -55,6 +55,12 @@ BDEPEND=">=dev-util/meson-0.62.2
> > # Build directory, location where all generated files should be placed.
> > # If this isn't set, it defaults to ${WORKDIR}/${P}-build.
> >
> > +# @ECLASS_VARIABLE: MESON_VERBOSE
> > +# @USER_VARIABLE
> > +# @DESCRIPTION:
> > +# Set to OFF to disable verbose messages during compilation
> > +: "${MESON_VERBOSE:=ON}"
> > +
> > # @ECLASS_VARIABLE: EMESON_BUILDTYPE
> > # @DESCRIPTION:
> > # The buildtype value to pass to meson setup.
> > @@ -385,10 +391,15 @@ meson_src_compile() {
> > -C "${BUILD_DIR}"
> > --jobs "$(makeopts_jobs "${MAKEOPTS}" 0)"
> > --load-average "$(makeopts_loadavg "${MAKEOPTS}" 0)"
> > - --verbose
> > - "$@"
> > )
> >
> > + case ${MESON_VERBOSE} in
> > + OFF) ;;
> > + *) mesoncompileargs+=( --verbose ) ;;
> > + esac
>
> No strong opinion, just to educate myself, but is there an advantage of
> using case/easc over if/fi here?
>
> That is
>
> if [[ ${MESON_VERBOSE} != off ]]; then
> mesoncompileargs+=( --verbose )
> fi
>
> or even the shell-style short idiom using ||.
No advantage as far as I'm aware. I was just copying the style used in
cmake.eclass.
I really wish bash just had boolean types :(
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-20 15:00 ` Matt Turner
@ 2023-07-20 15:06 ` Florian Schmaus
2023-07-20 15:08 ` Matt Turner
2023-07-20 15:45 ` Mike Gilbert
0 siblings, 2 replies; 13+ messages in thread
From: Florian Schmaus @ 2023-07-20 15:06 UTC (permalink / raw
To: Matt Turner, gentoo-dev
[-- Attachment #1.1.1: Type: text/plain, Size: 2387 bytes --]
On 20/07/2023 17.00, Matt Turner wrote:
> On Wed, Jul 19, 2023 at 3:23 AM Florian Schmaus <flow@gentoo.org> wrote:
>>
>> On 18/07/2023 18.44, Matt Turner wrote:
>>> From: Jonas Rakebrandt <xarblu@protonmail.com>
>>>
>>> This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
>>>
>>> Closes: https://github.com/gentoo/gentoo/pull/28942
>>> Signed-off-by: Jonas Rakebrandt <xarblu@protonmail.com>
>>> Signed-off-by: Matt Turner <mattst88@gentoo.org>
>>> ---
>>> eclass/meson.eclass | 15 +++++++++++++--
>>> 1 file changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/eclass/meson.eclass b/eclass/meson.eclass
>>> index 2c274b213191..3b30f66bf30a 100644
>>> --- a/eclass/meson.eclass
>>> +++ b/eclass/meson.eclass
>>> @@ -55,6 +55,12 @@ BDEPEND=">=dev-util/meson-0.62.2
>>> # Build directory, location where all generated files should be placed.
>>> # If this isn't set, it defaults to ${WORKDIR}/${P}-build.
>>>
>>> +# @ECLASS_VARIABLE: MESON_VERBOSE
>>> +# @USER_VARIABLE
>>> +# @DESCRIPTION:
>>> +# Set to OFF to disable verbose messages during compilation
>>> +: "${MESON_VERBOSE:=ON}"
>>> +
>>> # @ECLASS_VARIABLE: EMESON_BUILDTYPE
>>> # @DESCRIPTION:
>>> # The buildtype value to pass to meson setup.
>>> @@ -385,10 +391,15 @@ meson_src_compile() {
>>> -C "${BUILD_DIR}"
>>> --jobs "$(makeopts_jobs "${MAKEOPTS}" 0)"
>>> --load-average "$(makeopts_loadavg "${MAKEOPTS}" 0)"
>>> - --verbose
>>> - "$@"
>>> )
>>>
>>> + case ${MESON_VERBOSE} in
>>> + OFF) ;;
>>> + *) mesoncompileargs+=( --verbose ) ;;
>>> + esac
>>
>> No strong opinion, just to educate myself, but is there an advantage of
>> using case/easc over if/fi here?
>>
>> That is
>>
>> if [[ ${MESON_VERBOSE} != off ]]; then
>> mesoncompileargs+=( --verbose )
>> fi
>>
>> or even the shell-style short idiom using ||.
>
> No advantage as far as I'm aware. I was just copying the style used in
> cmake.eclass.
>
> I really wish bash just had boolean types :(
While the bash language has no boolean datatype, you can exploit the
fact that 'true' and 'false' are usually shell builtins:
: "${MESON_VERBOSE:=true}"
and then later
if $MESON_VERBOSE; then
mesoncompileargs+=( --verbose )
fi
- Flow
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 17273 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 618 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-20 15:06 ` Florian Schmaus
@ 2023-07-20 15:08 ` Matt Turner
2023-07-20 15:45 ` Mike Gilbert
1 sibling, 0 replies; 13+ messages in thread
From: Matt Turner @ 2023-07-20 15:08 UTC (permalink / raw
To: Florian Schmaus; +Cc: gentoo-dev
On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus <flow@gentoo.org> wrote:
>
> On 20/07/2023 17.00, Matt Turner wrote:
> > On Wed, Jul 19, 2023 at 3:23 AM Florian Schmaus <flow@gentoo.org> wrote:
> >>
> >> On 18/07/2023 18.44, Matt Turner wrote:
> >>> From: Jonas Rakebrandt <xarblu@protonmail.com>
> >>>
> >>> This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
> >>>
> >>> Closes: https://github.com/gentoo/gentoo/pull/28942
> >>> Signed-off-by: Jonas Rakebrandt <xarblu@protonmail.com>
> >>> Signed-off-by: Matt Turner <mattst88@gentoo.org>
> >>> ---
> >>> eclass/meson.eclass | 15 +++++++++++++--
> >>> 1 file changed, 13 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/eclass/meson.eclass b/eclass/meson.eclass
> >>> index 2c274b213191..3b30f66bf30a 100644
> >>> --- a/eclass/meson.eclass
> >>> +++ b/eclass/meson.eclass
> >>> @@ -55,6 +55,12 @@ BDEPEND=">=dev-util/meson-0.62.2
> >>> # Build directory, location where all generated files should be placed.
> >>> # If this isn't set, it defaults to ${WORKDIR}/${P}-build.
> >>>
> >>> +# @ECLASS_VARIABLE: MESON_VERBOSE
> >>> +# @USER_VARIABLE
> >>> +# @DESCRIPTION:
> >>> +# Set to OFF to disable verbose messages during compilation
> >>> +: "${MESON_VERBOSE:=ON}"
> >>> +
> >>> # @ECLASS_VARIABLE: EMESON_BUILDTYPE
> >>> # @DESCRIPTION:
> >>> # The buildtype value to pass to meson setup.
> >>> @@ -385,10 +391,15 @@ meson_src_compile() {
> >>> -C "${BUILD_DIR}"
> >>> --jobs "$(makeopts_jobs "${MAKEOPTS}" 0)"
> >>> --load-average "$(makeopts_loadavg "${MAKEOPTS}" 0)"
> >>> - --verbose
> >>> - "$@"
> >>> )
> >>>
> >>> + case ${MESON_VERBOSE} in
> >>> + OFF) ;;
> >>> + *) mesoncompileargs+=( --verbose ) ;;
> >>> + esac
> >>
> >> No strong opinion, just to educate myself, but is there an advantage of
> >> using case/easc over if/fi here?
> >>
> >> That is
> >>
> >> if [[ ${MESON_VERBOSE} != off ]]; then
> >> mesoncompileargs+=( --verbose )
> >> fi
> >>
> >> or even the shell-style short idiom using ||.
> >
> > No advantage as far as I'm aware. I was just copying the style used in
> > cmake.eclass.
> >
> > I really wish bash just had boolean types :(
>
> While the bash language has no boolean datatype, you can exploit the
> fact that 'true' and 'false' are usually shell builtins:
>
> : "${MESON_VERBOSE:=true}"
>
> and then later
>
> if $MESON_VERBOSE; then
> mesoncompileargs+=( --verbose )
> fi
Oh neat, thanks for the info!
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-20 15:06 ` Florian Schmaus
2023-07-20 15:08 ` Matt Turner
@ 2023-07-20 15:45 ` Mike Gilbert
2023-07-20 16:58 ` Ulrich Mueller
1 sibling, 1 reply; 13+ messages in thread
From: Mike Gilbert @ 2023-07-20 15:45 UTC (permalink / raw
To: gentoo-dev; +Cc: Matt Turner
On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus <flow@gentoo.org> wrote:
>
> On 20/07/2023 17.00, Matt Turner wrote:
> > On Wed, Jul 19, 2023 at 3:23 AM Florian Schmaus <flow@gentoo.org> wrote:
> >>
> >> On 18/07/2023 18.44, Matt Turner wrote:
> >>> From: Jonas Rakebrandt <xarblu@protonmail.com>
> >>>
> >>> This works similar to cmake.eclass's ${CMAKE_VERBOSE}.
> >>>
> >>> Closes: https://github.com/gentoo/gentoo/pull/28942
> >>> Signed-off-by: Jonas Rakebrandt <xarblu@protonmail.com>
> >>> Signed-off-by: Matt Turner <mattst88@gentoo.org>
> >>> ---
> >>> eclass/meson.eclass | 15 +++++++++++++--
> >>> 1 file changed, 13 insertions(+), 2 deletions(-)
> >>>
> >>> diff --git a/eclass/meson.eclass b/eclass/meson.eclass
> >>> index 2c274b213191..3b30f66bf30a 100644
> >>> --- a/eclass/meson.eclass
> >>> +++ b/eclass/meson.eclass
> >>> @@ -55,6 +55,12 @@ BDEPEND=">=dev-util/meson-0.62.2
> >>> # Build directory, location where all generated files should be placed.
> >>> # If this isn't set, it defaults to ${WORKDIR}/${P}-build.
> >>>
> >>> +# @ECLASS_VARIABLE: MESON_VERBOSE
> >>> +# @USER_VARIABLE
> >>> +# @DESCRIPTION:
> >>> +# Set to OFF to disable verbose messages during compilation
> >>> +: "${MESON_VERBOSE:=ON}"
> >>> +
> >>> # @ECLASS_VARIABLE: EMESON_BUILDTYPE
> >>> # @DESCRIPTION:
> >>> # The buildtype value to pass to meson setup.
> >>> @@ -385,10 +391,15 @@ meson_src_compile() {
> >>> -C "${BUILD_DIR}"
> >>> --jobs "$(makeopts_jobs "${MAKEOPTS}" 0)"
> >>> --load-average "$(makeopts_loadavg "${MAKEOPTS}" 0)"
> >>> - --verbose
> >>> - "$@"
> >>> )
> >>>
> >>> + case ${MESON_VERBOSE} in
> >>> + OFF) ;;
> >>> + *) mesoncompileargs+=( --verbose ) ;;
> >>> + esac
> >>
> >> No strong opinion, just to educate myself, but is there an advantage of
> >> using case/easc over if/fi here?
> >>
> >> That is
> >>
> >> if [[ ${MESON_VERBOSE} != off ]]; then
> >> mesoncompileargs+=( --verbose )
> >> fi
> >>
> >> or even the shell-style short idiom using ||.
> >
> > No advantage as far as I'm aware. I was just copying the style used in
> > cmake.eclass.
> >
> > I really wish bash just had boolean types :(
>
> While the bash language has no boolean datatype, you can exploit the
> fact that 'true' and 'false' are usually shell builtins:
>
> : "${MESON_VERBOSE:=true}"
>
> and then later
>
> if $MESON_VERBOSE; then
> mesoncompileargs+=( --verbose )
> fi
I think we generally try to avoid exploiting that behavior in ebuilds.
It's usually much more obvious to check for a non-empty string, or for
a specific value.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-20 15:45 ` Mike Gilbert
@ 2023-07-20 16:58 ` Ulrich Mueller
2023-07-20 17:11 ` Ionen Wolkens
0 siblings, 1 reply; 13+ messages in thread
From: Ulrich Mueller @ 2023-07-20 16:58 UTC (permalink / raw
To: Mike Gilbert; +Cc: gentoo-dev, Matt Turner
[-- Attachment #1: Type: text/plain, Size: 757 bytes --]
>>>>> On Thu, 20 Jul 2023, Mike Gilbert wrote:
> On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus <flow@gentoo.org> wrote:
>> While the bash language has no boolean datatype, you can exploit the
>> fact that 'true' and 'false' are usually shell builtins:
>>
>> : "${MESON_VERBOSE:=true}"
>>
>> and then later
>>
>> if $MESON_VERBOSE; then
>> mesoncompileargs+=( --verbose )
>> fi
> I think we generally try to avoid exploiting that behavior in ebuilds.
> It's usually much more obvious to check for a non-empty string, or for
> a specific value.
Testing for a non-empty variable is also faster than executing "true"
or "false" builtins from variable values. (Which doesn't play any role
here, but readability of the code does.)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-20 16:58 ` Ulrich Mueller
@ 2023-07-20 17:11 ` Ionen Wolkens
2023-07-20 17:33 ` Ionen Wolkens
0 siblings, 1 reply; 13+ messages in thread
From: Ionen Wolkens @ 2023-07-20 17:11 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]
On Thu, Jul 20, 2023 at 06:58:04PM +0200, Ulrich Mueller wrote:
> >>>>> On Thu, 20 Jul 2023, Mike Gilbert wrote:
>
> > On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus <flow@gentoo.org> wrote:
> >> While the bash language has no boolean datatype, you can exploit the
> >> fact that 'true' and 'false' are usually shell builtins:
> >>
> >> : "${MESON_VERBOSE:=true}"
> >>
> >> and then later
> >>
> >> if $MESON_VERBOSE; then
> >> mesoncompileargs+=( --verbose )
> >> fi
>
> > I think we generally try to avoid exploiting that behavior in ebuilds.
> > It's usually much more obvious to check for a non-empty string, or for
> > a specific value.
>
> Testing for a non-empty variable is also faster than executing "true"
> or "false" builtins from variable values. (Which doesn't play any role
> here, but readability of the code does.)
Yes, this is what I'd recommend typically. Then documentation can say
"if set to a non-empty value" to toggle.
Unfortunately this doesn't work so great when the default is enabled.
Telling people to empty it is probably weird.
wrt true/false, given MESON_VERBOSE can be set "by users" to anything
I think trying to execute that would be extra weird.
On a side-note, another way to avoid case statements is extglob which
is always enabled in [[ ]] (no need for shopt)
aka: [[ ${var} == @(first|second|third) ]]
--
ionen
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
2023-07-20 17:11 ` Ionen Wolkens
@ 2023-07-20 17:33 ` Ionen Wolkens
0 siblings, 0 replies; 13+ messages in thread
From: Ionen Wolkens @ 2023-07-20 17:33 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]
On Thu, Jul 20, 2023 at 01:11:10PM -0400, Ionen Wolkens wrote:
> On Thu, Jul 20, 2023 at 06:58:04PM +0200, Ulrich Mueller wrote:
> > >>>>> On Thu, 20 Jul 2023, Mike Gilbert wrote:
> >
> > > On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus <flow@gentoo.org> wrote:
> > >> While the bash language has no boolean datatype, you can exploit the
> > >> fact that 'true' and 'false' are usually shell builtins:
> > >>
> > >> : "${MESON_VERBOSE:=true}"
> > >>
> > >> and then later
> > >>
> > >> if $MESON_VERBOSE; then
> > >> mesoncompileargs+=( --verbose )
> > >> fi
> >
> > > I think we generally try to avoid exploiting that behavior in ebuilds.
> > > It's usually much more obvious to check for a non-empty string, or for
> > > a specific value.
> >
> > Testing for a non-empty variable is also faster than executing "true"
> > or "false" builtins from variable values. (Which doesn't play any role
> > here, but readability of the code does.)
>
> Yes, this is what I'd recommend typically. Then documentation can say
> "if set to a non-empty value" to toggle.
...ultimately I feel these should be e.g. MESON_NO_VERBOSE, and be
default unset (same for the others build systems).
Alternatively could also consider a unified SOMETHING_NO_VERBOSE
variable that would be used by all eclasses / ebuild where possible
or relevant.
>
> Unfortunately this doesn't work so great when the default is enabled.
> Telling people to empty it is probably weird.
>
> wrt true/false, given MESON_VERBOSE can be set "by users" to anything
> I think trying to execute that would be extra weird.
>
> On a side-note, another way to avoid case statements is extglob which
> is always enabled in [[ ]] (no need for shopt)
s/another/a/, just meant this as a side-tidbit that doesn't use
full on regex (unrelated)
>
> aka: [[ ${var} == @(first|second|third) ]]
--
ionen
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-07-20 17:33 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-17 14:51 [gentoo-dev] [PATCH] meson.eclass: allow disabling verbose compilation Matt Turner
2023-07-17 14:56 ` Adrian Schollmeyer
2023-07-17 15:24 ` Matt Turner
2023-07-17 15:23 ` [gentoo-dev] " Matt Turner
2023-07-18 16:44 ` [gentoo-dev] [PATCH v2] " Matt Turner
2023-07-19 7:23 ` Florian Schmaus
2023-07-20 15:00 ` Matt Turner
2023-07-20 15:06 ` Florian Schmaus
2023-07-20 15:08 ` Matt Turner
2023-07-20 15:45 ` Mike Gilbert
2023-07-20 16:58 ` Ulrich Mueller
2023-07-20 17:11 ` Ionen Wolkens
2023-07-20 17:33 ` Ionen Wolkens
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox