Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
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 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 signature.asc Description: PGP signature
Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
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 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 signature.asc Description: PGP signature
Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
> On Thu, 20 Jul 2023, Mike Gilbert wrote: > On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus 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.) signature.asc Description: PGP signature
Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus wrote: > > On 20/07/2023 17.00, Matt Turner wrote: > > On Wed, Jul 19, 2023 at 3:23 AM Florian Schmaus wrote: > >> > >> On 18/07/2023 18.44, Matt Turner wrote: > >>> From: Jonas Rakebrandt > >>> > >>> This works similar to cmake.eclass's ${CMAKE_VERBOSE}. > >>> > >>> Closes: https://github.com/gentoo/gentoo/pull/28942 > >>> Signed-off-by: Jonas Rakebrandt > >>> Signed-off-by: Matt Turner > >>> --- > >>>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.
Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
On Thu, Jul 20, 2023 at 11:06 AM Florian Schmaus wrote: > > On 20/07/2023 17.00, Matt Turner wrote: > > On Wed, Jul 19, 2023 at 3:23 AM Florian Schmaus wrote: > >> > >> On 18/07/2023 18.44, Matt Turner wrote: > >>> From: Jonas Rakebrandt > >>> > >>> This works similar to cmake.eclass's ${CMAKE_VERBOSE}. > >>> > >>> Closes: https://github.com/gentoo/gentoo/pull/28942 > >>> Signed-off-by: Jonas Rakebrandt > >>> Signed-off-by: Matt Turner > >>> --- > >>>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!
Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
On 20/07/2023 17.00, Matt Turner wrote: On Wed, Jul 19, 2023 at 3:23 AM Florian Schmaus wrote: On 18/07/2023 18.44, Matt Turner wrote: From: Jonas Rakebrandt This works similar to cmake.eclass's ${CMAKE_VERBOSE}. Closes: https://github.com/gentoo/gentoo/pull/28942 Signed-off-by: Jonas Rakebrandt Signed-off-by: Matt Turner --- 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 OpenPGP_0x8CAC2A9678548E35.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature
Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
On Wed, Jul 19, 2023 at 3:23 AM Florian Schmaus wrote: > > On 18/07/2023 18.44, Matt Turner wrote: > > From: Jonas Rakebrandt > > > > This works similar to cmake.eclass's ${CMAKE_VERBOSE}. > > > > Closes: https://github.com/gentoo/gentoo/pull/28942 > > Signed-off-by: Jonas Rakebrandt > > Signed-off-by: Matt Turner > > --- > > 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 :(
Re: [gentoo-dev] [PATCH v2] meson.eclass: allow disabling verbose compilation
On 18/07/2023 18.44, Matt Turner wrote: From: Jonas Rakebrandt This works similar to cmake.eclass's ${CMAKE_VERBOSE}. Closes: https://github.com/gentoo/gentoo/pull/28942 Signed-off-by: Jonas Rakebrandt Signed-off-by: Matt Turner --- 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 OpenPGP_0x8CAC2A9678548E35.asc Description: OpenPGP public key OpenPGP_signature Description: OpenPGP digital signature