diff mbox series

[v3,08/23] buildman: Allow building within a subdir of the current dir

Message ID 20200318154302.16389-6-sjg@chromium.org
State Accepted
Commit b2d89bc53887dfee44220243c1266a7cf627feff
Headers show
Series gitlab: Simplify the test script | expand

Commit Message

Simon Glass March 18, 2020, 3:42 p.m. UTC
This is useful in some situations, in particular with -w and when building
in-tree. Now that we are more careful about what we remove in
_PrepareOutputSpace(), it should be safe to relax this restriction.

Update the progress information also so it is clear what buildman is
doing. Remove files can take a long time.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v3: None
Changes in v2: None

 tools/buildman/builder.py   |  3 ++-
 tools/buildman/control.py   | 23 -----------------------
 tools/buildman/func_test.py |  9 ---------
 3 files changed, 2 insertions(+), 33 deletions(-)
diff mbox series

Patch

diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py
index 30ec4254f8..70c55c588a 100644
--- a/tools/buildman/builder.py
+++ b/tools/buildman/builder.py
@@ -1560,10 +1560,11 @@  class Builder:
         """
         to_remove = self._GetOutputSpaceRemovals()
         if to_remove:
-            Print('Removing %d old build directories' % len(to_remove),
+            Print('Removing %d old build directories...' % len(to_remove),
                   newline=False)
             for dirname in to_remove:
                 shutil.rmtree(dirname)
+            Print('done')
 
     def BuildBoards(self, commits, board_selected, keep_outputs, verbose):
         """Build all commits for a list of boards
diff --git a/tools/buildman/control.py b/tools/buildman/control.py
index ded4360250..7d31863c63 100644
--- a/tools/buildman/control.py
+++ b/tools/buildman/control.py
@@ -85,28 +85,6 @@  def ShowActions(series, why_selected, boards_selected, builder, options,
         for warning in board_warnings:
             print(col.Color(col.YELLOW, warning))
 
-def CheckOutputDir(output_dir):
-    """Make sure that the output directory is not within the current directory
-
-    If we try to use an output directory which is within the current directory
-    (which is assumed to hold the U-Boot source) we may end up deleting the
-    U-Boot source code. Detect this and print an error in this case.
-
-    Args:
-        output_dir: Output directory path to check
-    """
-    path = os.path.realpath(output_dir)
-    cwd_path = os.path.realpath('.')
-    while True:
-        if os.path.realpath(path) == cwd_path:
-            Print("Cannot use output directory '%s' since it is within the current directory '%s'" %
-                  (path, cwd_path))
-            sys.exit(1)
-        parent = os.path.dirname(path)
-        if parent == path:
-            break
-        path = parent
-
 def ShowToolchainInfo(boards, toolchains, print_arch, print_prefix):
     """Show information about a the tool chain used by one or more boards
 
@@ -331,7 +309,6 @@  def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
             output_dir = os.path.join(options.output_dir, dirname)
         if clean_dir and os.path.exists(output_dir):
             shutil.rmtree(output_dir)
-    CheckOutputDir(output_dir)
     builder = Builder(toolchains, output_dir, options.git_dir,
             options.threads, options.jobs, gnu_make=gnu_make, checkout=True,
             show_unknown=options.show_unknown, step=options.step,
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index f9f8f80593..2a256a9263 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -534,15 +534,6 @@  class TestFunctional(unittest.TestCase):
         self.assertEqual(self._builder.count, self._total_builds)
         self.assertEqual(self._builder.fail, 0)
 
-    def testBadOutputDir(self):
-        """Test building with an output dir the same as out current dir"""
-        self._test_branch = '/__dev/__testbranch'
-        with self.assertRaises(SystemExit):
-            self._RunControl('-b', self._test_branch, '-o', os.getcwd())
-        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()