At present patman sets the python path on startup so that it can access
the libraries it needs. If we convert to use absolute imports this is not
necessary.
Move patman to use absolute imports. This requires changes in tools which
use the patman libraries (which is most of them).
Signed-off-by: Simon Glass <sjg@chromium.org>
58 files changed:
import sys
from binman import elf
import sys
from binman import elf
-import command
-import tools
+from patman import command
+from patman import tools
# Set to True to enable printing output while working
DEBUG = False
# Set to True to enable printing output while working
DEBUG = False
from binman import cbfs_util
from binman.cbfs_util import CbfsWriter
from binman import elf
from binman import cbfs_util
from binman.cbfs_util import CbfsWriter
from binman import elf
-import test_util
-import tools
+from patman import test_util
+from patman import tools
U_BOOT_DATA = b'1234'
U_BOOT_DTB_DATA = b'udtb'
U_BOOT_DATA = b'1234'
U_BOOT_DTB_DATA = b'udtb'
from collections import OrderedDict
import os
import sys
from collections import OrderedDict
import os
import sys
+from patman import tools
from binman import cbfs_util
from binman import elf
from binman import cbfs_util
from binman import elf
-import command
-import tout
+from patman import command
+from patman import tout
# List of images we plan to create
# Make this global so that it can be referenced from tests
# List of images we plan to create
# Make this global so that it can be referenced from tests
import struct
import tempfile
import struct
import tempfile
-import command
-import tools
-import tout
+from patman import command
+from patman import tools
+from patman import tout
import unittest
from binman import elf
import unittest
from binman import elf
-import command
-import test_util
-import tools
-import tout
+from patman import command
+from patman import test_util
+from patman import tools
+from patman import tout
binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
binman_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
import sys
from dtoc import fdt_util
import sys
from dtoc import fdt_util
+from patman import tools
from patman.tools import ToHex, ToHexSize
from patman.tools import ToHex, ToHexSize
from binman import entry
from dtoc import fdt
from dtoc import fdt_util
from binman import entry
from dtoc import fdt
from dtoc import fdt_util
+from patman import tools
class TestEntry(unittest.TestCase):
def setUp(self):
class TestEntry(unittest.TestCase):
def setUp(self):
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
+from patman import tools
class Entry__testing(Entry):
class Entry__testing(Entry):
from binman.entry import Entry
from dtoc import fdt_util
from binman.entry import Entry
from dtoc import fdt_util
-import tools
-import tout
+from patman import tools
+from patman import tout
class Entry_blob(Entry):
"""Entry containing an arbitrary binary blob
class Entry_blob(Entry):
"""Entry containing an arbitrary binary blob
"""
from binman.entry import Entry
"""
from binman.entry import Entry
-import tools
-import tout
+from patman import tools
+from patman import tout
FDTMAP_MAGIC = b'_FDTMAP_'
FDTMAP_HDR_LEN = 16
FDTMAP_MAGIC = b'_FDTMAP_'
FDTMAP_HDR_LEN = 16
from binman.etype.section import Entry_section
from dtoc import fdt_util
from binman.etype.section import Entry_section
from dtoc import fdt_util
+from patman import tools
class Entry_files(Entry_section):
class Entry_files(Entry_section):
from binman.entry import Entry
from dtoc import fdt_util
from binman.entry import Entry
from dtoc import fdt_util
+from patman import tools
class Entry_fill(Entry):
"""An entry which is filled to a particular byte value
class Entry_fill(Entry):
"""An entry which is filled to a particular byte value
from binman.entry import Entry
from binman import fmap_util
from binman.entry import Entry
from binman import fmap_util
+from patman import tools
from patman.tools import ToHexSize
from patman.tools import ToHexSize
from collections import OrderedDict
from collections import OrderedDict
+from patman import command
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
+from patman import tools
# Build GBB flags.
# (src/platform/vboot_reference/firmware/include/gbb_header.h)
# Build GBB flags.
# (src/platform/vboot_reference/firmware/include/gbb_header.h)
from binman.entry import Entry
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
from binman.entry import Entry
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
+from patman import tools
class Entry_intel_ifwi(Entry_blob):
"""Entry containing an Intel Integrated Firmware Image (IFWI) file
class Entry_intel_ifwi(Entry_blob):
"""Entry containing an Intel Integrated Firmware Image (IFWI) file
from binman.entry import Entry
from dtoc import fdt_util
from binman.entry import Entry
from dtoc import fdt_util
-import tools
-import tout
+from patman import tools
+from patman import tout
class Entry_section(Entry):
class Entry_section(Entry):
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
+from patman import tools
from binman.entry import Entry
from binman.etype.blob_dtb import Entry_blob_dtb
from binman.entry import Entry
from binman.etype.blob_dtb import Entry_blob_dtb
+from patman import tools
class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb):
"""A U-Boot device tree file, with the microcode removed
class Entry_u_boot_dtb_with_ucode(Entry_blob_dtb):
"""A U-Boot device tree file, with the microcode removed
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
+from patman import tools
class Entry_u_boot_elf(Entry_blob):
"""U-Boot ELF image
class Entry_u_boot_elf(Entry_blob):
"""U-Boot ELF image
from binman import elf
from binman.entry import Entry
from binman import elf
from binman.entry import Entry
+from patman import command
from binman.etype.blob import Entry_blob
from binman.etype.blob import Entry_blob
+from patman import tools
class Entry_u_boot_spl_bss_pad(Entry_blob):
"""U-Boot SPL binary padded with a BSS region
class Entry_u_boot_spl_bss_pad(Entry_blob):
"""U-Boot SPL binary padded with a BSS region
+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 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
class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr):
"""U-Boot TPL with embedded microcode pointer
class Entry_u_boot_tpl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr):
"""U-Boot TPL with embedded microcode pointer
from binman.entry import Entry
from binman.etype.blob import Entry_blob
from binman.entry import Entry
from binman.etype.blob import Entry_blob
+from patman import tools
class Entry_u_boot_ucode(Entry_blob):
"""U-Boot microcode block
class Entry_u_boot_ucode(Entry_blob):
"""U-Boot microcode block
from binman.entry import Entry
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
from binman.entry import Entry
from binman.etype.blob import Entry_blob
from dtoc import fdt_util
-import tools
-import command
+from patman import tools
+from patman import command
class Entry_u_boot_with_ucode_ptr(Entry_blob):
"""U-Boot with embedded microcode pointer
class Entry_u_boot_with_ucode_ptr(Entry_blob):
"""U-Boot with embedded microcode pointer
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
from binman.entry import Entry, EntryArg
from dtoc import fdt_util
+from patman import tools
class Entry_vblock(Entry):
"""An entry which contains a Chromium OS verified boot block
class Entry_vblock(Entry):
"""An entry which contains a Chromium OS verified boot block
from dtoc import fdt
from dtoc import fdt_util
from dtoc.fdt import FdtScan
from dtoc import fdt
from dtoc import fdt_util
from dtoc.fdt import FdtScan
+from patman import tools
class TestFdt(unittest.TestCase):
@classmethod
class TestFdt(unittest.TestCase):
@classmethod
+from patman import tools
# constants imported from lib/fmap.h
FMAP_SIGNATURE = b'__FMAP__'
# constants imported from lib/fmap.h
FMAP_SIGNATURE = b'__FMAP__'
from binman.etype import fdtmap
from binman.etype import image_header
from image import Image
from binman.etype import fdtmap
from binman.etype import image_header
from image import Image
-import command
-import test_util
-import tools
-import tout
+from patman import command
+from patman import test_util
+from patman import tools
+from patman import tout
# Contents of test files, corresponding to different entry types
U_BOOT_DATA = b'1234'
# Contents of test files, corresponding to different entry types
U_BOOT_DATA = b'1234'
from binman.etype import section
from dtoc import fdt
from dtoc import fdt_util
from binman.etype import section
from dtoc import fdt
from dtoc import fdt_util
-import tools
-import tout
+from patman import tools
+from patman import tout
class Image(section.Entry_section):
"""A Image, representing an output from binman
class Image(section.Entry_section):
"""A Image, representing an output from binman
from binman import cmdline
from binman import control
from binman import cmdline
from binman import control
+from patman import test_util
def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
"""Run the functional tests and any embedded doctests
def RunTests(debug, verbosity, processes, test_preserve_dirs, args, toolpath):
"""Run the functional tests and any embedded doctests
from dtoc import fdt
import os
from dtoc import fdt
import os
-import tools
-import tout
+from patman import tools
+from patman import tout
# Records the device-tree files known to binman, keyed by entry type (e.g.
# 'u-boot-spl-dtb'). These are the output FDT files, which can be updated by
# Records the device-tree files known to binman, keyed by entry type (e.g.
# 'u-boot-spl-dtb'). These are the output FDT files, which can be updated by
from buildman import builderthread
from buildman import toolchain
from buildman import builderthread
from buildman import toolchain
-import command
-import gitutil
-import terminal
-from terminal import Print
+from patman import command
+from patman import gitutil
+from patman import terminal
+from patman.terminal import Print
import sys
import threading
import sys
import threading
-import command
-import gitutil
+from patman import command
+from patman import gitutil
from buildman import bsettings
from buildman import toolchain
from buildman.builder import Builder
from buildman import bsettings
from buildman import toolchain
from buildman.builder import Builder
-import command
-import gitutil
-import patchstream
-import terminal
-from terminal import Print
+from patman import command
+from patman import gitutil
+from patman import patchstream
+from patman import terminal
+from patman.terminal import Print
def GetPlural(count):
"""Returns a plural 's' if count is not 1"""
def GetPlural(count):
"""Returns a plural 's' if count is not 1"""
from buildman import cmdline
from buildman import control
from buildman import toolchain
from buildman import cmdline
from buildman import control
from buildman import toolchain
-import command
-import gitutil
-import terminal
-import toolchain
-import tools
+from patman import command
+from patman import gitutil
+from patman import terminal
+from patman import tools
settings_data = '''
# Buildman settings file
settings_data = '''
# Buildman settings file
from buildman import cmdline
from buildman import control
from buildman import toolchain
from buildman import cmdline
from buildman import control
from buildman import toolchain
-import patchstream
-import gitutil
-import terminal
+from patman import patchstream
+from patman import gitutil
+from patman import terminal
def RunTests(skip_net_tests):
import func_test
def RunTests(skip_net_tests):
import func_test
from buildman import builder
from buildman import control
from buildman import toolchain
from buildman import builder
from buildman import control
from buildman import toolchain
-import commit
-import command
-import terminal
-import test_util
-import tools
+from patman import commit
+from patman import command
+from patman import terminal
+from patman import test_util
+from patman import tools
import urllib.request, urllib.error, urllib.parse
from buildman import bsettings
import urllib.request, urllib.error, urllib.parse
from buildman import bsettings
-import command
-import terminal
-import tools
+from patman import command
+from patman import terminal
+from patman import tools
(PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH,
PRIORITY_CALC) = list(range(4))
(PRIORITY_FULL_PREFIX, PRIORITY_PREFIX_GCC, PRIORITY_PREFIX_GCC_PATH,
PRIORITY_CALC) = list(range(4))
-import fdt
-import fdt_util
-import tools
+from dtoc import fdt
+from dtoc import fdt_util
+from patman import tools
# When we see these properties we ignore them - i.e. do not create a structure member
PROP_IGNORE_LIST = [
# When we see these properties we ignore them - i.e. do not create a structure member
PROP_IGNORE_LIST = [
+from dtoc import fdt_util
import libfdt
from libfdt import QUIET_NOTFOUND
import libfdt
from libfdt import QUIET_NOTFOUND
+from patman 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
# This deals with a device tree, presenting it as an assortment of Node and
# Prop objects, representing nodes and properties, respectively. This file
import sys
import tempfile
import sys
import tempfile
-import command
-import tools
+from patman import command
+from patman import tools
def fdt32_to_cpu(val):
"""Convert a device tree cell to an integer
def fdt32_to_cpu(val):
"""Convert a device tree cell to an integer
# Bring in the patman libraries
our_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(our_path, '../patman'))
# Bring in the patman libraries
our_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(our_path, '../patman'))
+sys.path.append(os.path.join(our_path, '..'))
# Bring in the libfdt module
sys.path.insert(0, 'scripts/dtc/pylibfdt')
sys.path.insert(0, os.path.join(our_path,
'../../build-sandbox_spl/scripts/dtc/pylibfdt'))
# Bring in the libfdt module
sys.path.insert(0, 'scripts/dtc/pylibfdt')
sys.path.insert(0, os.path.join(our_path,
'../../build-sandbox_spl/scripts/dtc/pylibfdt'))
-import dtb_platdata
-import test_util
+from dtoc import dtb_platdata
+from patman import test_util
def run_tests(args):
"""Run all the test we have for dtoc
def run_tests(args):
"""Run all the test we have for dtoc
import struct
import unittest
import struct
import unittest
+from dtoc import dtb_platdata
from dtb_platdata import conv_name_to_c
from dtb_platdata import get_compat_name
from dtb_platdata import get_value
from dtb_platdata import tab_to
from dtb_platdata import conv_name_to_c
from dtb_platdata import get_compat_name
from dtb_platdata import get_value
from dtb_platdata import tab_to
-import fdt
-import fdt_util
-import test_util
-import tools
+from dtoc import fdt
+from dtoc import fdt_util
+from patman import test_util
+from patman import tools
our_path = os.path.dirname(os.path.realpath(__file__))
our_path = os.path.dirname(os.path.realpath(__file__))
for dirname in ['../patman', '..']:
sys.path.insert(0, os.path.join(our_path, dirname))
for dirname in ['../patman', '..']:
sys.path.insert(0, os.path.join(our_path, dirname))
-import command
-import fdt
+from dtoc import fdt
+from dtoc import fdt_util
+from dtoc.fdt_util import fdt32_to_cpu
from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, BytesToValue
from fdt import TYPE_BYTE, TYPE_INT, TYPE_STRING, TYPE_BOOL, BytesToValue
-import fdt_util
-from fdt_util import fdt32_to_cpu
-import test_util
-import tools
+from patman import command
+from patman import test_util
+from patman import tools
def _GetPropertyValue(dtb, node, prop_name):
"""Low-level function to get the property value based on its offset
def _GetPropertyValue(dtb, node, prop_name):
"""Low-level function to get the property value based on its offset
-import command
-import gitutil
import os
import re
import sys
import os
import re
import sys
+
+from patman import command
+from patman import gitutil
+from patman import terminal
+from patman import tools
def FindCheckPatch():
top_level = gitutil.GetTopLevel()
def FindCheckPatch():
top_level = gitutil.GetTopLevel()
-import cros_subprocess
-import tools
+
+from patman import cros_subprocess
+from patman import tools
"""Shell command ease-ups for Python."""
"""Shell command ease-ups for Python."""
-import gitutil
-import patchstream
-import settings
-import tools
+from patman import gitutil
+from patman import patchstream
+from patman import settings
+from patman import tools
@contextlib.contextmanager
@contextlib.contextmanager
# Copyright (c) 2012 The Chromium OS Authors.
#
# Copyright (c) 2012 The Chromium OS Authors.
#
-import command
-import gitutil
+from patman import command
+from patman import gitutil
+
def FindGetMaintainer():
"""Look for the get_maintainer.pl script.
def FindGetMaintainer():
"""Look for the get_maintainer.pl script.
# Copyright (c) 2011 The Chromium OS Authors.
#
# Copyright (c) 2011 The Chromium OS Authors.
#
import subprocess
import sys
import subprocess
import sys
-import checkpatch
-import settings
-import tools
+from patman import checkpatch
+from patman import command
+from patman import series
+from patman import settings
+from patman import terminal
+from patman import tools
# True to use --no-decorate - we check this in Setup()
use_no_decorate = True
# True to use --no-decorate - we check this in Setup()
use_no_decorate = True
sys.path.append(os.path.join(our_path, '..'))
# Our modules
sys.path.append(os.path.join(our_path, '..'))
# Our modules
-import checkpatch
-import command
-import gitutil
-import patchstream
-import project
-import settings
-import terminal
-import test
+from patman import checkpatch
+from patman import command
+from patman import gitutil
+from patman import patchstream
+from patman import project
+from patman import settings
+from patman import terminal
+from patman import test
# Run our meagre tests
elif options.test:
import doctest
# Run our meagre tests
elif options.test:
import doctest
+ from patman import func_test
sys.argv = [sys.argv[0]]
result = unittest.TestResult()
sys.argv = [sys.argv[0]]
result = unittest.TestResult()
import shutil
import tempfile
import shutil
import tempfile
-import command
-import commit
-import gitutil
-from series import Series
+from patman import command
+from patman import commit
+from patman import gitutil
+from patman.series import Series
# Tags that we detect and remove
re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Review URL:'
# Tags that we detect and remove
re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Review URL:'
+from patman import gitutil
def DetectProject():
"""Autodetect the name of the current project.
def DetectProject():
"""Autodetect the name of the current project.
import itertools
import os
import itertools
import os
-import get_maintainer
-import gitutil
-import settings
-import terminal
-import tools
+from patman import get_maintainer
+from patman import gitutil
+from patman import settings
+from patman import terminal
+from patman import tools
# Series-xxx tags that we understand
valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
# Series-xxx tags that we understand
valid_series = ['to', 'cc', 'version', 'changes', 'prefix', 'notes', 'name',
-import command
-import gitutil
-import tools
+from patman import command
+from patman import gitutil
+from patman import tools
"""Default settings per-project.
"""Default settings per-project.
import tempfile
import unittest
import tempfile
import unittest
-import checkpatch
-import gitutil
-import patchstream
-import series
-import commit
+from patman import checkpatch
+from patman import gitutil
+from patman import patchstream
+from patman import series
+from patman import commit
class TestPatch(unittest.TestCase):
class TestPatch(unittest.TestCase):
import sys
import unittest
import sys
import unittest
+from patman import command
+from patman import test_util
# Copyright (c) 2016 Google, Inc
#
# Copyright (c) 2016 Google, Inc
#
import glob
import os
import shutil
import glob
import os
import shutil
import sys
import tempfile
import sys
import tempfile
+from patman import command
+from patman import tout
# Output directly (generally this is temporary)
outdir = None
# Output directly (generally this is temporary)
outdir = None
+from patman import terminal
# Output verbosity levels that we support
ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6)
# Output verbosity levels that we support
ERROR, WARNING, NOTICE, INFO, DETAIL, DEBUG = range(6)
our_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(our_path, '../tools/patman'))
our_path = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(our_path, '../tools/patman'))
+from patman import command
def rm_kconfig_include(path):
"""Remove a path from Kconfig files
def rm_kconfig_include(path):
"""Remove a path from Kconfig files