Commit graph

113 commits

Author SHA1 Message Date
Simon Glass
5579ce747d Revert "Revert "global: Remove CONFIG_SYS_EXTRA_OPTIONS support""
This is not needed now that CONFIG_SYS_TARGET_NAME is correctly determined
when scanning Kconfig.

This reverts commit 25b8acee2e.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2022-08-05 11:47:56 -04:00
Tom Rini
25b8acee2e Revert "global: Remove CONFIG_SYS_EXTRA_OPTIONS support"
Unfortunately, we require additional logic to buildman to support this
removal and still use SYS_SOC, etc, for build targets.

This reverts commit eeec00072d.

Signed-off-by: Tom Rini <trini@konsulko.com>
2022-04-02 18:18:57 -04:00
Tom Rini
eeec00072d global: Remove CONFIG_SYS_EXTRA_OPTIONS support
All options have now been migrated to Kconfig correctly so remove this
support.

Signed-off-by: Tom Rini <trini@konsulko.com>
2022-04-01 10:28:47 -04:00
Simon Glass
d9c958f49c moveconfig: Use re.fullmatch() to avoid extra check
Simplify the code by using the available function.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-03-18 19:24:24 -06:00
Simon Glass
78f12e5369 moveconfig: Remove remove_defconfig()
This is not necessary if simpler code is used. Use the split function and
drop the unnecessary []

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Suggested-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-03-18 19:24:24 -06:00
Simon Glass
68a0b7156a moveconfig: Correct pylint errors
Fix two pylint errors in this file.

Note ACTION_SPL_NOT_EXIST is not defined so the dead code can be removed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-03-02 10:28:12 -05:00
Simon Glass
941671a19c moveconfig: Allow regex matches when finding combinations
It is useful to be able to search for CONFIG options that match a regex,
such as this, which lists boards which define SPL_FIT_GENERATOR and
anything not starting with ROCKCHIP:

   ./tools/moveconfig.py -f SPL_FIT_GENERATOR ~ROCKCHIP.*

Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22 10:05:44 -07:00
Simon Glass
b8d11da0d0 moveconfig: Show the config name rather than the defconfig
The _defconfig suffix is unnecessary when showing matching boards. Drop
it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22 10:05:44 -07:00
Alper Nebi Yasak
6c928c63a1 moveconfig: Fix code relying on now-stripped newline characters
Commit 37f815cad0 ("moveconfig: Use a function to read files") adds a
helper function that can read a file as lines, but strips the newline
characters. This change broke parts of moveconfig code that relied on
their existence, resulting in a few issues:

Configs that are defined as empty aren't removed from header files (e.g.
"#define CONFIG_REMAKE_ELF"). Make regex patterns use '\b' to match word
boundaries instead of '\W' (which matched the newlines) so these lines
still match and get removed.

All changes in defconfig are considered removed by savedefconfig even
if they weren't, and line continuations in the headers aren't recognized
and removed properly, because their checks explicitly look for a newline
character. Remove the character from both comparisons.

The printed diff of header files is wrongly formatted and raises an
IndexError if a blank line was removed. Let print() print the new lines,
and use size-independent ways to check strings to fix the diff output.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
2022-01-30 20:40:58 -07:00
Simon Glass
91197aa696 moveconfig: Fix some pylint errors
There are over 200 errors in this file. Fix some of them, starting at the
beginning of the file. Future work can continue this effort.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:30 -05:00
Simon Glass
37f815cad0 moveconfig: Use a function to read files
At present there is quite a bit of ad-hoc code reading from files. The
most common case is to read the file as lines. Put it in a function and
set the unicode encoding correctly.

Avoid writing back to a file when there are obviously no changes as this
speeds things up slightly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:30 -05:00
Simon Glass
2fd85bd326 moveconfig: Use a function to write files
At present there is quite a bit of ad-hoc code writing to files. The
treatment of newlines is different in some of them. Put it in a function
and set the unicode encoding correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:30 -05:00
Simon Glass
478920dc58 moveconfig: Drop check for old Python
Python 2 is not supported anymore and Python 3 has had subprocess.DEVNULL
since version 3.3 which was released in 2012. Drop the unnecessary check.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-01-24 17:36:29 -05:00
Simon Glass
b2e83c6348 moveconfig: Convert to ArgumentParser
This is a newer library and is now preferred for Python scripts. Update
the code to use it instead of optparse

Use 'args' instead of 'options' throughout, since this is the term used
in that module. Also it helps to avoid confusion with CONFIG options, a
term that is used in this file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:29 -05:00
Simon Glass
daa694d39e moveconfig: Use single quotes
Quite a few places use double quotes. Fix this to be consistent with
other Python code in U-Boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-01-24 17:36:29 -05:00
Simon Glass
65d7fcec5a moveconfig: Allow querying board configuration
It is useful to be able to find out which boards define a particular
option, or combination of options. This is not as easy as grepping the
defconfig files since many options are implied by others.

Add a -f option to the moveconfig tool to permit this. Update the
documentation to cover this, including a better title for the doc page.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:29 -05:00
Simon Glass
84067a5890 moveconfig: Allow adding unit tests
Add a -t option to run unit tests in this program. So far, there is none.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:29 -05:00
Simon Glass
e1ae563294 moveconfig: Sort the options
Put the options in sorted order by their short name so it is easier to
find an option.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:29 -05:00
Simon Glass
9d603391a7 moveconfig: Read the database in a separate function
Move this code out into a function so it can be used elsewhere.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:29 -05:00
Simon Glass
a36270861b moveconfig: Correct operation of the 'imply' feature
This doesn't work anymore, since the Kconfig update. The script has no
tests so we did not notice. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-24 17:36:29 -05:00
Simon Glass
ea40b20431 moveconfig: Update to newer kconfiglib
Some of the more advanced features of this tool don't work anymore since
kconfiglib was update. Update the code accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-08-01 09:05:24 -06:00
Simon Glass
5c72c0e0d2 doc: Add docs for the moveconfig tool
Move these docs into htmldocs so they can be read there.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-08-01 09:05:24 -06:00
Trevor Woerner
dc514d7ea2 moveconfig.py: add to the "do not process" list
Skip the processing of *.aml and *.dat files while iterating through the
source in order to process header files.

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
2021-04-12 17:44:55 -04:00
Simon Glass
7570d9bb47 moveconfig: Handle binary files cleanly
Some files are not actually source code and thus can produce unicode
errors. Report this and continue.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-06 16:33:19 +12:00
Simon Glass
a38cc1726b moveconfig: Skip binary and ELF files
Add a few more file extensions to the list of files that should not be
processed. This avoids unicode errors, for example.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-23 13:43:10 -04:00
Simon Glass
b4fa94959d patman: Tidy up sys.path changes
Now that we are using absolute paths we can remove some of the sys.path
mangling that appears in the tools.

We only need to add the path to 'tools/' so that everything can find
modules relative to that directory.

The special paths for finding pylibfdt remain.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26 14:25:21 -06:00
Simon Glass
0ede00fdaf buildman: Move to absolute imports
At present buildman 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 buildman to use absolute imports. Also adjust moveconfig.py too since
it uses some buildman modules and cannot work without this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26 14:25:21 -06:00
Markus Klotzbuecher
4f5c5e99bb moveconfig: convert ps.stderr to string
Printing the error message in verbose mode fails, since python3
doesn't implicitely convert bytes to strings.

Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2020-02-25 13:46:25 -05:00
Markus Klotzbuecher
b3192f48c1 moveconfig: replace unsafe eval with asteval
Commit b237d358b4 ("moveconfig: expand simple expressions") added
support for expanding expressions in configs, but used the unsafe python
built-in "eval". This patch fixes this by replacing eval with the
asteval module.

Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2020-02-25 13:46:25 -05:00
Tom Rini
02b5670e65 moveconfig.py: Fix more Python3 UTF issues
With the move to using Python 3 for real, we encounter two different
issues.  First, the file include/video_font_data.h includes at least one
UTF-16 character.  Given that it does not include any CONFIG symbols it
is easiest to just ignore this file.  Next, we encounter similar
problems with some dts/dtsi files that come from Linux.  In this case
it's easiest to simply ignore all dts/dtsi files as there will not be
CONFIG symbols for us to migrate in them.

Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2019-11-23 14:53:48 -05:00
Simon Glass
793dca34ca move_config: Convert to Python 3
Convert this tool to Python 3 and make it use that, to meet the 2020
deadline.

Signed-off-by: Simon Glass <sjg@chromium.org>
2019-11-04 18:15:32 -07:00
Tom Rini
65e05ddc1a kconfiglib: Update to the 12.14.0 release
A large number of changes have happened upstream since our last sync
which was to 375506d.  The reason to do the upgrade at this point is for
improved Python 3 support.

As part of this upgrade we need to update moveconfig.py and
genboardscfg.py the current API.  This is:
- Change "kconfiglib.Config" calls to "kconfiglib.Kconfig"
- Change get_symbol() calls to syms.get().
- Change get_value() to str_value.

Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2019-10-08 08:37:29 -04:00
Markus Klotzbuecher
b237d358b4 moveconfig: expand simple expressions
Add support for expanding simple expressions and sizes such as
"(4 * 1024)", "(512 << 10)" or "(SZ_256K)".

This can help to significantly reduce the number of "suspicious"
moves, such as

 'CONFIG_ENV_SIZE="(64 << 10)"' was removed by savedefconfig.

If the expansion fails, it falls back to the original string.

Signed-off-by: Markus Klotzbuecher <markus.klotzbuecher@kistler.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Heiko Schocher <hs@denx.de>
2019-07-09 07:00:04 +02:00
Chris Packham
4d9dbb1fbb moveconfig: add a second pass for empty #if/#endif blocks
Moveconfig already attempts to remove empty #if/#endif blocks when there
is a matching CONFIG_ being moved. Add a second pass which covers files
without a match.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
2019-02-09 07:50:54 -05:00
Tom Rini
83d290c56f 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>
2018-05-07 09:34:12 -04:00
Chris Packham
ce3ba458a8 moveconfig: fix error message in do_autoconf()
Move the % arch outside the double quote so that the missing toolchain
message is displayed correctly.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
2017-10-15 18:13:13 +09:00
Ulf Magnusson
4e1102f6de kconfiglib: update with 'imply' support
Corresponds to 375506d (File writing nit) from upstream
(https://github.com/ulfalizer/Kconfiglib).

Adds proper 'imply' support and fixes a few minor issues, one of which
previously triggered the following weird warning:

  configs/taurus_defconfig: /tmp/tmpisI45S:6: warning: assignment to SPL_LDSCRIPT changes mode of containing choice from "arch/$(ARCH)/cpu/u-boot-spl.lds" to "y"

The change in 8639f69 (genconfig.py: Print defconfig next to warnings)
was reapplied.

tools/moveconfig.py previously depended on a hack that merged 'select's
with 'imply's. It was modified to look at the union of
Symbol.get_selected_symbols() and Symbol.get_implied_symbols(), which
should give the same behavior.

tools/genboardscfg.py was verified to produce identical board.cfg's
before and after the change.

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
2017-09-29 14:07:54 -04:00
Simon Glass
c79d18c4b4 moveconfig: Use fd.write() instead of print >>
Adjust this code so that it can work with Python 2 and 3.

Fixes: d73fcb1 (moveconfig: Support building a simple config database)
Reported-by: Chris Packham <judge.packham@gmail.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2017-09-11 21:43:58 -06:00
Simon Glass
6821a7457c RFC: moveconfig: Use toolchains from buildman
It is annoying to have to set up and maintain two sets of toolchains, one
for buildman and one for moveconfig.

Adjust moveconfig to make use to buildman's toolchains. This should make
things easier.

One missing feature is the ability to specify the toolchain on the command
line with a special environment variable, e.g. CROSS_COMPILE_ARM. I'm not
sure if that is useful, but if it is it could be implemented in buildman.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
2017-07-22 22:22:46 -04:00
Simon Glass
dee36c74ea moveconfig: Tidy up imply flag parsing
Add an option to specify 'all' to enable all flags. Also print an error
if an unrecognised flag is used. At present it just prints usage
information which is not very helpful.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-22 22:22:46 -04:00
Simon Glass
cb008830aa moveconfig: Allow automatic location and adding of 'imply'
By using a Kconfig parser we can find the location of each option in the
Kconfig tree. Using the information from the database we can then
automatically add an 'imply' option into the right place if requested by
the user.

Add a -a option to support adding 'imply' options. Display the location of
any existing 'imply' option so that progress can be examined. Add a -A
option to hide any existing 'imply' options so that already-completed
additions need not be considered further.

Also add documentation for this feature.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:20 -06:00
Simon Glass
9b2a2e87d2 moveconfig: Allow control of which implying configs are shown
Sometimes it is useful to display CONFIG_TARGET or CONFIG_CMD configs. Add
an option to control this.

Also we generally ignore implying configs which affect fewer than 5
boards. But sometimes it is useful to show those those, so add an option
that reduces the minimum to two.

ERRATUM configs are never useful for implying things, so ignore those.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:20 -06:00
Simon Glass
2ddd85dc34 moveconfig: Allow piping in 'git show --stat' output
It is useful to be able to process only a subset of boards to save time.
Often that subset is defined by the defconfig files in a git commit. This
change allows things like:

   # Build the database
   ./tools.moveconfig.py -b

   # Find some implying configs
   ./tools/moveconfig.py -i CONFIG_X

   # Add some 'imply' statements to Kconfig files
   ./tools/moveconfig.py -i CONFIG_X -a CONFIG_A,CONFIG_B

   # Reprocess the defconfig files to see if we can drop some changes
   git show --stat | ./tools/moveconfig.py -s -d -

   # Update the commit, with fewer defconfig changes
   gii commit -au

Where the commit contains defconfig files, this will reprocess them to
take account of the imply statements that you added.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:20 -06:00
Simon Glass
99b66605f0 moveconfig: Support looking for implied CONFIG options
Some CONFIG options can be implied by others and this can help to reduce
the size of the defconfig files. For example, CONFIG_X86 implies
CONFIG_CMD_IRQ, so we can put 'imply CMD_IRQ' under 'config X86' and
all x86 boards will have that option, avoiding adding CONFIG_CMD_IRQ to
each of the x86 defconfig files.

Add a -i option which searches for such options.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
2017-07-11 10:08:19 -06:00
Simon Glass
d73fcb12e2 moveconfig: Support building a simple config database
Add a -b option which scans all the defconfigs and builds a database of
all the CONFIG options used by each. This is useful for querying later.

At present this only works with the separate -b option, which does not
move any configs. It would be possible to adjust the script to build the
database automatically when moving configs, but this might not be useful
as the database does not change that often.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:19 -06:00
Simon Glass
f3b8e6470c moveconfig: Add a constant for auto.conf
This filename is used a few times. Move it to a constant before adding
further uses.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:19 -06:00
Simon Glass
ddf91c6423 moveconfig: Tidy up the documentation and add hints
The newest clean-up features are not mentioned in the docs. Fix this and
add a few hints for particular workflows that are hopefully helpful.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:19 -06:00
Simon Glass
ee4e61bda4 moveconfig: Allow reading the defconfig list from stdin
Support passes in a defconfig filename of '-' to read the list from stdin
instead of from a file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:19 -06:00
Simon Glass
25f978cb1c moveconfig: Support providing a path to the defconfig files
It is convenient to provide the full patch to the defconfig files in some
situations, e.g. when the file was generated by a shell command (e.g.
'ls configs/zynq*').

Add support for this, and move the globbing code into a function with its
own documentation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-11 10:08:19 -06:00
Andy Shevchenko
daab59ac05 avr32: Retire AVR32 for good
AVR32 is gone. It's already more than two years for no support in Buildroot,
even longer there is no support in GCC (last version is heavily patched 4.2.4).

Linux kernel v4.12 got rid of it (and v4.11 didn't build successfully).

There is no good point to keep this support in U-Boot either.

Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-07-06 16:17:19 -04:00