Is there a document, or better yet a diagram, showing the order in which
various config files, recipes, tasks, etc are parsed?

Figuring out the order of the config files is easy enough (bitbake.conf), but
trying to figure out when various other parts are processed is just a guess
for me right now.

Conceptually this is what I want to do:

        Currently the meson build system (class) is hard-coded to always produce
        a buildtype of "plain", which are (basically) production builds. But
        there are other buildtypes that can be specified; such as
        "debugoptimized". I want a recipe to be able to influence the meson
        buildtype, and I want the user to be able to tweak this parameter from
        their conf/local.conf.

Here's what I want to do:

        diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
        index dc8c28963c..e1a13bbbf7 100644
        --- a/meta/classes/meson.bbclass
        +++ b/meta/classes/meson.bbclass
        @@ -12,8 +12,9 @@ MESON_SOURCEPATH = "${S}"
         def noprefix(var, d):
             return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)

        +MESON_BUILDTYPE ?= "plain"
         MESONOPTS = " --prefix ${prefix} \
        -              --buildtype plain \
        +              --buildtype ${MESON_BUILDTYPE} \
                       --bindir ${@noprefix('bindir', d)} \
                       --sbindir ${@noprefix('sbindir', d)} \
                       --datadir ${@noprefix('datadir', d)} \
        diff --git a/meta/recipes-graphics/mesa/mesa.inc 
b/meta/recipes-graphics/mesa/mesa.inc
        index 5838207e6b..fb232d414e 100644
        --- a/meta/recipes-graphics/mesa/mesa.inc
        +++ b/meta/recipes-graphics/mesa/mesa.inc
        @@ -46,6 +46,20 @@ export WANT_LLVM_RELEASE = "${MESA_LLVM_RELEASE}"

         MESA_LLVM_RELEASE ?= "${LLVMVERSION}"

        +# set the build type to either 'release' or 'debug'
        +# the upstream mesa sources actually build a debug release by default
        +# but here we assume the user will want a release build by default
        +MESA_BUILD_TYPE ?= "release"
        +python do_check_build_type() {
        +    _buildtype = d.getVar('MESA_BUILD_TYPE')
        +    if _buildtype not in ['release', 'debug']:
        +        bb.fatal("unknown build type (%s), please set to either 
'release' or 'debug'" % _buildtype)
        +    if _buildtype == 'debug':
        +        d.setVar('MESON_BUILDTYPE', 'debugoptimized')
        +        bb.plain("setting meson build type to debugoptimized")
        +}
        +addtask check_build_type before do_configure
        +
         EXTRA_OEMESON = " \
             -Dshared-glapi=true \
             -Dgallium-opencl=disabled \

Therefore if the user doesn't do anything explicitly, a production buildtype
will be produced. However, if the user were to specify the following in their
conf/local.conf:

        MESA_BUILD_TYPE = "debug"

I want mesa's buildtype to be "debugoptimized".

I don't want the user to specify the following in their conf/local.conf:

        MESON_BUILDTYPE = "debugoptimized"

because that would cause *all* meson-built packages to switch to the
debugoptimized buildtype. I only want mesa's build to be debugoptimized.

However, the above doesn't work. If I set MESA_BUILD_TYPE to "hello" in my
conf/local.conf, then the build will flag it and error out asking me to
specify either 'release' or 'debug', which is great. But if I set
MESA_BUILD_TYPE to 'debug' the MESON_BUILDTYPE variable is always set to
"plain" regardless. So this task runs, but I guess it runs too late to
influence the MESON_BUILDTYPE variable?

So, how can I run this function earlier (?) so that it can set the
MESON_BUILDTYPE variable correctly? I tried the following:

        diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
        index dc8c28963c..e1a13bbbf7 100644
        --- a/meta/classes/meson.bbclass
        +++ b/meta/classes/meson.bbclass
        @@ -12,8 +12,9 @@ MESON_SOURCEPATH = "${S}"
         def noprefix(var, d):
             return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)

        +MESON_BUILDTYPE ?= "plain"
         MESONOPTS = " --prefix ${prefix} \
        -              --buildtype plain \
        +              --buildtype ${MESON_BUILDTYPE} \
                       --bindir ${@noprefix('bindir', d)} \
                       --sbindir ${@noprefix('sbindir', d)} \
                       --datadir ${@noprefix('datadir', d)} \
        diff --git a/meta/recipes-graphics/mesa/mesa.inc 
b/meta/recipes-graphics/mesa/mesa.inc
        index 5838207e6b..b302f8ee55 100644
        --- a/meta/recipes-graphics/mesa/mesa.inc
        +++ b/meta/recipes-graphics/mesa/mesa.inc
        @@ -46,6 +46,20 @@ export WANT_LLVM_RELEASE = "${MESA_LLVM_RELEASE}"

         MESA_LLVM_RELEASE ?= "${LLVMVERSION}"

        +# set the build type to either 'release' or 'debug'
        +# the upstream mesa sources actually build a debug release by default
        +# but here we assume the user will want a release build by default
        +MESA_BUILD_TYPE ?= "release"
        +def check_buildtype(d):
        +    _buildtype = d.getVar('MESA_BUILD_TYPE')
        +    if _buildtype not in ['release', 'debug']:
        +        bb.fatal("unknown build type (%s), please set to either 
'release' or 'debug'" % _buildtype)
        +    if _buildtype == 'debug':
        +        bb.plain("setting meson build type to debugoptimized")
        +        return 'debugoptimized'
        +    return 'plain'
        +MESON_BUILDTYPE = "${@check_buildtype(d)}"
        +
         EXTRA_OEMESON = " \
             -Dshared-glapi=true \
             -Dgallium-opencl=disabled \

This will print out the bb.plain() message 16 times during parsing etc, it
will fail out if MESA_BUILD_TYPE is not one of 'release' or 'debug' (which is
good), but if this occurs, the error message is printed out twice plus a
python traceback, which might be scary to users.

The last thing I tried was the following:

        diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
        index dc8c28963c..e1a13bbbf7 100644
        --- a/meta/classes/meson.bbclass
        +++ b/meta/classes/meson.bbclass
        @@ -12,8 +12,9 @@ MESON_SOURCEPATH = "${S}"
         def noprefix(var, d):
             return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)

        +MESON_BUILDTYPE ?= "plain"
         MESONOPTS = " --prefix ${prefix} \
        -              --buildtype plain \
        +              --buildtype ${MESON_BUILDTYPE} \
                       --bindir ${@noprefix('bindir', d)} \
                       --sbindir ${@noprefix('sbindir', d)} \
                       --datadir ${@noprefix('datadir', d)} \
        diff --git a/meta/recipes-graphics/mesa/mesa.inc 
b/meta/recipes-graphics/mesa/mesa.inc
        index 5838207e6b..c265ffc246 100644
        --- a/meta/recipes-graphics/mesa/mesa.inc
        +++ b/meta/recipes-graphics/mesa/mesa.inc
        @@ -46,6 +46,12 @@ export WANT_LLVM_RELEASE = "${MESA_LLVM_RELEASE}"

         MESA_LLVM_RELEASE ?= "${LLVMVERSION}"

        +# set the build type to either 'release' or 'debug'
        +# the upstream mesa sources actually build a debug release by default
        +# but here we assume the user will want a release build by default
        +MESA_BUILD_TYPE ?= "release"
        +MESON_BUILDTYPE = "${@bb.utils.contains('MESA_BUILD_TYPE', 'debug', 
'debugoptimized', 'plain', d)}"
        +
         EXTRA_OEMESON = " \
             -Dshared-glapi=true \
             -Dgallium-opencl=disabled \

This works perfectly, but it lacks the error checking and helpful messages of
the previous attempts.

Any thoughts on how I can have it all? (i.e. nice error checking and error
messages with the variable tweakable from conf/local.conf?

Best regards,
        Trevor
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#47628): https://lists.yoctoproject.org/g/yocto/message/47628
Mute This Topic: https://lists.yoctoproject.org/mt/68144480/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub  
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to