diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/main/TARGETS | 6 | ||||
-rw-r--r-- | src/buildtool/main/build_utils.cpp | 26 | ||||
-rw-r--r-- | src/buildtool/main/build_utils.hpp | 7 |
3 files changed, 25 insertions, 14 deletions
diff --git a/src/buildtool/main/TARGETS b/src/buildtool/main/TARGETS index f7e90e6c..d2d3c1fa 100644 --- a/src/buildtool/main/TARGETS +++ b/src/buildtool/main/TARGETS @@ -249,14 +249,14 @@ , ["src/buildtool/common", "common"] , ["src/buildtool/common", "config"] , ["src/buildtool/execution_api/common", "common"] + , ["src/buildtool/logging", "logging"] , ["src/buildtool/multithreading", "async_map_consumer"] - , ["src/buildtool/multithreading", "async_map_utils"] , ["src/buildtool/storage", "storage"] ] , "stage": ["src", "buildtool", "main"] , "private-deps": - [ ["src/buildtool/logging", "log_level"] - , ["src/buildtool/logging", "logging"] + [ ["src/buildtool/multithreading", "async_map_utils"] + , ["src/buildtool/logging", "log_level"] ] } } diff --git a/src/buildtool/main/build_utils.cpp b/src/buildtool/main/build_utils.cpp index 4b6c7dab..492e80d6 100644 --- a/src/buildtool/main/build_utils.cpp +++ b/src/buildtool/main/build_utils.cpp @@ -15,9 +15,7 @@ #include "src/buildtool/main/build_utils.hpp" #ifndef BOOTSTRAP_BUILD_TOOL #include "src/buildtool/logging/log_level.hpp" -#include "src/buildtool/logging/logger.hpp" #include "src/buildtool/multithreading/async_map_utils.hpp" -#include "src/buildtool/storage/storage.hpp" #include "src/buildtool/storage/target_cache_entry.hpp" #endif // BOOTSTRAP_BUILD_TOOL @@ -162,12 +160,15 @@ void WriteTargetCacheEntries( gsl::not_null<IExecutionApi*> const& local_api, gsl::not_null<IExecutionApi*> const& remote_api, TargetCacheWriteStrategy strategy, - TargetCache<true> const& tc) { + TargetCache<true> const& tc, + Logger const* logger, + bool strict_logging) { if (strategy == TargetCacheWriteStrategy::Disable) { return; } if (!cache_targets.empty()) { - Logger::Log(LogLevel::Info, + Logger::Log(logger, + LogLevel::Info, "Backing up artifacts of {} export targets", cache_targets.size()); } @@ -187,10 +188,12 @@ void WriteTargetCacheEntries( &ts, cache_targets_ids, []([[maybe_unused]] auto _) {}, // map doesn't set anything - [&failed](auto const& msg, bool fatal) { - Logger::Log(LogLevel::Warning, - "While writing target cache entries:\n{}", - msg); + [&failed, logger, strict_logging](auto const& msg, bool fatal) { + Logger::Log( + logger, + strict_logging ? LogLevel::Error : LogLevel::Warning, + "While writing target cache entries:\n{}", + msg); failed = failed or fatal; }); } @@ -200,11 +203,14 @@ void WriteTargetCacheEntries( } if (auto error = DetectAndReportCycle( "writing cache targets", tc_writer_map, kObjectInfoPrinter)) { - Logger::Log(LogLevel::Warning, *error); + Logger::Log(logger, + strict_logging ? LogLevel::Error : LogLevel::Warning, + *error); return; } - Logger::Log(LogLevel::Debug, + Logger::Log(logger, + LogLevel::Debug, "Finished backing up artifacts of export targets"); } #endif // BOOTSTRAP_BUILD_TOOL diff --git a/src/buildtool/main/build_utils.hpp b/src/buildtool/main/build_utils.hpp index cf1c68ec..e86e2a90 100644 --- a/src/buildtool/main/build_utils.hpp +++ b/src/buildtool/main/build_utils.hpp @@ -30,6 +30,7 @@ #include "src/buildtool/common/artifact.hpp" #include "src/buildtool/common/artifact_digest.hpp" #include "src/buildtool/execution_api/common/execution_api.hpp" +#include "src/buildtool/logging/logger.hpp" #include "src/buildtool/multithreading/async_map_consumer.hpp" #include "src/buildtool/storage/storage.hpp" #include "src/buildtool/storage/target_cache.hpp" @@ -79,6 +80,8 @@ static const std::function<std::string(Artifact::ObjectInfo const&)> return x.ToString(); }; +/// \brief Write the target cache entries resulting after a build. +/// \param strict_logging Bump warnings to actual errors. void WriteTargetCacheEntries( std::unordered_map<TargetCacheKey, AnalysedTargetPtr> const& cache_targets, std::unordered_map<ArtifactDescription, Artifact::ObjectInfo> const& @@ -87,7 +90,9 @@ void WriteTargetCacheEntries( gsl::not_null<IExecutionApi*> const& local_api, gsl::not_null<IExecutionApi*> const& remote_api, TargetCacheWriteStrategy strategy = TargetCacheWriteStrategy::Sync, - TargetCache<true> const& tc = Storage::Instance().TargetCache()); + TargetCache<true> const& tc = Storage::Instance().TargetCache(), + Logger const* logger = nullptr, + bool strict_logging = false); #endif // BOOTSTRAP_BUILD_TOOL #endif // INCLUDED_SRC_BUILDOOL_MAIN_BUILD_UTILS_HPP |