diff mbox series

[3/3] bitbake-setup: Add --build-dir-style to init

Message ID 20250912204559.10360-3-reatmon@ti.com
State New
Headers show
Series [1/3] bitbake-setup: Tweak user inputs | expand

Commit Message

Ryan Eatmon Sept. 12, 2025, 8:45 p.m. UTC
To allow for user control over the name of the build directory, add a
new command line argument to the init function that allows you to choose
from a list of options:

flat    - <config>-<opt1>-<opt2>-...-<optn>
hier    - <config>/<opt1>/<opt2>/.../<optn>
config  - <config>
options - <opt1>-<opt2>-...-<optn>

Where the <opt#> is the sequence of option choices configured in the
json file.

Signed-off-by: Ryan Eatmon <reatmon@ti.com>
---
 bin/bitbake-setup | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/bin/bitbake-setup b/bin/bitbake-setup
index 342251bd5..cce9dcc70 100755
--- a/bin/bitbake-setup
+++ b/bin/bitbake-setup
@@ -386,7 +386,15 @@  def init_config(settings, args, d):
     upstream_config = obtain_config(settings, args, source_overrides, d)
     print("\nRun 'bitbake-setup init --non-interactive {}' to select this configuration non-interactively.\n".format(" ".join(upstream_config['non-interactive-cmdline-options'])))
 
-    builddir = os.path.join(os.path.abspath(args.top_dir), "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_")))
+    if args.build_dir_style == "hier":
+        builddir = os.path.join(os.path.abspath(args.top_dir), "{}/{}".format(upstream_config['name'],"*slash*".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_").replace("*slash*","/")))
+    elif args.build_dir_style == "config":
+        builddir = os.path.join(os.path.abspath(args.top_dir), "{}".format(upstream_config['name']))
+    elif args.build_dir_style == "options":
+        builddir = os.path.join(os.path.abspath(args.top_dir), "{}".format(" ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_")))
+    else:
+        builddir = os.path.join(os.path.abspath(args.top_dir), "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_")))
+
     if os.path.exists(builddir):
         print("Build already initialized in {}\nUse 'bitbake-setup status' to check if it needs to be updated or 'bitbake-setup update' to perform the update.".format(builddir))
         return
@@ -749,6 +757,7 @@  def main():
     parser_init.add_argument('config', nargs='*', help="path/URL/id to a configuration file (use 'list' command to get available ids), followed by configuration options. Bitbake-setup will ask to choose from available choices if command line doesn't completely specify them.")
     parser_init.add_argument('--non-interactive', action='store_true', help='Do not ask to interactively choose from available options; if bitbake-setup cannot make a decision it will stop with a failure.')
     parser_init.add_argument('--source-overrides', action='store', help='Override sources information (repositories/revisions) with values from a local json file.')
+    parser_init.add_argument('--build-dir-style', action='store', default='flat', choices=['flat','hier','config','options'], help='Style to use for assembling the path to the build directory.  Default is flat.')
     parser_init.set_defaults(func=init_config)
 
     parser_status = subparsers.add_parser('status', help='Check if the build needs to be synchronized with configuration')