aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc/main.py
AgeCommit message (Collapse)AuthorFilesLines
2023-03-08dtoc: Move the main code into a functionSimon Glass1-48/+52
Put this code into a function so it is easy for it be run when packaged. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08dtoc: Hide the test options unless test code is availableSimon Glass1-6/+13
It doesn't make much sense to expose tests when dtoc is running outside of the U-Boot git checkout. Hide the option in this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Move library functions into a library directorySimon Glass1-2/+3
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>
2022-06-28patman: test_util: Use unittest text runner to print test resultsAlper Nebi Yasak1-5/+4
The python tools' test utilities handle printing test results, but the output is quite bare compared to an ordinary unittest run. Delegate printing the results to a unittest text runner, which gives us niceties like clear separation between each test's result and how long it took to run the test suite. Unfortunately it does not print info for skipped tests by default, but this can be handled later by a custom test result subclass. It also does not print the tool name; manually print a heading that includes the toolname so that the outputs of each tool's tests are distinguishable in the CI output. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in test_util.pySimon Glass1-3/+3
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-08patman: Update test_util to run doc testsSimon Glass1-1/+1
At present this function does not run the doctests. Allow the caller to pass these modules in as strings. Update patman to use this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21dtoc: Convert to use ArgumentParserSimon Glass1-24/+27
Use this parser instead of OptionParser, which is deprecated. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-03-22dtoc: Add an option for device instantiationSimon Glass1-1/+3
Add an option to instantiate devices at build time. For now this just parses the option and sets up a few parameters. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Support tracking the phase of U-BootSimon Glass1-1/+4
U-Boot operates in several phases, typically TPL, SPL and U-Boot proper. The latter does not use dtoc. In some rare cases different drivers are used for two phases. For example, in TPL it may not be necessary to use the full PCI subsystem, so a simple driver can be used instead. This works in the build system simply by compiling in one driver or the other (e.g. PCI driver + uclass for SPL; simple_bus for TPL). But dtoc has no way of knowing which code is compiled in for which phase, since it does not inspect Makefiles or dependency graphs. So to make this work for dtoc, we need to be able to explicitly mark drivers with their phase. This is done by adding an empty macro to the driver. Add support for this in dtoc. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-22dtoc: Save scan information across test runsSimon Glass1-0/+2
At present most of the tests scan the U-Boot source tree as part of their run. This information does not change across tests, so we can save time by remembering it. Add a way to set up this information and use it for each test, taking a copy first, so as not to mess up the original. This reduces the run time from about 1.6 seconds to 1.5 seconds on my machine. For code coverage (which cannot run in parallel), it reduces from 33 seconds to 5. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dtoc: Move src_scan tests to a separate fileSimon Glass1-2/+3
Move the tests related to scanning into their own class, updating them to avoid using dtb_platdata as a pass-through. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dtoc: Run tests using test_utilSimon Glass1-21/+10
Use the standard function for running tests and reported results. This allows the tests to run in parallel, which is a significant speed-up on most machines (e.g. 4.5 seconds -> 1.5s on mine). Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dtoc: Add an 'all' commandSimon Glass1-5/+1
With upcoming changes, dtoc will output several files for different of-platdata components. Add a way to output all ava!ilable files at once ('all'), to the appropriate directories, without needing to specify each one invidually. This puts the commands in alphabetical order, so update the tests accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dtoc: Allow providing a directory to write files toSimon Glass1-1/+6
At present dtoc writes only a single file on each invocation. U-Boot writes the two files it needs by separate invocations of dtoc. Since dtoc now scans all U-Boot driver source, this is fairly slow (about 1 second per file). It would be better if dtoc could write all the files at once. In preparation for this, add a way to specify an output directory for the files. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-05dtoc: Use None to mean stdoutSimon Glass1-1/+1
At present dtoc uses '-' internally to mean that output should go to stdout. This is not necessary and None is more convenient. Update it. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Tidy up sys.path changesSimon Glass1-1/+0
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-26patman: Move to absolute importsSimon Glass1-2/+3
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>
2020-04-26dtoc: Rename the main moduleSimon Glass1-0/+114
Python does not like the module name being the same as the module directory. To allow dtoc modules to be used from other tools, rename it. Signed-off-by: Simon Glass <sjg@chromium.org>