Commit Graph

29 Commits

Author SHA1 Message Date
Richard Purdie
997b11a5a1 bitbake: build: Ensure addtask before/after tasknames have prefix applied
"addtask do_XXX before YYY after ZZZ "

where YYY or ZZZ is missing the "do_" prefix don't work as expected. Ajust the
code so that it doesn't just silently do the wrong thing but works as expected.

Expand a test case to cover this.

(Bitbake rev: 21670b9bb8936ec44aedff26163948bbc2ceb44a)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2024-08-13 15:47:55 +01:00
Richard Purdie
5226f46342 bitbake: BBHandler/ast: Improve addtask handling
The recent addtask improvement to handle comments complicated the regex significantly
and there are already a number of corner cases in that code which aren't handled well.

Instead of trying to complicate the regex further, switch to code logic instead. This
means the following cases are now handled:

* addtask with multiple task names
* addtask with multiple before constraints
* addtask with multiple after constraints

The testcase is updated to match the improvements.

(Bitbake rev: 417016b83c21fca7616b2ee768d5d08e1edd1e06)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2024-08-13 15:47:55 +01:00
Richard Purdie
60cba6a073 bitbake: BBHandler: Handle comments in addtask/deltask
Technically our syntax would allow for comments after an addtask/deltask.
Currently these get silently processed in various ways by the code which
is bad.

Tweak the regex to drop any comments and add test cases to ensure this
continues to work in the future.

[YOCTO #15250]

(Bitbake rev: 64f8796e55a8826ffec0d76b993c8256713f67a3)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2024-08-13 15:47:55 +01:00
Richard Purdie
c665a2c933 bitbake: ast: Fix EXPORT_FUNCTIONS bug
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>
2024-01-10 13:55:33 +00:00
Peter Hoyes
fd1d2c6dc7 bitbake: bitbake: tests: Use assertLogs to test logging output
By default, pytest captures all stdout and exposes it using its built-in
fixtures (capsys, caplog etc), so stdout does not support getvalue().

To support running tests using both unittest and pytest, use assertLogs
to capture logging and assert on the log output instead.

(Bitbake rev: 2d28caa01bab9540d2bbaf713ae3e5c563d003f5)

Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2023-06-27 15:28:56 +01:00
Kai Kang
a99566dac1 bitbake: bitbake: ConfHandler: Allow variable flag name with a single character
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-04-13 12:01:45 +01:00
James R T
f14328c22f bitbake: ConfHandler: Allow the '@' character in variable flag names
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-23 22:41:32 +00:00
Richard Purdie
7bd328f9d2 bitbake: BBHandler/cooker: Implement recipe and global classes
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-12 11:49:29 +01:00
Richard Purdie
bc6d96e696 bitbake: ConfHandler/BBHandler: Improve comment error messages and add tests
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-07-04 22:52:36 +01:00
Richard Purdie
d951d478b8 bitbake: tests/parse: Fix one test overwriting another
Fix an issue where two tests have the same name with one overwriting the
other.

(Bitbake rev: da812d938fd79e2cc7bdf355ccf5b0f9ead684c4)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-04-21 21:00:35 +01:00
Richard Purdie
7f0f1179eb bitbake: fetch/tests/toaster: Override conversion fixups
Fix some references that missed during the overrides syntax migration or
were incorrect. Thanks to Quentin Schulz <foss@0leil.net> for the patch.

(Bitbake rev: 6184cb07dfa44f5f76f1c423533b4547d80b20ab)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-08-06 06:34:58 +01:00
Richard Purdie
4512f767ea bitbake: doc/lib: Add fixes for issues missed by the automated conversion
The examples and tests use non-standard override names, convert these to
the new syntax by hand.

(Bitbake rev: a6c40eca1146c0160da7e4e0bd7ac52fef2029e0)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-08-02 15:44:10 +01:00
Richard Purdie
2d7cf6c056 bitbake: doc/lib: Update to use new override syntax containing colons
This runs the overrides conversion script in OE-Core over the bitbake code
base including the docs. A handful of things were excluded in toaster
and for the Changelog file.

(Bitbake rev: 47f8d3b24fd52381bf3b41e2f55a53e57841344c)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2021-08-02 15:44:10 +01:00
Richard Purdie
acce65abb9 bitbake: build: Allow deltask to take multiple tasknames
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-07-21 16:57:43 +01:00
Richard Purdie
9501864db8 bitbake: bitbake: Strip old editor directives from file headers
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-04 10:44:10 +01:00
Richard Purdie
cf9c0be3f6 bitbake: bitbake: Drop duplicate license boilerplace text
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-04 10:44:10 +01:00
Richard Purdie
79834a7144 bitbake: bitbake: Add initial pass of SPDX license headers to source code
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-05-04 10:44:04 +01:00
Richard Purdie
a85601aae1 bitbake: build: Disable warning about dependent tasks for now
This breaks with rm_work so disable the warning until we find a better
solution (and change the test accordingly too).

(Bitbake rev: 93e94c06baf013e3d072465a55bddd1fe61c0772)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-01 23:09:08 +01:00
Richard Purdie
dabc5ae13a bitbake: build: Ensure warning for invalid task dependencies is useful
WARNING: elfutils: dependent task do_rm_work does not exist

is much less useful than

WARNING: elfutils: dependent task do_rm_work for do_deploy does not exist

(Bitbake rev: e034c6f75e3d7730ff16a8d1bd0cba03beda0af8)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-05-01 23:09:08 +01:00
Robert Yang
c761fb126d bitbake: tests/parse.py: Add testcase for addtask and deltask
(Bitbake rev: 4ac388646624e08bef848b560fa52deacf2ff4fb)

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2019-04-30 12:05:24 +01:00
Mark Hatle
5fae3cb56e bitbake: lib/bb/tests/parse.py: Test case was changing chdir
The test case was changing the current directory, but was never restoring it
to the original location.  This causes occasional failures in later test cases.

(Bitbake rev: 8c222c45148d1f21c2390d66ddd9d3e33b397f05)

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2018-09-26 15:14:33 +01:00
Ola x Nilsson
ca68d71ddc bitbake: ConfHandler: Require whitespace between export and variable name
(Bitbake rev: 22bb7c9270f02ddae72e13d849375feee5f4a98b)

Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-06-05 09:19:51 +01:00
Joshua Lock
ddaac5e4e3 bitbake: bitbake: remove True option to getVarFlag calls
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\)

(Bitbake rev: c19baa8c19ea8ab9b9b64fd30298d8764c6fd2cd)

Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-11-30 15:48:09 +00:00
Joshua Lock
1fce7ecbbb bitbake: bitbake: remove True option to getVar calls
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\)

(Bitbake rev: 3b45c479de8640f92dd1d9f147b02e1eecfaadc8)

Signed-off-by: Joshua Lock <joshua.g.lock@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-11-30 15:48:09 +00:00
Jérémy Rosen
0eb6d709b6 bitbake: ast/ConfHandler: Add a syntax to clear variable
unset VAR
will clear variable VAR
unset VAR[flag]
will clear flag "flag" from var VAR

(Bitbake rev: bedbd46ece8d1285b5cd2ea07dc64b4875b479aa)

Signed-off-by: Jérémy Rosen <jeremy.rosen@openwide.fr>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-08-18 10:06:26 +01:00
Richard Purdie
0f2c59367a bitbake: bitbake: Convert to python 3
Various misc changes to convert bitbake to python3 which don't warrant
separation into separate commits.

(Bitbake rev: d0f904d407f57998419bd9c305ce53e5eaa36b24)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2016-06-02 08:24:02 +01:00
Richard Purdie
aaea533e70 bitbake: tests/parse: Add BBCLASSEXTEND multiple data store corruption reproducer
One data store changing a variable poked through into a different data
store. This test case replicates that issue where the value 'B' would
become unset/disappear.

We also enhance parsehelper to generate files with an optional suffix
such as bbclass.

(Bitbake rev: 5c4179f58a4e04f1c354df5f17d1860eb403f0ac)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-23 08:48:41 +01:00
Richard Purdie
a730981b75 bitbake: tests/data: Add new data tests
Add a variety of tests which were found to be useful when working
on the data store recently.

(Bitbake rev: 5c5f8da509f6bbc1fad263462142519ef3d54a35)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-12 22:50:46 +01:00
Richard Purdie
bc162d21dd bitbake: tests/parse: Add file missing from previous commit
(Bitbake rev: 76f095107a0eaf987a5a6a48eed7b98f87aea121)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-05-16 22:40:44 +01:00