summaryrefslogtreecommitdiff
path: root/src/buildtool/main/build_utils.cpp
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-06-06 16:07:51 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-06-06 16:55:26 +0200
commitf63d3df866a2d75b694c8c484b21fbcdccd58acd (patch)
treec6a08e3e3f0636b21bec536d8212b30d5b1732ed /src/buildtool/main/build_utils.cpp
parent9516b96d83e8c4c21ad7f774099b5272deec6529 (diff)
downloadjustbuild-f63d3df866a2d75b694c8c484b21fbcdccd58acd.tar.gz
tc cache: abort writing if a dependent target is not available
After successful build of an export target target a cache entry is written. As those export targets have a dependency structure, care is taken to write them in correct order. Writing a cache entry for an export target requires knowledge of the analysis result of that target. Originally, all targets used to be analysed locally, so that information was available for every target that was not read from the local target cache already. However, with the introduction of serve endpoints, it can happen that a target was analyzed locally, but it depends on targets obtained from serve. In this case, we have to refrain from writing a target-level cache entry to keep the the consistency invariants of the target-level cache.
Diffstat (limited to 'src/buildtool/main/build_utils.cpp')
-rw-r--r--src/buildtool/main/build_utils.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/buildtool/main/build_utils.cpp b/src/buildtool/main/build_utils.cpp
index 5b8d142d..b29ff0c5 100644
--- a/src/buildtool/main/build_utils.cpp
+++ b/src/buildtool/main/build_utils.cpp
@@ -83,8 +83,15 @@ auto CreateTargetCacheWriterMap(
TargetCacheKey tc_key{key};
// check if entry actually needs storing
if (not cache_targets.contains(tc_key)) {
- // entry already in target-cache, so nothing to be done
- (*setter)(nullptr);
+ if (tc.Read(tc_key)) {
+ // entry already in target-cache, so nothing to be done
+ (*setter)(nullptr);
+ return;
+ }
+ (*logger)(fmt::format("Export target {} not analysed locally; "
+ "not caching anything depending on it",
+ key.ToString()),
+ true);
return;
}
auto const& target = cache_targets.at(tc_key);