mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-14 12:56:00 +01:00
buildman: Convert camel case in board.py
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
fb5cb07abe
commit
6014db68d3
@ -16,7 +16,7 @@ class Expr:
|
|||||||
self._expr = expr
|
self._expr = expr
|
||||||
self._re = re.compile(expr)
|
self._re = re.compile(expr)
|
||||||
|
|
||||||
def Matches(self, props):
|
def matches(self, props):
|
||||||
"""Check if any of the properties match the regular expression.
|
"""Check if any of the properties match the regular expression.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -42,7 +42,7 @@ class Term:
|
|||||||
self._expr_list = []
|
self._expr_list = []
|
||||||
self._board_count = 0
|
self._board_count = 0
|
||||||
|
|
||||||
def AddExpr(self, expr):
|
def add_expr(self, expr):
|
||||||
"""Add an Expr object to the list to check.
|
"""Add an Expr object to the list to check.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -55,7 +55,7 @@ class Term:
|
|||||||
"""Return some sort of useful string describing the term"""
|
"""Return some sort of useful string describing the term"""
|
||||||
return '&'.join([str(expr) for expr in self._expr_list])
|
return '&'.join([str(expr) for expr in self._expr_list])
|
||||||
|
|
||||||
def Matches(self, props):
|
def matches(self, props):
|
||||||
"""Check if any of the properties match this term
|
"""Check if any of the properties match this term
|
||||||
|
|
||||||
Each of the expressions in the term is checked. All must match.
|
Each of the expressions in the term is checked. All must match.
|
||||||
@ -66,7 +66,7 @@ class Term:
|
|||||||
True if all of the expressions in the Term match, else False
|
True if all of the expressions in the Term match, else False
|
||||||
"""
|
"""
|
||||||
for expr in self._expr_list:
|
for expr in self._expr_list:
|
||||||
if not expr.Matches(props):
|
if not expr.matches(props):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ class Boards:
|
|||||||
# Use a simple list here, sinc OrderedDict requires Python 2.7
|
# Use a simple list here, sinc OrderedDict requires Python 2.7
|
||||||
self._boards = []
|
self._boards = []
|
||||||
|
|
||||||
def AddBoard(self, brd):
|
def add_board(self, brd):
|
||||||
"""Add a new board to the list.
|
"""Add a new board to the list.
|
||||||
|
|
||||||
The board's target member must not already exist in the board list.
|
The board's target member must not already exist in the board list.
|
||||||
@ -113,7 +113,7 @@ class Boards:
|
|||||||
"""
|
"""
|
||||||
self._boards.append(brd)
|
self._boards.append(brd)
|
||||||
|
|
||||||
def ReadBoards(self, fname):
|
def read_boards(self, fname):
|
||||||
"""Read a list of boards from a board file.
|
"""Read a list of boards from a board file.
|
||||||
|
|
||||||
Create a Board object for each and add it to our _boards list.
|
Create a Board object for each and add it to our _boards list.
|
||||||
@ -137,10 +137,10 @@ class Boards:
|
|||||||
fields = fields[:8]
|
fields = fields[:8]
|
||||||
|
|
||||||
brd = Board(*fields)
|
brd = Board(*fields)
|
||||||
self.AddBoard(brd)
|
self.add_board(brd)
|
||||||
|
|
||||||
|
|
||||||
def GetList(self):
|
def get_list(self):
|
||||||
"""Return a list of available boards.
|
"""Return a list of available boards.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -148,7 +148,7 @@ class Boards:
|
|||||||
"""
|
"""
|
||||||
return self._boards
|
return self._boards
|
||||||
|
|
||||||
def GetDict(self):
|
def get_dict(self):
|
||||||
"""Build a dictionary containing all the boards.
|
"""Build a dictionary containing all the boards.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -161,7 +161,7 @@ class Boards:
|
|||||||
board_dict[brd.target] = brd
|
board_dict[brd.target] = brd
|
||||||
return board_dict
|
return board_dict
|
||||||
|
|
||||||
def GetSelectedDict(self):
|
def get_selected_dict(self):
|
||||||
"""Return a dictionary containing the selected boards
|
"""Return a dictionary containing the selected boards
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -173,7 +173,7 @@ class Boards:
|
|||||||
board_dict[brd.target] = brd
|
board_dict[brd.target] = brd
|
||||||
return board_dict
|
return board_dict
|
||||||
|
|
||||||
def GetSelected(self):
|
def get_selected(self):
|
||||||
"""Return a list of selected boards
|
"""Return a list of selected boards
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -181,7 +181,7 @@ class Boards:
|
|||||||
"""
|
"""
|
||||||
return [brd for brd in self._boards if brd.build_it]
|
return [brd for brd in self._boards if brd.build_it]
|
||||||
|
|
||||||
def GetSelectedNames(self):
|
def get_selected_names(self):
|
||||||
"""Return a list of selected boards
|
"""Return a list of selected boards
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -189,7 +189,7 @@ class Boards:
|
|||||||
"""
|
"""
|
||||||
return [brd.target for brd in self._boards if brd.build_it]
|
return [brd.target for brd in self._boards if brd.build_it]
|
||||||
|
|
||||||
def _BuildTerms(self, args):
|
def _build_terms(self, args):
|
||||||
"""Convert command line arguments to a list of terms.
|
"""Convert command line arguments to a list of terms.
|
||||||
|
|
||||||
This deals with parsing of the arguments. It handles the '&'
|
This deals with parsing of the arguments. It handles the '&'
|
||||||
@ -227,18 +227,18 @@ class Boards:
|
|||||||
if sym == '&':
|
if sym == '&':
|
||||||
oper = sym
|
oper = sym
|
||||||
elif oper:
|
elif oper:
|
||||||
term.AddExpr(sym)
|
term.add_expr(sym)
|
||||||
oper = None
|
oper = None
|
||||||
else:
|
else:
|
||||||
if term:
|
if term:
|
||||||
terms.append(term)
|
terms.append(term)
|
||||||
term = Term()
|
term = Term()
|
||||||
term.AddExpr(sym)
|
term.add_expr(sym)
|
||||||
if term:
|
if term:
|
||||||
terms.append(term)
|
terms.append(term)
|
||||||
return terms
|
return terms
|
||||||
|
|
||||||
def SelectBoards(self, args, exclude=[], brds=None):
|
def select_boards(self, args, exclude=[], brds=None):
|
||||||
"""Mark boards selected based on args
|
"""Mark boards selected based on args
|
||||||
|
|
||||||
Normally either boards (an explicit list of boards) or args (a list of
|
Normally either boards (an explicit list of boards) or args (a list of
|
||||||
@ -262,7 +262,7 @@ class Boards:
|
|||||||
"""
|
"""
|
||||||
result = OrderedDict()
|
result = OrderedDict()
|
||||||
warnings = []
|
warnings = []
|
||||||
terms = self._BuildTerms(args)
|
terms = self._build_terms(args)
|
||||||
|
|
||||||
result['all'] = []
|
result['all'] = []
|
||||||
for term in terms:
|
for term in terms:
|
||||||
@ -279,7 +279,7 @@ class Boards:
|
|||||||
if terms:
|
if terms:
|
||||||
match = False
|
match = False
|
||||||
for term in terms:
|
for term in terms:
|
||||||
if term.Matches(brd.props):
|
if term.matches(brd.props):
|
||||||
matching_term = str(term)
|
matching_term = str(term)
|
||||||
build_it = True
|
build_it = True
|
||||||
break
|
break
|
||||||
@ -292,7 +292,7 @@ class Boards:
|
|||||||
|
|
||||||
# Check that it is not specifically excluded
|
# Check that it is not specifically excluded
|
||||||
for expr in exclude_list:
|
for expr in exclude_list:
|
||||||
if expr.Matches(brd.props):
|
if expr.matches(brd.props):
|
||||||
build_it = False
|
build_it = False
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ def ShowToolchainPrefix(brds, toolchains):
|
|||||||
Return:
|
Return:
|
||||||
None on success, string error message otherwise
|
None on success, string error message otherwise
|
||||||
"""
|
"""
|
||||||
board_selected = brds.GetSelectedDict()
|
board_selected = brds.get_selected_dict()
|
||||||
tc_set = set()
|
tc_set = set()
|
||||||
for brd in board_selected.values():
|
for brd in board_selected.values():
|
||||||
tc_set.add(toolchains.Select(brd.arch))
|
tc_set.add(toolchains.Select(brd.arch))
|
||||||
@ -198,7 +198,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None,
|
|||||||
sys.exit("Failed to generate boards.cfg")
|
sys.exit("Failed to generate boards.cfg")
|
||||||
|
|
||||||
brds = board.Boards()
|
brds = board.Boards()
|
||||||
brds.ReadBoards(board_file)
|
brds.read_boards(board_file)
|
||||||
|
|
||||||
exclude = []
|
exclude = []
|
||||||
if options.exclude:
|
if options.exclude:
|
||||||
@ -211,9 +211,9 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None,
|
|||||||
requested_boards += b.split(',')
|
requested_boards += b.split(',')
|
||||||
else:
|
else:
|
||||||
requested_boards = None
|
requested_boards = None
|
||||||
why_selected, board_warnings = brds.SelectBoards(args, exclude,
|
why_selected, board_warnings = brds.select_boards(args, exclude,
|
||||||
requested_boards)
|
requested_boards)
|
||||||
selected = brds.GetSelected()
|
selected = brds.get_selected()
|
||||||
if not len(selected):
|
if not len(selected):
|
||||||
sys.exit(col.build(col.RED, 'No matching boards found'))
|
sys.exit(col.build(col.RED, 'No matching boards found'))
|
||||||
|
|
||||||
@ -349,7 +349,7 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None,
|
|||||||
builder.in_tree = options.in_tree
|
builder.in_tree = options.in_tree
|
||||||
|
|
||||||
# Work out which boards to build
|
# Work out which boards to build
|
||||||
board_selected = brds.GetSelectedDict()
|
board_selected = brds.get_selected_dict()
|
||||||
|
|
||||||
if series:
|
if series:
|
||||||
commits = series.commits
|
commits = series.commits
|
||||||
|
@ -189,7 +189,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
self._toolchains.Add('powerpc-gcc', test=False)
|
self._toolchains.Add('powerpc-gcc', test=False)
|
||||||
self._boards = board.Boards()
|
self._boards = board.Boards()
|
||||||
for brd in BOARDS:
|
for brd in BOARDS:
|
||||||
self._boards.AddBoard(board.Board(*brd))
|
self._boards.add_board(board.Board(*brd))
|
||||||
|
|
||||||
# Directories where the source been cloned
|
# Directories where the source been cloned
|
||||||
self._clone_dirs = []
|
self._clone_dirs = []
|
||||||
@ -476,7 +476,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
self.assertEqual(ret_code, 100)
|
self.assertEqual(ret_code, 100)
|
||||||
|
|
||||||
for commit in range(self._commits):
|
for commit in range(self._commits):
|
||||||
for brd in self._boards.GetList():
|
for brd in self._boards.get_list():
|
||||||
if brd.arch != 'sandbox':
|
if brd.arch != 'sandbox':
|
||||||
errfile = self._builder.GetErrFile(commit, brd.target)
|
errfile = self._builder.GetErrFile(commit, brd.target)
|
||||||
fd = open(errfile)
|
fd = open(errfile)
|
||||||
@ -581,7 +581,7 @@ class TestFunctional(unittest.TestCase):
|
|||||||
def testWorkInOutput(self):
|
def testWorkInOutput(self):
|
||||||
"""Test the -w option which should write directly to the output dir"""
|
"""Test the -w option which should write directly to the output dir"""
|
||||||
board_list = board.Boards()
|
board_list = board.Boards()
|
||||||
board_list.AddBoard(board.Board(*BOARDS[0]))
|
board_list.add_board(board.Board(*BOARDS[0]))
|
||||||
self._RunControl('-o', self._output_dir, '-w', clean_dir=False,
|
self._RunControl('-o', self._output_dir, '-w', clean_dir=False,
|
||||||
brds=board_list)
|
brds=board_list)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
@ -600,14 +600,14 @@ class TestFunctional(unittest.TestCase):
|
|||||||
os.path.exists(os.path.join(self._output_dir, 'u-boot')))
|
os.path.exists(os.path.join(self._output_dir, 'u-boot')))
|
||||||
|
|
||||||
board_list = board.Boards()
|
board_list = board.Boards()
|
||||||
board_list.AddBoard(board.Board(*BOARDS[0]))
|
board_list.add_board(board.Board(*BOARDS[0]))
|
||||||
with self.assertRaises(SystemExit) as e:
|
with self.assertRaises(SystemExit) as e:
|
||||||
self._RunControl('-b', self._test_branch, '-o', self._output_dir,
|
self._RunControl('-b', self._test_branch, '-o', self._output_dir,
|
||||||
'-w', clean_dir=False, brds=board_list)
|
'-w', clean_dir=False, brds=board_list)
|
||||||
self.assertIn("single commit", str(e.exception))
|
self.assertIn("single commit", str(e.exception))
|
||||||
|
|
||||||
board_list = board.Boards()
|
board_list = board.Boards()
|
||||||
board_list.AddBoard(board.Board(*BOARDS[0]))
|
board_list.add_board(board.Board(*BOARDS[0]))
|
||||||
with self.assertRaises(SystemExit) as e:
|
with self.assertRaises(SystemExit) as e:
|
||||||
self._RunControl('-w', clean_dir=False)
|
self._RunControl('-w', clean_dir=False)
|
||||||
self.assertIn("specify -o", str(e.exception))
|
self.assertIn("specify -o", str(e.exception))
|
||||||
|
@ -133,8 +133,8 @@ class TestBuild(unittest.TestCase):
|
|||||||
# Set up boards to build
|
# Set up boards to build
|
||||||
self.brds = board.Boards()
|
self.brds = board.Boards()
|
||||||
for brd in BOARDS:
|
for brd in BOARDS:
|
||||||
self.brds.AddBoard(board.Board(*brd))
|
self.brds.add_board(board.Board(*brd))
|
||||||
self.brds.SelectBoards([])
|
self.brds.select_boards([])
|
||||||
|
|
||||||
# Add some test settings
|
# Add some test settings
|
||||||
bsettings.Setup(None)
|
bsettings.Setup(None)
|
||||||
@ -203,7 +203,7 @@ class TestBuild(unittest.TestCase):
|
|||||||
build = builder.Builder(self.toolchains, self.base_dir, None, threads,
|
build = builder.Builder(self.toolchains, self.base_dir, None, threads,
|
||||||
2, checkout=False, show_unknown=False)
|
2, checkout=False, show_unknown=False)
|
||||||
build.do_make = self.Make
|
build.do_make = self.Make
|
||||||
board_selected = self.brds.GetSelectedDict()
|
board_selected = self.brds.get_selected_dict()
|
||||||
|
|
||||||
# Build the boards for the pre-defined commits and warnings/errors
|
# Build the boards for the pre-defined commits and warnings/errors
|
||||||
# associated with each. This calls our Make() to inject the fake output.
|
# associated with each. This calls our Make() to inject the fake output.
|
||||||
@ -468,18 +468,18 @@ class TestBuild(unittest.TestCase):
|
|||||||
|
|
||||||
def testBoardSingle(self):
|
def testBoardSingle(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards(['sandbox']),
|
self.assertEqual(self.brds.select_boards(['sandbox']),
|
||||||
({'all': ['board4'], 'sandbox': ['board4']}, []))
|
({'all': ['board4'], 'sandbox': ['board4']}, []))
|
||||||
|
|
||||||
def testBoardArch(self):
|
def testBoardArch(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards(['arm']),
|
self.assertEqual(self.brds.select_boards(['arm']),
|
||||||
({'all': ['board0', 'board1'],
|
({'all': ['board0', 'board1'],
|
||||||
'arm': ['board0', 'board1']}, []))
|
'arm': ['board0', 'board1']}, []))
|
||||||
|
|
||||||
def testBoardArchSingle(self):
|
def testBoardArchSingle(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards(['arm sandbox']),
|
self.assertEqual(self.brds.select_boards(['arm sandbox']),
|
||||||
({'sandbox': ['board4'],
|
({'sandbox': ['board4'],
|
||||||
'all': ['board0', 'board1', 'board4'],
|
'all': ['board0', 'board1', 'board4'],
|
||||||
'arm': ['board0', 'board1']}, []))
|
'arm': ['board0', 'board1']}, []))
|
||||||
@ -487,20 +487,20 @@ class TestBuild(unittest.TestCase):
|
|||||||
|
|
||||||
def testBoardArchSingleMultiWord(self):
|
def testBoardArchSingleMultiWord(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards(['arm', 'sandbox']),
|
self.assertEqual(self.brds.select_boards(['arm', 'sandbox']),
|
||||||
({'sandbox': ['board4'],
|
({'sandbox': ['board4'],
|
||||||
'all': ['board0', 'board1', 'board4'],
|
'all': ['board0', 'board1', 'board4'],
|
||||||
'arm': ['board0', 'board1']}, []))
|
'arm': ['board0', 'board1']}, []))
|
||||||
|
|
||||||
def testBoardSingleAnd(self):
|
def testBoardSingleAnd(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards(['Tester & arm']),
|
self.assertEqual(self.brds.select_boards(['Tester & arm']),
|
||||||
({'Tester&arm': ['board0', 'board1'],
|
({'Tester&arm': ['board0', 'board1'],
|
||||||
'all': ['board0', 'board1']}, []))
|
'all': ['board0', 'board1']}, []))
|
||||||
|
|
||||||
def testBoardTwoAnd(self):
|
def testBoardTwoAnd(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards(['Tester', '&', 'arm',
|
self.assertEqual(self.brds.select_boards(['Tester', '&', 'arm',
|
||||||
'Tester' '&', 'powerpc',
|
'Tester' '&', 'powerpc',
|
||||||
'sandbox']),
|
'sandbox']),
|
||||||
({'sandbox': ['board4'],
|
({'sandbox': ['board4'],
|
||||||
@ -511,19 +511,19 @@ class TestBuild(unittest.TestCase):
|
|||||||
|
|
||||||
def testBoardAll(self):
|
def testBoardAll(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards([]),
|
self.assertEqual(self.brds.select_boards([]),
|
||||||
({'all': ['board0', 'board1', 'board2', 'board3',
|
({'all': ['board0', 'board1', 'board2', 'board3',
|
||||||
'board4']}, []))
|
'board4']}, []))
|
||||||
|
|
||||||
def testBoardRegularExpression(self):
|
def testBoardRegularExpression(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards(['T.*r&^Po']),
|
self.assertEqual(self.brds.select_boards(['T.*r&^Po']),
|
||||||
({'all': ['board2', 'board3'],
|
({'all': ['board2', 'board3'],
|
||||||
'T.*r&^Po': ['board2', 'board3']}, []))
|
'T.*r&^Po': ['board2', 'board3']}, []))
|
||||||
|
|
||||||
def testBoardDuplicate(self):
|
def testBoardDuplicate(self):
|
||||||
"""Test single board selection"""
|
"""Test single board selection"""
|
||||||
self.assertEqual(self.brds.SelectBoards(['sandbox sandbox',
|
self.assertEqual(self.brds.select_boards(['sandbox sandbox',
|
||||||
'sandbox']),
|
'sandbox']),
|
||||||
({'all': ['board4'], 'sandbox': ['board4']}, []))
|
({'all': ['board4'], 'sandbox': ['board4']}, []))
|
||||||
def CheckDirs(self, build, dirname):
|
def CheckDirs(self, build, dirname):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user