]> git.sur5r.net Git - u-boot/commitdiff
buildman: Add an option to flatten output directory trees
authorSimon Glass <sjg@chromium.org>
Tue, 2 Dec 2014 00:33:55 +0000 (17:33 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 15 Jan 2015 05:16:52 +0000 (21:16 -0800)
When building current source for a single board, buildman puts the output
in <output_dir>/current/current/<board>. Add an option to make it use
<output_dir>/<board> instead. This removes the unnecessary directories
in that case, controlled by the --no-subdirs/-N option.

Suggested-by: Tom Rini <trini@ti.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
tools/buildman/builder.py
tools/buildman/cmdline.py
tools/buildman/control.py
tools/buildman/test.py

index 05ebfd20219744e523930883510a5420c627c4e8..ca74c3645ef3e6a7d0f774989c8483650fb55e90 100644 (file)
@@ -174,7 +174,8 @@ class Builder:
             self.func_sizes = func_sizes
 
     def __init__(self, toolchains, base_dir, git_dir, num_threads, num_jobs,
-                 gnu_make='make', checkout=True, show_unknown=True, step=1):
+                 gnu_make='make', checkout=True, show_unknown=True, step=1,
+                 no_subdirs=False):
         """Create a new Builder object
 
         Args:
@@ -213,6 +214,7 @@ class Builder:
         self._step = step
         self.in_tree = False
         self._error_lines = 0
+        self.no_subdirs = no_subdirs
 
         self.col = terminal.Color()
 
@@ -392,15 +394,17 @@ class Builder:
         Args:
             commit_upto: Commit number to use (0..self.count-1)
         """
+        commit_dir = None
         if self.commits:
             commit = self.commits[commit_upto]
             subject = commit.subject.translate(trans_valid_chars)
             commit_dir = ('%02d_of_%02d_g%s_%s' % (commit_upto + 1,
                     self.commit_count, commit.hash, subject[:20]))
-        else:
+        elif not self.no_subdirs:
             commit_dir = 'current'
-        output_dir = os.path.join(self.base_dir, commit_dir)
-        return output_dir
+        if not commit_dir:
+            return self.base_dir
+        return os.path.join(self.base_dir, commit_dir)
 
     def GetBuildDir(self, commit_upto, target):
         """Get the name of the build directory for a commit number
index 27d3c708e6f311d473ed8f6cb9200d82ba148779..2b7565351206666ae181294bf7d5857e9548204b 100644 (file)
@@ -55,6 +55,8 @@ def ParseArgs():
           help='List available tool chains')
     parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
           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='..',
           help='Directory where all builds happen and buildman has its workspace (default is ../)')
index cec02c6d5391f3c72bf5bda36a03f8f03e4aa57f..747c80d76a57d2c6f5f0e80ea5f9e242ae93430a 100644 (file)
@@ -211,12 +211,16 @@ def DoBuildman(options, args, toolchains=None, make_func=None, boards=None,
     output_dir = options.output_dir
     if options.branch:
         dirname = options.branch.replace('/', '_')
-        output_dir = os.path.join(options.output_dir, dirname)
+        # As a special case allow the board directory to be placed in the
+        # output directory itself rather than any subdirectory.
+        if not options.no_subdirs:
+            output_dir = os.path.join(options.output_dir, dirname)
     if clean_dir and os.path.exists(output_dir):
         shutil.rmtree(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)
+            show_unknown=options.show_unknown, step=options.step,
+            no_subdirs=options.no_subdirs)
     builder.force_config_on_failure = not options.quick
     if make_func:
         builder.do_make = make_func
index f16d2fd1a5f2dde899f86f45ae2818e372067dc5..c085d2f43093f9aa0905ae223f34c7bea808efc0 100644 (file)
@@ -373,5 +373,13 @@ class TestBuild(unittest.TestCase):
         build.commit_count = 0
         self.CheckDirs(build, '/current')
 
+    def testOutputDirNoSubdirs(self):
+        build = builder.Builder(self.toolchains, BASE_DIR, None, 1, 2,
+                                checkout=False, show_unknown=False,
+                                no_subdirs=True)
+        build.commits = None
+        build.commit_count = 0
+        self.CheckDirs(build, '')
+
 if __name__ == "__main__":
     unittest.main()