aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/parse/parse_py/BBHandler.py
AgeCommit message (Collapse)Author
2019-06-19bitbake: 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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com>
2019-06-19bitbake: 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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com>
2019-01-14bitbake: 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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-12-01bitbake: 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 Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-11-16BBHandler: 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. Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-02-09bitbake: 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. Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-07-07BBHandler: 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' Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-12-16BBHandler: use with instead of open/closeRoss Burton
This is more pythonic and can handle unclosed file warnings better than the previous code structure. Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-11-30bitbake: remove True option to getVar callsJoshua Lock
getVar() now defaults to expanding by default, thus remove the True option from getVar() calls with a regex search and replace. Search made with the following regex: getVar ?\(( ?[^,()]*), True\) Signed-off-by: Joshua Lock <joshua.g.lock@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-24bitbake: Drop futures usage since we're python 3Richard Purdie
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-10BBHandler/ast: Merge handMethod and handleMethodFlagsRichard Purdie
The functionality overlap between these two functions is significant and its clearer to handle both things together since they are intimately linked. There should be no behaviour change, just clearer code. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-12-22BBHandler: Improve IN_PYTHON_EOF handlingRichard Purdie
Now we're actively using the line numbers for other thins, having magic values like IN_PYTHON_EOF causes problems, in particular, 32 bit overflow on 32 bit machines. There is a neater way to signal eof to feeder(), just using an extra parameter so use this instead and drop the IN_PYTHON_EOF magic values. This has the added bonus that line numbers are then correct for python functions at the end of files. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-06-19bitbake: Add explict getVar param for (non) expansionRichard Purdie
Rather than just use d.getVar(X), use the more explict d.getVar(X, False) since at some point in the future, having the default of expansion would be nice. This is the first step towards that. This patch was mostly made using the command: sed -e 's:\(getVar([^,()]*\)\s*):\1, False):g' -i `grep -ril getVar *` Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-06-05parse/BBHandler: Avoid repeatedly resetting FILERichard Purdie
If we're not going to change the value of FILE, or we know it isn't going to have changed (ext == bbclass), don't set FILE. This avoids messy looking history of the variable as well as optimises parsing speed slightly. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-05-29BBHandler: Drop cwd from search pathRichard Purdie
Whilst bitbake has done this for a long time, the behaviour of resolving class files against cwd is not desirable. This can be seen during base configuration parsing when looking for base.bbclass where a dependency on cwd is added. If cwd then changes, the cache is invalid and triggers a re-parse. The only real option is to drop this entry and if files can't be found, we fix BBPATH in the cases where it needs fixing. I didn't find any in the random selection of layers I tested parsing locally. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-05-14BBHandler: Error for incomplete function definitionsRichard Purdie
Add some sanity checks on the parsing state engine when returning data so that incomplete functions raise parse errors. This means a recipe doing: do_somefunction { echo 1 VAR = "1" will now raise a ParseError. To get the right file/line information, __infunc__ was changed to a list. [YOCTO #7633] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-05-30event: Add SkipRecipe event to replace SkipPackageRichard Purdie
In the depths of time we were rather confused about naming. bb files are recipes, the event to skip parsing them should be SkipRecipe, not SkipPackage. This changes bitbake to use the better name but leaves the other around for now. We can therefore start removing references to it from the metadata. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-05-11parse: Improve file inheritance loggingRichard Purdie
The file inheritance logging has been here since the dawn of time. It duplicates output many times over and logs to debug level 2. When running with the debug option, its understandable the user may want to see the paths of files included in the build. These changes remove pointless/duplicate output and print the include paths clearly at debug level one in a form which users should be able to more easily parse. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-12-18ast/BBHandler/build: Add support for removing tasks (deltask)Richard Purdie
Back in the depths of time we did support task removal. In the pre AST days it was nearly impossible to continue supporting it, it wasn't used so it was dropped. With the modern codebase we can easily now support deltask and it would be very useful within the metadata since it can massively simplify dependency trees. As an example, a core-image-sato had 47703 inter task dependencies before this patch and a patch to native.bbclass, afterwards with the noexec tasks deleted, we had 29883. Such a significant simplification is worthwhile and justifies adding a deltask operation to the system. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-11-29parse/ConfHander/BBHandler/utils: Fix cache dependency bugsRichard Purdie
Currently bitbake only adds files to its dependency list if they exist. If you add 'include foo.inc' to your recipe and the file doesn't exist, then later you add the file, the cache will not be invalidated. This leads to another bug which is that if files don't exist and then you add them and they should be found first due to BBPATH, again the cache won't invalidate. This patch adds in tracking of files we check for the existence of so that if they are added later, the cache correctly invalidates. This necessitated a new version of bb.utils.which which returns a list of files tested for. The patch also adds in checks for duplicate file includes and for now prints a warning about this. That will likely become a fatal error at some point since its never usually desired to include a file twice. The same issue is also fixed for class inheritance. Now when a class is added which would be found in the usual search path, it will cause the cache to be invalidated. Unfortunately this is old code in bitbake and the patch isn't the neatest since we have to work within that framework. [YOCTO #5611] [YOCTO #4425] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-23methodpool: Retire it, remove global method scopeRichard Purdie
Having a global method scope confuses users and with the introduction of parallel parsing, its not even possible to correctly detect conflicting functions. Rather than try and fix that, its simpler to retire the global method scope and restrict functions to those locations they're defined within. This is more what users actually expect too. If we remove the global function scope, the need for methodpool is reduced to the point we may as well retire it. There is some small loss of caching of parsed functions but timing measurements so the impact to be neglibile in the overall parsing time. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-09lib: Clean up various file access syntaxRichard Purdie
Python 3 is stricter about how files are accessed. Specficially: * Use open(), not file() * Use binary mode for binary files (when checksumming) * Use with statements to ensure files get closed * Add missing file close statements Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-21BBHandler/ConfHandler: Merge fix for multiline commentsRichard Purdie
This was meant to be squashed into the previous commit for multiline comment handling. It fixes the case the commented multiline is followed by an empty line which was resulting in a traceback instead of a sane error message. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-21bitbake: BBHandler/ConfHandler: Improve multiline comment handlingRichard Purdie
Faced with an expression like: # Some comment \ FOO = "bar" what should bitbake do? Technically, the \ character means its multiline and currently the code treats this as a continuation of the comment. This can surprise some people and is not intuitive. This patch makes bitbake simply error and asks the user to be clearer about what they mean. (Bitbake rev: 589d31ce41e019ee6a7cb6527d67bc76c0b6382a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18BBHandler/data: Standardise some setVar access formatsRichard Purdie
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-12-14data_smart/BBHandler: Fix SkipParse exception handlingRichard Purdie
If SkipParse is raised from something which isn't anonymous python, it wasn't being handled correctly. This improves the handling for example from within inline python. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-12-11BBhandler/data: Fix __inherit_cache duplicationRichard Purdie
The inherits cache contains duplicate entries, some with the full patch, some just starting classes/xxx. This is a waste of parse time and potentially error prone. This patch fixes various pieces of code so the absolute paths are always preferred and work correctly. The inherits_class function did not work with full paths so the patch fixes this. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-12-11BBHandler/ast: Simplify/fix EXPORT_FUNCTIONS usageRichard Purdie
The current usage of EXPORT_FUNCTIONS is rather problematic since a class list (classes) is passed into the ast statement and cached as it was when first parsed. This class list may be different in other cases but is locked once in the cache. Worse, the construction of classes can be broken by exceptions during parsing at the wrong moments since the state of the parser is not always reset correctly. This can lead to leakage of other classes into the classes list. The current EXPORT_FUNCTIONS implementation looks at the last two currently inherited classes and sets up an indirect function call view the second last class inherited, e.g.: do_configure calls gnomebase_do_configure gnomebase_do_configure calls autotools_do_configure This intermediary doesn't seem to serve a useful purpose. This patch therefore makes builds deterministic and fixes various cache problems and indirection by removing the intermediaries and simply performing directly mapping for the cases where its needed. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-12-07Revert "BBHandler: Ensure parser state engine is correctly reset for new ↵Richard Purdie
parsing" This reverts commit 3dc5e896a97154914cee6c47900e3bb2a2627cdb.
2012-12-07BBHandler: Ensure parser state engine is correctly reset for new parsingRichard Purdie
The classes variable in particular could be in an odd state if parsing of a previous recipe had abruptly ended. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-08-23methodpool: Clean up the parsed module list handling to be slightly less insaneRichard Purdie
This removes some dubious functions and replaces them with a simpler, cleaner API which better describes what the code is doing. Unused code/variables are removed and comments tweaked. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-05-24BBHandler: Tweak some data store access methods to the preferred syntaxRichard Purdie
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-03-15parse/ast: Expand inherit statements before splitting themRichard Purdie
This means that statements that expand to more then one entry such as: CLASSES = "a b" inherit ${CLASSES} work correctly instead of trying to inherit a class called "a b". Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-02-23bitbake: add file and line number to ParseErrorPaul Eggleton
Ensure that a file and line number are reported for ParseError where possible. This helps particularly in the case of inherit and require which previously did not report either of these upon failure. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-27Update users of getVar/setVar to use the data store functions directlyRichard Purdie
(From Poky rev: affd0907253387cee0ba0c7e9f92bcc109895446) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-11-18parse_py: Use absolute paths for FILERichard Purdie
Its possible for relative paths to creep into FILE. These confuse the build system no end as its not clear where they might be releative to. This patch ensures we always use resolved absolute paths for FILE so that things behave in a deterministic way. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-08-31bitbake: Correctly handle multiline comments including whitespaceRichard Purdie
If metadata contains: """ FOO = "bar" """ The variable FOO should get set to "bar" but doesn't due to the empty lines be swallowed by the parser and FOO becomming part of the multiline comment. This patch corrects that behaviour so FOO is set as expected. [YOCTO #1377] This patch fixes parsing of multiline comments so lines ending with \ behave consistently and we warn users where there is something happening they likely don't expect. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-02-10BBHandler: remove bb.fetch referrenceYu Ke
BBHandler.py no longer use bb.fetch, so remove its import statement (From Poky rev: 9e3a92c04a5be4932a0324af4a74bce871126e9d) Signed-off-by: Yu Ke <ke.yu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-01-07Merge branch 'poky-sync'Chris Larson
* poky-sync: build: kill unneeded environment setup bits parse: save python functions into the metadata Include exported variables in task process env runqueue: start implementing quieterrors Overhaul environment handling runqueue: resurrect use of file objects for pipein/pipeout runqueue: clean up message log levels runqueue: use correct task ID when checking validity of setscene tasks Add support for 'noexec' tasks runqueue: implement cache checking from metadata runqueue: pass task hash information to tasks runqueue: avoid unnecessary delays Implement task signatures data: Add emit_func and generate_dependencies codeparser: Implement persistent cache data_smart: track variable references codeparser: add module for parsing shell/python runqueue: implement scenequeue fetch: add SRC_URI checksum Signed-off-by: Chris Larson <chris_larson@mentor.com>
2011-01-05parse: pass filename, lineno into the astChris Larson
We will be needing this information to improve the tracebacks of python code from the metadata, as well as to give the user information about where variables were defined, so they know how it ended up the way it is. Signed-off-by: Chris Larson <chris_larson@mentor.com>
2011-01-04BBHandler: use basename directly in handler()Bernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-12-30parse: save python functions into the metadataRichard Purdie
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
2010-11-15BBHandler: use os.path in inherit()Bernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-11-15BBHandler: simplify supports()Bernhard Reutner-Fischer
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-09-03Switch bitbake internals to use logging directly rather than bb.msgChris Larson
We use a custom Logger subclass for our loggers This logger provides: - 'debug' method which accepts a debug level - 'plain' method which bypasses log formatting - 'verbose' method which is more detail than info, but less than debug Signed-off-by: Chris Larson <chris_larson@mentor.com>
2010-06-213.0 prepChris Larson
2010-06-09parser: fix harmless typo in variable nameBernhard Reutner-Fischer
s/absolsute/absolute/ Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2010-04-20Don't try to expand non-string valuesChris Larson
Signed-off-by: Chris Larson <chris_larson@mentor.com>
2010-04-11Apply some 2to3 transforms that don't cause issues in 2.6Chris Larson
Signed-off-by: Chris Larson <chris_larson@mentor.com>
2010-04-09Deprecate the usage of certain objects via certain modulesChris Larson
As an example, this displays a deprecation warning for the use of "bb.encodeurl" when you should be using "bb.fetch.encodeurl". It includes a convenience function for this purpose. It should be of use when moving objects between modules permanently, changing the API the user sees. Signed-off-by: Chris Larson <chris_larson@mentor.com>