buildman -O clang-7 --board sandbox
+Doing a simple build
+====================
+
+In some cases you just want to build a single board and get the full output, use
+the -w option, for example:
+
+ buildman -o /tmp/build --board sandbox -w
+
+This will write the full build into /tmp/build including object files.
+
+
Other options
=============
in_tree: Build U-Boot in-tree instead of specifying an output
directory separate from the source code. This option is really
only useful for testing in-tree builds.
+ work_in_output: Use the output directory as the work directory and
+ don't write to a separate output directory.
Private members:
_base_board_dict: Last-summarised Dict of boards
no_subdirs=False, full_path=False, verbose_build=False,
incremental=False, per_board_out_dir=False,
config_only=False, squash_config_y=False,
- warnings_as_errors=False):
+ warnings_as_errors=False, work_in_output=False):
"""Create a new Builder object
Args:
config_only: Only configure each build, don't build it
squash_config_y: Convert CONFIG options with the value 'y' to '1'
warnings_as_errors: Treat all compiler warnings as errors
+ work_in_output: Use the output directory as the work directory and
+ don't write to a separate output directory.
"""
self.toolchains = toolchains
self.base_dir = base_dir
- self._working_dir = os.path.join(base_dir, '.bm-work')
+ if work_in_output:
+ self._working_dir = base_dir
+ else:
+ self._working_dir = os.path.join(base_dir, '.bm-work')
self.threads = []
self.do_make = self.Make
self.gnu_make = gnu_make
self.config_only = config_only
self.squash_config_y = squash_config_y
self.config_filenames = BASE_CONFIG_FILENAMES
+ self.work_in_output = work_in_output
if not self.squash_config_y:
self.config_filenames += EXTRA_CONFIG_FILENAMES
Args:
thread_num: Number of thread to check.
"""
+ if self.work_in_output:
+ return self._working_dir
return os.path.join(self._working_dir, '%02d' % thread_num)
def _PrepareThread(self, thread_num, setup_git):
job.board = brd
job.commits = commits
job.keep_outputs = keep_outputs
+ job.work_in_output = self.work_in_output
job.step = self._step
self.queue.put(job)
commits: List of Commit objects to build
keep_outputs: True to save build output files
step: 1 to process every commit, n to process every nth commit
+ work_in_output: Use the output directory as the work directory and
+ don't write to a separate output directory.
"""
def __init__(self):
self.board = None
self.commits = []
self.keep_outputs = False
self.step = 1
+ self.work_in_output = False
class ResultThread(threading.Thread):
**kwargs)
def RunCommit(self, commit_upto, brd, work_dir, do_config, config_only,
- force_build, force_build_failures):
+ force_build, force_build_failures, work_in_output):
"""Build a particular commit.
If the build is already done, and we are not forcing a build, we skip
force_build: Force a build even if one was previously done
force_build_failures: Force a bulid if the previous result showed
failure
+ work_in_output: Use the output directory as the work directory and
+ don't write to a separate output directory.
Returns:
tuple containing:
# self.Make() below, in the event that we do a build.
result = command.CommandResult()
result.return_code = 0
- if self.builder.in_tree:
+ if work_in_output or self.builder.in_tree:
out_dir = work_dir
else:
if self.per_board_out_dir:
result.out_dir = out_dir
return result, do_config
- def _WriteResult(self, result, keep_outputs):
+ def _WriteResult(self, result, keep_outputs, work_in_output):
"""Write a built result to the output directory.
Args:
result: CommandResult object containing result to write
keep_outputs: True to store the output binaries, False
to delete them
+ work_in_output: Use the output directory as the work directory and
+ don't write to a separate output directory.
"""
+ if work_in_output:
+ return
# Fatal error
if result.return_code < 0:
return
result, request_config = self.RunCommit(commit_upto, brd,
work_dir, do_config, self.builder.config_only,
force_build or self.builder.force_build,
- self.builder.force_build_failures)
+ self.builder.force_build_failures,
+ work_in_output=job.work_in_output)
failed = result.return_code or result.stderr
did_config = do_config
if failed and not do_config:
# with a reconfig.
if self.builder.force_config_on_failure:
result, request_config = self.RunCommit(commit_upto,
- brd, work_dir, True, False, True, False)
+ brd, work_dir, True, False, True, False,
+ work_in_output=job.work_in_output)
did_config = True
if not self.builder.force_reconfig:
do_config = request_config
raise ValueError('Interrupt')
# We have the build results, so output the result
- self._WriteResult(result, job.keep_outputs)
+ self._WriteResult(result, job.keep_outputs, job.work_in_output)
self.builder.out_queue.put(result)
else:
# Just build the currently checked-out build
result, request_config = self.RunCommit(None, brd, work_dir, True,
self.builder.config_only, True,
- self.builder.force_build_failures)
+ self.builder.force_build_failures,
+ work_in_output=job.work_in_output)
result.commit_upto = 0
- self._WriteResult(result, job.keep_outputs)
+ self._WriteResult(result, job.keep_outputs, job.work_in_output)
self.builder.out_queue.put(result)
def run(self):
default=False, help='Show build results while the build progresses')
parser.add_option('-V', '--verbose-build', action='store_true',
default=False, help='Run make with V=1, logging all output')
+ parser.add_option('-w', '--work-in-output', action='store_true',
+ default=False, help='Use the output directory as the work directory')
parser.add_option('-x', '--exclude', dest='exclude',
type='string', action='append',
help='Specify a list of boards to exclude, separated by comma')
str = ("No commits found to process in branch '%s': "
"set branch's upstream or use -c flag" % options.branch)
sys.exit(col.Color(col.RED, str))
+ if options.work_in_output:
+ if len(selected) != 1:
+ sys.exit(col.Color(col.RED,
+ '-w can only be used with a single board'))
+ if count != 1:
+ sys.exit(col.Color(col.RED,
+ '-w can only be used with a single commit'))
# Read the metadata from the commits. First look at the upstream commit,
# then the ones in the branch. We would like to do something like
per_board_out_dir=options.per_board_out_dir,
config_only=options.config_only,
squash_config_y=not options.preserve_config_y,
- warnings_as_errors=options.warnings_as_errors)
+ warnings_as_errors=options.warnings_as_errors,
+ work_in_output=options.work_in_output)
builder.force_config_on_failure = not options.quick
if make_func:
builder.do_make = make_func
import gitutil
import terminal
import toolchain
+import tools
settings_data = '''
# Buildman settings file
def tearDown(self):
shutil.rmtree(self._base_dir)
- shutil.rmtree(self._output_dir)
+ #shutil.rmtree(self._output_dir)
def setupToolchains(self):
self._toolchains = toolchain.Toolchains()
return command.RunPipe([[self._buildman_pathname] + list(args)],
capture=True, capture_stderr=True)
- def _RunControl(self, *args, **kwargs):
+ def _RunControl(self, *args, clean_dir=False, boards=None):
sys.argv = [sys.argv[0]] + list(args)
options, args = cmdline.ParseArgs()
result = control.DoBuildman(options, args, toolchains=self._toolchains,
- make_func=self._HandleMake, boards=self._boards,
- clean_dir=kwargs.get('clean_dir', True))
+ make_func=self._HandleMake, boards=boards or self._boards,
+ clean_dir=clean_dir)
self._builder = control.builder
return result
combined='Test configuration complete')
elif stage == 'build':
stderr = ''
+ out_dir = ''
+ for arg in args:
+ if arg.startswith('O='):
+ out_dir = arg[2:]
+ fname = os.path.join(cwd or '', out_dir, 'u-boot')
+ tools.WriteFile(fname, b'U-Boot')
if type(commit) is not str:
stderr = self._error.get((brd.target, commit.sequence))
if stderr:
with self.assertRaises(SystemExit):
self._RunControl('-b', self._test_branch, '-o',
os.path.join(os.getcwd(), 'test'))
+
+ def testWorkInOutput(self):
+ """Test the -w option which should write directly to the output dir"""
+ board_list = board.Boards()
+ board_list.AddBoard(board.Board(*boards[0]))
+ self._RunControl('-o', self._output_dir, '-w', clean_dir=False,
+ boards=board_list)
+ self.assertTrue(
+ os.path.exists(os.path.join(self._output_dir, 'u-boot')))
+
+ def testWorkInOutputFail(self):
+ """Test the -w option failures"""
+ with self.assertRaises(SystemExit) as e:
+ self._RunControl('-o', self._output_dir, '-w', clean_dir=False)
+ self.assertIn("single board", str(e.exception))
+ self.assertFalse(
+ os.path.exists(os.path.join(self._output_dir, 'u-boot')))
+
+ board_list = board.Boards()
+ board_list.AddBoard(board.Board(*boards[0]))
+ with self.assertRaises(SystemExit) as e:
+ self._RunControl('-b', self._test_branch, '-o', self._output_dir,
+ '-w', clean_dir=False, boards=board_list)
+ self.assertIn("single commit", str(e.exception))