History log of /u-boot/tools/buildman/builderthread.py
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# dc314185 26-Oct-2023 Simon Glass <sjg@chromium.org>

buildman: Use oldconfig when adjusting the config

We cannot be sure that the new config is consistent, particularly when
changing a major item like CONFIG_CMDLINE. Use 'make oldconfig' to
check that and avoid any such problems.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 124a0da5 07-Sep-2023 Simon Glass <sjg@chromium.org>

buildman: Keep all common output files

Make a list of common output extensions and use it to ensure that the -k
option preserves all of these.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 2ecc5805 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move copy_files() out ot BuilderThread class

This does not need to be in the class. Move it out to avoid a pylint
warning.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 236f9593 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Tidy up some comments in builderthread

Make sure all functions have full argument documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 57686d33 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Tidy up reporting of a toolchain error

Provide the text of the exception when something goes wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5e5044b0 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Avoid passing result into _read_done_file()

Move the creating of the result object into the function which sets it
up, to simplify the code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 335c1b9f 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Create a function to handle config and build

Move this code into a _config_and_build() function, so reduce the size of
run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# ad7181c7 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move checkout code to a separate function

Put this in its own function to reduce the size of the run_commit()
function

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9bdf0238 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move code to decide output dirs

Put this in its own function to reduce the size of the run_commit()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5490b7f 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move code to remove old outputs

Put this in its own function to reduce the size of the run_commit()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4981bd3d 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move reading of the done file into a function

Move this logic into its own function to reduce the size of the
run_commt() function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 14c15233 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move bulid code into its own function

Split this into its own function so reduce the size of run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# ec2f492e 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move reconfigure code into its own function

Split this into its own function so reduce the size of run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# dab3a4a0 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert config_out to string IO

This is probably a little more efficient and it allows passing the object
to another function to write data. Convert config_out to use a string I/O
device.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ed007bfa 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move more things into _build_args()

Move more of the argument-building code into this function. Fix a missing
assignment for out_rel_dir too.

Rename the function since it now builds all the arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a06ed7fb 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move setting of toolchain arguments to _build_args()

Move a few more pieces to this new function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 75247000 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Start a function to set up the make arguments

Move some of this code into a new funciion, to help reduce the size of the
run_commits() function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8926025e 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Drop unnecessary assignment of config_out

This is already set up earlier in the function, so drop the extra
assignment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cc923faf 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Correct invalid use of out_dir variable

This variable has a different meaning in the outer scope. Use a different
name to avoid confusion, or bugs.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4a7419bf 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Export _get_output_dir() to avoid warnings

Make this a public memory since it is used outside the class.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 606e5435 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Correct most pylint warnings in builderthread

Fix the easy warnings in this file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f06d333d 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert camel case in builderthread.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 37edf5fc 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert camel case in builder.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43bdb3b3 28-Apr-2023 Simon Glass <sjg@chromium.org>

buildman: Pass -Werror to the host compiler too

The host compiler is not failing on warnings at present, when the
-E flag is used in buildman. Add the required flag to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@konsulko.com>

# 4583c002 23-Feb-2023 Simon Glass <sjg@chromium.org>

patman: Move library functions into a library directory

The patman directory has a number of modules which are used by other tools
in U-Boot. This makes it hard to package the tools using pypi since the
common files must be copied along with the tool that uses them.

To address this, move these files into a new u_boot_pylib library. This
can be packaged separately and listed as a dependency of each tool.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bfb708ad 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Add a flag for reproducible builds

This is quite a useful thing to use when building since it avoids small
size changes between commits. Add a -r flag for it.

Also undefine CONFIG_LOCALVERSION_AUTO since this appends the git hash
to the version string, causing every build to be slightly different.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 93202d72 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Support disabling LTO

This cuts down build performance considerably and is not always needed,
when checking for build errors, etc.

Add a flag to disable it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cd37d5bc 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Write out the build command used

It is sometimes useful to see the exact 'make' command used by buildman
for a commit. Add an output file for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d7713ad3 09-Nov-2022 Tom Rini <trini@konsulko.com>

buildman: Add --allow-missing flag to allow missing blobs

Add a new flag to buildman so that we will in turn pass
BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.

Allow the settings file to control this.

Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 35b6e53d 09-Nov-2022 Simon Glass <sjg@chromium.org>

buildman: Detect binman reporting missing blobs

Buildman should consider a build as a success (with warnings) if missing
blobs have been dealt with by binman, even though buildman itself returns
and error code overall. This is how other warnings are dealt with.

We cannot easily access the 103 exit code, so detect the problem in the
output.

With this change, missing blobs result in an exit code of 101, although
they still indicate failure.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f4ed4706 11-Jul-2022 Simon Glass <sjg@chromium.org>

buildman: Avoid using board as a variable

We have a module called 'board'. Sometimes buildman uses 'brd' as an
instance variable but sometimes it uses 'board', which is confusing and
can mess with the module handling. Update the code to use 'brd'
consistently, making it easier for tools to determine when the module
is being referenced.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0157b187 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in gitutil.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9800699 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in command.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@konsulko.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 124a0da5 07-Sep-2023 Simon Glass <sjg@chromium.org>

buildman: Keep all common output files

Make a list of common output extensions and use it to ensure that the -k
option preserves all of these.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>

# 2ecc5805 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move copy_files() out ot BuilderThread class

This does not need to be in the class. Move it out to avoid a pylint
warning.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 236f9593 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Tidy up some comments in builderthread

Make sure all functions have full argument documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 57686d33 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Tidy up reporting of a toolchain error

Provide the text of the exception when something goes wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5e5044b0 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Avoid passing result into _read_done_file()

Move the creating of the result object into the function which sets it
up, to simplify the code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 335c1b9f 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Create a function to handle config and build

Move this code into a _config_and_build() function, so reduce the size of
run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# ad7181c7 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move checkout code to a separate function

Put this in its own function to reduce the size of the run_commit()
function

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9bdf0238 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move code to decide output dirs

Put this in its own function to reduce the size of the run_commit()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5490b7f 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move code to remove old outputs

Put this in its own function to reduce the size of the run_commit()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4981bd3d 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move reading of the done file into a function

Move this logic into its own function to reduce the size of the
run_commt() function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 14c15233 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move bulid code into its own function

Split this into its own function so reduce the size of run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# ec2f492e 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move reconfigure code into its own function

Split this into its own function so reduce the size of run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# dab3a4a0 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert config_out to string IO

This is probably a little more efficient and it allows passing the object
to another function to write data. Convert config_out to use a string I/O
device.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ed007bfa 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move more things into _build_args()

Move more of the argument-building code into this function. Fix a missing
assignment for out_rel_dir too.

Rename the function since it now builds all the arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a06ed7fb 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move setting of toolchain arguments to _build_args()

Move a few more pieces to this new function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 75247000 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Start a function to set up the make arguments

Move some of this code into a new funciion, to help reduce the size of the
run_commits() function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8926025e 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Drop unnecessary assignment of config_out

This is already set up earlier in the function, so drop the extra
assignment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cc923faf 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Correct invalid use of out_dir variable

This variable has a different meaning in the outer scope. Use a different
name to avoid confusion, or bugs.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4a7419bf 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Export _get_output_dir() to avoid warnings

Make this a public memory since it is used outside the class.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 606e5435 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Correct most pylint warnings in builderthread

Fix the easy warnings in this file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f06d333d 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert camel case in builderthread.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 37edf5fc 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert camel case in builder.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43bdb3b3 28-Apr-2023 Simon Glass <sjg@chromium.org>

buildman: Pass -Werror to the host compiler too

The host compiler is not failing on warnings at present, when the
-E flag is used in buildman. Add the required flag to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@konsulko.com>

# 4583c002 23-Feb-2023 Simon Glass <sjg@chromium.org>

patman: Move library functions into a library directory

The patman directory has a number of modules which are used by other tools
in U-Boot. This makes it hard to package the tools using pypi since the
common files must be copied along with the tool that uses them.

To address this, move these files into a new u_boot_pylib library. This
can be packaged separately and listed as a dependency of each tool.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bfb708ad 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Add a flag for reproducible builds

This is quite a useful thing to use when building since it avoids small
size changes between commits. Add a -r flag for it.

Also undefine CONFIG_LOCALVERSION_AUTO since this appends the git hash
to the version string, causing every build to be slightly different.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 93202d72 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Support disabling LTO

This cuts down build performance considerably and is not always needed,
when checking for build errors, etc.

Add a flag to disable it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cd37d5bc 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Write out the build command used

It is sometimes useful to see the exact 'make' command used by buildman
for a commit. Add an output file for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d7713ad3 09-Nov-2022 Tom Rini <trini@konsulko.com>

buildman: Add --allow-missing flag to allow missing blobs

Add a new flag to buildman so that we will in turn pass
BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.

Allow the settings file to control this.

Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 35b6e53d 09-Nov-2022 Simon Glass <sjg@chromium.org>

buildman: Detect binman reporting missing blobs

Buildman should consider a build as a success (with warnings) if missing
blobs have been dealt with by binman, even though buildman itself returns
and error code overall. This is how other warnings are dealt with.

We cannot easily access the 103 exit code, so detect the problem in the
output.

With this change, missing blobs result in an exit code of 101, although
they still indicate failure.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f4ed4706 11-Jul-2022 Simon Glass <sjg@chromium.org>

buildman: Avoid using board as a variable

We have a module called 'board'. Sometimes buildman uses 'brd' as an
instance variable but sometimes it uses 'board', which is confusing and
can mess with the module handling. Update the code to use 'brd'
consistently, making it easier for tools to determine when the module
is being referenced.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0157b187 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in gitutil.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9800699 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in command.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@konsulko.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2ecc5805 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move copy_files() out ot BuilderThread class

This does not need to be in the class. Move it out to avoid a pylint
warning.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 236f9593 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Tidy up some comments in builderthread

Make sure all functions have full argument documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 57686d33 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Tidy up reporting of a toolchain error

Provide the text of the exception when something goes wrong.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5e5044b0 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Avoid passing result into _read_done_file()

Move the creating of the result object into the function which sets it
up, to simplify the code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 335c1b9f 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Create a function to handle config and build

Move this code into a _config_and_build() function, so reduce the size of
run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# ad7181c7 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move checkout code to a separate function

Put this in its own function to reduce the size of the run_commit()
function

Signed-off-by: Simon Glass <sjg@chromium.org>

# 9bdf0238 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move code to decide output dirs

Put this in its own function to reduce the size of the run_commit()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5490b7f 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move code to remove old outputs

Put this in its own function to reduce the size of the run_commit()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4981bd3d 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move reading of the done file into a function

Move this logic into its own function to reduce the size of the
run_commt() function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 14c15233 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move bulid code into its own function

Split this into its own function so reduce the size of run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# ec2f492e 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move reconfigure code into its own function

Split this into its own function so reduce the size of run_commit().

Signed-off-by: Simon Glass <sjg@chromium.org>

# dab3a4a0 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert config_out to string IO

This is probably a little more efficient and it allows passing the object
to another function to write data. Convert config_out to use a string I/O
device.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ed007bfa 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move more things into _build_args()

Move more of the argument-building code into this function. Fix a missing
assignment for out_rel_dir too.

Rename the function since it now builds all the arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# a06ed7fb 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Move setting of toolchain arguments to _build_args()

Move a few more pieces to this new function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 75247000 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Start a function to set up the make arguments

Move some of this code into a new funciion, to help reduce the size of the
run_commits() function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8926025e 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Drop unnecessary assignment of config_out

This is already set up earlier in the function, so drop the extra
assignment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cc923faf 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Correct invalid use of out_dir variable

This variable has a different meaning in the outer scope. Use a different
name to avoid confusion, or bugs.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4a7419bf 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Export _get_output_dir() to avoid warnings

Make this a public memory since it is used outside the class.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 606e5435 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Correct most pylint warnings in builderthread

Fix the easy warnings in this file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f06d333d 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert camel case in builderthread.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 37edf5fc 19-Jul-2023 Simon Glass <sjg@chromium.org>

buildman: Convert camel case in builder.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43bdb3b3 28-Apr-2023 Simon Glass <sjg@chromium.org>

buildman: Pass -Werror to the host compiler too

The host compiler is not failing on warnings at present, when the
-E flag is used in buildman. Add the required flag to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@konsulko.com>

# 4583c002 23-Feb-2023 Simon Glass <sjg@chromium.org>

patman: Move library functions into a library directory

The patman directory has a number of modules which are used by other tools
in U-Boot. This makes it hard to package the tools using pypi since the
common files must be copied along with the tool that uses them.

To address this, move these files into a new u_boot_pylib library. This
can be packaged separately and listed as a dependency of each tool.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bfb708ad 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Add a flag for reproducible builds

This is quite a useful thing to use when building since it avoids small
size changes between commits. Add a -r flag for it.

Also undefine CONFIG_LOCALVERSION_AUTO since this appends the git hash
to the version string, causing every build to be slightly different.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 93202d72 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Support disabling LTO

This cuts down build performance considerably and is not always needed,
when checking for build errors, etc.

Add a flag to disable it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cd37d5bc 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Write out the build command used

It is sometimes useful to see the exact 'make' command used by buildman
for a commit. Add an output file for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d7713ad3 09-Nov-2022 Tom Rini <trini@konsulko.com>

buildman: Add --allow-missing flag to allow missing blobs

Add a new flag to buildman so that we will in turn pass
BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.

Allow the settings file to control this.

Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 35b6e53d 09-Nov-2022 Simon Glass <sjg@chromium.org>

buildman: Detect binman reporting missing blobs

Buildman should consider a build as a success (with warnings) if missing
blobs have been dealt with by binman, even though buildman itself returns
and error code overall. This is how other warnings are dealt with.

We cannot easily access the 103 exit code, so detect the problem in the
output.

With this change, missing blobs result in an exit code of 101, although
they still indicate failure.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f4ed4706 11-Jul-2022 Simon Glass <sjg@chromium.org>

buildman: Avoid using board as a variable

We have a module called 'board'. Sometimes buildman uses 'brd' as an
instance variable but sometimes it uses 'board', which is confusing and
can mess with the module handling. Update the code to use 'brd'
consistently, making it easier for tools to determine when the module
is being referenced.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0157b187 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in gitutil.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9800699 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in command.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@konsulko.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 43bdb3b3 28-Apr-2023 Simon Glass <sjg@chromium.org>

buildman: Pass -Werror to the host compiler too

The host compiler is not failing on warnings at present, when the
-E flag is used in buildman. Add the required flag to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@konsulko.com>

# 4583c002 23-Feb-2023 Simon Glass <sjg@chromium.org>

patman: Move library functions into a library directory

The patman directory has a number of modules which are used by other tools
in U-Boot. This makes it hard to package the tools using pypi since the
common files must be copied along with the tool that uses them.

To address this, move these files into a new u_boot_pylib library. This
can be packaged separately and listed as a dependency of each tool.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bfb708ad 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Add a flag for reproducible builds

This is quite a useful thing to use when building since it avoids small
size changes between commits. Add a -r flag for it.

Also undefine CONFIG_LOCALVERSION_AUTO since this appends the git hash
to the version string, causing every build to be slightly different.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 93202d72 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Support disabling LTO

This cuts down build performance considerably and is not always needed,
when checking for build errors, etc.

Add a flag to disable it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cd37d5bc 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Write out the build command used

It is sometimes useful to see the exact 'make' command used by buildman
for a commit. Add an output file for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d7713ad3 09-Nov-2022 Tom Rini <trini@konsulko.com>

buildman: Add --allow-missing flag to allow missing blobs

Add a new flag to buildman so that we will in turn pass
BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.

Allow the settings file to control this.

Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 35b6e53d 09-Nov-2022 Simon Glass <sjg@chromium.org>

buildman: Detect binman reporting missing blobs

Buildman should consider a build as a success (with warnings) if missing
blobs have been dealt with by binman, even though buildman itself returns
and error code overall. This is how other warnings are dealt with.

We cannot easily access the 103 exit code, so detect the problem in the
output.

With this change, missing blobs result in an exit code of 101, although
they still indicate failure.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f4ed4706 11-Jul-2022 Simon Glass <sjg@chromium.org>

buildman: Avoid using board as a variable

We have a module called 'board'. Sometimes buildman uses 'brd' as an
instance variable but sometimes it uses 'board', which is confusing and
can mess with the module handling. Update the code to use 'brd'
consistently, making it easier for tools to determine when the module
is being referenced.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0157b187 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in gitutil.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9800699 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in command.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@konsulko.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 4583c002 23-Feb-2023 Simon Glass <sjg@chromium.org>

patman: Move library functions into a library directory

The patman directory has a number of modules which are used by other tools
in U-Boot. This makes it hard to package the tools using pypi since the
common files must be copied along with the tool that uses them.

To address this, move these files into a new u_boot_pylib library. This
can be packaged separately and listed as a dependency of each tool.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bfb708ad 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Add a flag for reproducible builds

This is quite a useful thing to use when building since it avoids small
size changes between commits. Add a -r flag for it.

Also undefine CONFIG_LOCALVERSION_AUTO since this appends the git hash
to the version string, causing every build to be slightly different.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 93202d72 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Support disabling LTO

This cuts down build performance considerably and is not always needed,
when checking for build errors, etc.

Add a flag to disable it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cd37d5bc 21-Feb-2023 Simon Glass <sjg@chromium.org>

buildman: Write out the build command used

It is sometimes useful to see the exact 'make' command used by buildman
for a commit. Add an output file for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d7713ad3 09-Nov-2022 Tom Rini <trini@konsulko.com>

buildman: Add --allow-missing flag to allow missing blobs

Add a new flag to buildman so that we will in turn pass
BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.

Allow the settings file to control this.

Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 35b6e53d 09-Nov-2022 Simon Glass <sjg@chromium.org>

buildman: Detect binman reporting missing blobs

Buildman should consider a build as a success (with warnings) if missing
blobs have been dealt with by binman, even though buildman itself returns
and error code overall. This is how other warnings are dealt with.

We cannot easily access the 103 exit code, so detect the problem in the
output.

With this change, missing blobs result in an exit code of 101, although
they still indicate failure.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f4ed4706 11-Jul-2022 Simon Glass <sjg@chromium.org>

buildman: Avoid using board as a variable

We have a module called 'board'. Sometimes buildman uses 'brd' as an
instance variable but sometimes it uses 'board', which is confusing and
can mess with the module handling. Update the code to use 'brd'
consistently, making it easier for tools to determine when the module
is being referenced.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0157b187 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in gitutil.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9800699 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in command.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@konsulko.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d7713ad3 09-Nov-2022 Tom Rini <trini@konsulko.com>

buildman: Add --allow-missing flag to allow missing blobs

Add a new flag to buildman so that we will in turn pass
BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.

Allow the settings file to control this.

Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

# 35b6e53d 09-Nov-2022 Simon Glass <sjg@chromium.org>

buildman: Detect binman reporting missing blobs

Buildman should consider a build as a success (with warnings) if missing
blobs have been dealt with by binman, even though buildman itself returns
and error code overall. This is how other warnings are dealt with.

We cannot easily access the 103 exit code, so detect the problem in the
output.

With this change, missing blobs result in an exit code of 101, although
they still indicate failure.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f4ed4706 11-Jul-2022 Simon Glass <sjg@chromium.org>

buildman: Avoid using board as a variable

We have a module called 'board'. Sometimes buildman uses 'brd' as an
instance variable but sometimes it uses 'board', which is confusing and
can mess with the module handling. Update the code to use 'brd'
consistently, making it easier for tools to determine when the module
is being referenced.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0157b187 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in gitutil.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9800699 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in command.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@konsulko.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f4ed4706 11-Jul-2022 Simon Glass <sjg@chromium.org>

buildman: Avoid using board as a variable

We have a module called 'board'. Sometimes buildman uses 'brd' as an
instance variable but sometimes it uses 'board', which is confusing and
can mess with the module handling. Update the code to use 'brd'
consistently, making it easier for tools to determine when the module
is being referenced.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0157b187 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in gitutil.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9800699 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in command.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@konsulko.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0157b187 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in gitutil.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d9800699 29-Jan-2022 Simon Glass <sjg@chromium.org>

patman: Convert camel case in command.py

Convert this file to snake case and update all files which use it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 2b4806e4 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Allow adjusting board config on the fly

Add a -a option to specify changes to the config before the build
commences. For example

buildman -a ~CONFIG_CMDLINE

disables CONFIG_CMDLINE before doing the build.

This makes it easier to try things out as well as to write tests without
creating a new board or manually manging the .config file.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 8ca0931a 22-Jan-2022 Simon Glass <sjg@chromium.org>

buildman: Provide a hint on how to debug thread crashes

If a thread crashes it is helpful to try the operation again with
threading disabled. Add a hint about that.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bafdeb45 19-Oct-2021 Simon Glass <sjg@chromium.org>

buildman: Write output even on fatal error

At present buildman does not write any output (to the 'out' and 'err)
files if the build terminates with a fatal error. This is to avoid adding
lots of spam to the logs.

However there are times when this is actually useful, such as when the
build fails for an obscure reason such as a Kconfig loop.

Update the logic to always write the output, so that the user gets a clue
as to what is happening.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f1a83abe 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use bytes for the environment

At present we sometimes see problems in gitlab where the environment has
0x80 characters or sequences which are not valid UTF-8.

Avoid this by using bytes for the environment, both internal to buildman
and when writing out the 'env' file. Add a test to make sure this works
as expected.

Reported-by: Marek Vasut <marex@denx.de>
Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file")
Signed-off-by: Simon Glass <sjg@chromium.org>

# 8116c78f 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Handle exceptions in threads gracefully

There have been at least a few cases where an exception has occurred in a
thread and resulted in buildman hanging: running out of disk space and
getting a unicode error.

Handle these by collecting a list of exceptions, printing them out and
reporting failure if any are found. Add a test for this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ab9b4f35 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Use common code to send an result

At present the code to report a build result is duplicated. Put it in a
common function to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 24993313 10-Apr-2021 Simon Glass <sjg@chromium.org>

buildman: Tidy up a few comments

Add some function comments which are missing, or missing arguments.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5f86454b 25-Mar-2021 Simon Glass <sjg@chromium.org>

buildman: Add an encoding to the out-env file

The environment may contain some unicode characters. At least that is what
seemed to happen on one commit:

Building current source for 1 boards (0 threads, 64 jobs per thread)
0 0 0 /1 -1 (starting)
Traceback (most recent call last):
File ".../tools/buildman/buildman", line 64, in <module>
ret_code = control.DoBuildman(options, args)
File "tools/buildman/control.py", line 372, in DoBuildman
options.keep_outputs, options.verbose)
File ".../tools/buildman/builder.py", line 1704, in BuildBoards
results = self._single_builder.RunJob(job)
File ".../tools/buildman/builderthread.py", line 526, in RunJob
self._WriteResult(result, job.keep_outputs, job.work_in_output)
File ".../tools//buildman/builderthread.py", line 349, in _WriteResult
print('%s="%s"' % (var, env[var]), file=fd)
UnicodeEncodeError: 'ascii' codec can't encode characters in position
311-312: ordinal not in range(128)

The problem defies repetition with any change at all to buildman. But
let's set an encoding in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b82492bb 30-Jan-2021 Simon Glass <sjg@chromium.org>

buildman: Support single-threaded operation

At present even if only a single thread is in use, buildman still uses
threading.

For some debugging it is helpful to do everything in the main process.
Allow -T0 to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 73da3d2c 16-Dec-2020 Simon Glass <sjg@chromium.org>

buildman: Remove output binaries before building

Buildman reuses build directories from previous builds to avoid the cost
of 'make mrproper' for every build. If the previous build produced an SPL
image but the current one does not, the SPL image will remain and buildman
will think it is a result of building the current board.

Remove these files before building, to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bf776679 17-Apr-2020 Simon Glass <sjg@chromium.org>

patman: Move to absolute imports

At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.

Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 60b285f8 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Write output files when using -w

At present buildman does not write its own output files (err, done, the
environment) when using -w. However this is useful for when the build is
run with -s to check it.

In fact ProduceResultSummary() reads the result from those files rather
than using the 'result' info directly. So ProcessResult() does not work
with -w at present. It does not print any output.

Fix this by writing output files even when -w is used.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 166a98a4 17-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Use out-env for environment output

At present the environment used by U-Boot is written to the 'env'
directory. This is fine when the output directory is not the same as the
source directory, but when it is (as with -w) it conflicts with the source
directory of the same name.

Rename 'env' to 'out-env' to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# eb70a2c0 09-Apr-2020 Simon Glass <sjg@chromium.org>

buildman: Make -I the default

At present buildman defaults to running 'mrproper' on every thread before
it starts building commits for each board. This can add a delay of about 5
seconds to the start of the process, since the tools and other invariants
must be rebuilt.

In particular, a build without '-b', to build current source, runs much
slower without -I, since any existing build is removed, thus losing the
possibility of an incremental build.

Partly this behaviour was to avoid strange build-system problems caused by
running 'make defconfig' for one board and then one with a different
architecture. But these problems were fixed quite a while ago.

The -I option (which disabled mrproper) was introduced four years ago and
does not seem to cause any problems with builds.

So make -I the default and deprecate the option. To allow use of
'mrproper', add a new -m flag.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d829f121 18-Mar-2020 Simon Glass <sjg@chromium.org>

bulidman: Add support for a simple build

It is useful to run a simple build and put all the output in a single
directory. Add a -w option to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e9fbbf63 18-Mar-2020 Simon Glass <sjg@chromium.org>

buildman: Document the members of BuilderJob

This class has a few more members now. Add documentation for them and fix
a nit in the 'commits' comment.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# c05aa036 31-Oct-2019 Simon Glass <sjg@chromium.org>

buildman: Convert to Python 3

Convert buildman to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e5fc79ea 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Write the environment out to an 'env' file

Sometimes it is useful to see the environment that was used to build
U-Boot. Write this out to a file in the build directory.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 00beb248 07-Jan-2019 Simon Glass <sjg@chromium.org>

buildman: Add support for building with clang

Add a -O option which allows building with clang.

Signed-off-by: Simon Glass <sjg@chromium.org>

# e74429bb 10-Dec-2018 Simon Glass <sjg@chromium.org>

buildman: Deal nicely with invalid build-status file

The 'done' files created by buildman may end up being empty if buildman
runs out of disk space while writing them. This error is then persistent,
since even if disk space is reclaimed and the build retries, the empty
file causes an exception in the builder thread.

Deal with this silently by doing a rebuild.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>

# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>

# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>

# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>

# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>

# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>

# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>

# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>

# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>

# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>

# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>

# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>

# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>

# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>

# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>

# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 0ddc510e 30-May-2018 Alex Kiernan <alex.kiernan@gmail.com>

buildman: Extract environment as part of each build

As we're building the boards, extract the default U-Boot environment to
uboot.env so we can interrogate it later.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>


# 409fc029 08-Apr-2018 Lothar Waßmann <LW@KARO-electronics.de>

tools: buildman: Don't use the working dir as build dir

When the U-Boot base directory happens to have the same name as the branch
that buildman is directed to use via the '-b' option and no output
directory is specified with '-o', buildman happily starts removing the
whole U-Boot sources eventually only stopped with the error message:

OSError: [Errno 20] Not a directory: '../<branch-name>/boards.cfg

Add a check to avoid this and also deal with the case where '-o' points
to the source directory, or any subdirectory of it.

Finally, tidy up the confusing logic for removing the old tree when using
-b. This is only done when building a branch.

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Lothar Waßmann <LW@KARO-electronics.de>


# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

When U-Boot started using SPDX tags we were among the early adopters and
there weren't a lot of other examples to borrow from. So we picked the
area of the file that usually had a full license text and replaced it
with an appropriate SPDX-License-Identifier: entry. Since then, the
Linux Kernel has adopted SPDX tags and they place it as the very first
line in a file (except where shebangs are used, then it's second line)
and with slightly different comment styles than us.

In part due to community overlap, in part due to better tag visibility
and in part for other minor reasons, switch over to that style.

This commit changes all instances where we have a single declared
license in the tag as both the before and after are identical in tag
contents. There's also a few places where I found we did not have a tag
and have introduced one.

Signed-off-by: Tom Rini <trini@konsulko.com>


# 2371d1bc 26-Jan-2018 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: add option -E for treating compiler warnings as errors

Add a new option '-E' for treating all compiler warnings as errors.
Eventually this will pass 'KCFLAGS=-Werror' to Kbuild.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>


# aafbe82f 07-Jun-2017 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

buildman: properly translate strings for log and err files to ASCII

The build output can still produce unicode encoded output. But in
the buildman's log and err files we only want plain ASCII characters.

To handle all situations with unicode and non-unicode output, encode
the stdout and stderr strings to UTF-8 and afterwards to ASCII with
replacing all special characters.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>


# fbeb3375 14-Apr-2017 Tom Rini <trini@konsulko.com>

buildman: Translate more strings to latin-1

When writing out some of our results we may now have UTF-8 characters
in there as well. Translate these to latin-1 and ignore any errors (as
this is for diagnostic and given the githash anything else can be
reconstructed by the user.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>


# a9401b2b 16-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Rename do_build to config_only

This variable name is needlessly confusion. Adjust it to use a 'positive'
name instead.

Signed-off-by: Simon Glass <sjg@chromium.org>


# b50113f3 13-Nov-2016 Simon Glass <sjg@chromium.org>

buildman: Add an option to just create the config

Normally buildman does a full build of a board. This includes creating the
u-boot.cfg file which contains all the configuration options. Buildman uses
this file with the -K option, to show differences in effective configuration
for each commit.

Doing a full build of U-Boot just to create the u-boot.cfg file is wasteful.
Add a -D option which causes buildman to only create the configuration. This
is enough to support use of -K and can be done much more quickly (typically
5-10 times faster).

Signed-off-by: Simon Glass <sjg@chromium.org>


# f40fa9b3 04-Oct-2016 York Sun <york.sun@nxp.com>

tools: buildman: Remove duplicated code

Signed-off-by: York Sun <york.sun@nxp.com>
CC: Simon Glass <sjg@chromium.org>
Fixed commit subject:
Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>


# 2880e6b5 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'alive' flag in BuilderThread

This is not used, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 63781bd6 18-Sep-2016 Simon Glass <sjg@chromium.org>

buildman: Drop the 'active' flag in the builder

This serves no real purpose, since when we are not active, we exit. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>


# f79f1e0c 11-Apr-2016 Stephen Warren <swarren@nvidia.com>

buildman: allow more incremental building

One use-case for buildman is to continually run it interactively after
each small step in a large refactoring operation. This gives more
immediate feedback than making a number of commits and then going back and
testing them. For this to work well, buildman needs to be extremely fast.
At present, a couple issues prevent it being as fast as it could be:

1) Each time buildman runs "make %_defconfig", it runs "make mrproper"
first. This throws away all previous build results, requiring a
from-scratch build. Optionally avoiding this would speed up the build, at
the cost of potentially causing or missing some build issues.

2) A build tree is created per thread rather than per board. When a thread
switches between building different boards, this often causes many files
to be rebuilt due to changing config options. Using a separate build tree
for each board would avoid this. This does put more strain on the system's
disk cache, but it is worth it on my system at least.

This commit adds two command-line options to implement the changes
described above; -I ("--incremental") turns of "make mrproper" and -P
("--per-board-out-dir") creats a build directory per board rather than per
thread.

Tested:

./tools/buildman/buildman.py tegra
./tools/buildman/buildman.py -I -P tegra
./tools/buildman/buildman.py -b tegra_dev tegra
./tools/buildman/buildman.py -b tegra_dev -I -P tegra

... each once after deleting the buildman result/work directory, and once
"incrementally" after a previous identical invocation.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org> # v1
Tested-by: Simon Glass <sjg@chromium.org> # v1
Acked-by: Simon Glass <sjg@chromium.org>


# dd592110 27-Apr-2015 Tom Rini <trini@konsulko.com>

builderthread.py: Keep 'SPL'

On i.MX platforms the SPL binary is called "SPL" so make sure we keep
that.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>


# f5e5ece0 01-Apr-2015 Tom Rini <trini@konsulko.com>

buildman: Make -V (verbose_build) really be verbose

The help text for -V says we will pass V=1 but all it really did was not
pass in -s. Change the logic to pass make V=1 with given to buildman -V or
-s to make otherwise.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>


# 0eb4c045 20-Mar-2015 Tom Rini <trini@konsulko.com>

buildman: Keep more outputs with the --keep-outputs flag

When told to keep outputs, be much more liberal in what files we keep.
In addition to adding 'MLO', keep anything that matches u-boot-spl.* (so
that we keep the map file as well) and anything we generate about
'u-boot itself. A large number of bootable formats now match this and
thus it's easier to build many targets and then boot them afterwards
using buildman.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Simon Glass <sjg@chromium.org>


# 970f932a 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Store build config files

Store all config file output so that we can compare changes if requested.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 88c8dcf9 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Adjust the 'aborted' heuristic for writing output

At present buildman tries to detect an aborted build and doesn't record a
result in that case. This is to make sure that an abort (e.g. with Ctrl-C)
does not mark the build as done. Without this option, buildman would never
retry the build unless -f/-F are provided. The effect is that aborting the
build creates 'fake errors' on whatever builds buildman happens to be
working on at the time.

Unfortunately the current test is not reliable and this detection can
trigger if a required toolchain tool is missing. In this case the toolchain
problem is never reported.

Adjust the logic to continue processing the build result, mark the build as
done (and failed), but with a return code which indicates that it should be
retried.

The correct fix is to fully and correctly detect an aborted build, quit
buildman immediately and not write any partial build results in this case.
Unfortunately this is currently beyond my powers and is left as an exercise
for the reader (and patches are welcome).

Signed-off-by: Simon Glass <sjg@chromium.org>


# 40f11fce 05-Feb-2015 Simon Glass <sjg@chromium.org>

buildman: Show 'make' command line when -V is used

When a verbose build it selected, show the make command before the output of
that command.

Signed-off-by: Simon Glass <sjg@chromium.org>


# d2ce658d 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to write the full build output

Normally buildman runs with 'make -s' meaning that only errors and warnings
appear in the log file. Add a -V option to run make in verbose mode, and
with V=1, causing a full build log to be created.

Signed-off-by: Simon Glass <sjg@chromium.org>


# bb1501f2 01-Dec-2014 Simon Glass <sjg@chromium.org>

buildman: Add an option to use the full tool chain path

In some cases there may be multiple toolchains with the same name in the
path. Provide an option to use the full path in the CROSS_COMPILE
environment variable.

Note: Wolfgang mentioned that this is dangerous since in some cases there
may be other tools on the path that are needed. So this is set up as an
option, not the default. I will need test confirmation (i.e. that this
commit fixes a real problem) before merging it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Steve Rae <srae@broadcom.com>


# ce267335 11-Nov-2014 Tom Rini <trini@ti.com>

buildman: Save *.img files too

When saving binary files we likely want to keep any .img files that have
been generated as well.

Signed-off-by: Tom Rini <trini@ti.com>
Acked-by: Simon Glass <sjg@chromium.org>


# f3d015cb 19-Aug-2014 Thierry Reding <treding@nvidia.com>

buildman: Create parent directories as necessary

When creating build directories also create parents as necessary. This
fixes a failure when building a hierarchical branch (i.e. foo/bar).

Signed-off-by: Thierry Reding <treding@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@ti.com>


# fb3954f9 05-Sep-2014 Simon Glass <sjg@chromium.org>

buildman: Correct counting of build failures on retry

When a build is to be performed, buildman checks to see if it has already
been done. In most cases it will not bother trying again. However, it was
not reading the return code from the 'done' file, so if the result was a
failure, it would not be counted. This depresses the 'failure' count stats
that buildman prints in this case.

Fix this bug by always reading the return code.

Signed-off-by: Simon Glass <sjg@chromium.org>


# 48c1b6a8 28-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Remove the directory prefix from each error line

The full path is long and also includes buildman private directories.
Clean this up, so that only a relative U-Boot path is shown.

This will change warnings like these:

/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/buildman5/.bm-work/00/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
/home/sjg/c/src/third_party/u-boot/files/arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

to:

arch/sandbox/cpu/cpu.c: In function 'timer_get_us':
arch/sandbox/cpu/cpu.c:40:9: warning: unused variable 'i' [-Wunused-variable]

Signed-off-by: Simon Glass <sjg@chromium.org>


# fd18a89e 20-Aug-2014 Roger Meier <roger@bufferoverflow.ch>

Makefile: remove generated boards.cfg within make distclean

Signed-off-by: Roger Meier <roger@bufferoverflow.ch>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Tested-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Tom Rini <trini@ti.com>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Simon Glass <sjg@chromium.org>


# 190064b4 09-Aug-2014 Simon Glass <sjg@chromium.org>

buildman: Move BuilderThread code to its own file

The builder.py file is getting too long, so split out some code.

Signed-off-by: Simon Glass <sjg@chromium.org>