@@ -838,6 +838,31 @@ def create_siteconf(top_dir, non_interactive, settings):
os.makedirs(top_dir, exist_ok=True)
with open(siteconfpath, 'w') as siteconffile:
+ sstate_settings = textwrap.dedent(
+ """
+ #
+ # Where to place shared-state files
+ #
+ # BitBake has the capability to accelerate builds based on previously built output.
+ # This is done using "shared state" files which can be thought of as cache objects
+ # and this option determines where those files are placed.
+ #
+ # You can wipe out TMPDIR leaving this directory intact and the build would regenerate
+ # from these files if no changes were made to the configuration. If changes were made
+ # to the configuration, only shared state files where the state was still valid would
+ # be used (done using checksums).
+ SSTATE_DIR = "{sstate_dir}"
+ #
+ # Hash Equivalence database location
+ #
+ # Hash equivalence improves reuse of sstate by detecting when a given sstate
+ # artifact can be reused as equivalent, even if the current task hash doesn't
+ # match the one that generated the artifact. This variable controls where the
+ # Hash Equivalence database ("hashserv.db") is stored and can be shared between
+ # concurrent builds.
+ BB_HASHSERVE_DB_DIR = "{sstate_dir}"
+ """.format(sstate_dir=os.path.join(top_dir, ".sstate-cache"))
+ )
siteconffile.write(
textwrap.dedent(
"""\
@@ -855,7 +880,7 @@ def create_siteconf(top_dir, non_interactive, settings):
""".format(
dl_dir=settings["default"]["dl-dir"],
)
- )
+ ) + (sstate_settings if settings["default"]["common-sstate"] == 'yes' else "")
)
@@ -1061,6 +1086,7 @@ def main():
'top-dir-name':'bitbake-builds',
'registry':default_registry,
'use-full-setup-dir-name':'no',
+ 'common-sstate':'yes',
}
global_settings = load_settings(global_settings_path(args))
@@ -517,6 +517,7 @@ A valid settings file would for example be:
registry = /path/to/bitbake/default-registry
dl-dir = /path/to/bitbake-setup-downloads
use-full-setup-dir-name = yes
+ common-sstate = 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
@@ -621,6 +622,24 @@ will override the suggestions for the :term:`Setup` directory name made by
will make the directory names longer, but fully specific: they will contain
all selections made during initialization.
+.. _ref-bbsetup-setting-common-sstate:
+
+``common-sstate``
+-----------------
+
+When this setting is set to ``yes`` (which is also the default), bitbake-setup will
+set up a common sstate directory and common hash equivalency database for all the
+:term:`setups <Setup>` in a :term:`Top Directory`. This is very beneficial for speeding
+up builds as build artefacts will be reused whenever possible between them.
+
+Set this to ``no`` for advanced use cases, such as placing the sstate directory on a NFS
+mount and maintaining a separate hash equivalency server, so that sstate and hash equivalency
+data can be shared between several computers. For such use cases the sstate settings need
+to be added to a build configuration separately.
+
+See https://docs.yoctoproject.org/dev-manual/hashequivserver.html for how to share sstate
+on the network.
+
.. _ref-bbsetup-section-config-reference:
Generic Configuration Files Reference