summaryrefslogtreecommitdiff
path: root/src/buildstream/_includes.py
diff options
context:
space:
mode:
authorTristan van Berkom <tristan.vanberkom@codethink.co.uk>2020-08-13 19:01:00 +0900
committerTristan van Berkom <tristan@codethink.co.uk>2020-10-01 13:27:30 +0900
commit751c80d4938b7c3a798d056134f58844242939b3 (patch)
treea31bd535be946b3032d22b6296a49b735ba5e2b1 /src/buildstream/_includes.py
parent348108d933be748727ee8aec861ecd5c168db72e (diff)
downloadbuildstream-751c80d4938b7c3a798d056134f58844242939b3.tar.gz
Refactor: Lazily instantiate ProvenanceInformation objectstristan/lazy-provenance
As a rule, throughout the codebase we should not be using internal ProvenanceInformation objects in our APIs, but rather Node objects. This is because ProvenanceInformation is generated on the fly from a Node object, and it is needlessly expensive to instantiate one before it is absolutely needed. This patch unilaterally fixes the codebase to pass `provenance_node` Node objects around as arguments rather than `provenance` ProvenanceInformation objects.
Diffstat (limited to 'src/buildstream/_includes.py')
-rw-r--r--src/buildstream/_includes.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/buildstream/_includes.py b/src/buildstream/_includes.py
index 1556bc613..9542003ad 100644
--- a/src/buildstream/_includes.py
+++ b/src/buildstream/_includes.py
@@ -133,18 +133,17 @@ class Includes:
# Can be prefixed with junctio name.
# loader (Loader): Loader for the current project.
def _include_file(self, include, loader):
- provenance = include.get_provenance()
- include = include.as_str()
- shortname = include
- if ":" in include:
- junction, include = include.rsplit(":", 1)
- current_loader = loader.get_loader(junction, provenance)
+ include_str = include.as_str()
+ shortname = include_str
+ if ":" in include_str:
+ junction, include_str = include_str.rsplit(":", 1)
+ current_loader = loader.get_loader(junction, include)
current_loader.project.ensure_fully_loaded()
else:
current_loader = loader
project = current_loader.project
directory = project.directory
- file_path = os.path.join(directory, include)
+ file_path = os.path.join(directory, include_str)
key = (current_loader, file_path)
if key not in self._loaded:
try:
@@ -152,7 +151,7 @@ class Includes:
file_path, shortname=shortname, project=project, copy_tree=self._copy_tree
)
except LoadError as e:
- raise LoadError("{}: {}".format(provenance, e), e.reason, detail=e.detail) from e
+ raise LoadError("{}: {}".format(include.get_provenance(), e), e.reason, detail=e.detail) from e
return self._loaded[key], file_path, current_loader