All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Kanavin <alex.kanavin@gmail.com>
To: Joel Winarske <joel.winarske@gmail.com>
Cc: OE-core <Openembedded-core@lists.openembedded.org>
Subject: Re: [OE-core] [RFC] meson needs a pkg-config wrapper script
Date: Tue, 30 Nov 2021 19:53:08 +0100	[thread overview]
Message-ID: <CANNYZj8+jV09y-p1Fciw6xY_PHabj1DtEdG0ywxGpBOgHrUoyw@mail.gmail.com> (raw)
In-Reply-To: <CABKMkP+1pDhZqzGwz-6baUnhEhsOopGonP5d7njNJ0WxsfgLEA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4390 bytes --]

I do not quite understand the use case. What is being done with the full
path to the header?

Alex

On Tue, 30 Nov 2021 at 19:26, Joel Winarske <joel.winarske@gmail.com> wrote:

> This pattern works to get the absolute path of the header:
>
> Yocto
>
>     EXTRA_OEMESON += "--prefix ${STAGING_DIR_TARGET}/usr"
>
> Meson
>
>     vulkan_dep = dependency('vulkan')
>     vulkan_hpp = join_paths([
>         vulkan_dep.get_pkgconfig_variable('includedir', define_variable:
> ['prefix', get_option('prefix')]),
>         'vulkan',
>         'vulkan.hpp'
>         ])
>
> Implementation in build/meson-log.txt
>
> Called
> `/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/rpi4/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot-native/usr/bin/pkg-config
> --define-variable=prefix=/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/rpi4/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot/usr
> --variable=includedir vulkan` -> 0
>
>
> One would expect the following meson to work if STAGING_DIR_TARGET were
> set, as that's how pkg-config works:
>
>     vulkan_dep = dependency('vulkan')
>     vulkan_hpp = join_paths([
>         vulkan_dep.get_pkgconfig_variable('includedir'),
>         'vulkan',
>         'vulkan.hpp'
>         ])
>
> This will always return /usr/include/vulkan/vulkan.hpp regardless of
> PKG_CONFIG_SYSROOT_DIR value.  With PKG_CONFIG_SYSROOT_DIR set, it should
> be /usr/include/vulkan/vulkan.hpp with prepend of PKG_CONFIG_SYSROOT_DIR
> value.
>
>
> Sandbox testing of pkg-config
>
>     $ export
> STAGING_DIR_TARGET=/b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/raspberrypi4-64/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot
>     $ PKG_CONFIG_SYSROOT_DIR=$STAGING_DIR_TARGET pkg-config
> --define-variable=prefix=/opt --variable=includedir vulkan
>
> /b/github-ci/_work/meta-flutter/rpi4-drm-honister-latest/raspberrypi4-64/tmp/work/cortexa72-poky-linux/vkmark/git-r0/recipe-sysroot/opt/include
>
>
> meson.cross
>
> Setting sys_root in the properties section of meson.cross (patching
> meson.bbclass) indirectly sets PKG_CONFIG_SYSROOT_DIR.  The setting of
> sys_root is present in nativesdk_meson*.bb, not meson*.bb.
>
> The issue for meson is that they are not passing the
> PKG_CONFIG_SYSROOT_DIR variable to the shell that launches pkg-config.
>
> My proposed work around (this email thread) would fix the behavior.  I
> believe the proper fix is for meson to address upstream.  Still waiting on
> a response from them: https://github.com/mesonbuild/meson/issues/9674
>
>
> Joel
>
> On Tue, Nov 30, 2021 at 9:49 AM Alexander Kanavin <alex.kanavin@gmail.com>
> wrote:
>
>> On Tue, 30 Nov 2021 at 18:20, Joel Winarske <joel.winarske@gmail.com>
>> wrote:
>>
>>> Meson does not expose PKG_CONFIG_SYSROOT_DIR to the pkg-config process.
>>>
>>> Currently meson.cross as generated in meson.bbclass points directly to
>>> the pkg-config executable (no wrapper script).
>>>
>>> PKG_CONFIG_SYSROOT_DIR behaves like a simple string prepend to all
>>> package config variable queries.  So if you want to determine the absolute
>>> path of a variable in .pc you set PKG_CONFIG_SYSROOT_DIR and make your
>>> query.  Currently this is not possible with Yocto+Meson.
>>>
>>> I think a simple wrapper script would resolve this.  This is from
>>> https://autotools.io/pkgconfig/cross-compiling.html:
>>>
>>> #!/bin/sh
>>>
>>> SYSROOT=/build/root
>>>
>>> export PKG_CONFIG_PATH=
>>> export PKG_CONFIG_LIBDIR=${SYSROOT}/usr/lib/pkgconfig:${SYSROOT}/usr/share/pkgconfig
>>> export PKG_CONFIG_SYSROOT_DIR=${SYSROOT}
>>>
>>> exec pkg-config "$@"
>>>
>>>
>>> The wrapper script would be generated per recipe via meson.bbclass,
>>> meson.cross would then reference this wrapper instead of the pkg-config
>>> executable.
>>>
>>> Thoughts?
>>>
>>
>> I don't think this is correct. Meson's way of doing things is that you
>> are not supposed to get the include/library paths directly from pkg-config,
>> but rather use
>> https://mesonbuild.com/Reference-manual_functions.html#dependency and
>> meson will take care of any needed prefixes to the paths.
>>
>> For the custom variables defined in .pc that happen to contain paths,
>> PKG_CONFIG_SYSROOT_DIR has no effect at all, so you need to manually
>> prepend it anyway everywhere where they're used. pkg-config does not know
>> what variable is a path and what isn't.
>>
>> Alex
>>
>

[-- Attachment #2: Type: text/html, Size: 6314 bytes --]

  reply	other threads:[~2021-11-30 18:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 17:20 [RFC] meson needs a pkg-config wrapper script Joel Winarske
2021-11-30 17:49 ` [OE-core] " Alexander Kanavin
2021-11-30 18:25   ` Joel Winarske
2021-11-30 18:53     ` Alexander Kanavin [this message]
2021-11-30 19:15       ` Joel Winarske
2021-11-30 19:39         ` Alexander Kanavin
2021-11-30 20:00           ` Joel Winarske
2021-11-30 20:03             ` Joel Winarske
2021-11-30 20:13             ` Alexander Kanavin
2021-11-30 22:37               ` Joel Winarske
2021-12-01  8:36                 ` Alexander Kanavin
2021-12-01  9:11                   ` Eero Aaltonen
     [not found]                   ` <CABKMkPJ+6xA9BtZsv-tcKKssJdhfjA4w7eSxJzNyBOg4Ak2=gw@mail.gmail.com>
2021-12-01 22:38                     ` Alexander Kanavin
2021-12-01 23:27                       ` Joel Winarske
     [not found]                       ` <16BCC5463709ABBF.10763@lists.openembedded.org>
2021-12-01 23:56                         ` Joel Winarske
2021-11-30 21:18 ` Ross Burton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANNYZj8+jV09y-p1Fciw6xY_PHabj1DtEdG0ywxGpBOgHrUoyw@mail.gmail.com \
    --to=alex.kanavin@gmail.com \
    --cc=Openembedded-core@lists.openembedded.org \
    --cc=joel.winarske@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.