summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse
AgeCommit message (Collapse)Author
2024-04-14bitbake: BBHandler: Handle unclosed functions correctlyRichard Purdie
A function accidentally defined as: somefunction() { : } which is unclosed due to the space at the end, would currently silently cause breakage. Have the parser throw and error for this. [YOCTO #15470] (Bitbake rev: a7dce72da6be626734486808f1b731247697e638) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2024-01-18bitbake: ast/BBHandler: Add inherit_defer supportRichard Purdie
Add support for an inherit_defer statement which works as inherit does but is only evaulated at the end of parsing. This allows conditional expressions to be evaulated 'late' meaning changes to PACKAGECONFIG from bbappends can be applied for example. This addresses a usability/confusion issue users have with the current conditional inherit mechanism since they don't realise the condition has to be expanded immediately with the current model. There is a commented out warning we could enable in future which warns about the use of a conditional inherit that isn't deferred. There is a behaviour difference in the placement of the inherit, particularly around variables set using ?= which means wen swapping from one to the other, caution must be used as values can change. (Bitbake rev: 5c2e840eafeba1f0f754c226b87bfb674f7bea29) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2024-01-10bitbake: ast: Fix EXPORT_FUNCTIONS bugRichard Purdie
If you have two classes, both of which set EXPORT_FUNCTIONS for the same funciton and a standard funciton definition for the function that is exported, the export function can sometimes overwrite the standard one. The issue is that the internal flag the code uses isn't ovweritten if the variable is giving a new value. Fix the issue by using a comment in the code that is injected so that we know if it is ours or not. Also add some testing for EXPORT_FUNCTIONS, not perfect but a start. (Bitbake rev: 66306d5151acb0a26a171c338d8f60eb9eb16c6b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-09-18bitbake: lib: Drop inotify support and replace with mtime checksRichard Purdie
With the flush in serverlog() removed and a memory resident bitbake with a 60s timeout, the following could fail in strange ways: rm bitbake-cookerdaemon.log bitbake-layers add-layer ../meta-virtualization/ bitbake-layers add-layer ../meta-openembedded/meta-oe/ bitbake -m specifically that it might error adding meta-oe with an error related to meta-virt. This clearly shows that whilst bblayers.conf was modified, bitbake was not recognising that. This would fit with the random autobuilder issues seen when the serverlog flush() call was removed. The issue appears to be that you have no way to "sync()" the inotify events with the command stream coming over the socket. There is no way to know if there are changes in the IO queue which bitbake needs to wait for before proceeding with the next command. I did experiment with os.sync() and fsync on the inotify fd, however nothing addressed the issue. Since it is extremely important we have accurate cache data, the only realistic thing to do is to switch to stat() calls and check mtime. For bitbake commands, this is straightforward since we can revalidate the cache upon new connections/commands. For tinfoil this is problematic and we need to introduce and explict command "revalidateCaches" that the code can use to force bitbake to re-check it's cache validity. I've exposed this through tinfoil with a new "modified_files" function. So, this patch: a) drops inotify support within bitbake's cooker/server and switch to using mtime b) requires a new function call in tinfoil when metadata has been modified (Bitbake rev: da3ec3801bdb80180b3f1ac24edb27a698415ff7) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-04-13bitbake: bitbake: ConfHandler: Allow variable flag name with a single characterKai Kang
Update regex pattern to allow variable flag name with a single character. Regression tests have also been updated in `bb.parse` and `bin/bitbake-selftest -k ParseTest` has been successfully executed. Eliminate a trailing space as well. (Bitbake rev: bb9e523291a3cad6e1596ee6a1e715b5e5feba8f) Signed-off-by: Kai Kang <kai.kang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-03-23bitbake: ConfHandler: Allow the '@' character in variable flag namesJames R T
This patch enables the usage of the '@' character in variable flag names. One use case of variable flags is to assign the network namespaces of some systemd services/targets to configure other parts of the build process of some system. The filenames of systemd services/targets might contain the '@' character if they are template unit files that can take in a single parameter/argument and be instanced multiple times, as indicated by systemd's official manual page. The '@' character is disallowed as the first character in a variable flag name. Imposing more restrictions on the first character is a compromise to make parsing easier and to allow for more options in the future to extend the syntax. This patch is successfully verified by creating a custom BitBake recipe that sets and unsets the value of a variable flag with the '@' character in its name and ensuring that no ParseError is being thrown. Regression tests have also been added to `bb.parse`. `bin/bitbake-selftest` has also been successfully executed and all tests passed. (Bitbake rev: 00f9ab2cacfbd2a63b6b4959cf5401babae7e32a) Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-03-22bitbake: fetch2: Add autorev warning when it is set too lateRichard Purdie
Bitbake expects a consistent metadata environment when it parses. There are plenty of ways you can set a recipe to autorev at a point where parts of the fetcher have already been triggered leading to obsure bugs which I struggled to debug, let alone anyone not familar with the code. If anyone is running into the message from the commit, the issue is likely one of timing. Keep in mind that the anonymous python code in base.bbclass will expand variables like FILESPATH, WORKDIR and others which contain PV. The recipe needs to be set to AUTOREV before that anonymous python runs. In particular, that means you can't set SRCREV = "${AUTOREV}" in other anonymous python, it needs to happen earlier. (Bitbake rev: 4d9ec332d5bfc8b60b54f8ec2a17d34e35aa903a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-12-17bitbake: ast/data/codeparser: Add dependencies from python module functionsRichard Purdie
Moving code into python modules is a very effective way to reduce parsing time and overhead in recipes. The downside has always been that any dependency information on which variables those functions access is lost and the hashes can therefore become less reliable. This patch adds parsing of the imported module functions and that dependency information is them injected back into the hash dependency information. Intermodule function references are resolved to the full function call names in our module namespace to ensure interfunction dependencies are correctly handled too. (Bitbake rev: 605c478ce14cdc3c02d6ef6d57146a76d436a83c) (Bitbake rev: 91441e157e495b02db44e19e836afad366ee8924) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-12-08bitbake: parse: Add support for addpylib conf file directive and ↵Richard Purdie
BB_GLOBAL_PYMODULES For many years OE-Core has injected it's own python modules into the python namespace using an immediate expansion of a variable in base.bbclass. It also added all entries from BBPATH to sys.path. We really need this to become a first class citizen of the langauge, this new addpylib directive allows that. Usage is of the form: addpylib <directory> <namespace> The namespace is imported and if there is an attribute BBIMPORT, that list of names is iterated and imported too. This mirrors what OE-Core has done for a long time with one difference in implmentation, sys.path is only appended to. This means later imported namespaces can't overwrite an earlier one and can't overwrite the main python module space. In practice we've never done that and it isn't something we should encourage or support. The new directive is only applied for .conf files and not other filetypes as it only makes sense in that context. It is also only allowed in the "base configuration" context of cookerdata since adding it at the recipe level wouldn't work properly due to the way it changes the global namespace. At the same time, move the list of modules to place in the global namespace into a BB_GLOBAL_PYMODULES variable. It is intended that only the core layer should touch this and it is meant to be a very small list, usually os and sys. BB_GLOBAL_PYMODULES is expected to be set before the first addpylib directive. Layers adding a lib directory will now need to use this directive as BBPATH is not going to be added automatically by OE-Core in future. The directives are immediate operations so it does make modules available sooner than the current OE-Core approach. The new code appends to sys.path rather than prepends as core did, as overwriting python standard library modules would be a bad idea and naturally encouraging people to collaborate around our own core modules is desireable. (Bitbake rev: afb8478d3853f6edf3669b93588314627d617d6b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-11-29bitbake: BBHandler: Remove pointless global variable declarationsRichard Purdie
These are static regex compilations which don't change or a standard module import (bb). There is noneed to declare them as global so drop the pointless code which doesn't do anything. (Bitbake rev: 09a4c159e3fd184f730821e7bd99916b0d28dc70) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-08-12bitbake: BBHandler/cooker: Implement recipe and global classesRichard Purdie
We have some confusion for users since some classes are meant to work in the configuration space (or "globally") and some are meant to be selected by recipes individually. The cleanest way I could find to clarify this is to create "classes-global" and "classes-recipe" directories which contain the approproate classes and have bitbake switch scope between them at the appropriate point during parsing. The existing "classes" directory is always searched as a fallback. Once a class is moved to a specific directory, it will no longer be found in the incorrect context. A good example from OE is that INHERIT += "testimage" will no longer work but IMAGE_CLASSES += "testimage" will, which makes the global scope cleaner by only including it where it is useful and intended to be used (images). (Bitbake rev: f33ce7e742f46635658c400b82558cf822690b5e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-08-12bitbake: BBHandler: Make inherit calls more directlyRichard Purdie
Rather than recursing into the conf handler code, simply call into the parse code directly when inheriting files as we've already resolved the paths and don't need anything the other codepath brings. This makes the codepath clearer at the expense of some slight duplication. (Bitbake rev: 0f4f3af6d93a0018df58b8a1d8d423c78ba6526d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-08-12bitbake: BBHandler: Allow earlier exit for classes not foundRichard Purdie
Rather than relying on later code to error if the class isn't found, exit earlier and more clearly from a code perspective. (Bitbake rev: f7c55c8147329670fd5bc55b1ae3f47f25b89bab) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-07-04bitbake: ConfHandler/BBHandler: Improve comment error messages and add testsRichard Purdie
Currently if you trigger one of the comment errors, the newline characters are stripped and the line numbers are incorrect. In one case it prints the empty line which is also unhelpful. Rework the code around these errors so the line numbers are correct and the lines in question are more clearly displayed complete with newlines so the user can more clearly see the error. I also added a couple of simplistic test cases to ensure that errors are raised by the two known comment format errors. [YOCTO #11904] (Bitbake rev: 712da71b24445c814d79a206ce26188def8fce0a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-06-21bitbake: ConfHandler: Remove lingering closeOla x Nilsson
The f.close() statement should have been removed in 459ad524756a3f9b50feeedf31e33502dceae8d5. (Bitbake rev: 9fc1bab6b7e3c0fca3ddec4bc8c7763d2aff8bab) Signed-off-by: Ola x Nilsson <ola.x.nilsson@axis.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-14bitbake: ast: Improve function flags handling for EXPORT_FUNCTIONSRichard Purdie
Currently, if you use one of the functions from EXPORT_FUNCTIONS, the meaning of cleandirs and fakeroot are lost. This leads to the function changing in behaviour depending upon it's caller context. This isn't intended so add mapping for the cleandirs and fakeroot flags too. This does break devtool in OE-Core and there is a separate fix for that. [YOCTO #8621] (Bitbake rev: b074f4aff00923acc5bf6649d204d541a79fd2b6) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-03bitbake: parse: Ensure any existing siggen is closed down firstRichard Purdie
We're still seeing issues with unclosed asyncio event loops. At the init site, make sure any existing one is closed first to try and avoid this. (Bitbake rev: 78dee3c03c75a27531fcff26f9298fce2519bdde) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-02-21bitbake: lib/bb: fix exit when found renamed variablesMarta Rybczynska
Until now, if a renamed variable was found, bitbake exited immediately if it was in a class, but continued after an error message if the variable was in a recipe. This was caused by cookerdata.py CookerDataBuilder::parseBaseConfiguration checking a different DataSmart instance than the variable was set in. To solve the issue, add a special variable and set it when we find a renamed variable. Check for it in ast.py and bail out if needed. (Bitbake rev: d12400600e30549c88dc9e7883dc3d63b1dc1117) Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-11-15bitbake: cache/ConfHandler: Drop TOPDIR/chdir manipulationsRichard Purdie
This code has been unchanged since 2006 apart from attempts to optimise performance by minimising chdir() calls. There is no reason the modern bitbake parser should be changing directory all the time. We did have some path assumptions in the mists of time but those were resovled and the code is deterministic and doesn't depend on cwd now for parsing. We can therefore drop the changes in directory. Also, TOPDIR is now being set by cookerdata in all cases so we don't need the fallbacks in this code (which was used to effectively initialise a value). We don't need to change TOPDIR when parsing a recipe, that makes no sense. If we stop all the other messing around, we don't need to expand TMPDIR either. These changes have the potential to break some obscure use cases such as an anonymous function assuming the current working directory, or some case which depends on TOPDIR changing but I believe any such uses should be fixed at this point. (Bitbake rev: add5d488e1d6607a98441836075d01cb1dc9c0fa) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-11-10bitbake: parse/ast: Show warnings for append/prepend/remove operators ↵Richard Purdie
combined with +=/.= Operations like XXX:append += "YYY" are almost always wrong and this is a common mistake made in the metadata. Show warnings for these usages with a view to making it a fatal error eventually. (Bitbake rev: 8c31e75557dc6a8d8f407b5d24d6327889a3e3b1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-09-10bitbake: parse_py: Drop deprecated function referenceRichard Purdie
This is now used from bb.parse everywhere so drop this long deprecated reference. (Bitbake rev: aaa5292ef96ea27f505bc5c5a4b1eb4f497ed061) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-08-02bitbake: bitbake: Switch to using new override syntaxRichard Purdie
This change updates the datastore to use the new override syntax using colons instead of underscores exclusively. It is expected layers would have to be converted to work with bitbake after this change. Supporting mixed syntax isn't possible, it is only feasible to have one internal representation of overrides. Whilst we can't warn for every possible override that may be set in the old format, show errors for _append/_prepend/_remove since those should never be present. (Bitbake rev: 7dcf317cc141dc980634f8c18bfa84f83e57206a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-07-29bitbake: parse/ast: Substitute '~' when naming anonymous functionsPaul Barker
When parsing an anonymous python function, bitbake generates a name for the function based on the full path to the file in which it was found. As not all characters which are valid in file paths are valid in Python function names we have a translation table. However, this translation table was missing an entry for '~'. (Bitbake rev: b201c0b284e25c20685d9d206797c4cc650eeca0) Signed-off-by: Paul Barker <paul@pbarker.dev> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-07-20bitbake: data_smart/parse: Allow ':' characters in variable/function namesRichard Purdie
It is becomming increasingly clear we need to find a way to show what is/is not an override in our syntax. We need to do this in a way which is clear to users, readable and in a way we can transition to. The most effective way I've found to this is to use the ":" charater to directly replace "_" where an override is being specified. This includes "append", "prepend" and "remove" which are effectively special override directives. This patch simply adds the character to the parser so bitbake accepts the value but maps it back to "_" internally so there is no behaviour change. This change is simple enough it could potentially be backported to older version of bitbake meaning layers using the new syntax/markup could work with older releases. Even if other no other changes are accepted at this time and we don't backport, it does set us on a path where at some point in future we could require a more explict syntax. I've tested this patch by converting oe-core/meta-yocto to the new syntax for overrides (9000+ changes) and then seeing that builds continue to work with this patch. (Bitbake rev: 0dbbb4547cb2570d2ce607e9a53459df3c0ac284) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-02-16bitbake: event: Prevent bitbake from executing event handler for wrong ↵Tomasz Dziendzielski
multiconfig target When multiconfig is used bitbake might try to run events that don't exist for specific mc target. In cooker.py we pass `self.databuilder.mcdata[mc]` data that contains names of events' handlers per mc target, but fire_class_handlers uses global _handlers variable that is created during parsing of all the targets. This leads to a problem where bitbake runs event handler that don't exist for a target or even overrides them - if multiple targets use event handler with the same name but different code then only one version will be executed for all targets. See [YOCTO #13071] for detailed bug information. Add mc target name as a prefix to event handler name so there won't be two different handlers with the same name. Add internal __BBHANDLERS_MC variable to have the handlers lists per machine. (Bitbake rev: 5f7fdf7b2d8c59805c8ef4dae84f536baa5e172b) Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-02-10bitbake: logging: Make bitbake logger compatible with python loggerJoshua Watt
The bitbake logger overrode the definition of the debug() logging call to include a debug level, but this causes problems with code that may be using standard python logging, since the extra argument is interpreted differently. Instead, change the bitbake loggers debug() call to match the python logger call and add a debug2() and debug3() API to replace calls that were logging to a different debug level. [RP: Small fix to ensure bb.debug calls bbdebug()] (Bitbake rev: f68682a79d83e6399eb403f30a1f113516575f51) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-02-10bitbake: BBHandler: Don't classify shell functions that names start with ↵Tomasz Dziendzielski
"python*" as python function If shell function name starts with 'python' or 'fakeroot' parser wrongly assumes it's python/fakeroot function. [YOCTO #14204] Use regex lookahead assertions to check if 'python' expression is followed by whitespace or '(' and if 'fakeroot' is followed by whitespace. (Bitbake rev: b07b226d5d1b3acd3f76d8365bc8002293365999) Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-11-08bitbake: BBHandler: prompt error when task name contain expressionLee Chee Yang
Task name contain expresion (eg, do_foo_remove_bar) can cause fatal error. Check for naming before addtask. Prompt with understandable error message when expression found in task name. [YOCTO #8805] (Bitbake rev: 5b4a5bb0960386f9c524c220e43a16e60e38964d) Signed-off-by: Lee Chee Yang <chee.yang.lee@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-07-21bitbake: build: Allow deltask to take multiple tasknamesRichard Purdie
deltask currently supports only one task to delete but it would be useful if it could support a variable which gets expanded to allow flexibility in the metadata. This is simple to support in bitbake and is how other directives such as inherit operate so adjust the parser/code to handle that. It means that syntax like: EXTRA_NOPACKAGE_DELTASKS = "" deltask ${EXTRA_NOPACKAGE_DELTASKS} is now allowed. (Bitbake rev: 883d926120833c85a16dcf60425dd7af7699046a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-05-27bitbake: event/ast: Add RecipePostKeyExpansion eventRichard Purdie
(Bitbake rev: 5c30cbe35e921f118e7da6b804af281627329d77) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-19bitbake: lib: amend code to use proper singleton comparisons where possibleFrazer Clews
amend the code to handle singleton comparisons properly so it only checks if they only refer to the same object or not, and not bother comparing the values. (Bitbake rev: b809a6812aa15a8a9af97bc382cc4b19571e6bfc) Signed-off-by: Frazer Clews <frazer.clews@codethink.co.uk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2020-01-19bitbake: lib: remove unused importsFrazer Clews
removed unused imports which made the code harder to read, and slightly but less efficient (Bitbake rev: 4367692a932ac135c5aa4f9f2a4e4f0150f76697) Signed-off-by: Frazer Clews <frazer.clews@codethink.co.uk> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-10-28bitbake: bitbake: ConfHandler: Use with to manage filehandle lifetimeOla x Nilsson
(Bitbake rev: 459ad524756a3f9b50feeedf31e33502dceae8d5) Signed-off-by: Ola x Nilsson <olani@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-06-28bitbake: bitbake: lib: Cleanup /usr/bin/env pythonRobert Yang
(Bitbake rev: cc712f3257904960247a7532cfc4611f3dccd36c) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-04bitbake: bitbake: Strip old editor directives from file headersRichard Purdie
There are much better ways to handle this and most editors shouldn't need this in modern times, drop the noise from the files. Its not consitently applied anyway. (Bitbake rev: 5e43070e3087d09aea2f459b033d035c5ef747d0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-04bitbake: bitbake: Drop duplicate license boilerplace textRichard Purdie
With the introduction of SPDX-License-Identifier headers, we don't need a ton of header boilerplate in every file. Simplify the files and rely on the top level for the full licence text. (Bitbake rev: 695d84397b68cc003186e22f395caa378b06bc75) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-04bitbake: bitbake: Add initial pass of SPDX license headers to source codeRichard Purdie
This adds the SPDX-License-Identifier license headers to the majority of our source files to make it clearer exactly which license files are under. The bulk of the files are under GPL v2.0 with one found to be under V2.0 or later, some under MIT and some have dual license. There are some files which are potentially harder to classify where we've imported upstream code and those can be handled specifically in later commits. The COPYING file is replaced with LICENSE.X files which contain the full license texts. (Bitbake rev: ff237c33337f4da2ca06c3a2c49699bc26608a6b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-04-30bitbake: BBHandler: Fix addtask and deltaskRobert Yang
The following commands are not supported, but they were ignored silently, that may suprise users: * addtask task1 task2 task2 is ignored * addtask task1 before task2 before task3 Should be: addtask task1 before task2 task3 * addtask task1 after task2 after task3 Should be: addtask task1 after task2 task3 * deltask task1 task2 task2 is ignore This patch can check and warn for them. [YOCTO #13282] (Bitbake rev: 675689aa7cc7287efecf8ef775ca2059369167f1) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-02-06bitbake: bitbake: ConfHandler: Don't strip leading spacesRobert Yang
Fixed: - Add the following lines to conf/local.conf: FOO = "BAR1" FOO_append = "\ BAR2" $ bitbake -e | grep '^FOO' FOO="BAR1BAR2" The leading spaces in the second line have been removed. - But if add the previous two lines to base.bbclass: $ bitbake -e | grep '^FOO' FOO="BAR1 BAR2" The leading spaces in the second line are preserved, this is inconsistent, now fix ConfHandler to preserve leading spaces. [YOCTO #12380] (Bitbake rev: 8c3bc15a7b5e0a81d7b6c9d3fe43fbff63207156) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-01-16bitbake: bitbake: Fix Deprecated warnings from regexsRichard Purdie
Fix handling of escape characters in regexs and hence fix python Deprecation warnings which will be problematic in python 3.8. (Bitbake rev: c1fcc46e2498ddd41425d8756754f814d682aba3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-05bitbake: bitbake: BBHandler: Check tab indentation for python codeRobert Yang
The previous check was in data.py which only can check code like "python funcname()" in the dependency chain, but there are 3 kinds of python functions: - python() - def py_funcname() - python funcname() Add the checking to BBHandler to check and warn for all of them. The warning looks like: WARNING: /path/to/recipes-core/busybox/busybox_1.29.2.bb: python should use 4 spaces indentation, but found tabs in busybox.inc, line 75 (Bitbake rev: 0cdc5b81fc1f5e5281a525a657e420ebc3bb9e90) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-19bitbake: BBHandler: Fix __python_func_regexp__ for comment linesRobert Yang
Fixed: - Add a comment in base.bbclass: def oe_import(d): import sys # Comment bbpath = d.getVar("BBPATH").split(":") [snip] Note, '# Comment' is started with '#', it is legal in python's syntax (though maybe not a good style), but bitbake reported errors: $ bitbake -p ERROR: ParseError at /path/to/base.bbclass:20: unparsed line: ' bbpath = d.getVar("BBPATH").split(":")' This error report would mislead people, the real problem is that '# Comment' is not supported, but it reports the next line, this may make it hard to debug the code are complicated. We can make __python_func_regexp__ handle '^#' to fix the problem, since it already can handle blank line "^$" in a python function, so it would be pretty safe to handle "^#" as well. (Bitbake rev: 79e62eef1c93f742bf71e9f25db57fdd2ffedd02) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-19bitbake: parse/ast: fix line number for anonymous functionRobert Yang
Fixed: - Define an error anonymous function in base.bbclass: 15 16 python() { 17 Compile error 18 } $ bitbake -p ERROR: Error in compiling python function in /buildarea1/lyang1/poky/meta/classes/base.bbclass, line 18: The code lines resulting in this error were: 0001:def __anon_18__buildarea1_lyang1_poky_meta_classes_base_bbclass(d): *** 0002: Compile error 0003: SyntaxError: invalid syntax (base.bbclass, line 18) The lineno should be 17, but it reported 18, this would mislead people a lot when there more lines. - Now fix it to: ERROR: Error in compiling python function in /buildarea1/lyang1/poky/meta/classes/base.bbclass, line 17: The code lines resulting in this error were: 0001:def __anon_18__buildarea1_lyang1_poky_meta_classes_base_bbclass(d): *** 0002: Compile error 0003: SyntaxError: invalid syntax (base.bbclass, line 17) This is because the anonymous function is constructed by: text = "def %s(d):\n" % (funcname) + text The len(self.body) doesn't include the "def " line, the length of the function should be "len(self.body) + 1", so we need pass "self.lineno - (len(self.body) + 1)" which is the same as 'self.lineno - len(self.body) - 1' to bb.methodpool.insert_method() as we already had done to named function. Otherwise, the lineno is wrong, and would cause other problems such as report which line is wrong, but the line is not what we want since it reports incorrect line. (Bitbake rev: 7466c8765fcc792e5ea3daefda3c5895e782d6c4) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-08-24bitbake: parse/ast: ensure saved event handlers really do get restoredPaul Eggleton
In finalize() we save event handlers, register the ones relevant to the recipe being finalised, trigger events, and then restore the handlers so that one recipe's custom handlers (actually implemented within a class inherited by the recipe) do not affect other recipes. However, if an exception occurs during parsing, the saved handlers were not being restored. Use a try...finally block to ensure that the handlers are always restored. This issue became apparent since in OpenEmbedded-Core we have recently introduced a find_intercepts() handler for the bb.event.RecipePreFinalise event in image-postinst-intercepts.bbclass that images and old-style SDK recipes will end up inheriting. So far it doesn't seem that the the error has manifested itself in normal builds, but when parsing OE-Core recipes in the OE layer index it has: core-image-rt-* image recipes were parsed which in the default configuration raise SkipRecipe. The next non-image recipe that is parsed will trigger a real exception, because the find_intercepts() handler is still registered and gets fired, but in the context of the new recipe the POSTINST_INTERCEPTS_PATHS variable is not set, and the code in find_intercepts() is written with the reasonable assumption that that isn't possible given that the class itself sets a default, and thus it fails. (Bitbake rev: e5f1f8fa201774e0c3c554d59b277baa2128708f) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-03-04bitbake: parse/ast: Abstract anonymous function execution into a functionRichard Purdie
This allows us to call this code from other contexts without duplicating it. (Bitbake rev: c6be487f9bd5d95915f2495d555b9f539adb1d44) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-02-14bitbake: bitbake: parse: fixes for resolve_file()Robert Yang
The resolve_file() calls mark_dependency(), so the one which calls resolve_file() doesn't need call mark_dependency() again. (Bitbake rev: 4682571107323a39b42cd9ec8ee67419e7f15acc) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-08-13bitbake: cooker: Improve inotify overflow handlingRichard Purdie
Add a proper function for clearing the mtime cache. Clean up the inotify event overflow case to err on the side of caution and clear any potentially now out of sync caches. (Bitbake rev: ec60459fe2ba16966544eebff43b061abb7ed3ba) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-07-08bitbake: BBHandler: Remove old style bb.data.setVar() syntax usageEnrico Scholz
Fixes except bb.parse.SkipRecipe: > bb.data.setVar("__SKIPPED", True, d) if include == 0: AttributeError: module 'bb.data' has no attribute 'setVar' (Bitbake rev: d43e97226dc7f53592c06a528f20390b68dc854f) Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-13bitbake: ConfHandler.py: allow require or include with multiple parametersPatrick Ohly
"inherit" already allows inheriting more than one class in a single statement. The same also makes sense for "include" and "require", because then one can generate a list of files to be included dynamically also for the case that more than one file needs to be included. (Bitbake rev: 8d0a76f5a595dddf16b7268bae2c00ef5f568316) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-13bitbake: ConfHandler.py: allow require or include without parameterPatrick Ohly
Writing .bbappends that only have an effect when some configuration variable like DISTRO_FEATURES is changed becomes easier when allowing "include" or "require" without a parameter. The same was already allowed for "inherit". Then one can write in a .bbappend: require ${@bb.utils.contains('DISTRO_FEATURES', 'foo', 'bar.inc', '', d)} (Bitbake rev: 8b39c6361758b96fce50a53a6dba8008cd7e6433) Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>