tools: Support uploading tools to PyPi for use with pip
v2 cover tools: Support uploading tools to PyPi for use with pip
Some of the tools in U-Boot are useful beyond just U-Boot. For example, patman can be used to work with Linux and other projects which use mailing lists (and patchwork) for patch submissions. Binman can be used to package firmware for any project, even though it is heavily slanted towards U-Boot so far.
While patman has a setup script which is easy to use, binman is a little more complicated, since it has dependencies, in particular pylibfdt
It would be better if we could put all the tools on PyPi.
This series adds a script for uploading tools. It makes it easier to update PyPi from time to time, when new features appear.
U-Boot uses tools/patman as a common library of Python functions. For this to work with PyPi it is easier to split these into a separate library, used by patman as well. This series creates a new 'u_boot_pylib' package for this purpose.
Unfortunately, the U-Boot version of concurrencytest has some local patches. To avoid dependency issues it seems better to revert these and rely on the upstream package[1], although note that it is not actually installed.
[1] Which unfortunately may be dead but perhaps we could request a new maintainer?
Changes in v2:
- Add a patch to hide the test options unless test code is available
- Add new patch to avoid importing test_checkpatch before it is needed
- Add new patch to use importlib to find the help
- Add patch to fix use of a type as a variable
- Add patch to split out the main code into a function
- Drop test files
- Fix removable of the /tmp dir
- Quite a few updates to make things work with the new names
- Rename the package to patch-manager
- Update the cover letter
Simon Glass (24):
binman: Avoid unwanted output in testFitFirmwareLoadables() Revert "patman: test_util: Print test stdout/stderr within test
summaries"
Remove concurrencytest
patman: Move library functions into a library directory
script: Add a script to build a PyPi package
patman: Add support for building a u_boot_tools PyPi package
patman: Avoid importing test_checkpatch before it is needed
patman: Add support for building a patman PyPi package
buildman: Move the main code into a function
buildman: Hide the test options unless test code is available
buildman: Fix use of a type as a variable
buildman: Use importlib to find the help
buildman: Add support for building a buildman PyPi package
dtoc: Hide the test options unless test code is available
dtoc: Move the main code into a function
dtoc: Use pathlib to find the test directory
dtoc: Add support for building a dtoc PyPi package
binman: Move the main code into a function
binman: Hide the 'test' command unless test code is available
binman: Use importlib to find the help
binman: Add support for building a binmanu PyPi package
test: Add concurrencytest to the requirements
doc: Add notes on how to install patman and binman
CI: Add a check for building tools for PyPi
.azure-pipelines.yml | 10 +
.gitlab-ci.yml | 6 +
Makefile | 22 +-
scripts/event_dump.py | 2 +-
scripts/make_pip.sh | 117 ++++++
test/py/requirements.txt | 1 +
test/run | 1 +
tools/binman/binman.rst | 13 +
tools/binman/bintool.py | 8 +-
tools/binman/bintool_test.py | 8 +-
tools/binman/btool/lz4.py | 2 +-
tools/binman/btool/lzma_alone.py | 2 +-
tools/binman/cbfs_util.py | 4 +-
tools/binman/cbfs_util_test.py | 4 +-
tools/binman/cmdline.py | 34 +-
tools/binman/control.py | 12 +-
tools/binman/elf.py | 6 +-
tools/binman/elf_test.py | 8 +-
tools/binman/entry.py | 6 +-
tools/binman/entry_test.py | 2 +-
tools/binman/etype/_testing.py | 2 +-
tools/binman/etype/atf_fip.py | 2 +-
tools/binman/etype/blob.py | 4 +-
tools/binman/etype/blob_ext.py | 4 +-
tools/binman/etype/blob_ext_list.py | 4 +-
tools/binman/etype/fdtmap.py | 4 +-
tools/binman/etype/files.py | 2 +-
tools/binman/etype/fill.py | 2 +-
tools/binman/etype/fit.py | 2 +-
tools/binman/etype/fmap.py | 6 +-
tools/binman/etype/gbb.py | 4 +-
tools/binman/etype/intel_ifwi.py | 2 +-
tools/binman/etype/mkimage.py | 2 +-
tools/binman/etype/null.py | 2 +-
tools/binman/etype/pre_load.py | 2 +-
tools/binman/etype/section.py | 6 +-
tools/binman/etype/text.py | 2 +-
tools/binman/etype/u_boot_dtb_with_ucode.py | 2 +-
tools/binman/etype/u_boot_elf.py | 2 +-
tools/binman/etype/u_boot_env.py | 2 +-
tools/binman/etype/u_boot_spl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_spl_expanded.py | 2 +-
tools/binman/etype/u_boot_tpl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_tpl_expanded.py | 2 +-
.../binman/etype/u_boot_tpl_with_ucode_ptr.py | 4 +-
tools/binman/etype/u_boot_ucode.py | 2 +-
tools/binman/etype/u_boot_vpl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_vpl_expanded.py | 2 +-
tools/binman/etype/u_boot_with_ucode_ptr.py | 4 +-
tools/binman/etype/vblock.py | 2 +-
tools/binman/fdt_test.py | 2 +-
tools/binman/fip_util.py | 4 +-
tools/binman/fip_util_test.py | 4 +-
tools/binman/fmap_util.py | 2 +-
tools/binman/ftest.py | 17 +-
tools/binman/image.py | 4 +-
tools/binman/image_test.py | 2 +-
tools/binman/main.py | 19 +-
tools/binman/pyproject.toml | 29 ++
tools/binman/state.py | 4 +-
tools/buildman/builder.py | 6 +-
tools/buildman/builderthread.py | 2 +-
tools/buildman/cfgutil.py | 2 +-
tools/buildman/cmdline.py | 14 +-
tools/buildman/control.py | 18 +-
tools/buildman/func_test.py | 8 +-
tools/buildman/main.py | 31 +-
tools/buildman/pyproject.toml | 29 ++
tools/buildman/test.py | 8 +-
tools/buildman/toolchain.py | 6 +-
tools/concurrencytest/.gitignore | 1 -
tools/concurrencytest/README.md | 74 ----
tools/concurrencytest/__init__.py | 0
tools/concurrencytest/concurrencytest.py | 221 ------------
tools/dtoc/README.rst | 15 +
tools/dtoc/fdt.py | 2 +-
tools/dtoc/fdt_util.py | 4 +-
tools/dtoc/main.py | 110 +++---
tools/dtoc/pyproject.toml | 26 ++
tools/dtoc/test_dtoc.py | 10 +-
tools/dtoc/test_fdt.py | 7 +-
tools/dtoc/test_src_scan.py | 4 +-
tools/patman/__init__.py | 7 +-
tools/patman/__main__.py | 10 +-
tools/patman/checkpatch.py | 4 +-
tools/patman/control.py | 2 +-
tools/patman/func_test.py | 6 +-
tools/patman/get_maintainer.py | 2 +-
tools/patman/gitutil.py | 4 +-
tools/patman/patchstream.py | 2 +-
tools/patman/patman.rst | 12 +
tools/patman/pyproject.toml | 29 ++
tools/patman/series.py | 4 +-
tools/patman/status.py | 4 +-
tools/patman/test_settings.py | 2 +-
tools/rmboard.py | 2 +-
tools/u_boot_pylib/LICENSE | 339 ++++++++++++++++++
tools/u_boot_pylib/README.rst | 15 +
tools/u_boot_pylib/__init__.py | 4 +
tools/u_boot_pylib/__main__.py | 23 ++
tools/{patman => u_boot_pylib}/command.py | 2 +-
.../cros_subprocess.py | 0
tools/u_boot_pylib/pyproject.toml | 22 ++
tools/{patman => u_boot_pylib}/terminal.py | 0
tools/{patman => u_boot_pylib}/test_util.py | 39 +-
tools/{patman => u_boot_pylib}/tools.py | 4 +-
tools/{patman => u_boot_pylib}/tout.py | 2 +-
tools/u_boot_pylib/u_boot_pylib | 1 +
108 files changed, 1000 insertions(+), 576 deletions(-)
create mode 100755 scripts/make_pip.sh
create mode 100644 tools/binman/pyproject.toml
create mode 100644 tools/buildman/pyproject.toml
delete mode 100644 tools/concurrencytest/.gitignore
delete mode 100644 tools/concurrencytest/README.md
delete mode 100644 tools/concurrencytest/__init__.py
delete mode 100644 tools/concurrencytest/concurrencytest.py
create mode 100644 tools/dtoc/README.rst
create mode 100644 tools/dtoc/pyproject.toml
create mode 100644 tools/patman/pyproject.toml
create mode 100644 tools/u_boot_pylib/LICENSE
create mode 100644 tools/u_boot_pylib/README.rst
create mode 100644 tools/u_boot_pylib/__init__.py
create mode 100755 tools/u_boot_pylib/__main__.py
rename tools/{patman => u_boot_pylib}/command.py (99%)
rename tools/{patman => u_boot_pylib}/cros_subprocess.py (100%)
create mode 100644 tools/u_boot_pylib/pyproject.toml
rename tools/{patman => u_boot_pylib}/terminal.py (100%)
rename tools/{patman => u_boot_pylib}/test_util.py (85%)
rename tools/{patman => u_boot_pylib}/tools.py (99%)
rename tools/{patman => u_boot_pylib}/tout.py (99%)
create mode 120000 tools/u_boot_pylib/u_boot_pylibSignature · 1 line
2.39.2.637.g21b0678d19-goog
PATCH v2 1/24 binman: Avoid unwanted output in testFitFirmwareLoadables()
This prints a message about the missing tee-os generated by the test. This is confusing, so suppress it.
---
(no changes since v1)
tools/binman/ftest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/binman/ftest.py +5 -4
@@ -6353,10 +6353,11 @@ fdt fdtmap Extract the devicetree blob from the fdtmap 'tee-os-path': 'missing.bin', } test_subdir = os.path.join(self._indir, TEST_FDT_SUBDIR) - data = self._DoReadFileDtb( - '276_fit_firmware_loadables.dts', - entry_args=entry_args, - extra_indirs=[test_subdir])[0] + with test_util.capture_sys_output() as (stdout, stderr): + data = self._DoReadFileDtb( + '276_fit_firmware_loadables.dts', + entry_args=entry_args, + extra_indirs=[test_subdir])[0] dtb = fdt.Fdt.FromData(data) dtb.Scan()
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 01/24] binman: Avoid unwanted output in testFitFirmwareLoadables()
This prints a message about the missing tee-os generated by the test. This is confusing, so suppress it.
---
(no changes since v1)
tools/binman/ftest.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 2/24 Revert "patman: test_util: Print test stdout/stderr within test summaries"
In reply to Simon GlassUnfortunately this adds a new feature to concurrencytest and it has not made it upstream to the project[1].
Drop it for now so we can use the upstream module. Once it is applied we can bring this functionality back.
[1] https://github.com/cgoldberg/concurrencytest
This reverts commit ebcaafcded40da8ae6cb4234c2ba9901c7bee644.
---
(no changes since v1)
tools/concurrencytest/concurrencytest.py | 83 +----------------------- tools/patman/test_util.py | 33 +--------- 2 files changed, 4 insertions(+), 112 deletions(-)
tools/concurrencytest/concurrencytest.py +3 -80
@@ -31,7 +31,6 @@ from subunit import ProtocolTestCase, TestProtocolClient from subunit.test_results import AutoTimingTestResultDecorator from testtools import ConcurrentTestSuite, iterate_tests -from testtools.content import TracebackContent, text_content _all__ = [
@@ -44,81 +43,11 @@ _all__ = [ CPU_COUNT = cpu_count() -class BufferingTestProtocolClient(TestProtocolClient): - """A TestProtocolClient which can buffer the test outputs - - This class captures the stdout and stderr output streams of the - tests as it runs them, and includes the output texts in the subunit - stream as additional details. - - Args: - stream: A file-like object to write a subunit stream to - buffer (bool): True to capture test stdout/stderr outputs and - include them in the test details - """ - def __init__(self, stream, buffer=True): - super().__init__(stream) - self.buffer = buffer - - def _addOutcome(self, outcome, test, error=None, details=None, - error_permitted=True): - """Report a test outcome to the subunit stream - - The parent class uses this function as a common implementation - for various methods that report successes, errors, failures, etc. - - This version automatically upgrades the error tracebacks to the - new 'details' format by wrapping them in a Content object, so - that we can include the captured test output in the test result - details. - - Args: - outcome: A string describing the outcome - used as the - event name in the subunit stream. - test: The test case whose outcome is to be reported - error: Standard unittest positional argument form - an - exc_info tuple. - details: New Testing-in-python drafted API; a dict from - string to subunit.Content objects. - error_permitted: If True then one and only one of error or - details must be supplied. If False then error must not - be supplied and details is still optional. - """ - if details is None: - details = {} - - # Parent will raise an exception if error_permitted is False but - # error is not None. We want that exception in that case, so - # don't touch error when error_permitted is explicitly False. - if error_permitted and error is not None: - # Parent class prefers error over details - details['traceback'] = TracebackContent(error, test) - error_permitted = False - error = None - - if self.buffer: - stdout = sys.stdout.getvalue() - if stdout: - details['stdout'] = text_content(stdout) - - stderr = sys.stderr.getvalue() - if stderr: - details['stderr'] = text_content(stderr) - - return super()._addOutcome(outcome, test, error=error, - details=details, error_permitted=error_permitted) - - -def fork_for_tests(concurrency_num=CPU_COUNT, buffer=False): +def fork_for_tests(concurrency_num=CPU_COUNT): """Implementation of `make_tests` used to construct `ConcurrentTestSuite`. :param concurrency_num: number of processes to use. """ - if buffer: - test_protocol_client_class = BufferingTestProtocolClient - else: - test_protocol_client_class = TestProtocolClient - def do_fork(suite): """Take suite and start up multiple runners by forking (Unix only).
@@ -147,7 +76,7 @@ def fork_for_tests(concurrency_num=CPU_COUNT, buffer=False): # child actually gets keystrokes for pdb etc). sys.stdin.close() subunit_result = AutoTimingTestResultDecorator( - test_protocol_client_class(stream) + TestProtocolClient(stream) ) process_suite.run(subunit_result) except:
@@ -164,13 +93,7 @@ def fork_for_tests(concurrency_num=CPU_COUNT, buffer=False): else: os.close(c2pwrite) stream = os.fdopen(c2pread, 'rb') - # If we don't pass the second argument here, it defaults - # to sys.stdout.buffer down the line. But if we don't - # pass it *now*, it may be resolved after sys.stdout is - # replaced with a StringIO (to capture tests' outputs) - # which doesn't have a buffer attribute and can end up - # occasionally causing a 'broken-runner' error. - test = ProtocolTestCase(stream, sys.stdout.buffer) + test = ProtocolTestCase(stream) result.append(test) return result return do_fork
tools/patman/test_util.py +1 -32
@@ -15,7 +15,6 @@ from patman import command from io import StringIO -buffer_outputs = True use_concurrent = True try: from concurrencytest.concurrencytest import ConcurrentTestSuite
@@ -120,7 +119,6 @@ class FullTextTestResult(unittest.TextTestResult): 0: Print nothing 1: Print a dot per test 2: Print test names - 3: Print test names, and buffered outputs for failing tests """ def __init__(self, stream, descriptions, verbosity): self.verbosity = verbosity
@@ -140,39 +138,12 @@ class FullTextTestResult(unittest.TextTestResult): self.printErrorList('XFAIL', self.expectedFailures) self.printErrorList('XPASS', unexpected_successes) - def addError(self, test, err): - """Called when an error has occurred.""" - super().addError(test, err) - self._mirrorOutput &= self.verbosity >= 3 - - def addFailure(self, test, err): - """Called when a test has failed.""" - super().addFailure(test, err) - self._mirrorOutput &= self.verbosity >= 3 - - def addSubTest(self, test, subtest, err): - """Called at the end of a subtest.""" - super().addSubTest(test, subtest, err) - self._mirrorOutput &= self.verbosity >= 3 - - def addSuccess(self, test): - """Called when a test has completed successfully""" - super().addSuccess(test) - # Don't print stdout/stderr for successful tests - self._mirrorOutput = False - def addSkip(self, test, reason): """Called when a test is skipped.""" # Add empty line to keep spacing consistent with other results if not reason.endswith('\n'): reason += '\n' super().addSkip(test, reason) - self._mirrorOutput &= self.verbosity >= 3 - - def addExpectedFailure(self, test, err): - """Called when an expected failure/error occurred.""" - super().addExpectedFailure(test, err) - self._mirrorOutput &= self.verbosity >= 3 def run_test_suites(toolname, debug, verbosity, test_preserve_dirs, processes,
@@ -208,14 +179,12 @@ def run_test_suites(toolname, debug, verbosity, test_preserve_dirs, processes, runner = unittest.TextTestRunner( stream=sys.stdout, verbosity=(1 if verbosity is None else verbosity), - buffer=False if test_name else buffer_outputs, resultclass=FullTextTestResult, ) if use_concurrent and processes != 1: suite = ConcurrentTestSuite(suite, - fork_for_tests(processes or multiprocessing.cpu_count(), - buffer=False if test_name else buffer_outputs)) + fork_for_tests(processes or multiprocessing.cpu_count())) for module in class_and_module_list: if isinstance(module, str) and (not test_name or test_name == module):
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 02/24] Revert "patman: test_util: Print test stdout/stderr within test summaries"
Unfortunately this adds a new feature to concurrencytest and it has not made it upstream to the project[1].
Drop it for now so we can use the upstream module. Once it is applied we can bring this functionality back.
[1] https://github.com/cgoldberg/concurrencytest
This reverts commit ebcaafcded40da8ae6cb4234c2ba9901c7bee644.
---
(no changes since v1)
tools/concurrencytest/concurrencytest.py | 83 +----------------------- tools/patman/test_util.py | 33 +--------- 2 files changed, 4 insertions(+), 112 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 3/24 Remove concurrencytest
In reply to Simon GlassWhile our version is better, it is tricky to use it when we are trying to package things with pip. Drop it.
Somewhat reduced functionality is provided by the upstream version[1], along with a rather annoying message each time it is used[2] [3].
[1] pip install concurrencytest
[2] https://github.com/cgoldberg/concurrencytest/issues/12
[3] https://github.com/cgoldberg/concurrencytest/pull/14
---
(no changes since v1)
tools/concurrencytest/.gitignore | 1 - tools/concurrencytest/README.md | 74 ------------ tools/concurrencytest/__init__.py | 0 tools/concurrencytest/concurrencytest.py | 144 ----------------------- tools/patman/test_util.py | 4 +- 5 files changed, 2 insertions(+), 221 deletions(-) delete mode 100644 tools/concurrencytest/.gitignore delete mode 100644 tools/concurrencytest/README.md delete mode 100644 tools/concurrencytest/__init__.py delete mode 100644 tools/concurrencytest/concurrencytest.py
tools/concurrencytest/.gitignore deleted +0 -1
@@ -1 +0,0 @@ -*.pyc
tools/concurrencytest/README.md deleted +0 -74
74 lines not on this page · raw message
tools/concurrencytest/__init__.py deleted +0 -0
tools/concurrencytest/concurrencytest.py deleted +0 -144
144 lines not on this page · raw message
tools/patman/test_util.py +2 -2
@@ -17,8 +17,8 @@ from io import StringIO use_concurrent = True try: - from concurrencytest.concurrencytest import ConcurrentTestSuite - from concurrencytest.concurrencytest import fork_for_tests + from concurrencytest import ConcurrentTestSuite + from concurrencytest import fork_for_tests except: use_concurrent = False
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 03/24] Remove concurrencytest
While our version is better, it is tricky to use it when we are trying to package things with pip. Drop it.
Somewhat reduced functionality is provided by the upstream version[1], along with a rather annoying message each time it is used[2] [3].
[1] pip install concurrencytest
[2] https://github.com/cgoldberg/concurrencytest/issues/12
[3] https://github.com/cgoldberg/concurrencytest/pull/14
---
(no changes since v1)
tools/concurrencytest/.gitignore | 1 - tools/concurrencytest/README.md | 74 ------------ tools/concurrencytest/__init__.py | 0 tools/concurrencytest/concurrencytest.py | 144 ----------------------- tools/patman/test_util.py | 4 +- 5 files changed, 2 insertions(+), 221 deletions(-) delete mode 100644 tools/concurrencytest/.gitignore delete mode 100644 tools/concurrencytest/README.md delete mode 100644 tools/concurrencytest/__init__.py delete mode 100644 tools/concurrencytest/concurrencytest.py
Applied to u-boot-dm/next, thanks!
PATCH v2 4/24 patman: Move library functions into a library directory
In reply to Simon GlassThe 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.
---
(no changes since v1)
scripts/event_dump.py | 2 +-
test/run | 1 +
tools/binman/bintool.py | 8 +++----
tools/binman/bintool_test.py | 8 +++----
tools/binman/btool/lz4.py | 2 +-
tools/binman/btool/lzma_alone.py | 2 +-
tools/binman/cbfs_util.py | 4 ++--
tools/binman/cbfs_util_test.py | 4 ++--
tools/binman/control.py | 6 ++---
tools/binman/elf.py | 6 ++---
tools/binman/elf_test.py | 8 +++----
tools/binman/entry.py | 6 ++---
tools/binman/entry_test.py | 2 +-
tools/binman/etype/_testing.py | 2 +-
tools/binman/etype/atf_fip.py | 2 +-
tools/binman/etype/blob.py | 4 ++--
tools/binman/etype/blob_ext.py | 4 ++--
tools/binman/etype/blob_ext_list.py | 4 ++--
tools/binman/etype/fdtmap.py | 4 ++--
tools/binman/etype/files.py | 2 +-
tools/binman/etype/fill.py | 2 +-
tools/binman/etype/fit.py | 2 +-
tools/binman/etype/fmap.py | 6 ++---
tools/binman/etype/gbb.py | 4 ++--
tools/binman/etype/intel_ifwi.py | 2 +-
tools/binman/etype/mkimage.py | 2 +-
tools/binman/etype/null.py | 2 +-
tools/binman/etype/pre_load.py | 2 +-
tools/binman/etype/section.py | 6 ++---
tools/binman/etype/text.py | 2 +-
tools/binman/etype/u_boot_dtb_with_ucode.py | 2 +-
tools/binman/etype/u_boot_elf.py | 2 +-
tools/binman/etype/u_boot_env.py | 2 +-
tools/binman/etype/u_boot_spl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_spl_expanded.py | 2 +-
tools/binman/etype/u_boot_tpl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_tpl_expanded.py | 2 +-
.../binman/etype/u_boot_tpl_with_ucode_ptr.py | 4 ++--
tools/binman/etype/u_boot_ucode.py | 2 +-
tools/binman/etype/u_boot_vpl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_vpl_expanded.py | 2 +-
tools/binman/etype/u_boot_with_ucode_ptr.py | 4 ++--
tools/binman/etype/vblock.py | 2 +-
tools/binman/fdt_test.py | 2 +-
tools/binman/fip_util.py | 4 ++--
tools/binman/fip_util_test.py | 4 ++--
tools/binman/fmap_util.py | 2 +-
tools/binman/ftest.py | 8 +++----
tools/binman/image.py | 4 ++--
tools/binman/image_test.py | 2 +-
tools/binman/main.py | 7 +++---
tools/binman/state.py | 4 ++--
tools/buildman/builder.py | 6 ++---
tools/buildman/builderthread.py | 2 +-
tools/buildman/cfgutil.py | 2 +-
tools/buildman/control.py | 8 +++----
tools/buildman/func_test.py | 8 +++----
tools/buildman/main.py | 4 ++--
tools/buildman/test.py | 8 +++----
tools/buildman/toolchain.py | 6 ++---
tools/dtoc/fdt.py | 2 +-
tools/dtoc/fdt_util.py | 4 ++--
tools/dtoc/main.py | 5 ++--
tools/dtoc/test_dtoc.py | 4 ++--
tools/dtoc/test_fdt.py | 7 +++---
tools/dtoc/test_src_scan.py | 4 ++--
tools/patman/__init__.py | 7 +++---
tools/patman/__main__.py | 8 +++----
tools/patman/checkpatch.py | 4 ++--
tools/patman/control.py | 2 +-
tools/patman/func_test.py | 6 ++---
tools/patman/get_maintainer.py | 2 +-
tools/patman/gitutil.py | 4 ++--
tools/patman/patchstream.py | 2 +-
tools/patman/series.py | 4 ++--
tools/patman/status.py | 4 ++--
tools/patman/test_settings.py | 2 +-
tools/rmboard.py | 2 +-
tools/u_boot_pylib/__init__.py | 4 ++++
tools/u_boot_pylib/__main__.py | 23 +++++++++++++++++++
tools/{patman => u_boot_pylib}/command.py | 2 +-
.../cros_subprocess.py | 0
tools/{patman => u_boot_pylib}/terminal.py | 0
tools/{patman => u_boot_pylib}/test_util.py | 2 +-
tools/{patman => u_boot_pylib}/tools.py | 4 ++--
tools/{patman => u_boot_pylib}/tout.py | 2 +-
tools/u_boot_pylib/u_boot_pylib | 1 +
87 files changed, 182 insertions(+), 151 deletions(-)
create mode 100644 tools/u_boot_pylib/__init__.py
create mode 100755 tools/u_boot_pylib/__main__.py
rename tools/{patman => u_boot_pylib}/command.py (99%)
rename tools/{patman => u_boot_pylib}/cros_subprocess.py (100%)
rename tools/{patman => u_boot_pylib}/terminal.py (100%)
rename tools/{patman => u_boot_pylib}/test_util.py (99%)
rename tools/{patman => u_boot_pylib}/tools.py (99%)
rename tools/{patman => u_boot_pylib}/tout.py (99%)
create mode 120000 tools/u_boot_pylib/u_boot_pylibscripts/event_dump.py +1 -1
@@ -15,7 +15,7 @@ src_path = os.path.dirname(our_path) sys.path.insert(1, os.path.join(our_path, '../tools')) from binman import elf -from patman import tools +from u_boot_pylib import tools # A typical symbol looks like this: # _u_boot_list_2_evspy_info_2_EVT_MISC_INIT_F_3_sandbox_misc_init_f
test/run +1 -0
@@ -76,6 +76,7 @@ TOOLS_DIR=build-sandbox_spl/tools run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test run_test "patman" ./tools/patman/patman test +run_test "u_boot_pylib" ./tools/u_boot_pylib/u_boot_pylib run_test "buildman" ./tools/buildman/buildman -t ${skip} run_test "fdt" ./tools/dtoc/test_fdt -t
tools/binman/bintool.py +4 -4
@@ -18,10 +18,10 @@ import shutil import tempfile import urllib.error -from patman import command -from patman import terminal -from patman import tools -from patman import tout +from u_boot_pylib import command +from u_boot_pylib import terminal +from u_boot_pylib import tools +from u_boot_pylib import tout BINMAN_DIR = os.path.dirname(os.path.realpath(__file__))
tools/binman/bintool_test.py +4 -4
@@ -16,10 +16,10 @@ import urllib.error from binman import bintool from binman.bintool import Bintool -from patman import command -from patman import terminal -from patman import test_util -from patman import tools +from u_boot_pylib import command +from u_boot_pylib import terminal +from u_boot_pylib import test_util +from u_boot_pylib import tools # pylint: disable=R0904 class TestBintool(unittest.TestCase):
tools/binman/btool/lz4.py +1 -1
@@ -60,7 +60,7 @@ import re import tempfile from binman import bintool -from patman import tools +from u_boot_pylib import tools # pylint: disable=C0103 class Bintoollz4(bintool.Bintool):
tools/binman/btool/lzma_alone.py +1 -1
@@ -37,7 +37,7 @@ import re import tempfile from binman import bintool -from patman import tools +from u_boot_pylib import tools # pylint: disable=C0103 class Bintoollzma_alone(bintool.Bintool):
tools/binman/cbfs_util.py +2 -2
@@ -22,8 +22,8 @@ import sys from binman import bintool from binman import elf -from patman import command -from patman import tools +from u_boot_pylib import command +from u_boot_pylib import tools # Set to True to enable printing output while working DEBUG = False
tools/binman/cbfs_util_test.py +2 -2
@@ -20,8 +20,8 @@ from binman import bintool from binman import cbfs_util from binman.cbfs_util import CbfsWriter from binman import elf -from patman import test_util -from patman import tools +from u_boot_pylib import test_util +from u_boot_pylib import tools U_BOOT_DATA = b'1234' U_BOOT_DTB_DATA = b'udtb'
tools/binman/control.py +3 -3
@@ -12,14 +12,14 @@ import pkg_resources import re import sys -from patman import tools from binman import bintool from binman import cbfs_util -from patman import command from binman import elf from binman import entry -from patman import tout +from u_boot_pylib import command +from u_boot_pylib import tools +from u_boot_pylib import tout # These are imported if needed since they import libfdt state = None
tools/binman/elf.py +3 -3
@@ -13,9 +13,9 @@ import shutil import struct import tempfile -from patman import command -from patman import tools -from patman import tout +from u_boot_pylib import command +from u_boot_pylib import tools +from u_boot_pylib import tout ELF_TOOLS = True try:
tools/binman/elf_test.py +4 -4
@@ -12,10 +12,10 @@ import tempfile import unittest from binman import elf -from patman import command -from patman import test_util -from patman import tools -from patman import tout +from u_boot_pylib import command +from u_boot_pylib import test_util +from u_boot_pylib import tools +from u_boot_pylib import tout binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
tools/binman/entry.py +3 -3
@@ -14,9 +14,9 @@ import time from binman import bintool from binman import elf from dtoc import fdt_util -from patman import tools -from patman.tools import to_hex, to_hex_size -from patman import tout +from u_boot_pylib import tools +from u_boot_pylib.tools import to_hex, to_hex_size +from u_boot_pylib import tout modules = {}
tools/binman/entry_test.py +1 -1
@@ -14,7 +14,7 @@ from binman import entry from binman.etype.blob import Entry_blob from dtoc import fdt from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class TestEntry(unittest.TestCase): def setUp(self):
tools/binman/etype/_testing.py +1 -1
@@ -9,7 +9,7 @@ from collections import OrderedDict from binman.entry import Entry, EntryArg from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry__testing(Entry):
tools/binman/etype/atf_fip.py +1 -1
@@ -11,7 +11,7 @@ from binman.entry import Entry from binman.etype.section import Entry_section from binman.fip_util import FIP_TYPES, FipReader, FipWriter, UUID_LEN from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_atf_fip(Entry_section): """ARM Trusted Firmware's Firmware Image Package (FIP)
tools/binman/etype/blob.py +2 -2
@@ -8,8 +8,8 @@ from binman.entry import Entry from binman import state from dtoc import fdt_util -from patman import tools -from patman import tout +from u_boot_pylib import tools +from u_boot_pylib import tout class Entry_blob(Entry): """Arbitrary binary blob
tools/binman/etype/blob_ext.py +2 -2
@@ -9,8 +9,8 @@ import os from binman.etype.blob import Entry_blob from dtoc import fdt_util -from patman import tools -from patman import tout +from u_boot_pylib import tools +from u_boot_pylib import tout class Entry_blob_ext(Entry_blob): """Externally built binary blob
tools/binman/etype/blob_ext_list.py +2 -2
@@ -9,8 +9,8 @@ import os from binman.etype.blob import Entry_blob from dtoc import fdt_util -from patman import tools -from patman import tout +from u_boot_pylib import tools +from u_boot_pylib import tout class Entry_blob_ext_list(Entry_blob): """List of externally built binary blobs
tools/binman/etype/fdtmap.py +2 -2
@@ -9,8 +9,8 @@ image. """ from binman.entry import Entry -from patman import tools -from patman import tout +from u_boot_pylib import tools +from u_boot_pylib import tout FDTMAP_MAGIC = b'_FDTMAP_' FDTMAP_HDR_LEN = 16
tools/binman/etype/files.py +1 -1
@@ -11,7 +11,7 @@ import os from binman.etype.section import Entry_section from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools # This is imported if needed state = None
tools/binman/etype/fill.py +1 -1
@@ -5,7 +5,7 @@ from binman.entry import Entry from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_fill(Entry): """An entry which is filled to a particular byte value
tools/binman/etype/fit.py +1 -1
@@ -12,7 +12,7 @@ from binman.etype.section import Entry_section from binman import elf from dtoc import fdt_util from dtoc.fdt import Fdt -from patman import tools +from u_boot_pylib import tools # Supported operations, with the fit,operation property OP_GEN_FDT_NODES, OP_SPLIT_ELF = range(2)
tools/binman/etype/fmap.py +3 -3
@@ -7,9 +7,9 @@ from binman.entry import Entry from binman import fmap_util -from patman import tools -from patman.tools import to_hex_size -from patman import tout +from u_boot_pylib import tools +from u_boot_pylib.tools import to_hex_size +from u_boot_pylib import tout class Entry_fmap(Entry):
tools/binman/etype/gbb.py +2 -2
@@ -8,11 +8,11 @@ from collections import OrderedDict -from patman import command +from u_boot_pylib import command from binman.entry import Entry, EntryArg from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools # Build GBB flags. # (src/platform/vboot_reference/firmware/include/gbb_header.h)
tools/binman/etype/intel_ifwi.py +1 -1
@@ -10,7 +10,7 @@ from collections import OrderedDict from binman.entry import Entry from binman.etype.blob_ext import Entry_blob_ext from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_intel_ifwi(Entry_blob_ext): """Intel Integrated Firmware Image (IFWI) file
tools/binman/etype/mkimage.py +1 -1
@@ -9,7 +9,7 @@ from collections import OrderedDict from binman.entry import Entry from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_mkimage(Entry): """Binary produced by mkimage
tools/binman/etype/null.py +1 -1
@@ -5,7 +5,7 @@ from binman.entry import Entry from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_null(Entry): """An entry which has no contents of its own
tools/binman/etype/pre_load.py +1 -1
@@ -8,7 +8,7 @@ import os import struct from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools from binman.entry import Entry from binman.etype.collection import Entry_collection
tools/binman/etype/section.py +3 -3
@@ -16,9 +16,9 @@ import sys from binman.entry import Entry from binman import state from dtoc import fdt_util -from patman import tools -from patman import tout -from patman.tools import to_hex_size +from u_boot_pylib import tools +from u_boot_pylib import tout +from u_boot_pylib.tools import to_hex_size class Entry_section(Entry):
tools/binman/etype/text.py +1 -1
@@ -7,7 +7,7 @@ from collections import OrderedDict from binman.entry import Entry, EntryArg from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_text(Entry):
tools/binman/etype/u_boot_dtb_with_ucode.py +1 -1
@@ -7,7 +7,7 @@ from binman.entry import Entry from binman.etype.blob_dtb import Entry_blob_dtb -from patman import tools +from u_boot_pylib import tools # This is imported if needed state = None
tools/binman/etype/u_boot_elf.py +1 -1
@@ -9,7 +9,7 @@ from binman.entry import Entry from binman.etype.blob import Entry_blob from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_u_boot_elf(Entry_blob): """U-Boot ELF image
tools/binman/etype/u_boot_env.py +1 -1
@@ -8,7 +8,7 @@ import zlib from binman.etype.blob import Entry_blob from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_u_boot_env(Entry_blob): """An entry which contains a U-Boot environment
tools/binman/etype/u_boot_spl_bss_pad.py +1 -1
@@ -10,7 +10,7 @@ from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob -from patman import tools +from u_boot_pylib import tools class Entry_u_boot_spl_bss_pad(Entry_blob): """U-Boot SPL binary padded with a BSS region
tools/binman/etype/u_boot_spl_expanded.py +1 -1
@@ -5,7 +5,7 @@ # Entry-type module for expanded U-Boot SPL binary # -from patman import tout +from u_boot_pylib import tout from binman import state from binman.etype.blob_phase import Entry_blob_phase
tools/binman/etype/u_boot_tpl_bss_pad.py +1 -1
@@ -10,7 +10,7 @@ from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob -from patman import tools +from u_boot_pylib import tools class Entry_u_boot_tpl_bss_pad(Entry_blob): """U-Boot TPL binary padded with a BSS region
tools/binman/etype/u_boot_tpl_expanded.py +1 -1
@@ -5,7 +5,7 @@ # Entry-type module for expanded U-Boot TPL binary # -from patman import tout +from u_boot_pylib import tout from binman import state from binman.etype.blob_phase import Entry_blob_phase
tools/binman/etype/u_boot_tpl_with_ucode_ptr.py +2 -2
@@ -7,11 +7,11 @@ import struct -from patman import command from binman.entry import Entry from binman.etype.blob import Entry_blob from binman.etype.u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr -from patman import tools +from u_boot_pylib import command +from u_boot_pylib import tools class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr): """U-Boot TPL with embedded microcode pointer
tools/binman/etype/u_boot_ucode.py +1 -1
@@ -7,7 +7,7 @@ from binman.entry import Entry from binman.etype.blob import Entry_blob -from patman import tools +from u_boot_pylib import tools class Entry_u_boot_ucode(Entry_blob): """U-Boot microcode block
tools/binman/etype/u_boot_vpl_bss_pad.py +1 -1
@@ -10,7 +10,7 @@ from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob -from patman import tools +from u_boot_pylib import tools class Entry_u_boot_vpl_bss_pad(Entry_blob): """U-Boot VPL binary padded with a BSS region
tools/binman/etype/u_boot_vpl_expanded.py +1 -1
@@ -5,7 +5,7 @@ # Entry-type module for expanded U-Boot VPL binary # -from patman import tout +from u_boot_pylib import tout from binman import state from binman.etype.blob_phase import Entry_blob_phase
tools/binman/etype/u_boot_with_ucode_ptr.py +2 -2
@@ -11,8 +11,8 @@ from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob from dtoc import fdt_util -from patman import tools -from patman import command +from u_boot_pylib import tools +from u_boot_pylib import command class Entry_u_boot_with_ucode_ptr(Entry_blob): """U-Boot with embedded microcode pointer
tools/binman/etype/vblock.py +1 -1
@@ -13,7 +13,7 @@ from binman.entry import EntryArg from binman.etype.collection import Entry_collection from dtoc import fdt_util -from patman import tools +from u_boot_pylib import tools class Entry_vblock(Entry_collection): """An entry which contains a Chromium OS verified boot block
tools/binman/fdt_test.py +1 -1
@@ -12,7 +12,7 @@ import unittest from dtoc import fdt from dtoc import fdt_util from dtoc.fdt import FdtScan -from patman import tools +from u_boot_pylib import tools class TestFdt(unittest.TestCase): @classmethod
tools/binman/fip_util.py +2 -2
@@ -37,8 +37,8 @@ OUR_PATH = os.path.dirname(OUR_FILE) sys.path.insert(2, os.path.join(OUR_PATH, '..')) # pylint: disable=C0413 -from patman import command -from patman import tools +from u_boot_pylib import command +from u_boot_pylib import tools # The TOC header, at the start of the FIP HEADER_FORMAT = '<IIQ'
tools/binman/fip_util_test.py +2 -2
@@ -20,10 +20,10 @@ OUR_PATH = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(2, os.path.join(OUR_PATH, '..')) # pylint: disable=C0413 -from patman import test_util -from patman import tools from binman import bintool from binman import fip_util +from u_boot_pylib import test_util +from u_boot_pylib import tools FIPTOOL = bintool.Bintool.create('fiptool') HAVE_FIPTOOL = FIPTOOL.is_present()
tools/binman/fmap_util.py +1 -1
@@ -10,7 +10,7 @@ import collections import struct import sys -from patman import tools +from u_boot_pylib import tools # constants imported from lib/fmap.h FMAP_SIGNATURE = b'__FMAP__'
tools/binman/ftest.py +4 -4
@@ -34,10 +34,10 @@ from dtoc import fdt_util from binman.etype import fdtmap from binman.etype import image_header from binman.image import Image -from patman import command -from patman import test_util -from patman import tools -from patman import tout +from u_boot_pylib import command +from u_boot_pylib import test_util +from u_boot_pylib import tools +from u_boot_pylib import tout # Contents of test files, corresponding to different entry types U_BOOT_DATA = b'1234'
tools/binman/image.py +2 -2
@@ -18,8 +18,8 @@ from binman.etype import image_header from binman.etype import section from dtoc import fdt from dtoc import fdt_util -from patman import tools -from patman import tout +from u_boot_pylib import tools +from u_boot_pylib import tout class Image(section.Entry_section): """A Image, representing an output from binman
tools/binman/image_test.py +1 -1
@@ -7,7 +7,7 @@ import unittest from binman.image import Image -from patman.test_util import capture_sys_output +from u_boot_pylib.test_util import capture_sys_output class TestImage(unittest.TestCase): def testInvalidFormat(self):
tools/binman/main.py +4 -3
@@ -34,7 +34,7 @@ sys.pycache_prefix = os.path.relpath(our_path, srctree) sys.path.insert(2, our1_path) from binman import bintool -from patman import test_util +from u_boot_pylib import test_util # Bring in the libfdt module sys.path.insert(2, 'scripts/dtc/pylibfdt')
@@ -44,7 +44,7 @@ sys.path.insert(2, os.path.join(srctree, 'build-sandbox_spl/scripts/dtc/pylibfdt from binman import cmdline from binman import control -from patman import test_util +from u_boot_pylib import test_util def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): """Run the functional tests and any embedded doctests
@@ -95,7 +95,8 @@ def RunTestCoverage(toolpath): for path in toolpath: extra_args += ' --toolpath %s' % path test_util.run_test_coverage('tools/binman/binman', None, - ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*'], + ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*', + 'tools/u_boot_pylib/*'], args.build_dir, all_set, extra_args or None) def RunBinman(args):
tools/binman/state.py +2 -2
@@ -13,8 +13,8 @@ import threading from dtoc import fdt import os -from patman import tools -from patman import tout +from u_boot_pylib import tools +from u_boot_pylib import tout OUR_PATH = os.path.dirname(os.path.realpath(__file__))
tools/buildman/builder.py +3 -3
@@ -19,10 +19,10 @@ import time from buildman import builderthread from buildman import toolchain -from patman import command from patman import gitutil -from patman import terminal -from patman.terminal import tprint +from u_boot_pylib import command +from u_boot_pylib import terminal +from u_boot_pylib.terminal import tprint # This indicates an new int or hex Kconfig property with no default # It hangs the build since the 'conf' tool cannot proceed without valid input.
tools/buildman/builderthread.py +1 -1
@@ -10,8 +10,8 @@ import sys import threading from buildman import cfgutil -from patman import command from patman import gitutil +from u_boot_pylib import command RETURN_CODE_RETRY = -1 BASE_ELF_FILENAMES = ['u-boot', 'spl/u-boot-spl', 'tpl/u-boot-tpl']
tools/buildman/cfgutil.py +1 -1
@@ -7,7 +7,7 @@ import re -from patman import tools +from u_boot_pylib import tools RE_LINE = re.compile(r'(# )?CONFIG_([A-Z0-9_]+)(=(.*)| is not set)') RE_CFG = re.compile(r'(~?)(CONFIG_)?([A-Z0-9_]+)(=.*)?')
tools/buildman/control.py +4 -4
@@ -13,12 +13,12 @@ from buildman import bsettings from buildman import cfgutil from buildman import toolchain from buildman.builder import Builder -from patman import command from patman import gitutil from patman import patchstream -from patman import terminal -from patman import tools -from patman.terminal import tprint +from u_boot_pylib import command +from u_boot_pylib import terminal +from u_boot_pylib import tools +from u_boot_pylib.terminal import tprint def GetPlural(count): """Returns a plural 's' if count is not 1"""
tools/buildman/func_test.py +4 -4
@@ -14,11 +14,11 @@ from buildman import bsettings from buildman import cmdline from buildman import control from buildman import toolchain -from patman import command from patman import gitutil -from patman import terminal -from patman import test_util -from patman import tools +from u_boot_pylib import command +from u_boot_pylib import terminal +from u_boot_pylib import test_util +from u_boot_pylib import tools settings_data = ''' # Buildman settings file
tools/buildman/main.py +2 -2
@@ -25,8 +25,8 @@ from buildman import control from buildman import toolchain from patman import patchstream from patman import gitutil -from patman import terminal -from patman import test_util +from u_boot_pylib import terminal +from u_boot_pylib import test_util def RunTests(skip_net_tests, verboose, args): from buildman import func_test
tools/buildman/test.py +4 -4
@@ -17,10 +17,10 @@ from buildman import cfgutil from buildman import control from buildman import toolchain from patman import commit -from patman import command -from patman import terminal -from patman import test_util -from patman import tools +from u_boot_pylib import command +from u_boot_pylib import terminal +from u_boot_pylib import test_util +from u_boot_pylib import tools use_network = True
tools/buildman/toolchain.py +3 -3
@@ -11,9 +11,9 @@ import tempfile import urllib.request, urllib.error, urllib.parse from buildman import bsettings -from patman import command -from patman import terminal -from patman import tools +from u_boot_pylib import command +from u_boot_pylib import terminal +from u_boot_pylib import tools (PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH, PRIORITY_CALC) = list(range(4))
tools/dtoc/fdt.py +1 -1
@@ -12,7 +12,7 @@ import sys from dtoc import fdt_util import libfdt from libfdt import QUIET_NOTFOUND -from patman import tools +from u_boot_pylib import tools # This deals with a device tree, presenting it as an assortment of Node and # Prop objects, representing nodes and properties, respectively. This file
tools/dtoc/fdt_util.py +2 -2
@@ -13,8 +13,8 @@ import struct import sys import tempfile -from patman import command -from patman import tools +from u_boot_pylib import command +from u_boot_pylib import tools def fdt32_to_cpu(val): """Convert a device tree cell to an integer
tools/dtoc/main.py +3 -2
@@ -35,7 +35,7 @@ sys.path.insert(0, os.path.join(our_path, '../../build-sandbox_spl/scripts/dtc/pylibfdt')) from dtoc import dtb_platdata -from patman import test_util +from u_boot_pylib import test_util def run_tests(processes, args): """Run all the test we have for dtoc
@@ -65,7 +65,8 @@ def RunTestCoverage(): """Run the tests and check that we get 100% coverage""" sys.argv = [sys.argv[0]] test_util.run_test_coverage('tools/dtoc/dtoc', '/main.py', - ['tools/patman/*.py', '*/fdt*', '*test*'], args.build_dir) + ['tools/patman/*.py', 'tools/u_boot_pylib/*','*/fdt*', '*test*'], + args.build_dir) if __name__ != '__main__':
tools/dtoc/test_dtoc.py +2 -2
@@ -25,8 +25,8 @@ from dtoc.dtb_platdata import get_value from dtoc.dtb_platdata import tab_to from dtoc.src_scan import conv_name_to_c from dtoc.src_scan import get_compat_name -from patman import test_util -from patman import tools +from u_boot_pylib import test_util +from u_boot_pylib import tools OUR_PATH = os.path.dirname(os.path.realpath(__file__))
tools/dtoc/test_fdt.py +4 -3
@@ -30,8 +30,8 @@ from dtoc import fdt_util from dtoc.fdt_util import fdt32_to_cpu, fdt64_to_cpu from dtoc.fdt import Type, BytesToValue import libfdt -from patman import test_util -from patman import tools +from u_boot_pylib import test_util +from u_boot_pylib import tools #pylint: disable=protected-access
@@ -814,7 +814,8 @@ def run_test_coverage(build_dir): build_dir (str): Directory containing the build output """ test_util.run_test_coverage('tools/dtoc/test_fdt.py', None, - ['tools/patman/*.py', '*test_fdt.py'], build_dir) + ['tools/patman/*.py', 'tools/u_boot_pylib/*', '*test_fdt.py'], + build_dir) def run_tests(names, processes):
tools/dtoc/test_src_scan.py +2 -2
@@ -15,8 +15,8 @@ import unittest from unittest import mock from dtoc import src_scan -from patman import test_util -from patman import tools +from u_boot_pylib import test_util +from u_boot_pylib import tools OUR_PATH = os.path.dirname(os.path.realpath(__file__))
tools/patman/__init__.py +3 -4
@@ -1,6 +1,5 @@ # SPDX-License-Identifier: GPL-2.0+ -__all__ = ['checkpatch', 'command', 'commit', 'control', 'cros_subprocess', - 'func_test', 'get_maintainer', 'gitutil', '__main__', 'patchstream', - 'project', 'series', 'setup', 'settings', 'terminal', - 'test_checkpatch', 'test_util', 'tools', 'tout'] +__all__ = ['checkpatch', 'commit', 'control', 'func_test', 'get_maintainer', + 'gitutil', '__main__', 'patchstream', 'project', 'series', + 'settings','setup', 'status', 'test_checkpatch', 'test_settings']
tools/patman/__main__.py +4 -4
@@ -24,10 +24,10 @@ from patman import func_test from patman import gitutil from patman import project from patman import settings -from patman import terminal -from patman import test_util from patman import test_checkpatch -from patman import tools +from u_boot_pylib import terminal +from u_boot_pylib import test_util +from u_boot_pylib import tools epilog = '''Create patches from commits in a branch, check them and email them as specified by tags you place in the commits. Use -n to do a dry run first.'''
@@ -150,7 +150,7 @@ if args.cmd == 'test': result = test_util.run_test_suites( 'patman', False, False, False, None, None, None, [test_checkpatch.TestPatch, func_test.TestFunctional, - 'gitutil', 'settings', 'terminal']) + 'gitutil', 'settings']) sys.exit(0 if result.wasSuccessful() else 1)
tools/patman/checkpatch.py +2 -2
@@ -7,9 +7,9 @@ import os import re import sys -from patman import command from patman import gitutil -from patman import terminal +from u_boot_pylib import command +from u_boot_pylib import terminal EMACS_PREFIX = r'(?:[0-9]{4}.*\.patch:[0-9]+: )?' TYPE_NAME = r'([A-Z_]+:)?'
tools/patman/control.py +1 -1
@@ -14,7 +14,7 @@ import sys from patman import checkpatch from patman import gitutil from patman import patchstream -from patman import terminal +from u_boot_pylib import terminal def setup(): """Do required setup before doing anything"""
tools/patman/func_test.py +3 -3
@@ -23,9 +23,9 @@ from patman import patchstream from patman.patchstream import PatchStream from patman.series import Series from patman import settings -from patman import terminal -from patman import tools -from patman.test_util import capture_sys_output +from u_boot_pylib import terminal +from u_boot_pylib import tools +from u_boot_pylib.test_util import capture_sys_output import pygit2 from patman import status
tools/patman/get_maintainer.py +1 -1
@@ -7,8 +7,8 @@ import os import shlex import shutil -from patman import command from patman import gitutil +from u_boot_pylib import command def find_get_maintainer(script_file_name):
tools/patman/gitutil.py +2 -2
@@ -5,9 +5,9 @@ import os import sys -from patman import command from patman import settings -from patman import terminal +from u_boot_pylib import command +from u_boot_pylib import terminal # True to use --no-decorate - we check this in setup() use_no_decorate = True
tools/patman/patchstream.py +1 -1
@@ -14,10 +14,10 @@ import queue import shutil import tempfile -from patman import command from patman import commit from patman import gitutil from patman.series import Series +from u_boot_pylib import command # Tags that we detect and remove RE_REMOVE = re.compile(r'^BUG=|^TEST=|^BRANCH=|^Review URL:'
tools/patman/series.py +2 -2
@@ -11,8 +11,8 @@ import os from patman import get_maintainer from patman import gitutil from patman import settings -from patman import terminal -from patman import tools +from u_boot_pylib import terminal +from u_boot_pylib import tools # Series-xxx tags that we understand valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
tools/patman/status.py +2 -2
@@ -18,8 +18,8 @@ import requests from patman import patchstream from patman.patchstream import PatchStream -from patman import terminal -from patman import tout +from u_boot_pylib import terminal +from u_boot_pylib import tout # Patches which are part of a multi-patch series are shown with a prefix like # [prefix, version, sequence], for example '[RFC, v2, 3/5]'. All but the last
tools/patman/test_settings.py +1 -1
@@ -10,7 +10,7 @@ import sys import tempfile from patman import settings -from patman import tools +from u_boot_pylib import tools @contextlib.contextmanager
tools/rmboard.py +1 -1
@@ -28,7 +28,7 @@ import os import re import sys -from patman import command +from u_boot_pylib import command def rm_kconfig_include(path): """Remove a path from Kconfig files
tools/u_boot_pylib/__init__.py new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ + +__all__ = ['command', 'cros_subprocess','terminal', 'test_util', 'tools', + 'tout']
tools/u_boot_pylib/__main__.py new file +23 -0
@@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright 2023 Google LLC +# + +import os +import sys + +if __name__ == "__main__": + # Allow 'from u_boot_pylib import xxx to work' + our_path = os.path.dirname(os.path.realpath(__file__)) + sys.path.append(os.path.join(our_path, '..')) + + # Run tests + from u_boot_pylib import terminal + from u_boot_pylib import test_util + + result = test_util.run_test_suites( + 'u_boot_pylib', False, False, False, None, None, None, + ['terminal']) + + sys.exit(0 if result.wasSuccessful() else 1)
tools/u_boot_pylib/command.py renamed from tools/patman/command.py +1 -1
@@ -4,7 +4,7 @@ import os -from patman import cros_subprocess +from u_boot_pylib import cros_subprocess """Shell command ease-ups for Python."""
tools/u_boot_pylib/cros_subprocess.py renamed from tools/patman/cros_subprocess.py +0 -0
tools/u_boot_pylib/terminal.py renamed from tools/patman/terminal.py +0 -0
tools/u_boot_pylib/test_util.py renamed from tools/patman/test_util.py +1 -1
@@ -11,7 +11,7 @@ import os import sys import unittest -from patman import command +from u_boot_pylib import command from io import StringIO
tools/u_boot_pylib/tools.py renamed from tools/patman/tools.py +2 -2
@@ -11,8 +11,8 @@ import sys import tempfile import urllib.request -from patman import command -from patman import tout +from u_boot_pylib import command +from u_boot_pylib import tout # Output directly (generally this is temporary) outdir = None
tools/u_boot_pylib/tout.py renamed from tools/patman/tout.py +1 -1
@@ -6,7 +6,7 @@ import sys -from patman import terminal +from u_boot_pylib import terminal # Output verbosity levels that we support ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6)
tools/u_boot_pylib/u_boot_pylib new file +1 -0
@@ -0,0 +1 @@ +__main__.py
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 04/24] 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.
---
(no changes since v1)
scripts/event_dump.py | 2 +-
test/run | 1 +
tools/binman/bintool.py | 8 +++----
tools/binman/bintool_test.py | 8 +++----
tools/binman/btool/lz4.py | 2 +-
tools/binman/btool/lzma_alone.py | 2 +-
tools/binman/cbfs_util.py | 4 ++--
tools/binman/cbfs_util_test.py | 4 ++--
tools/binman/control.py | 6 ++---
tools/binman/elf.py | 6 ++---
tools/binman/elf_test.py | 8 +++----
tools/binman/entry.py | 6 ++---
tools/binman/entry_test.py | 2 +-
tools/binman/etype/_testing.py | 2 +-
tools/binman/etype/atf_fip.py | 2 +-
tools/binman/etype/blob.py | 4 ++--
tools/binman/etype/blob_ext.py | 4 ++--
tools/binman/etype/blob_ext_list.py | 4 ++--
tools/binman/etype/fdtmap.py | 4 ++--
tools/binman/etype/files.py | 2 +-
tools/binman/etype/fill.py | 2 +-
tools/binman/etype/fit.py | 2 +-
tools/binman/etype/fmap.py | 6 ++---
tools/binman/etype/gbb.py | 4 ++--
tools/binman/etype/intel_ifwi.py | 2 +-
tools/binman/etype/mkimage.py | 2 +-
tools/binman/etype/null.py | 2 +-
tools/binman/etype/pre_load.py | 2 +-
tools/binman/etype/section.py | 6 ++---
tools/binman/etype/text.py | 2 +-
tools/binman/etype/u_boot_dtb_with_ucode.py | 2 +-
tools/binman/etype/u_boot_elf.py | 2 +-
tools/binman/etype/u_boot_env.py | 2 +-
tools/binman/etype/u_boot_spl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_spl_expanded.py | 2 +-
tools/binman/etype/u_boot_tpl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_tpl_expanded.py | 2 +-
.../binman/etype/u_boot_tpl_with_ucode_ptr.py | 4 ++--
tools/binman/etype/u_boot_ucode.py | 2 +-
tools/binman/etype/u_boot_vpl_bss_pad.py | 2 +-
tools/binman/etype/u_boot_vpl_expanded.py | 2 +-
tools/binman/etype/u_boot_with_ucode_ptr.py | 4 ++--
tools/binman/etype/vblock.py | 2 +-
tools/binman/fdt_test.py | 2 +-
tools/binman/fip_util.py | 4 ++--
tools/binman/fip_util_test.py | 4 ++--
tools/binman/fmap_util.py | 2 +-
tools/binman/ftest.py | 8 +++----
tools/binman/image.py | 4 ++--
tools/binman/image_test.py | 2 +-
tools/binman/main.py | 7 +++---
tools/binman/state.py | 4 ++--
tools/buildman/builder.py | 6 ++---
tools/buildman/builderthread.py | 2 +-
tools/buildman/cfgutil.py | 2 +-
tools/buildman/control.py | 8 +++----
tools/buildman/func_test.py | 8 +++----
tools/buildman/main.py | 4 ++--
tools/buildman/test.py | 8 +++----
tools/buildman/toolchain.py | 6 ++---
tools/dtoc/fdt.py | 2 +-
tools/dtoc/fdt_util.py | 4 ++--
tools/dtoc/main.py | 5 ++--
tools/dtoc/test_dtoc.py | 4 ++--
tools/dtoc/test_fdt.py | 7 +++---
tools/dtoc/test_src_scan.py | 4 ++--
tools/patman/__init__.py | 7 +++---
tools/patman/__main__.py | 8 +++----
tools/patman/checkpatch.py | 4 ++--
tools/patman/control.py | 2 +-
tools/patman/func_test.py | 6 ++---
tools/patman/get_maintainer.py | 2 +-
tools/patman/gitutil.py | 4 ++--
tools/patman/patchstream.py | 2 +-
tools/patman/series.py | 4 ++--
tools/patman/status.py | 4 ++--
tools/patman/test_settings.py | 2 +-
tools/rmboard.py | 2 +-
tools/u_boot_pylib/__init__.py | 4 ++++
tools/u_boot_pylib/__main__.py | 23 +++++++++++++++++++
tools/{patman => u_boot_pylib}/command.py | 2 +-
.../cros_subprocess.py | 0
tools/{patman => u_boot_pylib}/terminal.py | 0
tools/{patman => u_boot_pylib}/test_util.py | 2 +-
tools/{patman => u_boot_pylib}/tools.py | 4 ++--
tools/{patman => u_boot_pylib}/tout.py | 2 +-
tools/u_boot_pylib/u_boot_pylib | 1 +
87 files changed, 182 insertions(+), 151 deletions(-)
create mode 100644 tools/u_boot_pylib/__init__.py
create mode 100755 tools/u_boot_pylib/__main__.py
rename tools/{patman => u_boot_pylib}/command.py (99%)
rename tools/{patman => u_boot_pylib}/cros_subprocess.py (100%)
rename tools/{patman => u_boot_pylib}/terminal.py (100%)
rename tools/{patman => u_boot_pylib}/test_util.py (99%)
rename tools/{patman => u_boot_pylib}/tools.py (99%)
rename tools/{patman => u_boot_pylib}/tout.py (99%)
create mode 120000 tools/u_boot_pylib/u_boot_pylibApplied to u-boot-dm/next, thanks!
PATCH v2 5/24 script: Add a script to build a PyPi package
In reply to Simon GlassCreate a script which can package a tool for use with PyPi and the 'pip' tool. This involves quite a few steps so is best automated. Future work will enable use of this for some of the tools in U-Boot.
---
Changes in v2:
- Drop test files
- Fix removable of the /tmp dir
- Quite a few updates to make things work with the new names
scripts/make_pip.sh | 117 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 scripts/make_pip.sh
scripts/make_pip.sh new file +117 -0
@@ -0,0 +1,117 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ + +# Packages a U-Boot tool +# +# Usage: make_pip.sh <tool_name> [--real] +# +# Where tool_name is one of patman, buildman, dtoc, binman, u_boot_pylib +# +# and --real means to upload to the real server (otherwise the test one is used) +# +# The username for upload is always __token__ so set TWINE_PASSWORD to your +# password before running this script: +# +# export TWINE_PASSWORD=pypi-xxx +# +# To test your new packages: +# +# pip install -i https://test.pypi.org/simple/ <tool_name> +# + +# DO NOT use patman or binman + +set -xe + +# Repo to upload to +repo="--repository testpypi" + +# Non-empty to do the actual upload +upload=1 + +tool="$1" +shift +flags="$*" + +if [[ "${tool}" =~ ^(patman|buildman|dtoc|binman|u_boot_pylib)$ ]]; then + echo "Building dist package for tool ${tool}" +else + echo "Unknown tool ${tool}: use patman, buildman, dtoc or binman" + exit 1 +fi + +for flag in "${flags}"; do + if [ "${flag}" == "--real" ]; then + echo "Using real server" + repo= + fi + if [ "${flag}" == "-n" ]; then + echo "Doing dry run" + upload= + fi +done + +if [ -n "${upload}" ]; then + if [ -z "${TWINE_PASSWORD}" ]; then + echo "Please set TWINE_PASSWORD to your password and retry" + exit 1 + fi +fi + +# Create a temp dir to work in +dir=$(mktemp -d) + +# Copy in some basic files +cp -v tools/${tool}/pyproject.toml ${dir} +cp -v Licenses/gpl-2.0.txt ${dir}/LICENSE +readme="tools/${tool}/README.*" + +# Copy in the README, dropping some Sphinx constructs that PyPi doesn't like +cat ${readme} | sed -E 's/:(doc|ref):`.*`//; /sectionauthor/d; /toctree::/d' \ + > ${dir}/$(basename ${readme}) + +# Copy the top-level Python and doc files +dest=${dir}/src/${tool} +mkdir -p ${dest} +cp -v tools/$tool/{*.py,*.rst} ${dest} + +# Copy over the subdirectories, including any sub files. Drop any cache files +# and other such things +pushd tools/${tool} +for subdir in $(find . -maxdepth 1 -type d | \ + grep -vE "(__pycache__|home|usr|scratch|\.$|pyproject)"); do + pathname="${dest}/${subdir}" + echo "Copy ${pathname}" + cp -a ${subdir} ${pathname} +done +popd + +# Remove cache files that accidentally made it through +find ${dest} -name __pycache__ -type f -exec rm {} \; +find ${dest} -depth -name __pycache__ -exec rmdir 112 \; + +# Remove test files +rm -rf ${dest}/*test* + +mkdir ${dir}/tests +cd ${dir} + +# Make sure the tools are up to date +python3 -m pip install --upgrade build +python3 -m pip install --upgrade twine + +# Build the PyPi package +python3 -m build + +echo "Completed build of ${tool}" + +# Use --skip-existing to work even if the version is already present +if [ -n "${upload}" ]; then + echo "Uploading from ${dir}" + python3 -m twine upload ${repo} -u __token__ dist/* + echo "Completed upload of ${tool}" +fi + +rm -rf "${dir}" + +echo -e "done\n\n"
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 05/24] script: Add a script to build a PyPi package
Create a script which can package a tool for use with PyPi and the 'pip' tool. This involves quite a few steps so is best automated. Future work will enable use of this for some of the tools in U-Boot.
---
Changes in v2:
- Drop test files
- Fix removable of the /tmp dir
- Quite a few updates to make things work with the new names
scripts/make_pip.sh | 117 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 scripts/make_pip.sh
Applied to u-boot-dm/next, thanks!
PATCH v2 6/24 patman: Add support for building a u_boot_tools PyPi package
In reply to Simon GlassCreate the necessary files to build this new package.
---
(no changes since v1)
Makefile | 18 +- tools/u_boot_pylib/LICENSE | 339 ++++++++++++++++++++++++++++++ tools/u_boot_pylib/README.rst | 15 ++ tools/u_boot_pylib/pyproject.toml | 22 ++ 4 files changed, 393 insertions(+), 1 deletion(-) create mode 100644 tools/u_boot_pylib/LICENSE create mode 100644 tools/u_boot_pylib/README.rst create mode 100644 tools/u_boot_pylib/pyproject.toml
Makefile +17 -1
@@ -522,7 +522,7 @@ env_h := include/generated/environment.h no-dot-config-targets := clean clobber mrproper distclean \ help %docs check% coccicheck \ ubootversion backup tests check pcheck qcheck tcheck \ - pylint pylint_err + pylint pylint_err _pip pip pip_test pip_release config-targets := 0 mixed-targets := 0
@@ -2272,6 +2272,17 @@ backup: F=`basename $(srctree)` ; cd .. ; \ gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F +PHONY += _pip pip pip_release + +pip_release: PIP_ARGS="--real" +pip_test: PIP_ARGS="" +pip: PIP_ARGS="-n" + +pip pip_test pip_release: _pip + +_pip: + scripts/make_pip.sh u_boot_pylib ${PIP_ARGS} + help: @echo 'Cleaning targets:' @echo ' clean - Remove most generated files but keep the config'
@@ -2305,6 +2316,11 @@ help: @echo " cfg - Don't build, just create the .cfg files" @echo " envtools - Build only the target-side environment tools" @echo '' + @echo 'PyPi / pip targets:' + @echo ' pip - Check building of PyPi packages' + @echo ' pip_test - Build PyPi pakages and upload to test server' + @echo ' pip_release - Build PyPi pakages and upload to release server' + @echo '' @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs' @echo ' coccicheck - Execute static code analysis with Coccinelle'
tools/u_boot_pylib/LICENSE new file +339 -0
339 lines not on this page · raw message
tools/u_boot_pylib/README.rst new file +15 -0
@@ -0,0 +1,15 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +# U-Boot Python Library +===================== + +This is a Python library used by various U-Boot tools, including patman, +buildman and binman. + +The module can be installed with pip:: + + pip install u_boot_pylib + +or via setup.py:: + + ./setup.py install [--user]
tools/u_boot_pylib/pyproject.toml new file +22 -0
@@ -0,0 +1,22 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "u_boot_pylib" +version = "0.0.2" +authors = [ + { name="Simon Glass", email="[email protected]" }, +] +description = "U-Boot python library" +readme = "README.md" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://u-boot.readthedocs.io" +"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues"
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 06/24] patman: Add support for building a u_boot_tools PyPi package
Create the necessary files to build this new package.
---
(no changes since v1)
Makefile | 18 +- tools/u_boot_pylib/LICENSE | 339 ++++++++++++++++++++++++++++++ tools/u_boot_pylib/README.rst | 15 ++ tools/u_boot_pylib/pyproject.toml | 22 ++ 4 files changed, 393 insertions(+), 1 deletion(-) create mode 100644 tools/u_boot_pylib/LICENSE create mode 100644 tools/u_boot_pylib/README.rst create mode 100644 tools/u_boot_pylib/pyproject.toml
Applied to u-boot-dm/next, thanks!
PATCH v2 7/24 patman: Avoid importing test_checkpatch before it is needed
In reply to Simon GlassTests are not packaged with patman so this file will not be accessible when installing with pip. Move the import later in the file, when we know the file is present.
---
Changes in v2:
- Add new patch to avoid importing test_checkpatch before it is needed
tools/patman/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/patman/__main__.py +1 -1
@@ -24,7 +24,6 @@ from patman import func_test from patman import gitutil from patman import project from patman import settings -from patman import test_checkpatch from u_boot_pylib import terminal from u_boot_pylib import test_util from u_boot_pylib import tools
@@ -146,6 +145,7 @@ if not args.debug: # Run our meagre tests if args.cmd == 'test': from patman import func_test + from patman import test_checkpatch result = test_util.run_test_suites( 'patman', False, False, False, None, None, None,
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 07/24] patman: Avoid importing test_checkpatch before it is needed
Tests are not packaged with patman so this file will not be accessible when installing with pip. Move the import later in the file, when we know the file is present.
---
Changes in v2:
- Add new patch to avoid importing test_checkpatch before it is needed
tools/patman/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 8/24 patman: Add support for building a patman PyPi package
In reply to Simon GlassCreate the necessary files to build this new package.
---
Changes in v2:
- Rename the package to patch-manager
Makefile | 1 + tools/patman/pyproject.toml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tools/patman/pyproject.toml
Makefile +1 -0
@@ -2282,6 +2282,7 @@ pip pip_test pip_release: _pip _pip: scripts/make_pip.sh u_boot_pylib ${PIP_ARGS} + scripts/make_pip.sh patman ${PIP_ARGS} help: @echo 'Cleaning targets:'
tools/patman/pyproject.toml new file +29 -0
@@ -0,0 +1,29 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "patch-manager" +version = "0.0.2" +authors = [ + { name="Simon Glass", email="[email protected]" }, +] +dependencies = ["u_boot_pylib"] +description = "Patman patch manager" +readme = "README.rst" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://u-boot.readthedocs.io/en/latest/develop/patman.html" +"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues" + +[project.scripts] +patman = "patman.__main__:run_patman" + +[tool.setuptools.package-data] +patman = ["*.rst"]
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 08/24] patman: Add support for building a patman PyPi package
Create the necessary files to build this new package.
---
Changes in v2:
- Rename the package to patch-manager
Makefile | 1 + tools/patman/pyproject.toml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tools/patman/pyproject.toml
Applied to u-boot-dm/next, thanks!
PATCH v2 9/24 buildman: Move the main code into a function
In reply to Simon GlassPut this code into a function so it is easy for it be run when packaged.
---
Changes in v2:
- Add patch to split out the main code into a function
tools/buildman/main.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
tools/buildman/main.py +16 -11
@@ -46,17 +46,22 @@ def RunTests(skip_net_tests, verboose, args): return (0 if result.wasSuccessful() else 1) -options, args = cmdline.ParseArgs() +def run_buildman(): + options, args = cmdline.ParseArgs() -if not options.debug: - sys.tracebacklimit = 0 + if not options.debug: + sys.tracebacklimit = 0 -# Run our meagre tests -if options.test: - RunTests(options.skip_net_tests, options.verbose, args) + # Run our meagre tests + if cmdline.HAS_TESTS and options.test: + RunTests(options.skip_net_tests, options.verbose, args) -# Build selected commits for selected boards -else: - bsettings.Setup(options.config_file) - ret_code = control.DoBuildman(options, args) - sys.exit(ret_code) + # Build selected commits for selected boards + else: + bsettings.Setup(options.config_file) + ret_code = control.DoBuildman(options, args) + sys.exit(ret_code) + + +if __name__ == "__main__": + run_buildman()
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 09/24] buildman: Move the main code into a function
Put this code into a function so it is easy for it be run when packaged.
---
Changes in v2:
- Add patch to split out the main code into a function
tools/buildman/main.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 10/24 buildman: Hide the test options unless test code is available
In reply to Simon GlassIt doesn't make much sense to expose tests when buildman is running outside of the U-Boot git checkout. Hide the option in this case
---
Changes in v2:
- Add a patch to hide the test options unless test code is available
tools/buildman/cmdline.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
tools/buildman/cmdline.py +10 -4
@@ -3,6 +3,11 @@ # from optparse import OptionParser +import os +import pathlib + +BUILDMAN_DIR = pathlib.Path(__file__).parent +HAS_TESTS = os.path.exists(BUILDMAN_DIR / "test.py") def ParseArgs(): """Parse command line arguments from sys.argv[]
@@ -101,12 +106,13 @@ def ParseArgs(): default=False, help='Show a build summary') parser.add_option('-S', '--show-sizes', action='store_true', default=False, help='Show image size variation in summary') - parser.add_option('--skip-net-tests', action='store_true', default=False, - help='Skip tests which need the network') parser.add_option('--step', type='int', default=1, help='Only build every n commits (0=just first and last)') - parser.add_option('-t', '--test', action='store_true', dest='test', - default=False, help='run tests') + if HAS_TESTS: + parser.add_option('--skip-net-tests', action='store_true', default=False, + help='Skip tests which need the network') + parser.add_option('-t', '--test', action='store_true', dest='test', + default=False, help='run tests') parser.add_option('-T', '--threads', type='int', default=None, help='Number of builder threads to use (0=single-thread)')
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 10/24] buildman: Hide the test options unless test code is available
It doesn't make much sense to expose tests when buildman is running outside of the U-Boot git checkout. Hide the option in this case
---
Changes in v2:
- Add a patch to hide the test options unless test code is available
tools/buildman/cmdline.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 11/24 buildman: Fix use of a type as a variable
In reply to Simon GlassUsing 'str' as a variable makes it impossible to use it as a type in the same function. Fix this by using a different name.
---
Changes in v2:
- Add patch to fix use of a type as a variable
tools/buildman/control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/buildman/control.py +2 -2
@@ -261,9 +261,9 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, count += 1 # Build upstream commit also if not count: - str = ("No commits found to process in branch '%s': " + msg = ("No commits found to process in branch '%s': " "set branch's upstream or use -c flag" % options.branch) - sys.exit(col.build(col.RED, str)) + sys.exit(col.build(col.RED, msg)) if options.work_in_output: if len(selected) != 1: sys.exit(col.build(col.RED,
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 11/24] buildman: Fix use of a type as a variable
Using 'str' as a variable makes it impossible to use it as a type in the same function. Fix this by using a different name.
---
Changes in v2:
- Add patch to fix use of a type as a variable
tools/buildman/control.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 12/24 buildman: Use importlib to find the help
In reply to Simon GlassUse this function so that the help can be found even when buildman is running from a package.
---
Changes in v2:
- Add new patch to use importlib to find the help
tools/buildman/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/buildman/control.py +3 -3
@@ -3,6 +3,7 @@ # import multiprocessing +import importlib.resources import os import shutil import subprocess
@@ -152,9 +153,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None, global builder if options.full_help: - tools.print_full_help( - os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), - 'README.rst')) + with importlib.resources.path('buildman', 'README.rst') as readme: + tools.print_full_help(str(readme)) return 0 gitutil.setup()
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 12/24] buildman: Use importlib to find the help
Use this function so that the help can be found even when buildman is running from a package.
---
Changes in v2:
- Add new patch to use importlib to find the help
tools/buildman/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 13/24 buildman: Add support for building a buildman PyPi package
In reply to Simon GlassCreate the necessary files to build this new package.
It is not actually clear whether this is useful, since buildman has no purpose outside U-Boot. It is included for completeness, since adding this later would be more trouble.
Move the main program into a function so that it can easily be called by the PyPi-created script.
---
(no changes since v1)
Makefile | 1 + tools/buildman/pyproject.toml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tools/buildman/pyproject.toml
Makefile +1 -0
@@ -2283,6 +2283,7 @@ pip pip_test pip_release: _pip _pip: scripts/make_pip.sh u_boot_pylib ${PIP_ARGS} scripts/make_pip.sh patman ${PIP_ARGS} + scripts/make_pip.sh buildman ${PIP_ARGS} help: @echo 'Cleaning targets:'
tools/buildman/pyproject.toml new file +29 -0
@@ -0,0 +1,29 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "buildman" +version = "0.0.2" +authors = [ + { name="Simon Glass", email="[email protected]" }, +] +dependencies = ["u_boot_pylib", "patch-manager"] +description = "Buildman build tool for U-Boot" +readme = "README.rst" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://u-boot.readthedocs.io/en/latest/build/buildman.html" +"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues" + +[project.scripts] +buildman = "buildman.main:run_buildman" + +[tool.setuptools.package-data] +buildman = ["*.rst"]
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 13/24] buildman: Add support for building a buildman PyPi package
Create the necessary files to build this new package.
It is not actually clear whether this is useful, since buildman has no purpose outside U-Boot. It is included for completeness, since adding this later would be more trouble.
Move the main program into a function so that it can easily be called by the PyPi-created script.
---
(no changes since v1)
Makefile | 1 + tools/buildman/pyproject.toml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tools/buildman/pyproject.toml
Applied to u-boot-dm/next, thanks!
PATCH v2 14/24 dtoc: Hide the test options unless test code is available
In reply to Simon GlassIt 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.
---
Changes in v2:
- Add a patch to hide the test options unless test code is available
tools/dtoc/main.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
tools/dtoc/main.py +13 -6
@@ -23,6 +23,7 @@ see doc/driver-model/of-plat.rst from argparse import ArgumentParser import os +import pathlib import sys # Bring in the patman libraries
@@ -37,6 +38,9 @@ sys.path.insert(0, os.path.join(our_path, from dtoc import dtb_platdata from u_boot_pylib import test_util +DTOC_DIR = pathlib.Path(__file__).parent +HAVE_TESTS = (DTOC_DIR / 'test_dtoc.py').exists() + def run_tests(processes, args): """Run all the test we have for dtoc
@@ -93,19 +97,22 @@ parser.add_argument('-p', '--phase', type=str, help='set phase of U-Boot this invocation is for (spl/tpl)') parser.add_argument('-P', '--processes', type=int, help='set number of processes to use for running tests') -parser.add_argument('-t', '--test', action='store_true', dest='test', - default=False, help='run tests') -parser.add_argument('-T', '--test-coverage', action='store_true', - default=False, help='run tests and check for 100%% coverage') +if HAVE_TESTS: + parser.add_argument('-t', '--test', action='store_true', dest='test', + default=False, help='run tests') + parser.add_argument( + '-T', '--test-coverage', action='store_true', + default=False, help='run tests and check for 100%% coverage') + parser.add_argument('files', nargs='*') args = parser.parse_args() # Run our meagre tests -if args.test: +if HAVE_TESTS and args.test: ret_code = run_tests(args.processes, args) sys.exit(ret_code) -elif args.test_coverage: +elif HAVE_TESTS and args.test_coverage: RunTestCoverage() else:
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 14/24] dtoc: Hide the test options unless test code is available
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.
---
Changes in v2:
- Add a patch to hide the test options unless test code is available
tools/dtoc/main.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 15/24 dtoc: Move the main code into a function
In reply to Simon GlassPut this code into a function so it is easy for it be run when packaged.
---
Changes in v2:
- Add patch to split out the main code into a function
tools/dtoc/main.py | 100 +++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 48 deletions(-)
tools/dtoc/main.py +52 -48
@@ -65,58 +65,62 @@ def run_tests(processes, args): return (0 if result.wasSuccessful() else 1) -def RunTestCoverage(): +def RunTestCoverage(build_dir): """Run the tests and check that we get 100% coverage""" sys.argv = [sys.argv[0]] test_util.run_test_coverage('tools/dtoc/dtoc', '/main.py', ['tools/patman/*.py', 'tools/u_boot_pylib/*','*/fdt*', '*test*'], - args.build_dir) - - -if __name__ != '__main__': - sys.exit(1) - -epilog = '''Generate C code from devicetree files. See of-plat.rst for details''' - -parser = ArgumentParser(epilog=epilog) -parser.add_argument('-B', '--build-dir', type=str, default='b', - help='Directory containing the build output') -parser.add_argument('-c', '--c-output-dir', action='store', - help='Select output directory for C files') -parser.add_argument('-C', '--h-output-dir', action='store', - help='Select output directory for H files (defaults to --c-output-di)') -parser.add_argument('-d', '--dtb-file', action='store', - help='Specify the .dtb input file') -parser.add_argument('-i', '--instantiate', action='store_true', default=False, - help='Instantiate devices to avoid needing device_bind()') -parser.add_argument('--include-disabled', action='store_true', - help='Include disabled nodes') -parser.add_argument('-o', '--output', action='store', - help='Select output filename') -parser.add_argument('-p', '--phase', type=str, - help='set phase of U-Boot this invocation is for (spl/tpl)') -parser.add_argument('-P', '--processes', type=int, - help='set number of processes to use for running tests') -if HAVE_TESTS: - parser.add_argument('-t', '--test', action='store_true', dest='test', - default=False, help='run tests') - parser.add_argument( - '-T', '--test-coverage', action='store_true', - default=False, help='run tests and check for 100%% coverage') - -parser.add_argument('files', nargs='*') -args = parser.parse_args() + build_dir) -# Run our meagre tests -if HAVE_TESTS and args.test: - ret_code = run_tests(args.processes, args) - sys.exit(ret_code) -elif HAVE_TESTS and args.test_coverage: - RunTestCoverage() +def run_dtoc(): + epilog = 'Generate C code from devicetree files. See of-plat.rst for details' -else: - dtb_platdata.run_steps(args.files, args.dtb_file, args.include_disabled, - args.output, - [args.c_output_dir, args.h_output_dir], - args.phase, instantiate=args.instantiate) + parser = ArgumentParser(epilog=epilog) + parser.add_argument('-B', '--build-dir', type=str, default='b', + help='Directory containing the build output') + parser.add_argument('-c', '--c-output-dir', action='store', + help='Select output directory for C files') + parser.add_argument( + '-C', '--h-output-dir', action='store', + help='Select output directory for H files (defaults to --c-output-di)') + parser.add_argument('-d', '--dtb-file', action='store', + help='Specify the .dtb input file') + parser.add_argument( + '-i', '--instantiate', action='store_true', default=False, + help='Instantiate devices to avoid needing device_bind()') + parser.add_argument('--include-disabled', action='store_true', + help='Include disabled nodes') + parser.add_argument('-o', '--output', action='store', + help='Select output filename') + parser.add_argument( + '-p', '--phase', type=str, + help='set phase of U-Boot this invocation is for (spl/tpl)') + parser.add_argument('-P', '--processes', type=int, + help='set number of processes to use for running tests') + if HAVE_TESTS: + parser.add_argument('-t', '--test', action='store_true', dest='test', + default=False, help='run tests') + parser.add_argument( + '-T', '--test-coverage', action='store_true', + default=False, help='run tests and check for 100%% coverage') + parser.add_argument('files', nargs='*') + args = parser.parse_args() + + # Run our meagre tests + if HAVE_TESTS and args.test: + ret_code = run_tests(args.processes, args) + sys.exit(ret_code) + + elif HAVE_TESTS and args.test_coverage: + RunTestCoverage(args.build_dir) + + else: + dtb_platdata.run_steps(args.files, args.dtb_file, args.include_disabled, + args.output, + [args.c_output_dir, args.h_output_dir], + args.phase, instantiate=args.instantiate) + + +if __name__ == '__main__': + run_dtoc()
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 15/24] dtoc: Move the main code into a function
Put this code into a function so it is easy for it be run when packaged.
---
Changes in v2:
- Add patch to split out the main code into a function
tools/dtoc/main.py | 100 +++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 48 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 16/24 dtoc: Use pathlib to find the test directory
In reply to Simon GlassUpdate this so that the directory being used is declared at the top of the file. Use pathlib as it seems to be more modern.
---
(no changes since v1)
tools/dtoc/test_dtoc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/dtoc/test_dtoc.py +4 -2
@@ -13,6 +13,7 @@ import collections import copy import glob import os +import pathlib import struct import unittest
@@ -28,7 +29,8 @@ from dtoc.src_scan import get_compat_name from u_boot_pylib import test_util from u_boot_pylib import tools -OUR_PATH = os.path.dirname(os.path.realpath(__file__)) +DTOC_DIR = pathlib.Path(__file__).parent +TEST_DATA_DIR = DTOC_DIR / 'test/' HEADER = '''/*
@@ -91,7 +93,7 @@ def get_dtb_file(dts_fname, capture_stderr=False): Returns: str: Filename of compiled file in output directory """ - return fdt_util.EnsureCompiled(os.path.join(OUR_PATH, 'test', dts_fname), + return fdt_util.EnsureCompiled(str(TEST_DATA_DIR / dts_fname), capture_stderr=capture_stderr)
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 16/24] dtoc: Use pathlib to find the test directory
Update this so that the directory being used is declared at the top of the file. Use pathlib as it seems to be more modern.
---
(no changes since v1)
tools/dtoc/test_dtoc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 17/24 dtoc: Add support for building a dtoc PyPi package
In reply to Simon GlassCreate the necessary files to build this new package.
This is needed for binman.
Move the main program into a function so that it can easily be called by the PyPi-created script.
---
(no changes since v1)
Makefile | 1 + tools/dtoc/README.rst | 15 +++++++++++++++ tools/dtoc/pyproject.toml | 26 ++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 tools/dtoc/README.rst create mode 100644 tools/dtoc/pyproject.toml
Makefile +1 -0
@@ -2284,6 +2284,7 @@ _pip: scripts/make_pip.sh u_boot_pylib ${PIP_ARGS} scripts/make_pip.sh patman ${PIP_ARGS} scripts/make_pip.sh buildman ${PIP_ARGS} + scripts/make_pip.sh dtoc ${PIP_ARGS} help: @echo 'Cleaning targets:'
tools/dtoc/README.rst new file +15 -0
@@ -0,0 +1,15 @@ +.. SPDX-License-Identifier: GPL-2.0+ + +Devicetree-to-C generator +========================= + +This is a Python program and associated utilities, which supports converting +devicetree files into C code. It generates header files containing struct +definitions, as well as C files containing the data. It does not require any +modification of the devicetree files. + +Some high-level libraries are provided for working with devicetree. These may +be useful in other projects. + +This package also includes some U-Boot-specific features, such as creating +`struct udevice` and `struct uclass` entries for devicetree nodes.
tools/dtoc/pyproject.toml new file +26 -0
@@ -0,0 +1,26 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "dtoc" +version = "0.0.2" +authors = [ + { name="Simon Glass", email="[email protected]" }, +] +dependencies = ["pylibfdt", "u_boot_pylib"] +description = "Devicetree-to-C generator" +readme = "README.rst" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://u-boot.readthedocs.io/en/latest/develop/driver-model/of-plat.html" +"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues" + +[project.scripts] +dtoc = "dtoc.main:run_dtoc"
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 17/24] dtoc: Add support for building a dtoc PyPi package
Create the necessary files to build this new package.
This is needed for binman.
Move the main program into a function so that it can easily be called by the PyPi-created script.
---
(no changes since v1)
Makefile | 1 + tools/dtoc/README.rst | 15 +++++++++++++++ tools/dtoc/pyproject.toml | 26 ++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 tools/dtoc/README.rst create mode 100644 tools/dtoc/pyproject.toml
Applied to u-boot-dm/next, thanks!
PATCH v2 18/24 binman: Move the main code into a function
In reply to Simon GlassPut this code into a function so it is easy for it be run when packaged.
---
Changes in v2:
- Add patch to split out the main code into a function
tools/binman/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
tools/binman/main.py +8 -4
@@ -85,7 +85,7 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath): return (0 if result.wasSuccessful() else 1) -def RunTestCoverage(toolpath): +def RunTestCoverage(toolpath, build_dir): """Run the tests and check that we get 100% coverage""" glob_list = control.GetEntryModules(False) all_set = set([os.path.splitext(os.path.basename(item))[0]
@@ -97,7 +97,7 @@ def RunTestCoverage(toolpath): test_util.run_test_coverage('tools/binman/binman', None, ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*', 'tools/u_boot_pylib/*'], - args.build_dir, all_set, extra_args or None) + build_dir, all_set, extra_args or None) def RunBinman(args): """Main entry point to binman once arguments are parsed
@@ -117,7 +117,7 @@ def RunBinman(args): if args.cmd == 'test': if args.test_coverage: - RunTestCoverage(args.toolpath) + RunTestCoverage(args.toolpath, args.build_dir) else: ret_code = RunTests(args.debug, args.verbosity, args.processes, args.test_preserve_dirs, args.tests,
@@ -141,8 +141,12 @@ def RunBinman(args): return ret_code -if __name__ == "__main__": +def start_binman(): args = cmdline.ParseArgs(sys.argv[1:]) ret_code = RunBinman(args) sys.exit(ret_code) + + +if __name__ == "__main__": + start_binman()
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 18/24] binman: Move the main code into a function
Put this code into a function so it is easy for it be run when packaged.
---
Changes in v2:
- Add patch to split out the main code into a function
tools/binman/main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 19/24 binman: Hide the 'test' command unless test code is available
In reply to Simon GlassIt 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.
Fix a long line while we are here.
---
Changes in v2:
- Add a patch to hide the test options unless test code is available
tools/binman/cmdline.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
tools/binman/cmdline.py +21 -13
@@ -8,6 +8,11 @@ import argparse from argparse import ArgumentParser from binman import state +import os +import pathlib + +BINMAN_DIR = pathlib.Path(__file__).parent +HAS_TESTS = (BINMAN_DIR / "ftest.py").exists() def make_extract_parser(subparsers): """make_extract_parser: Make a subparser for the 'extract' command
@@ -163,23 +168,26 @@ controlled by a description in the board device tree.''' replace_parser.add_argument('paths', type=str, nargs='*', help='Paths within file to replace (wildcard)') - test_parser = subparsers.add_parser('test', help='Run tests') - test_parser.add_argument('-P', '--processes', type=int, - help='set number of processes to use for running tests') - test_parser.add_argument('-T', '--test-coverage', action='store_true', - default=False, help='run tests and check for 100%% coverage') - test_parser.add_argument('-X', '--test-preserve-dirs', action='store_true', - help='Preserve and display test-created input directories; also ' - 'preserve the output directory if a single test is run (pass test ' - 'name at the end of the command line') - test_parser.add_argument('tests', nargs='*', - help='Test names to run (omit for all)') + if HAS_TESTS: + test_parser = subparsers.add_parser('test', help='Run tests') + test_parser.add_argument('-P', '--processes', type=int, + help='set number of processes to use for running tests') + test_parser.add_argument('-T', '--test-coverage', action='store_true', + default=False, help='run tests and check for 100%% coverage') + test_parser.add_argument( + '-X', '--test-preserve-dirs', action='store_true', + help='Preserve and display test-created input directories; also ' + 'preserve the output directory if a single test is run (pass ' + 'test name at the end of the command line') + test_parser.add_argument('tests', nargs='*', + help='Test names to run (omit for all)') tool_parser = subparsers.add_parser('tool', help='Check bintools') tool_parser.add_argument('-l', '--list', action='store_true', help='List all known bintools') - tool_parser.add_argument('-f', '--fetch', action='store_true', - help='fetch a bintool from a known location (or: all/missing)') + tool_parser.add_argument( + '-f', '--fetch', action='store_true', + help='fetch a bintool from a known location (or: all/missing)') tool_parser.add_argument('bintools', type=str, nargs='*') return parser.parse_args(argv)
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 19/24] binman: Hide the 'test' command unless test code is available
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.
Fix a long line while we are here.
---
Changes in v2:
- Add a patch to hide the test options unless test code is available
tools/binman/cmdline.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 20/24 binman: Use importlib to find the help
In reply to Simon GlassUse this function so that the help can be found even when binman is running from a package.
---
Changes in v2:
- Add new patch to use importlib to find the help
tools/binman/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/binman/control.py +3 -3
@@ -7,6 +7,7 @@ from collections import OrderedDict import glob +import importlib.resources import os import pkg_resources import re
@@ -641,9 +642,8 @@ def Binman(args): global state if args.full_help: - tools.print_full_help( - os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), 'README.rst') - ) + with importlib.resources.path('binman', 'README.rst') as readme: + tools.print_full_help(str(readme)) return 0 # Put these here so that we can import this module without libfdt
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 20/24] binman: Use importlib to find the help
Use this function so that the help can be found even when binman is running from a package.
---
Changes in v2:
- Add new patch to use importlib to find the help
tools/binman/control.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 21/24 binman: Add support for building a binmanu PyPi package
In reply to Simon GlassCreate the necessary files to build this new package.
It is not actually clear whether this is useful, since buildman has no purpose outside U-Boot.
Move the main program into a function so that it can easily be called by the PyPi-created script.
---
(no changes since v1)
Makefile | 1 + tools/binman/pyproject.toml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tools/binman/pyproject.toml
Makefile +1 -0
@@ -2285,6 +2285,7 @@ _pip: scripts/make_pip.sh patman ${PIP_ARGS} scripts/make_pip.sh buildman ${PIP_ARGS} scripts/make_pip.sh dtoc ${PIP_ARGS} + scripts/make_pip.sh binman ${PIP_ARGS} help: @echo 'Cleaning targets:'
tools/binman/pyproject.toml new file +29 -0
@@ -0,0 +1,29 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "binary-manager" +version = "0.0.2" +authors = [ + { name="Simon Glass", email="[email protected]" }, +] +dependencies = ["pylibfdt", "u_boot_pylib", "dtoc"] +description = "Binman firmware-packaging tool" +readme = "README.rst" +requires-python = ">=3.7" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)", + "Operating System :: OS Independent", +] + +[project.urls] +"Homepage" = "https://u-boot.readthedocs.io/en/latest/develop/package/index.html" +"Bug Tracker" = "https://source.denx.de/groups/u-boot/-/issues" + +[project.scripts] +binman = "binman.main:start_binman" + +[tool.setuptools.package-data] +patman = ["*.rst"]
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 21/24] binman: Add support for building a binmanu PyPi package
Create the necessary files to build this new package.
It is not actually clear whether this is useful, since buildman has no purpose outside U-Boot.
Move the main program into a function so that it can easily be called by the PyPi-created script.
---
(no changes since v1)
Makefile | 1 + tools/binman/pyproject.toml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tools/binman/pyproject.toml
Applied to u-boot-dm/next, thanks!
PATCH v2 22/24 test: Add concurrencytest to the requirements
In reply to Simon GlassThis allows tests to run in parallel and speeds up some tests markedly, particularly with binman. Add it to the requirements.
---
(no changes since v1)
test/py/requirements.txt | 1 + 1 file changed, 1 insertion(+)
test/py/requirements.txt +1 -0
@@ -1,5 +1,6 @@ atomicwrites==1.4.1 attrs==19.3.0 +concurrencytest==0.1.2 coverage==4.5.4 extras==1.0.0 filelock==3.0.12
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 22/24] test: Add concurrencytest to the requirements
This allows tests to run in parallel and speeds up some tests markedly, particularly with binman. Add it to the requirements.
---
(no changes since v1)
test/py/requirements.txt | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm/next, thanks!
PATCH v2 23/24 doc: Add notes on how to install patman and binman
In reply to Simon GlassThese can be installed with 'pip' now. Add the details for those who are interested.
---
(no changes since v1)
tools/binman/binman.rst | 13 +++++++++++++ tools/patman/patman.rst | 12 ++++++++++++ 2 files changed, 25 insertions(+)
tools/binman/binman.rst +13 -0
@@ -95,6 +95,19 @@ Binman uses the following terms: - binary - an input binary that goes into the image +Installation +------------ + +You can install binman using:: + + pip install binary-manager + +The name is chosen since binman conflicts with an existing package. + +If you are using binman within the U-Boot tree, it may be easiest to add a +symlink from your local `~/.bin` directory to `/path/to/tools/binman/binman`. + + Relationship to FIT -------------------
tools/patman/patman.rst +12 -0
@@ -41,6 +41,18 @@ In Linux and U-Boot this will also call get_maintainer.pl on each of your patches automatically (unless you use -m to disable this). +Installation +------------ + +You can install patman using:: + + pip install patch-manager + +The name is chosen since patman conflicts with an existing package. + +If you are using patman within the U-Boot tree, it may be easiest to add a +symlink from your local `~/.bin` directory to `/path/to/tools/patman/patman`. + How to use this tool --------------------
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 23/24] doc: Add notes on how to install patman and binman
These can be installed with 'pip' now. Add the details for those who are interested.
---
(no changes since v1)
tools/binman/binman.rst | 13 +++++++++++++ tools/patman/patman.rst | 12 ++++++++++++ 2 files changed, 25 insertions(+)
Applied to u-boot-dm/next, thanks!
PATCH v2 24/24 CI: Add a check for building tools for PyPi
In reply to Simon GlassAdd a simple check that the PyPi packages can be built.
---
Changes in v2:
- Update the cover letter
.azure-pipelines.yml | 10 ++++++++++ .gitlab-ci.yml | 6 ++++++ 2 files changed, 16 insertions(+)
.azure-pipelines.yml +10 -0
@@ -225,6 +225,16 @@ stages: # have no matches. - script: git grep u-boot,dm- -- '*.dts*' && exit 1 || exit 0 + - job: check_packing_of_python_tools + displayName: 'Check we can package the Python tools' + pool: + vmImage: $(ubuntu_vm) + container: + image: $(ci_runner_image) + options: $(container_option) + steps: + - script: make pip + - stage: test_py jobs: - job: test_py
.gitlab-ci.yml +6 -0
@@ -244,6 +244,12 @@ Check for pre-schema tags: # have no matches. - git grep u-boot,dm- -- '*.dts*' && exit 1 || exit 0 +# Check we can package the Python tools +Check packing of Python tools: + stage: testsuites + script: + - make pip + # Test sandbox with test.py sandbox test.py: variables:
Signature · 1 line
2.39.2.637.g21b0678d19-goog
Re: [PATCH v2 24/24] CI: Add a check for building tools for PyPi
Add a simple check that the PyPi packages can be built.
---
Changes in v2:
- Update the cover letter
.azure-pipelines.yml | 10 ++++++++++ .gitlab-ci.yml | 6 ++++++ 2 files changed, 16 insertions(+)
Applied to u-boot-dm/next, thanks!