Hi,

thanks for the quick reply I tried your suggestion but I get:

ERROR: Unable to parse Var <DISTRO_VERSION[:=]>
Traceback (most recent call last):
  File "Var <DISTRO_VERSION[:=]>", line 1, in <module>
bb.data_smart.ExpansionError: Failure expanding variable
DISTRO_VERSION[:=], expression was ${@my_distro_version(d)} which triggered
exception NameError: name 'my_distro_version' is not defined

I think in this case the INHERIT doesn't work !


Best regards,


On Thu, Apr 28, 2022 at 1:15 PM <mikko.rap...@bmw.de> wrote:

> Hi,
>
> On Thu, Apr 28, 2022 at 01:04:22PM +0200, Ayoub Zaki via
> lists.yoctoproject.org wrote:
> > hello,
> >
> >
> > I would like to have a custom DISTRO_VERSION based on "git describe" of
> my
> > layer:
> >
> >
> > 1) In my layer meta-mylayer/conf/layer.conf, I defined the following:
> >
> > # Set variable to get the location of the layer
> > > MY_LAYER_BASE := '${LAYERDIR}'
> >
> >
> >
> > 2) I created a my_distro_version.bbclass with following:
> >
> > def my_distro_version(d):
> > >     import subprocess
> > >     project_path = d.getVar('MY_LAYER_BASE', True)
> > >     cmd = "git describe --tags"
>
> I would also add --always and --dirty to be sure non-tagged clones
> of repo work and builds with local modifications get marked as such.
>
> > >     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True,
> > > cwd=project_path)
> > >     out, err =  proc.communicate()
> > >     return out.decode("utf-8").rstrip()
> >
> >
> > 3)  Then I inherited it my  meta-mylayer/conf/distro/my_distro.conf :
> >
> > INHERIT += "my_distro_version"
> > > DISTRO_VERSION = "${@my_distro_version(d)}"
>
> DISTRO_VERSION := "${@my_distro_version(d)}"
>
> That should do it :)
>
> Cheers,
>
> -Mikko
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#56932): https://lists.yoctoproject.org/g/yocto/message/56932
Mute This Topic: https://lists.yoctoproject.org/mt/90750240/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to