Message ID | 20210907132240.2987302-2-adrian.freihofer@siemens.com |
---|---|
State | Changes Requested |
Headers | show |
Series | swupdate-common: get do_swuimage vardeps | expand |
Hi Adrian, On 07.09.21 15:22, Adrian Freihofer wrote: > Read all variables from sw-description file and add them to the vardeps > of the do_swuimage task. Bitbake cannot know that the do_swuimage task > which evaluates the templated sw-description file needs to be executed > if a variable which is refered by the sw-description file but not by > the recipe itself. > --- > classes/swupdate-image.bbclass | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/classes/swupdate-image.bbclass b/classes/swupdate-image.bbclass > index 618b438..f25f1f0 100644 > --- a/classes/swupdate-image.bbclass > +++ b/classes/swupdate-image.bbclass > @@ -32,3 +32,26 @@ python do_swupdate_copy_swdescription() { > do_swupdate_copy_swdescription[nostamp] = "1" > addtask swupdate_copy_swdescription before do_image_complete after do_unpack > addtask swuimage after do_swupdate_copy_swdescription do_image_complete before do_build > + > +# Read all variables from sw-description file and add them to the vardeps of the do_swuimage task. Bitbake > +# cannot know that the do_swuimage task which evaluates the templated sw-description file needs to be executed > +# if a variable which is refered by the sw-description file but not by the recipe itself. > +def swupdate_find_bitbake_variables(d): > + import re > + > + vardeps = '' > + filespath = d.getVar('FILESPATH') > + sw_desc_path = bb.utils.which(filespath, "sw-description") > + try: > + with open(sw_desc_path, "r") as f: > + content_in = f.read() > + var_re = r"@@([^@].+)@@" I mentioned for V1 that rule does not work. The function itself can still be left in the swupdate-common class, and it could be then also reused, but it is not called automatically. > + m = re.findall(var_re, content_in) > + if m: > + vardeps = ' '.join(m) > + except IOError: > + # Since this runs at parse time where we don't know if this will be used later on we cannot threat this as an error > + bb.debug(1, "Cannot find sw-description. Please extend FILESPATH (%s)" % filespath) > + return vardeps > + > +do_swuimage[vardeps] ?= "${@swupdate_find_bitbake_variables(d)}" > Regards, Stefano
diff --git a/classes/swupdate-image.bbclass b/classes/swupdate-image.bbclass index 618b438..f25f1f0 100644 --- a/classes/swupdate-image.bbclass +++ b/classes/swupdate-image.bbclass @@ -32,3 +32,26 @@ python do_swupdate_copy_swdescription() { do_swupdate_copy_swdescription[nostamp] = "1" addtask swupdate_copy_swdescription before do_image_complete after do_unpack addtask swuimage after do_swupdate_copy_swdescription do_image_complete before do_build + +# Read all variables from sw-description file and add them to the vardeps of the do_swuimage task. Bitbake +# cannot know that the do_swuimage task which evaluates the templated sw-description file needs to be executed +# if a variable which is refered by the sw-description file but not by the recipe itself. +def swupdate_find_bitbake_variables(d): + import re + + vardeps = '' + filespath = d.getVar('FILESPATH') + sw_desc_path = bb.utils.which(filespath, "sw-description") + try: + with open(sw_desc_path, "r") as f: + content_in = f.read() + var_re = r"@@([^@].+)@@" + m = re.findall(var_re, content_in) + if m: + vardeps = ' '.join(m) + except IOError: + # Since this runs at parse time where we don't know if this will be used later on we cannot threat this as an error + bb.debug(1, "Cannot find sw-description. Please extend FILESPATH (%s)" % filespath) + return vardeps + +do_swuimage[vardeps] ?= "${@swupdate_find_bitbake_variables(d)}"