From patchwork Fri Apr 17 23:51:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 237948 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Fri, 17 Apr 2020 17:51:32 -0600 Subject: [PATCH 3/5] buildman: Make sure that -o is given with -w In-Reply-To: <20200417235134.226223-1-sjg@chromium.org> References: <20200417235134.226223-1-sjg@chromium.org> Message-ID: <20200417235134.226223-4-sjg@chromium.org> It is a bad idea to use the default output directory ('..') with -w since it does a build in that directory and writes various files these. Require that -o is given to avoid this problem. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/buildman/README | 3 ++- tools/buildman/cmdline.py | 3 +-- tools/buildman/control.py | 4 ++++ tools/buildman/func_test.py | 6 ++++++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/buildman/README b/tools/buildman/README index f3a0dc7288..b2f983c715 100644 --- a/tools/buildman/README +++ b/tools/buildman/README @@ -1091,7 +1091,8 @@ the -w option, for example: buildman -o /tmp/build --board sandbox -w -This will write the full build into /tmp/build including object files. +This will write the full build into /tmp/build including object files. You must +specify the output directory with -o when using -w. Other options diff --git a/tools/buildman/cmdline.py b/tools/buildman/cmdline.py index 1377b9d2be..680c072d66 100644 --- a/tools/buildman/cmdline.py +++ b/tools/buildman/cmdline.py @@ -76,8 +76,7 @@ def ParseArgs(): default=False, help="Do a dry run (describe actions, but do nothing)") parser.add_option('-N', '--no-subdirs', action='store_true', dest='no_subdirs', default=False, help="Don't create subdirectories when building current source for a single board") - parser.add_option('-o', '--output-dir', type='string', - dest='output_dir', default='..', + parser.add_option('-o', '--output-dir', type='string', dest='output_dir', help='Directory where all builds happen and buildman has its workspace (default is ../)') parser.add_option('-O', '--override-toolchain', type='string', help="Override host toochain to use for sandbox (e.g. 'clang-7')") diff --git a/tools/buildman/control.py b/tools/buildman/control.py index 7ee036824f..7c8d7520fb 100644 --- a/tools/buildman/control.py +++ b/tools/buildman/control.py @@ -175,6 +175,10 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None, if options.incremental: print(col.Color(col.RED, 'Warning: -I has been removed. See documentation')) + if not options.output_dir: + if options.work_in_output: + sys.exit(col.Color(col.RED, '-w requires that you specify -o')) + options.output_dir = '..' # Work out what subset of the boards we are building if not boards: diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index 1fbc6f6b00..8d3325d66f 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -569,3 +569,9 @@ class TestFunctional(unittest.TestCase): self._RunControl('-b', self._test_branch, '-o', self._output_dir, '-w', clean_dir=False, boards=board_list) self.assertIn("single commit", str(e.exception)) + + board_list = board.Boards() + board_list.AddBoard(board.Board(*boards[0])) + with self.assertRaises(SystemExit) as e: + self._RunControl('-w', clean_dir=False) + self.assertIn("specify -o", str(e.exception))