if self._tmpfile:
try_remove(self._tmpfile)
- def scan(self, defconfig):
+ def scan(self, defconfig, warn_targets):
"""Load a defconfig file to obtain board parameters.
Args:
defconfig (str): path to the defconfig file to be processed
+ warn_targets (bool): True to warn about missing or duplicate
+ CONFIG_TARGET options
Returns:
tuple: dictionary of board parameters. It has a form of:
params[key] = '-'
# Check there is exactly one TARGET_xxx set
- target = None
- for name, sym in self._conf.syms.items():
- if name.startswith('TARGET_') and sym.str_value == 'y':
- tname = name[7:].lower()
- if target:
- warnings.append(
- f'WARNING: {leaf}: Duplicate TARGET_xxx: {target} and {tname}')
- else:
- target = tname
-
- if not target:
- cfg_name = expect_target.replace('-', '_').upper()
- warnings.append(f'WARNING: {leaf}: No TARGET_{cfg_name} enabled')
+ if warn_targets:
+ target = None
+ for name, sym in self._conf.syms.items():
+ if name.startswith('TARGET_') and sym.str_value == 'y':
+ tname = name[7:].lower()
+ if target:
+ warnings.append(
+ f'WARNING: {leaf}: Duplicate TARGET_xxx: {target} and {tname}')
+ else:
+ target = tname
+
+ if not target:
+ cfg_name = expect_target.replace('-', '_').upper()
+ warnings.append(f'WARNING: {leaf}: No TARGET_{cfg_name} enabled')
params['target'] = expect_target
return result, warnings
@classmethod
- def scan_defconfigs_for_multiprocess(cls, srcdir, queue, defconfigs):
+ def scan_defconfigs_for_multiprocess(cls, srcdir, queue, defconfigs,
+ warn_targets):
"""Scan defconfig files and queue their board parameters
This function is intended to be passed to multiprocessing.Process()
written into this.
defconfigs (sequence of str): A sequence of defconfig files to be
scanned.
+ warn_targets (bool): True to warn about missing or duplicate
+ CONFIG_TARGET options
"""
kconf_scanner = KconfigScanner(srcdir)
for defconfig in defconfigs:
- queue.put(kconf_scanner.scan(defconfig))
+ queue.put(kconf_scanner.scan(defconfig, warn_targets))
@classmethod
def read_queues(cls, queues, params_list, warnings):
params_list.append(params)
warnings.update(warn)
- def scan_defconfigs(self, config_dir, srcdir, jobs=1):
+ def scan_defconfigs(self, config_dir, srcdir, jobs=1, warn_targets=False):
"""Collect board parameters for all defconfig files.
This function invokes multiple processes for faster processing.
config_dir (str): Directory containing the defconfig files
srcdir (str): Directory containing source code (Kconfig files)
jobs (int): The number of jobs to run simultaneously
+ warn_targets (bool): True to warn about missing or duplicate
+ CONFIG_TARGET options
Returns:
tuple:
que = multiprocessing.Queue(maxsize=-1)
proc = multiprocessing.Process(
target=self.scan_defconfigs_for_multiprocess,
- args=(srcdir, que, defconfigs))
+ args=(srcdir, que, defconfigs, warn_targets))
proc.start()
processes.append(proc)
queues.append(que)
with open(output, 'w', encoding="utf-8") as outf:
outf.write(COMMENT_BLOCK + '\n'.join(output_lines) + '\n')
- def build_board_list(self, config_dir, srcdir, jobs=1):
+ def build_board_list(self, config_dir=CONFIG_DIR, srcdir='.', jobs=1,
+ warn_targets=False):
"""Generate a board-database file
This works by reading the Kconfig, then loading each board's defconfig
config_dir (str): Directory containing the defconfig files
srcdir (str): Directory containing source code (Kconfig files)
jobs (int): The number of jobs to run simultaneously
+ warn_targets (bool): True to warn about missing or duplicate
+ CONFIG_TARGET options
Returns:
tuple:
value: string value of the key
list of str: Warnings that came up
"""
- params_list, warnings = self.scan_defconfigs(config_dir, srcdir, jobs)
+ params_list, warnings = self.scan_defconfigs(config_dir, srcdir, jobs,
+ warn_targets)
m_warnings = self.insert_maintainers_info(srcdir, params_list)
return params_list, warnings + m_warnings
sys.exit(col.build(col.RED, '-w requires that you specify -o'))
options.output_dir = '..'
+ nr_cups = options.threads or multiprocessing.cpu_count()
+
# Work out what subset of the boards we are building
if not brds:
if not os.path.exists(options.output_dir):
board_file = os.path.join(options.output_dir, 'boards.cfg')
brds = boards.Boards()
- ok = brds.ensure_board_list(board_file,
- options.threads or multiprocessing.cpu_count(),
+ if options.maintainer_check:
+ warnings = brds.build_board_list(jobs=nr_cups)[1]
+ if warnings:
+ for warn in warnings:
+ print(warn, file=sys.stderr)
+ return 2
+ return 0
+
+ ok = brds.ensure_board_list(board_file, nr_cups,
force=options.regen_board_list,
quiet=not options.verbose)
if options.regen_board_list:
endif
''')
tools.write_file(kc_file, orig_kc_data + extra)
- params_list, warnings = self._boards.build_board_list(config_dir, src)
+ params_list, warnings = self._boards.build_board_list(config_dir, src,
+ warn_targets=True)
self.assertEquals(2, len(params_list))
self.assertEquals(
['WARNING: board2_defconfig: Duplicate TARGET_xxx: board2 and other'],
lines = [b'' if line == b'config TARGET_BOARD2\n' else line
for line in orig_kc_data.splitlines(keepends=True)]
tools.write_file(kc_file, b''.join(lines))
- params_list, warnings = self._boards.build_board_list(config_dir, src)
+ params_list, warnings = self._boards.build_board_list(config_dir, src,
+ warn_targets=True)
self.assertEquals(2, len(params_list))
self.assertEquals(
['WARNING: board2_defconfig: No TARGET_BOARD2 enabled'],