* [PATCH] meson: Fix wrapper handling of implicit setup command
@ 2023-03-03 18:44 Tom Hochstein
2023-03-03 19:08 ` [OE-core] " Alexander Kanavin
0 siblings, 1 reply; 3+ messages in thread
From: Tom Hochstein @ 2023-03-03 18:44 UTC (permalink / raw)
To: openembedded-core; +Cc: Tom Hochstein
From an SDK, running a meson setup build without an explicit setup
command can result in a native build when a cross build is expected.
The problem is in meson-wrapper where it tries to detect whether a
setup command is being used. The logic looks through all arguments for
a command, and the first argument it finds that doesn't start with a -
is treated as the command. This doesn't work for an implicit setup
command if any option with a space-separated argument exists. In this
case, the argument is incorrectly selected as the command, causing the
setup command options for the cross build to be excluded from the
command line, and thus a native build.
Improve the logic by just looking at the first argument. If it is
a known comand, then record it. Otherwise just assume it is the
implicit setup command.
Note that this fix does not address the possibility of a new meson
command. Two new echo statements are included to help the user in case
of trouble:
```
~/git/weston-imx$ meson --warnlevel 3 --prefix=/usr -Ddoc=false -Dbackend-drm-screencast-vaapi=false -Dcolor-management-lcms=false -Dpipewire=false -Dbackend-x11=false -Dxwayland=true -Dsimple-clients=all -Dbackend-wayland=false -Dbackend-default=drm -Dbackend-rdp=false -Dtest-junit-xml=false -Dlauncher-libseat=false -Dimage-jpeg=false -Dimage-webp=false -Drenderer-g2d=true build
meson-wrapper: Implicit setup command assumed
meson-wrapper: Running meson with setup options: " --cross-file=/opt/fsl-imx-internal-xwayland/6.1-langdale/sysroots/x86_64-pokysdk-linux/usr/share/meson/aarch64-poky-linux-meson.cross --native-file=/opt/fsl-imx-internal-xwayland/6.1-langdale/sysroots/x86_64-pokysdk-linux/usr/share/meson/meson.native "
The Meson build system
Version: 0.63.3
```
Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
---
meta/recipes-devtools/meson/meson/meson-wrapper | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/meta/recipes-devtools/meson/meson/meson-wrapper b/meta/recipes-devtools/meson/meson/meson-wrapper
index fca64a5692..7455985297 100755
--- a/meta/recipes-devtools/meson/meson/meson-wrapper
+++ b/meta/recipes-devtools/meson/meson/meson-wrapper
@@ -13,20 +13,19 @@ fi
# config is already in meson.cross.
unset CC CXX CPP LD AR NM STRIP
-for arg in "$@"; do
- case "$arg" in
- -*) continue ;;
- *) SUBCMD="$arg"; break ;;
- esac
-done
+case "$1" in
+setup|configure|dist|install|introspect|init|test|wrap|subprojects|rewrite|compile|devenv|env2mfile|help) MESON_CMD="$1" ;;
+*) echo meson-wrapper: Implicit setup command assumed; MESON_CMD=setup ;;
+esac
-if [ "$SUBCMD" = "setup" ] || [ -d "$SUBCMD" ]; then
- MESON_SUB_OPTS=" \
+if [ "$MESON_CMD" = "setup" ]; then
+ MESON_SETUP_OPTS=" \
--cross-file="$OECORE_NATIVE_SYSROOT/usr/share/meson/${TARGET_PREFIX}meson.cross" \
--native-file="$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.native" \
"
+ echo meson-wrapper: Running meson with setup options: \"$MESON_SETUP_OPTS\"
fi
exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
"$@" \
- $MESON_SUB_OPTS
+ $MESON_SETUP_OPTS
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [OE-core] [PATCH] meson: Fix wrapper handling of implicit setup command
2023-03-03 18:44 [PATCH] meson: Fix wrapper handling of implicit setup command Tom Hochstein
@ 2023-03-03 19:08 ` Alexander Kanavin
2023-03-03 20:26 ` Tom Hochstein
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Kanavin @ 2023-03-03 19:08 UTC (permalink / raw)
To: Tom Hochstein; +Cc: openembedded-core
This should have been caught by meta/lib/oeqa/sdk/cases/buildepoxy.py
- why wasn't it? Does the test need to be fixed?
Alex
On Fri, 3 Mar 2023 at 19:45, Tom Hochstein <tom.hochstein@nxp.com> wrote:
>
> From an SDK, running a meson setup build without an explicit setup
> command can result in a native build when a cross build is expected.
>
> The problem is in meson-wrapper where it tries to detect whether a
> setup command is being used. The logic looks through all arguments for
> a command, and the first argument it finds that doesn't start with a -
> is treated as the command. This doesn't work for an implicit setup
> command if any option with a space-separated argument exists. In this
> case, the argument is incorrectly selected as the command, causing the
> setup command options for the cross build to be excluded from the
> command line, and thus a native build.
>
> Improve the logic by just looking at the first argument. If it is
> a known comand, then record it. Otherwise just assume it is the
> implicit setup command.
>
> Note that this fix does not address the possibility of a new meson
> command. Two new echo statements are included to help the user in case
> of trouble:
>
> ```
> ~/git/weston-imx$ meson --warnlevel 3 --prefix=/usr -Ddoc=false -Dbackend-drm-screencast-vaapi=false -Dcolor-management-lcms=false -Dpipewire=false -Dbackend-x11=false -Dxwayland=true -Dsimple-clients=all -Dbackend-wayland=false -Dbackend-default=drm -Dbackend-rdp=false -Dtest-junit-xml=false -Dlauncher-libseat=false -Dimage-jpeg=false -Dimage-webp=false -Drenderer-g2d=true build
> meson-wrapper: Implicit setup command assumed
> meson-wrapper: Running meson with setup options: " --cross-file=/opt/fsl-imx-internal-xwayland/6.1-langdale/sysroots/x86_64-pokysdk-linux/usr/share/meson/aarch64-poky-linux-meson.cross --native-file=/opt/fsl-imx-internal-xwayland/6.1-langdale/sysroots/x86_64-pokysdk-linux/usr/share/meson/meson.native "
> The Meson build system
> Version: 0.63.3
> ```
>
> Signed-off-by: Tom Hochstein <tom.hochstein@nxp.com>
> ---
> meta/recipes-devtools/meson/meson/meson-wrapper | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/meta/recipes-devtools/meson/meson/meson-wrapper b/meta/recipes-devtools/meson/meson/meson-wrapper
> index fca64a5692..7455985297 100755
> --- a/meta/recipes-devtools/meson/meson/meson-wrapper
> +++ b/meta/recipes-devtools/meson/meson/meson-wrapper
> @@ -13,20 +13,19 @@ fi
> # config is already in meson.cross.
> unset CC CXX CPP LD AR NM STRIP
>
> -for arg in "$@"; do
> - case "$arg" in
> - -*) continue ;;
> - *) SUBCMD="$arg"; break ;;
> - esac
> -done
> +case "$1" in
> +setup|configure|dist|install|introspect|init|test|wrap|subprojects|rewrite|compile|devenv|env2mfile|help) MESON_CMD="$1" ;;
> +*) echo meson-wrapper: Implicit setup command assumed; MESON_CMD=setup ;;
> +esac
>
> -if [ "$SUBCMD" = "setup" ] || [ -d "$SUBCMD" ]; then
> - MESON_SUB_OPTS=" \
> +if [ "$MESON_CMD" = "setup" ]; then
> + MESON_SETUP_OPTS=" \
> --cross-file="$OECORE_NATIVE_SYSROOT/usr/share/meson/${TARGET_PREFIX}meson.cross" \
> --native-file="$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.native" \
> "
> + echo meson-wrapper: Running meson with setup options: \"$MESON_SETUP_OPTS\"
> fi
>
> exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
> "$@" \
> - $MESON_SUB_OPTS
> + $MESON_SETUP_OPTS
> --
> 2.25.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#178021): https://lists.openembedded.org/g/openembedded-core/message/178021
> Mute This Topic: https://lists.openembedded.org/mt/97369067/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] meson: Fix wrapper handling of implicit setup command
2023-03-03 19:08 ` [OE-core] " Alexander Kanavin
@ 2023-03-03 20:26 ` Tom Hochstein
0 siblings, 0 replies; 3+ messages in thread
From: Tom Hochstein @ 2023-03-03 20:26 UTC (permalink / raw)
To: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 1027 bytes --]
On Fri, Mar 3, 2023 at 11:08 AM, Alexander Kanavin wrote:
>
> This should have been caught by meta/lib/oeqa/sdk/cases/buildepoxy.py
> - why wasn't it? Does the test need to be fixed?
The simple test case doesn't have the problematic syntax. Should I add this to the patch?
diff --git a/meta/lib/oeqa/sdk/cases/buildepoxy.py b/meta/lib/oeqa/sdk/cases/buildepoxy.py
index ee515be188..147ee3e0ee 100644
--- a/meta/lib/oeqa/sdk/cases/buildepoxy.py
+++ b/meta/lib/oeqa/sdk/cases/buildepoxy.py
@@ -35,7 +35,7 @@ class EpoxyTest(OESDKTestCase):
self.assertTrue(os.path.isdir(dirs["source"]))
os.makedirs(dirs["build"])
- log = self._run("meson -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
+ log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
# Check that Meson thinks we're doing a cross build and not a native
self.assertIn("Build type: cross build", log)
self._run("ninja -C {build} -v".format(**dirs))
[-- Attachment #2: Type: text/html, Size: 1516 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-03 20:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-03 18:44 [PATCH] meson: Fix wrapper handling of implicit setup command Tom Hochstein
2023-03-03 19:08 ` [OE-core] " Alexander Kanavin
2023-03-03 20:26 ` Tom Hochstein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox