@@ -19,6 +19,7 @@ import copy
import textwrap
import signal
import functools
+import string
default_registry = os.path.normpath(os.path.dirname(__file__) + "/../default-registry")
@@ -492,6 +493,20 @@ def init_config(top_dir, settings, args):
setup_dir_name = args.setup_dir_name
else:
setup_dir_name = "{}-{}".format(upstream_config['name']," ".join(upstream_config['non-interactive-cmdline-options'][1:]).replace(" ","-").replace("/","_"))
+ if 'setup-dir-name' in upstream_config['bitbake-config']:
+ mapping = {
+ k: v.replace(" ", "-").replace("/", "_")
+ for k, v in upstream_config['bitbake-config']['oe-fragment-choices'].items()
+ }
+ config_setup_dir_name = string.Template(upstream_config['bitbake-config']['setup-dir-name']).substitute(mapping)
+ config_setup_dir = os.path.join(top_dir, config_setup_dir_name)
+ if os.path.exists(config_setup_dir):
+ print("Setup directory {} (as suggested by configuration) already exists, using the full name instead.\n".format(config_setup_dir))
+ elif settings['default']['use-full-setup-dir-name'] != 'no':
+ print("Using the full setup directory name instead of {} suggested by configuration, as set in the settings.\n".format(config_setup_dir))
+ else:
+ setup_dir_name = config_setup_dir_name
+
if not args.non_interactive:
n = input(f"Enter setup directory name: [{setup_dir_name}] ")
if n:
@@ -935,6 +950,7 @@ def main():
'top-dir-prefix':os.getcwd(),
'top-dir-name':'bitbake-builds',
'registry':default_registry,
+ 'use-full-setup-dir-name':'no',
}
global_settings = load_settings(global_settings_path(args))
@@ -40,6 +40,7 @@
{
"name": "nodistro",
"description": "OpenEmbedded 'nodistro'",
+ "setup-dir-name": "oe-nodistro",
"bb-layers": ["openembedded-core/meta"],
"oe-fragments-one-of": {
"machine": {
@@ -50,6 +50,7 @@
"configurations": [
{
"bb-layers": ["openembedded-core/meta","meta-yocto/meta-yocto-bsp","meta-yocto/meta-poky"],
+ "setup-dir-name": "poky-master-$distro",
"oe-fragments-one-of": {
"machine": {
"description": "Target machines",
@@ -504,6 +504,7 @@ A valid settings file would for example be:
top-dir-name = bitbake-builds
registry = /path/to/bitbake/default-registry
dl-dir = /path/to/bitbake-setup-downloads
+ use-full-setup-dir-name = yes
Settings and their values can be listed and modified with the ``bitbake-setup
settings`` command. See the :ref:`ref-bbsetup-command-settings` section for
@@ -597,6 +598,17 @@ BitBake builds, so that there is a single directory containing a copy of
everything needed to set up and run a BitBake build offline in a reproducible
manner.
+.. _ref-bbsetup-setting-use-full-setup-dir-name:
+
+``use-full-setup-dir-name``
+---------------------------
+
+The :ref:`ref-bbsetup-setting-use-full-setup-dir-name` setting, if set to ``yes``
+will override the suggestions for the :term:`Setup` directory name made by
+``setup-dir-name`` entries in :term:`Generic Configuration` files. This
+will make the directory names longer, but fully specific: they will contain
+all selections made during initialization.
+
.. _ref-bbsetup-section-config-reference:
Generic Configuration Files Reference
@@ -802,6 +814,33 @@ They contain the following sections:
See https://docs.yoctoproject.org/dev/ref-manual/fragments.html for
more information of OpenEmbedded configuration fragments.
+ - ``setup-dir-name`` (*optional*): a suggestion for the :term:`Setup`
+ directory name. Bitbake-setup will use it, unless it already exists, or
+ the :ref:`ref-bbsetup-setting-use-full-setup-dir-name` setting is set
+ to ``yes`` (in those cases, it will fall back to the built-in full name,
+ containing the full set of choices made during initialization).
+
+ This key can have variable expansions in the same format as python
+ string.Template strings (which matches the shell variable expansion rules):
+ https://docs.python.org/3/library/string.html#template-strings-strings .
+
+ Variables that can be expanded are any fragment configuration prompted
+ by the user (e.g. the keys in "oe-fragments-one-of")::
+
+ {
+ ...
+ "oe-fragments-one-of": {
+ "machine": {
+ "description": "Target machines",
+ "options" : ["machine/gadget", "machine/gizmo"]
+ }
+ },
+ "setup-dir-name": "somebuild-$machine"
+ ...
+ }
+
+ would expand to ``somebuild-machine_gadget``.
+
Generic Configuration Examples
------------------------------
@@ -118,7 +118,8 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
"name": "gizmo",
"description": "Gizmo configuration",
"oe-template": "test-configuration-gizmo",
- "oe-fragments": ["test-fragment-2"]
+ "oe-fragments": ["test-fragment-2"],
+ "setup-dir-name": "this-is-a-custom-gizmo-build"
},
{
"name": "gizmo-env-passthrough",
@@ -227,6 +228,10 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
self.assertTrue('BUILD_SERVER' in init_build_env)
# a more throrough test could be to initialize a bitbake build-env, export FOO to the shell environment, set the env-passthrough on it and finally check against 'bitbake-getvar FOO'
+ def get_setup_path(self, cf, c):
+ if c == 'gizmo':
+ return os.path.join(self.tempdir, 'bitbake-builds', 'this-is-a-custom-gizmo-build')
+ return os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, c))
def test_setup(self):
# unset BBPATH to ensure tests run in isolation from the existing bitbake environment
@@ -307,7 +312,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
for cf, v in test_configurations.items():
for c in v['buildconfigs']:
out = self.runbbsetup("init --non-interactive {} {}".format(v['cmdline'], c))
- setuppath = os.path.join(self.tempdir, 'bitbake-builds', '{}-{}'.format(cf, c))
+ setuppath = self.get_setup_path(cf, c)
self.check_setupdir_files(setuppath, test_file_content)
os.environ['BBPATH'] = os.path.join(setuppath, 'build')
out = self.runbbsetup("status")
@@ -329,7 +334,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
'gizmo-env-passthrough',
'gizmo-no-fragment',
'gadget-notemplate', 'gizmo-notemplate'):
- setuppath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c))
+ setuppath = self.get_setup_path('test-config-1', c)
os.environ['BBPATH'] = os.path.join(setuppath, 'build')
out = self.runbbsetup("status")
self.assertIn("Layer repository file://{} checked out into {}/layers/test-repo updated revision master from".format(self.testrepopath, setuppath), out[0])
@@ -352,7 +357,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
'gizmo-env-passthrough',
'gizmo-no-fragment',
'gadget-notemplate', 'gizmo-notemplate'):
- setuppath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c))
+ setuppath = self.get_setup_path('test-config-1', c)
os.environ['BBPATH'] = os.path.join(setuppath, 'build')
out = self.runbbsetup("status")
self.assertIn("Configuration in {} has changed:".format(setuppath), out[0])
@@ -385,7 +390,7 @@ print("BBPATH is {{}}".format(os.environ["BBPATH"]))
'gizmo-env-passthrough',
'gizmo-no-fragment',
'gadget-notemplate', 'gizmo-notemplate'):
- setuppath = os.path.join(self.tempdir, 'bitbake-builds', 'test-config-1-{}'.format(c))
+ setuppath = self.get_setup_path('test-config-1', c)
os.environ['BBPATH'] = os.path.join(setuppath, 'build')
# write something in local.conf and bblayers.conf
for f in ["local.conf", "bblayers.conf"]:
@@ -96,6 +96,10 @@
"items": {
"type": "string"
}
+ },
+ "setup-dir-name": {
+ "type": "string",
+ "description": "A suggestion for the setup directory name, $-prefixed keys from oe-fragments-one-of will be substituted with user selections."
}
},
"additionalProperties": false