patman: Move library functions into a library directory

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

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

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2023-02-23 18:18:04 -07:00
parent 00290d6a5b
commit 4583c00236
87 changed files with 182 additions and 151 deletions

View file

@ -15,7 +15,7 @@ src_path = os.path.dirname(our_path)
sys.path.insert(1, os.path.join(our_path, '../tools')) sys.path.insert(1, os.path.join(our_path, '../tools'))
from binman import elf from binman import elf
from patman import tools from u_boot_pylib import tools
# A typical symbol looks like this: # A typical symbol looks like this:
# _u_boot_list_2_evspy_info_2_EVT_MISC_INIT_F_3_sandbox_misc_init_f # _u_boot_list_2_evspy_info_2_EVT_MISC_INIT_F_3_sandbox_misc_init_f

View file

@ -76,6 +76,7 @@ TOOLS_DIR=build-sandbox_spl/tools
run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test
run_test "patman" ./tools/patman/patman 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 "buildman" ./tools/buildman/buildman -t ${skip}
run_test "fdt" ./tools/dtoc/test_fdt -t run_test "fdt" ./tools/dtoc/test_fdt -t

View file

@ -18,10 +18,10 @@ import shutil
import tempfile import tempfile
import urllib.error import urllib.error
from patman import command from u_boot_pylib import command
from patman import terminal from u_boot_pylib import terminal
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
BINMAN_DIR = os.path.dirname(os.path.realpath(__file__)) BINMAN_DIR = os.path.dirname(os.path.realpath(__file__))

View file

@ -16,10 +16,10 @@ import urllib.error
from binman import bintool from binman import bintool
from binman.bintool import Bintool from binman.bintool import Bintool
from patman import command from u_boot_pylib import command
from patman import terminal from u_boot_pylib import terminal
from patman import test_util from u_boot_pylib import test_util
from patman import tools from u_boot_pylib import tools
# pylint: disable=R0904 # pylint: disable=R0904
class TestBintool(unittest.TestCase): class TestBintool(unittest.TestCase):

View file

@ -60,7 +60,7 @@ import re
import tempfile import tempfile
from binman import bintool from binman import bintool
from patman import tools from u_boot_pylib import tools
# pylint: disable=C0103 # pylint: disable=C0103
class Bintoollz4(bintool.Bintool): class Bintoollz4(bintool.Bintool):

View file

@ -37,7 +37,7 @@ import re
import tempfile import tempfile
from binman import bintool from binman import bintool
from patman import tools from u_boot_pylib import tools
# pylint: disable=C0103 # pylint: disable=C0103
class Bintoollzma_alone(bintool.Bintool): class Bintoollzma_alone(bintool.Bintool):

View file

@ -22,8 +22,8 @@ import sys
from binman import bintool from binman import bintool
from binman import elf from binman import elf
from patman import command from u_boot_pylib import command
from patman import tools from u_boot_pylib import tools
# Set to True to enable printing output while working # Set to True to enable printing output while working
DEBUG = False DEBUG = False

View file

@ -20,8 +20,8 @@ from binman import bintool
from binman import cbfs_util from binman import cbfs_util
from binman.cbfs_util import CbfsWriter from binman.cbfs_util import CbfsWriter
from binman import elf from binman import elf
from patman import test_util from u_boot_pylib import test_util
from patman import tools from u_boot_pylib import tools
U_BOOT_DATA = b'1234' U_BOOT_DATA = b'1234'
U_BOOT_DTB_DATA = b'udtb' U_BOOT_DTB_DATA = b'udtb'

View file

@ -12,14 +12,14 @@ import pkg_resources
import re import re
import sys import sys
from patman import tools
from binman import bintool from binman import bintool
from binman import cbfs_util from binman import cbfs_util
from patman import command
from binman import elf from binman import elf
from binman import entry 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 # These are imported if needed since they import libfdt
state = None state = None

View file

@ -13,9 +13,9 @@ import shutil
import struct import struct
import tempfile import tempfile
from patman import command from u_boot_pylib import command
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
ELF_TOOLS = True ELF_TOOLS = True
try: try:

View file

@ -12,10 +12,10 @@ import tempfile
import unittest import unittest
from binman import elf from binman import elf
from patman import command from u_boot_pylib import command
from patman import test_util from u_boot_pylib import test_util
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
binman_dir = os.path.dirname(os.path.realpath(sys.argv[0])) binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))

View file

@ -14,9 +14,9 @@ import time
from binman import bintool from binman import bintool
from binman import elf from binman import elf
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
from patman.tools import to_hex, to_hex_size from u_boot_pylib.tools import to_hex, to_hex_size
from patman import tout from u_boot_pylib import tout
modules = {} modules = {}

View file

@ -14,7 +14,7 @@ from binman import entry
from binman.etype.blob import Entry_blob from binman.etype.blob import Entry_blob
from dtoc import fdt from dtoc import fdt
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class TestEntry(unittest.TestCase): class TestEntry(unittest.TestCase):
def setUp(self): def setUp(self):

View file

@ -9,7 +9,7 @@ from collections import OrderedDict
from binman.entry import Entry, EntryArg from binman.entry import Entry, EntryArg
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry__testing(Entry): class Entry__testing(Entry):

View file

@ -11,7 +11,7 @@ from binman.entry import Entry
from binman.etype.section import Entry_section from binman.etype.section import Entry_section
from binman.fip_util import FIP_TYPES, FipReader, FipWriter, UUID_LEN from binman.fip_util import FIP_TYPES, FipReader, FipWriter, UUID_LEN
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_atf_fip(Entry_section): class Entry_atf_fip(Entry_section):
"""ARM Trusted Firmware's Firmware Image Package (FIP) """ARM Trusted Firmware's Firmware Image Package (FIP)

View file

@ -8,8 +8,8 @@
from binman.entry import Entry from binman.entry import Entry
from binman import state from binman import state
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
class Entry_blob(Entry): class Entry_blob(Entry):
"""Arbitrary binary blob """Arbitrary binary blob

View file

@ -9,8 +9,8 @@ import os
from binman.etype.blob import Entry_blob from binman.etype.blob import Entry_blob
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
class Entry_blob_ext(Entry_blob): class Entry_blob_ext(Entry_blob):
"""Externally built binary blob """Externally built binary blob

View file

@ -9,8 +9,8 @@ import os
from binman.etype.blob import Entry_blob from binman.etype.blob import Entry_blob
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
class Entry_blob_ext_list(Entry_blob): class Entry_blob_ext_list(Entry_blob):
"""List of externally built binary blobs """List of externally built binary blobs

View file

@ -9,8 +9,8 @@ image.
""" """
from binman.entry import Entry from binman.entry import Entry
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
FDTMAP_MAGIC = b'_FDTMAP_' FDTMAP_MAGIC = b'_FDTMAP_'
FDTMAP_HDR_LEN = 16 FDTMAP_HDR_LEN = 16

View file

@ -11,7 +11,7 @@ import os
from binman.etype.section import Entry_section from binman.etype.section import Entry_section
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
# This is imported if needed # This is imported if needed
state = None state = None

View file

@ -5,7 +5,7 @@
from binman.entry import Entry from binman.entry import Entry
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_fill(Entry): class Entry_fill(Entry):
"""An entry which is filled to a particular byte value """An entry which is filled to a particular byte value

View file

@ -12,7 +12,7 @@ from binman.etype.section import Entry_section
from binman import elf from binman import elf
from dtoc import fdt_util from dtoc import fdt_util
from dtoc.fdt import Fdt from dtoc.fdt import Fdt
from patman import tools from u_boot_pylib import tools
# Supported operations, with the fit,operation property # Supported operations, with the fit,operation property
OP_GEN_FDT_NODES, OP_SPLIT_ELF = range(2) OP_GEN_FDT_NODES, OP_SPLIT_ELF = range(2)

View file

@ -7,9 +7,9 @@
from binman.entry import Entry from binman.entry import Entry
from binman import fmap_util from binman import fmap_util
from patman import tools from u_boot_pylib import tools
from patman.tools import to_hex_size from u_boot_pylib.tools import to_hex_size
from patman import tout from u_boot_pylib import tout
class Entry_fmap(Entry): class Entry_fmap(Entry):

View file

@ -8,11 +8,11 @@
from collections import OrderedDict from collections import OrderedDict
from patman import command from u_boot_pylib import command
from binman.entry import Entry, EntryArg from binman.entry import Entry, EntryArg
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
# Build GBB flags. # Build GBB flags.
# (src/platform/vboot_reference/firmware/include/gbb_header.h) # (src/platform/vboot_reference/firmware/include/gbb_header.h)

View file

@ -10,7 +10,7 @@ from collections import OrderedDict
from binman.entry import Entry from binman.entry import Entry
from binman.etype.blob_ext import Entry_blob_ext from binman.etype.blob_ext import Entry_blob_ext
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_intel_ifwi(Entry_blob_ext): class Entry_intel_ifwi(Entry_blob_ext):
"""Intel Integrated Firmware Image (IFWI) file """Intel Integrated Firmware Image (IFWI) file

View file

@ -9,7 +9,7 @@ from collections import OrderedDict
from binman.entry import Entry from binman.entry import Entry
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_mkimage(Entry): class Entry_mkimage(Entry):
"""Binary produced by mkimage """Binary produced by mkimage

View file

@ -5,7 +5,7 @@
from binman.entry import Entry from binman.entry import Entry
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_null(Entry): class Entry_null(Entry):
"""An entry which has no contents of its own """An entry which has no contents of its own

View file

@ -8,7 +8,7 @@
import os import os
import struct import struct
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
from binman.entry import Entry from binman.entry import Entry
from binman.etype.collection import Entry_collection from binman.etype.collection import Entry_collection

View file

@ -16,9 +16,9 @@ import sys
from binman.entry import Entry from binman.entry import Entry
from binman import state from binman import state
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
from patman.tools import to_hex_size from u_boot_pylib.tools import to_hex_size
class Entry_section(Entry): class Entry_section(Entry):

View file

@ -7,7 +7,7 @@ from collections import OrderedDict
from binman.entry import Entry, EntryArg from binman.entry import Entry, EntryArg
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_text(Entry): class Entry_text(Entry):

View file

@ -7,7 +7,7 @@
from binman.entry import Entry from binman.entry import Entry
from binman.etype.blob_dtb import Entry_blob_dtb from binman.etype.blob_dtb import Entry_blob_dtb
from patman import tools from u_boot_pylib import tools
# This is imported if needed # This is imported if needed
state = None state = None

View file

@ -9,7 +9,7 @@ from binman.entry import Entry
from binman.etype.blob import Entry_blob from binman.etype.blob import Entry_blob
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_u_boot_elf(Entry_blob): class Entry_u_boot_elf(Entry_blob):
"""U-Boot ELF image """U-Boot ELF image

View file

@ -8,7 +8,7 @@ import zlib
from binman.etype.blob import Entry_blob from binman.etype.blob import Entry_blob
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_u_boot_env(Entry_blob): class Entry_u_boot_env(Entry_blob):
"""An entry which contains a U-Boot environment """An entry which contains a U-Boot environment

View file

@ -10,7 +10,7 @@
from binman import elf from binman import elf
from binman.entry import Entry from binman.entry import Entry
from binman.etype.blob import Entry_blob 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): class Entry_u_boot_spl_bss_pad(Entry_blob):
"""U-Boot SPL binary padded with a BSS region """U-Boot SPL binary padded with a BSS region

View file

@ -5,7 +5,7 @@
# Entry-type module for expanded U-Boot SPL binary # 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 import state
from binman.etype.blob_phase import Entry_blob_phase from binman.etype.blob_phase import Entry_blob_phase

View file

@ -10,7 +10,7 @@
from binman import elf from binman import elf
from binman.entry import Entry from binman.entry import Entry
from binman.etype.blob import Entry_blob 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): class Entry_u_boot_tpl_bss_pad(Entry_blob):
"""U-Boot TPL binary padded with a BSS region """U-Boot TPL binary padded with a BSS region

View file

@ -5,7 +5,7 @@
# Entry-type module for expanded U-Boot TPL binary # 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 import state
from binman.etype.blob_phase import Entry_blob_phase from binman.etype.blob_phase import Entry_blob_phase

View file

@ -7,11 +7,11 @@
import struct import struct
from patman import command
from binman.entry import Entry from binman.entry import Entry
from binman.etype.blob import Entry_blob from binman.etype.blob import Entry_blob
from binman.etype.u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr 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): class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr):
"""U-Boot TPL with embedded microcode pointer """U-Boot TPL with embedded microcode pointer

View file

@ -7,7 +7,7 @@
from binman.entry import Entry from binman.entry import Entry
from binman.etype.blob import Entry_blob from binman.etype.blob import Entry_blob
from patman import tools from u_boot_pylib import tools
class Entry_u_boot_ucode(Entry_blob): class Entry_u_boot_ucode(Entry_blob):
"""U-Boot microcode block """U-Boot microcode block

View file

@ -10,7 +10,7 @@
from binman import elf from binman import elf
from binman.entry import Entry from binman.entry import Entry
from binman.etype.blob import Entry_blob 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): class Entry_u_boot_vpl_bss_pad(Entry_blob):
"""U-Boot VPL binary padded with a BSS region """U-Boot VPL binary padded with a BSS region

View file

@ -5,7 +5,7 @@
# Entry-type module for expanded U-Boot VPL binary # 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 import state
from binman.etype.blob_phase import Entry_blob_phase from binman.etype.blob_phase import Entry_blob_phase

View file

@ -11,8 +11,8 @@ from binman import elf
from binman.entry import Entry from binman.entry import Entry
from binman.etype.blob import Entry_blob from binman.etype.blob import Entry_blob
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
from patman import command from u_boot_pylib import command
class Entry_u_boot_with_ucode_ptr(Entry_blob): class Entry_u_boot_with_ucode_ptr(Entry_blob):
"""U-Boot with embedded microcode pointer """U-Boot with embedded microcode pointer

View file

@ -13,7 +13,7 @@ from binman.entry import EntryArg
from binman.etype.collection import Entry_collection from binman.etype.collection import Entry_collection
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
class Entry_vblock(Entry_collection): class Entry_vblock(Entry_collection):
"""An entry which contains a Chromium OS verified boot block """An entry which contains a Chromium OS verified boot block

View file

@ -12,7 +12,7 @@ import unittest
from dtoc import fdt from dtoc import fdt
from dtoc import fdt_util from dtoc import fdt_util
from dtoc.fdt import FdtScan from dtoc.fdt import FdtScan
from patman import tools from u_boot_pylib import tools
class TestFdt(unittest.TestCase): class TestFdt(unittest.TestCase):
@classmethod @classmethod

View file

@ -37,8 +37,8 @@ OUR_PATH = os.path.dirname(OUR_FILE)
sys.path.insert(2, os.path.join(OUR_PATH, '..')) sys.path.insert(2, os.path.join(OUR_PATH, '..'))
# pylint: disable=C0413 # pylint: disable=C0413
from patman import command from u_boot_pylib import command
from patman import tools from u_boot_pylib import tools
# The TOC header, at the start of the FIP # The TOC header, at the start of the FIP
HEADER_FORMAT = '<IIQ' HEADER_FORMAT = '<IIQ'

View file

@ -20,10 +20,10 @@ OUR_PATH = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(2, os.path.join(OUR_PATH, '..')) sys.path.insert(2, os.path.join(OUR_PATH, '..'))
# pylint: disable=C0413 # pylint: disable=C0413
from patman import test_util
from patman import tools
from binman import bintool from binman import bintool
from binman import fip_util from binman import fip_util
from u_boot_pylib import test_util
from u_boot_pylib import tools
FIPTOOL = bintool.Bintool.create('fiptool') FIPTOOL = bintool.Bintool.create('fiptool')
HAVE_FIPTOOL = FIPTOOL.is_present() HAVE_FIPTOOL = FIPTOOL.is_present()

View file

@ -10,7 +10,7 @@ import collections
import struct import struct
import sys import sys
from patman import tools from u_boot_pylib import tools
# constants imported from lib/fmap.h # constants imported from lib/fmap.h
FMAP_SIGNATURE = b'__FMAP__' FMAP_SIGNATURE = b'__FMAP__'

View file

@ -34,10 +34,10 @@ from dtoc import fdt_util
from binman.etype import fdtmap from binman.etype import fdtmap
from binman.etype import image_header from binman.etype import image_header
from binman.image import Image from binman.image import Image
from patman import command from u_boot_pylib import command
from patman import test_util from u_boot_pylib import test_util
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
# Contents of test files, corresponding to different entry types # Contents of test files, corresponding to different entry types
U_BOOT_DATA = b'1234' U_BOOT_DATA = b'1234'

View file

@ -18,8 +18,8 @@ from binman.etype import image_header
from binman.etype import section from binman.etype import section
from dtoc import fdt from dtoc import fdt
from dtoc import fdt_util from dtoc import fdt_util
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
class Image(section.Entry_section): class Image(section.Entry_section):
"""A Image, representing an output from binman """A Image, representing an output from binman

View file

@ -7,7 +7,7 @@
import unittest import unittest
from binman.image import Image 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): class TestImage(unittest.TestCase):
def testInvalidFormat(self): def testInvalidFormat(self):

View file

@ -34,7 +34,7 @@ sys.pycache_prefix = os.path.relpath(our_path, srctree)
sys.path.insert(2, our1_path) sys.path.insert(2, our1_path)
from binman import bintool from binman import bintool
from patman import test_util from u_boot_pylib import test_util
# Bring in the libfdt module # Bring in the libfdt module
sys.path.insert(2, 'scripts/dtc/pylibfdt') 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 cmdline
from binman import control 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): def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
"""Run the functional tests and any embedded doctests """Run the functional tests and any embedded doctests
@ -95,7 +95,8 @@ def RunTestCoverage(toolpath):
for path in toolpath: for path in toolpath:
extra_args += ' --toolpath %s' % path extra_args += ' --toolpath %s' % path
test_util.run_test_coverage('tools/binman/binman', None, 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) args.build_dir, all_set, extra_args or None)
def RunBinman(args): def RunBinman(args):

View file

@ -13,8 +13,8 @@ import threading
from dtoc import fdt from dtoc import fdt
import os import os
from patman import tools from u_boot_pylib import tools
from patman import tout from u_boot_pylib import tout
OUR_PATH = os.path.dirname(os.path.realpath(__file__)) OUR_PATH = os.path.dirname(os.path.realpath(__file__))

View file

@ -19,10 +19,10 @@ import time
from buildman import builderthread from buildman import builderthread
from buildman import toolchain from buildman import toolchain
from patman import command
from patman import gitutil from patman import gitutil
from patman import terminal from u_boot_pylib import command
from patman.terminal import tprint 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 # 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. # It hangs the build since the 'conf' tool cannot proceed without valid input.

View file

@ -10,8 +10,8 @@ import sys
import threading import threading
from buildman import cfgutil from buildman import cfgutil
from patman import command
from patman import gitutil from patman import gitutil
from u_boot_pylib import command
RETURN_CODE_RETRY = -1 RETURN_CODE_RETRY = -1
BASE_ELF_FILENAMES = ['u-boot', 'spl/u-boot-spl', 'tpl/u-boot-tpl'] BASE_ELF_FILENAMES = ['u-boot', 'spl/u-boot-spl', 'tpl/u-boot-tpl']

View file

@ -7,7 +7,7 @@
import re 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_LINE = re.compile(r'(# )?CONFIG_([A-Z0-9_]+)(=(.*)| is not set)')
RE_CFG = re.compile(r'(~?)(CONFIG_)?([A-Z0-9_]+)(=.*)?') RE_CFG = re.compile(r'(~?)(CONFIG_)?([A-Z0-9_]+)(=.*)?')

View file

@ -13,12 +13,12 @@ from buildman import bsettings
from buildman import cfgutil from buildman import cfgutil
from buildman import toolchain from buildman import toolchain
from buildman.builder import Builder from buildman.builder import Builder
from patman import command
from patman import gitutil from patman import gitutil
from patman import patchstream from patman import patchstream
from patman import terminal from u_boot_pylib import command
from patman import tools from u_boot_pylib import terminal
from patman.terminal import tprint from u_boot_pylib import tools
from u_boot_pylib.terminal import tprint
def GetPlural(count): def GetPlural(count):
"""Returns a plural 's' if count is not 1""" """Returns a plural 's' if count is not 1"""

View file

@ -14,11 +14,11 @@ from buildman import bsettings
from buildman import cmdline from buildman import cmdline
from buildman import control from buildman import control
from buildman import toolchain from buildman import toolchain
from patman import command
from patman import gitutil from patman import gitutil
from patman import terminal from u_boot_pylib import command
from patman import test_util from u_boot_pylib import terminal
from patman import tools from u_boot_pylib import test_util
from u_boot_pylib import tools
settings_data = ''' settings_data = '''
# Buildman settings file # Buildman settings file

View file

@ -25,8 +25,8 @@ from buildman import control
from buildman import toolchain from buildman import toolchain
from patman import patchstream from patman import patchstream
from patman import gitutil from patman import gitutil
from patman import terminal from u_boot_pylib import terminal
from patman import test_util from u_boot_pylib import test_util
def RunTests(skip_net_tests, verboose, args): def RunTests(skip_net_tests, verboose, args):
from buildman import func_test from buildman import func_test

View file

@ -17,10 +17,10 @@ from buildman import cfgutil
from buildman import control from buildman import control
from buildman import toolchain from buildman import toolchain
from patman import commit from patman import commit
from patman import command from u_boot_pylib import command
from patman import terminal from u_boot_pylib import terminal
from patman import test_util from u_boot_pylib import test_util
from patman import tools from u_boot_pylib import tools
use_network = True use_network = True

View file

@ -11,9 +11,9 @@ import tempfile
import urllib.request, urllib.error, urllib.parse import urllib.request, urllib.error, urllib.parse
from buildman import bsettings from buildman import bsettings
from patman import command from u_boot_pylib import command
from patman import terminal from u_boot_pylib import terminal
from patman import tools from u_boot_pylib import tools
(PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH, (PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH,
PRIORITY_CALC) = list(range(4)) PRIORITY_CALC) = list(range(4))

View file

@ -12,7 +12,7 @@ import sys
from dtoc import fdt_util from dtoc import fdt_util
import libfdt import libfdt
from libfdt import QUIET_NOTFOUND 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 # This deals with a device tree, presenting it as an assortment of Node and
# Prop objects, representing nodes and properties, respectively. This file # Prop objects, representing nodes and properties, respectively. This file

View file

@ -13,8 +13,8 @@ import struct
import sys import sys
import tempfile import tempfile
from patman import command from u_boot_pylib import command
from patman import tools from u_boot_pylib import tools
def fdt32_to_cpu(val): def fdt32_to_cpu(val):
"""Convert a device tree cell to an integer """Convert a device tree cell to an integer

View file

@ -35,7 +35,7 @@ sys.path.insert(0, os.path.join(our_path,
'../../build-sandbox_spl/scripts/dtc/pylibfdt')) '../../build-sandbox_spl/scripts/dtc/pylibfdt'))
from dtoc import dtb_platdata from dtoc import dtb_platdata
from patman import test_util from u_boot_pylib import test_util
def run_tests(processes, args): def run_tests(processes, args):
"""Run all the test we have for dtoc """Run all the test we have for dtoc
@ -65,7 +65,8 @@ def RunTestCoverage():
"""Run the tests and check that we get 100% coverage""" """Run the tests and check that we get 100% coverage"""
sys.argv = [sys.argv[0]] sys.argv = [sys.argv[0]]
test_util.run_test_coverage('tools/dtoc/dtoc', '/main.py', 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__': if __name__ != '__main__':

View file

@ -25,8 +25,8 @@ from dtoc.dtb_platdata import get_value
from dtoc.dtb_platdata import tab_to from dtoc.dtb_platdata import tab_to
from dtoc.src_scan import conv_name_to_c from dtoc.src_scan import conv_name_to_c
from dtoc.src_scan import get_compat_name from dtoc.src_scan import get_compat_name
from patman import test_util from u_boot_pylib import test_util
from patman import tools from u_boot_pylib import tools
OUR_PATH = os.path.dirname(os.path.realpath(__file__)) OUR_PATH = os.path.dirname(os.path.realpath(__file__))

View file

@ -30,8 +30,8 @@ from dtoc import fdt_util
from dtoc.fdt_util import fdt32_to_cpu, fdt64_to_cpu from dtoc.fdt_util import fdt32_to_cpu, fdt64_to_cpu
from dtoc.fdt import Type, BytesToValue from dtoc.fdt import Type, BytesToValue
import libfdt import libfdt
from patman import test_util from u_boot_pylib import test_util
from patman import tools from u_boot_pylib import tools
#pylint: disable=protected-access #pylint: disable=protected-access
@ -814,7 +814,8 @@ def run_test_coverage(build_dir):
build_dir (str): Directory containing the build output build_dir (str): Directory containing the build output
""" """
test_util.run_test_coverage('tools/dtoc/test_fdt.py', None, 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): def run_tests(names, processes):

View file

@ -15,8 +15,8 @@ import unittest
from unittest import mock from unittest import mock
from dtoc import src_scan from dtoc import src_scan
from patman import test_util from u_boot_pylib import test_util
from patman import tools from u_boot_pylib import tools
OUR_PATH = os.path.dirname(os.path.realpath(__file__)) OUR_PATH = os.path.dirname(os.path.realpath(__file__))

View file

@ -1,6 +1,5 @@
# SPDX-License-Identifier: GPL-2.0+ # SPDX-License-Identifier: GPL-2.0+
__all__ = ['checkpatch', 'command', 'commit', 'control', 'cros_subprocess', __all__ = ['checkpatch', 'commit', 'control', 'func_test', 'get_maintainer',
'func_test', 'get_maintainer', 'gitutil', '__main__', 'patchstream', 'gitutil', '__main__', 'patchstream', 'project', 'series',
'project', 'series', 'setup', 'settings', 'terminal', 'settings','setup', 'status', 'test_checkpatch', 'test_settings']
'test_checkpatch', 'test_util', 'tools', 'tout']

View file

@ -24,10 +24,10 @@ from patman import func_test
from patman import gitutil from patman import gitutil
from patman import project from patman import project
from patman import settings from patman import settings
from patman import terminal
from patman import test_util
from patman import test_checkpatch 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 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.''' 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( result = test_util.run_test_suites(
'patman', False, False, False, None, None, None, 'patman', False, False, False, None, None, None,
[test_checkpatch.TestPatch, func_test.TestFunctional, [test_checkpatch.TestPatch, func_test.TestFunctional,
'gitutil', 'settings', 'terminal']) 'gitutil', 'settings'])
sys.exit(0 if result.wasSuccessful() else 1) sys.exit(0 if result.wasSuccessful() else 1)

View file

@ -7,9 +7,9 @@ import os
import re import re
import sys import sys
from patman import command
from patman import gitutil 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]+: )?' EMACS_PREFIX = r'(?:[0-9]{4}.*\.patch:[0-9]+: )?'
TYPE_NAME = r'([A-Z_]+:)?' TYPE_NAME = r'([A-Z_]+:)?'

View file

@ -14,7 +14,7 @@ import sys
from patman import checkpatch from patman import checkpatch
from patman import gitutil from patman import gitutil
from patman import patchstream from patman import patchstream
from patman import terminal from u_boot_pylib import terminal
def setup(): def setup():
"""Do required setup before doing anything""" """Do required setup before doing anything"""

View file

@ -23,9 +23,9 @@ from patman import patchstream
from patman.patchstream import PatchStream from patman.patchstream import PatchStream
from patman.series import Series from patman.series import Series
from patman import settings from patman import settings
from patman import terminal from u_boot_pylib import terminal
from patman import tools from u_boot_pylib import tools
from patman.test_util import capture_sys_output from u_boot_pylib.test_util import capture_sys_output
import pygit2 import pygit2
from patman import status from patman import status

View file

@ -7,8 +7,8 @@ import os
import shlex import shlex
import shutil import shutil
from patman import command
from patman import gitutil from patman import gitutil
from u_boot_pylib import command
def find_get_maintainer(script_file_name): def find_get_maintainer(script_file_name):

View file

@ -5,9 +5,9 @@
import os import os
import sys import sys
from patman import command
from patman import settings 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() # True to use --no-decorate - we check this in setup()
use_no_decorate = True use_no_decorate = True

View file

@ -14,10 +14,10 @@ import queue
import shutil import shutil
import tempfile import tempfile
from patman import command
from patman import commit from patman import commit
from patman import gitutil from patman import gitutil
from patman.series import Series from patman.series import Series
from u_boot_pylib import command
# Tags that we detect and remove # Tags that we detect and remove
RE_REMOVE = re.compile(r'^BUG=|^TEST=|^BRANCH=|^Review URL:' RE_REMOVE = re.compile(r'^BUG=|^TEST=|^BRANCH=|^Review URL:'

View file

@ -11,8 +11,8 @@ import os
from patman import get_maintainer from patman import get_maintainer
from patman import gitutil from patman import gitutil
from patman import settings from patman import settings
from patman import terminal from u_boot_pylib import terminal
from patman import tools from u_boot_pylib import tools
# Series-xxx tags that we understand # Series-xxx tags that we understand
valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name', valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',

View file

@ -18,8 +18,8 @@ import requests
from patman import patchstream from patman import patchstream
from patman.patchstream import PatchStream from patman.patchstream import PatchStream
from patman import terminal from u_boot_pylib import terminal
from patman import tout from u_boot_pylib import tout
# Patches which are part of a multi-patch series are shown with a prefix like # 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 # [prefix, version, sequence], for example '[RFC, v2, 3/5]'. All but the last

View file

@ -10,7 +10,7 @@ import sys
import tempfile import tempfile
from patman import settings from patman import settings
from patman import tools from u_boot_pylib import tools
@contextlib.contextmanager @contextlib.contextmanager

View file

@ -28,7 +28,7 @@ import os
import re import re
import sys import sys
from patman import command from u_boot_pylib import command
def rm_kconfig_include(path): def rm_kconfig_include(path):
"""Remove a path from Kconfig files """Remove a path from Kconfig files

View file

@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0+
__all__ = ['command', 'cros_subprocess','terminal', 'test_util', 'tools',
'tout']

23
tools/u_boot_pylib/__main__.py Executable file
View file

@ -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)

View file

@ -4,7 +4,7 @@
import os import os
from patman import cros_subprocess from u_boot_pylib import cros_subprocess
"""Shell command ease-ups for Python.""" """Shell command ease-ups for Python."""

View file

@ -11,7 +11,7 @@ import os
import sys import sys
import unittest import unittest
from patman import command from u_boot_pylib import command
from io import StringIO from io import StringIO

View file

@ -11,8 +11,8 @@ import sys
import tempfile import tempfile
import urllib.request import urllib.request
from patman import command from u_boot_pylib import command
from patman import tout from u_boot_pylib import tout
# Output directly (generally this is temporary) # Output directly (generally this is temporary)
outdir = None outdir = None

View file

@ -6,7 +6,7 @@
import sys import sys
from patman import terminal from u_boot_pylib import terminal
# Output verbosity levels that we support # Output verbosity levels that we support
ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6) ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6)

View file

@ -0,0 +1 @@
__main__.py