summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-11-04 14:47:04 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-11-04 14:47:04 +0000
commitabd09a9319376f40c7c05417338e70d5f2304f4a (patch)
tree7488ef38e94dc83e8eb47fa58eb94358640d7b57
parent1993ff0d96c51ee6aa1d4a601ad976b20f175a46 (diff)
parent2dd9f3721f23a9d13cebf22dfc42b35f7e0dab2c (diff)
downloadbuildstream-abd09a9319376f40c7c05417338e70d5f2304f4a.tar.gz
Merge branch 'traveltissues/changeflag' into 'master'
Replace flag name See merge request BuildStream/buildstream!1681
-rw-r--r--NEWS7
-rw-r--r--src/buildstream/plugins/sources/local.py2
-rw-r--r--src/buildstream/plugins/sources/workspace.py2
-rw-r--r--src/buildstream/source.py17
-rw-r--r--tests/sourcecache/staging.py2
5 files changed, 18 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index 4159f2f2d..3f7f1732e 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,13 @@ CLI
* `--track-cross-junctions` / `-J`
* `--track-save`
+API
+---
+
+ o Sources may force early staging to cache by advertising
+ `BST_KEY_REQUIRES_STAGE`. Sources setting this are staged to the cache to
+ generate unique keys. `WorkspaceSource` and `LocalSource` set this.
+
==================
buildstream 1.91.2
diff --git a/src/buildstream/plugins/sources/local.py b/src/buildstream/plugins/sources/local.py
index 98f74c16c..6114c60c9 100644
--- a/src/buildstream/plugins/sources/local.py
+++ b/src/buildstream/plugins/sources/local.py
@@ -46,7 +46,7 @@ class LocalSource(Source):
# pylint: disable=attribute-defined-outside-init
BST_STAGE_VIRTUAL_DIRECTORY = True
- BST_NO_PRESTAGE_KEY = True
+ BST_KEY_REQUIRES_STAGE = True
def __init__(self, context, project, meta):
super().__init__(context, project, meta)
diff --git a/src/buildstream/plugins/sources/workspace.py b/src/buildstream/plugins/sources/workspace.py
index 303b67938..1088f07f6 100644
--- a/src/buildstream/plugins/sources/workspace.py
+++ b/src/buildstream/plugins/sources/workspace.py
@@ -48,7 +48,7 @@ class WorkspaceSource(Source):
# pylint: disable=attribute-defined-outside-init
BST_STAGE_VIRTUAL_DIRECTORY = True
- BST_NO_PRESTAGE_KEY = True
+ BST_KEY_REQUIRES_STAGE = True
def __init__(self, context, project, meta) -> None:
super().__init__(context, project, meta)
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index 132856a6b..0312517c9 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -324,12 +324,11 @@ class Source(Plugin):
*Since: 1.4*
"""
- BST_NO_PRESTAGE_KEY = False
- """Whether the source will never have a key prior to staging (a pre-stage
- key). This is true in the case that the source requires staging in order to
- efficiently generate a unique key.
+ BST_KEY_REQUIRES_STAGE = False
+ """Whether the source will require staging in order to efficiently generate
+ a unique key.
- *Since: 1.91.1*
+ *Since: 1.91.2*
"""
def __init__(self,
@@ -788,7 +787,7 @@ class Source(Plugin):
def _stage(self, directory):
directory = self.__ensure_directory(directory)
- if self.BST_NO_PRESTAGE_KEY:
+ if self.BST_KEY_REQUIRES_STAGE:
# _get_unique_key should be called before _stage
assert self.__digest is not None
cas_dir = CasBasedDirectory(self._get_context().get_cascache(),
@@ -813,7 +812,7 @@ class Source(Plugin):
def _get_unique_key(self):
key = {}
key['directory'] = self.__directory
- if self.BST_NO_PRESTAGE_KEY:
+ if self.BST_KEY_REQUIRES_STAGE:
key['unique'] = self._stage_into_cas()
else:
key['unique'] = self.get_unique_key() # pylint: disable=assignment-from-no-return
@@ -1061,7 +1060,7 @@ class Source(Plugin):
# previous_sources (list): List of Sources listed prior to this source
#
def _track(self, previous_sources: List['Source']) -> SourceRef:
- if self.BST_NO_PRESTAGE_KEY:
+ if self.BST_KEY_REQUIRES_STAGE:
# ensure that these sources have a key after tracking
self._get_unique_key()
return None
@@ -1120,7 +1119,7 @@ class Source(Plugin):
self.__key = generate_key(keys)
sourcecache = self._get_context().sourcecache
- if self.BST_NO_PRESTAGE_KEY and not sourcecache.contains(self):
+ if self.BST_KEY_REQUIRES_STAGE and not sourcecache.contains(self):
sourcecache.commit(self, [])
@property
diff --git a/tests/sourcecache/staging.py b/tests/sourcecache/staging.py
index d7254b1ae..b0cc03119 100644
--- a/tests/sourcecache/staging.py
+++ b/tests/sourcecache/staging.py
@@ -138,7 +138,7 @@ def test_staged_source_build(tmpdir, datafiles, cli):
element = project.load_elements(["import-dev.bst"])[0]
# check consistency of the source
- # local sources set BST_NO_PRESTAGE_KEY so this is cached
+ # local sources set BST_KEY_REQUIRES_STAGE so this is cached
assert element._source_cached()
res = cli.run(project=project_dir, args=['build', 'target.bst'])