summaryrefslogtreecommitdiffstats
path: root/lib/bb/data.py
AgeCommit message (Collapse)Author
2016-11-30bitbake: remove True option to getVarFlag callsJoshua Lock
getVarFlag() now defaults to expanding by default, thus remove the True option from getVarFlag() calls with a regex search and replace. Search made with the following regex: getVarFlag ?\(( ?[^,()]*, ?[^,()]*), True\) Signed-off-by: Joshua Lock <joshua.g.lock@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-11-23data: Drop deprecated old style bitbake APIRichard Purdie
The old style bb.data.getVar/setVar API has long since been deprecated in favour of d.getVar/setVar and friends. Now we're about to change the default expansion parameter, drop the old APIs to simplify the transition and ensure everyone is using the new style functions. Conversion is trivial if there are remaining stragglers. I've left bb.data.expand() for now since its more widely used but would make a good follow up patch series. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-11-04data: fix exception handling in exported_vars()Markus Lehtonen
Fix a bug where a totally wrong value of a variable would be exported if an exception happened during d.getVar(). Also, print a warning if an exception happends instead of silently ignoring it. It would probably be best just to raise the exception, instead, but use the warning for now in order to avoid breaking existing builds. [YOCTO #10393] Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-09-30data: Fix handling of vardepvalueexcludeRichard Purdie
The value used for exclusion was always being expanded. This is actually a bad idea since in most cases you'd want to exclude an unexpanded value and makes it impossible to use the variable as intended. This adjusts things so the value is not expanded and we can correctly remove things from checksums much more easily. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-17Implement support for per-task exportsChristopher Larson
Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-09bitbake: Update logger.warn() -> logger.warning()Richard Purdie
python deprecated logger.warn() in favour of logger.warning(). This is only used in bitbake code so we may as well just translate everything to avoid warnings under python 3. Its safe for python 2.7. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-05-06bb.{cooker, data}: only emit a var as python if 'func' is setChristopher Larson
This avoids a common issue where PACKAGECONFIG is emitted as a function in bitbake -e when the 'python' flag exists. It isn't a python function unless both 'func' and 'python' are set. This aligns with the behavior of emit_func_python. Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-10build/data: Don't expand python functions before execution [API change]Richard Purdie
Right now, if you have some python code like: X = "a" def somefunction(d): d.setVar("X", "b") d.setVar("Y", "${X}") then any sane person would expect that Y = "b" at the end of the function. This is not the case, Y = "a". This is due to the python function being expanded before execution, the executed code would read d.setVar("Y", "a"). This understandably confuses people, it also makes it near impossible to write ${} in a python function without unintended things happening. I think there is general agreement we should fix this and standardise on non-expansion of python functions. We already don't expand anonymous python (mostly). I've checked OE-Core with buildhistory before and after this change and there were a small number of issues this exposed which I've sent patches for. I propose we default to not expanding python code and then deal with any consequences from that if/as/where identified. This will improve new user understanding and usability of the system, it also allows several long standing weird expansion issues to be fixed. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-10data: Don't expand python functions for variable dependenciesRichard Purdie
Expanding python functions for variable dependencies doesn't really make sense, not least since this causes execution of any inline python, it also makes it impossible to write expressions like d.expand("${X}") of d.setVar("X", "${Y}") which may have the wrong values if expanded now. This starts to standardise the approach across bitbake for handling python code. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-02-04lib/bb: Add expansion parameter to getVarFlagRichard Purdie
This sets the scene for removing the default False for expansion from getVarFlag. This would later allow True to become the expand default. On the most part this is an automatic translation with: sed -e 's:\(\.getVarFlag([^,()]*, [^,()]*\)):\1, False):g' -i `grep -ril getVar *` There should be no functional change from this patch. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-29data.py: avoid double newlines at the end of functions in emit_var()Andre McCurdy
A newline is always appended to the function body when it's written out, so strip any trailing newlines which may be there already. Signed-off-by: Andre McCurdy <armccurdy@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-05data: Drop misleading ExpansionError exceptionRichard Purdie
This codepath can be triggered by a python indentation error for example. Showing it as an ExpansionError is misleading. Change the code to add a warning about where the failure came from (in particular giving the variable key name that triggered it) but raise the proper exception. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-01-05data: Pass lineno/filename data from build_dependenciesRichard Purdie
If parse_python() fails, the output is confusing. Passing in the extra file/line data isn't expensive and improves readability significantly. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-24data_smart: Improve override history loggingRichard Purdie
Calling record() for each override alteration is slow. Since we now expand overrides dynamically we don't have to record the log data at each alteration, we can instead print it directly from the existing data stores at variable history print time using the exact same data stores. This massively improves performance of the data store when parsing with bitbake -e for example, it will improve memory overhead as well. The only downside is that VariableHistory has to poke into the datastore for some of its data but that seems an acceptable tradeoff rather than double caching. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-24data: Clean up datastore accesses and True/False valuesRichard Purdie
We should use the d.xxxVar syntax rather than the older function style. Also replace 0/1 with the more pythonic True/False. No functionality changes. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-23data: Add newline after the last export in emit_funcAndre McCurdy
Minor formatting improvement in generated shell scripts. Add a newline after the last export emitted by emit_func. Also, remove chance of putting an extra newline in the middle of the exports, since we never want to do that. Signed-off-by: Andre McCurdy <armccurdy@gmail.com> 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-05-29data: Make expandKeys deterministicRichard Purdie
At least in theory, the order the keys are expanded in can make a difference, particularly if there is key overlap. We also want to ensure that any underlying base key is processed before any overridden version of that variable (FOO before FOO_x) which helps the update_data removal code I've been testing. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-05-26data: Revert expandKeys warning moveRichard Purdie
This was incorrect, it *must* be done next to the rename as a previous may overlap with the current one and we need to detect this case. I'll add a test case to better catch this problem in future. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-05-26data: Clean up expandKeys None value handlingRichard Purdie
This comparison is interesting even in the case of empty vales. Enabling this warning actually found a bug in the metadata in avahi. Make the code handle None specifically and also remove the dead code path in the second if statement. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-05-25data: Move warning code to the first loop for performanceRichard Purdie
By doing this we can take advantage of the expansion cache before starting write operations on the data store. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-12-18data: escape '$' in shell variable assignmentRichard Tollerton
Running bitbake inside make results in the exported environment variable MAKEOVERRIDES="${-*-command-variables-*-}", which the shell chokes on when trying to expand it. But of course, it probably shouldn't have been trying to expand it in the first place -- so just escape the dollar sign. Signed-off-by: Richard Tollerton <rich.tollerton@ni.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-12-09data: Handle BASH_FUNC shellshock implicationRichard Purdie
The shellshock patches changed the way bash functions are exported. Unfortunately different distros used slightly different formats, Fedora went with BASH_FUNC_XXX()=() { echo foo; } and Ubuntu went with BASH_FUNC_foo%%=() { echo foo; }. The former causes errors in dealing with out output from emit_env, the functions are not exported in either case any more. This patch handles things so the functions work as expected in either case. [YOCTO #6880] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-08-27build/data: Write out more complete python run filesRichard Purdie
Currently the output in the python task/function run files is rather incomplete and effectively useless. This enhances the code to take advantage of the bitbake's dependency tracking and extend the output to include dependencies. This makes the files more usable for debugging purposes. Since this only happens at python function execution time, the overhead is minimal in the grand scheme of things. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-08-24lib/bb/*.py: Typo fixes/grammar/comment fixes, nothing functional.Robert P. J. Day
Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-03-06data: add vardepvalueexclude varflagPaul Eggleton
On rare occasions it's useful to be able to exclude a part of a variable's value from the variable's signature; for example if you want to add an item to a list sometimes and not have the signature of the variable change depending on whether the item is in the list or not. The initial intended use case for this in OpenEmbedded is to allow adding a function to SSTATEPOSTINSTFUNCS in buildhistory.bbclass and not have that change any task signatures (so adding and removing INHERIT += "buildhistory" won't lead to any rebuilds). Part of the fix for [YOCTO #5897]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-02-04data: Account for pre/postfunc functions when calculating dependenciesRichard Purdie
pre/postfuncs were not being added to checksums. This meant that when reconfiguration occurred, tasks were not always being rerun when they should. This include sstate functions as well as systemd's do_install function in the OE metadata. With the addition of postfuncs, its possible a shell task can have a python pre/postfunc so we have to guard against this when generating shell output in emit_func. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-12-09data: Ensure we add the contains keys in a particular orderRichard Purdie
If we don't sort the data, the values can reorder changing the signatures meaning we get confused builds and significant cache misses. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-11-26data/codeparser: Improve handling of contains functionsRichard Purdie
One of the current frustrations with the sstate checksums is that code like base_contains('X', 'y',...) adds a full dependency on X and varies depend even on whitespace changes in X. This patch adds special handling of the contains functions to expand the first parameter and check for the flag specified by the second parameter (assuming its a string). The result is then appended to the value of the variable with a "Set" or "Unset" status. If the flag is added/removed, the stored variable value changes and hence the checksum changes. No dependency on X is added so it is free to change with regard to other flags or whitespace. This code is far from ideal, ideally we'd have properly typed variables however it fixes a major annoyance of the current checksums and is of enough value its worth adding in a stopgap solution. It shouldn't significantly restrict any propely typed variable implementation in future. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-11-24data: Fix output inconsistencies for emit_varRichard Purdie
VAL = "" (not shown) VAL = " " (shown as "") VAL = " x" (shown as "x") would all show up rather differently to what would be expected in the bitbake -e output. This fixes things so they appear consistently. The output for running some shell functions may also change slightly but shouldn't change in a way that is likely to cause problems. [YOCTO #5507] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-17data: Optimise flag exclusion list handlingRichard Purdie
Move the variable lookup to the outer loop for performance, replacing a now unneeded parameter (after the previous changes). Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-17data: Optimise flag lookup in build_dependenciesRichard Purdie
When looking up flag variable dependencies, large chunks of the function aren't needed. Optimise the function flow accordingly for speed. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-17data: Optimise build_dependencies a littleRichard Purdie
Instead of multiple calls to getVarFlag, make one call to getVarFlags, only expanding the flags that need to be expanded. This improves performance. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-17data: Cache an list of export variablesRichard Purdie
Compute a cache of the list of potential export variables so that we don't have to compute the list from scratch. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-17data: Use direct iteration, not keys()Richard Purdie
Profiling shows the creation of keys() has overhead and we're better using an iterator rather than the memory associated with the huge list of keys when iterating the whoe datastore. We minimise the number of times we do this to twice only per recipe. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-17data: Be explicit in data_db checkRichard Purdie
The if statement current causes the size of parent to be calcuated which is like a len() operation on a datastore. Since we're only interested whether the value is none, checking explictly for this gives a small performance gain. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-06hob & bitbake: append a value to a variable from hob throught bitbakeCristiana Voicu
It was necessary to append ${TOPDIR}/recipes/images to BBFILES. Implemented the mechanism to append a value to a variable: a command and the method in cooker. [YOCTO #4193] Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-05-20data: Ensure dependencies of subfunctions are accounted forRichard Purdie
Currently we account of the top level function's vardeps but not those of any subfunction. This would imply we'd have to manually write the dependencies of all parent functions which would be crazy. This patch adds the dependencies to fix the issue. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-04-15data: fix performance regressionPaul Eggleton
BitBake commit 7c568132c54a21161de28907159f902462f1e2bb resulted in a fairly serious performance regression during parsing, almost doubling the time taken to do a full parse and almost certainly impacting performance during building. The expandKeys function is called frequently, and if we avoid using keys() and instead just use the normal variable lookup mechanism, performance is restored. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-04-10data.py: Add a warning when expandKeys overwrites an existing keyMark Hatle
When two variables are defined as: ${var} = "bar" foo = "foobar" The value of 'foo' when ${var} == foo becomes indeterminate. We want to warn a user when this situation has been encountered so they can take corrective actions. In the above example usually foo == bar, unless multilibs are enabled. Then ml-foo = "ml-foobar". Signed-off-by: Mark Hatle <mark.hatle@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-01-18bitbake: data_smart.py and friends: Track variable historyPeter Seebach
This patch adds tracking of the history of variable assignments. The changes are predominantly localized to data_smart.py and parse/ast.py. cooker.py and data.py are altered to display the recorded data, and turn tracking on for the bitbake -e case. The data.py update_data() function warns DataSmart.finalize() to report the caller one further back up the tree. In general, d.setVar() does what it used to do. Optionally, arguments describing an operation may be appended; if none are present, the operation is implicitly ignored. If it's not ignored, it will attempt to infer missing information (name of variable, value assigned, file and line) by examining the traceback. This slightly elaborate process eliminates a category of problems in which the 'var' member of the keyword arguments dict is set, and a positional argument corresponding to 'var' is also set. It also makes calling much simpler for the common cases. The resulting output gives you a pretty good picture of what values got set, and how they got set. RP Modifications: a) Split from IncludeHistory to separate VariableHistory b) Add dedicated copy function instead of deepcopy c) Use COW for variables dict d) Remove 'value' loginfo value and just use 'details' e) Desensitise code for calling order (set 'op' before/after infer_caller_details was error prone) f) Fix bug where ?= "" wasn't shown correctly g) Log more set operations as some variables mysteriously acquired values previously h) Standardise infer_caller_details to be triggered from .record() where at all possible to reduce overhead in non-enabled cases i) Rename variable parameter names to match inference code j) Add VariableHistory emit() function to match IncludeHistory k) Fix handling of appendVar, prependVar and matching flag ops l) Use ignored=True to stop logging further events where appropriate Signed-off-by: Peter Seebach <peter.seebach@windriver.com> 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-17data: Ensure emit_func honours vardeps flagRichard Purdie
Currently, calling a shell function using exec_func may result in dependent functions being missing, if the shell parser can't detect the dependency, even if it was specified with the vardeps flag. This patch ensures the function looks at the flag and considers it when deciding which other functions need to be output. [YOCTO #3561] 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-09-27lib/bb/data.py: improve output for expansion errorsPaul Eggleton
Instead of logging the function/variable separately as a NOTE when failing to expand, re-raise ExpansionError with more contextual information. This means that the full details are reported in Hob as well as actually reporting the original error message in any UI where we previously did not. For example, we used to get this with tab/space indentation issues in a python function: NOTE: Error expanding variable populate_packages ERROR: Unable to parse /path/to/recipename.bb Now, we will get this: ERROR: ExpansionError during parsing /path/to/recipename.bb: Failure expanding variable populate_packages: IndentationError: unindent does not match any outer indentation level (<string>, line 4) Fixes [YOCTO #3162]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-07-19bitbake: Warn upon finding tab indentation in python functionsRichard Purdie
Mixed spacing in python functions can cause subtle issues and generally confuses users. We've standardised on 4 space indentation, adding this warning helps ensure consistency and avoid bugs. It also makes _prepend and _append operations on python functions slightly less risky. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-05-30bitbake: include varflags in checksumsPaul Eggleton
Add a dependency to each variable on a filtered list of its varflags. This is intended to catch things such as SRC_URI checksums, varflags controlling extra functionality from classes (e.g. the recently updated update-alternatives class in OE-Core), etc. and ensure their values influence the sstate checksums. There is an exclusion list which needs to be set via bitbake.conf (BB_SIGNATURE_EXCLUDE_FLAGS), if this is not set then the functionality is disabled. The existing vardepsexclude mechanism can also be used to exclude undesired varflags, but they must be fully specified, e.g.: do_patch[vardepsexclude] += "do_patch[someflag]" Implements [YOCTO #2517]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-01-27data/runqueue.py: Fix commented out test code after variable name changesRichard Purdie
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>