Swift: add autobuild failure diagnostics

This commit is contained in:
Paolo Tranquilli
2023-05-08 10:28:10 +02:00
parent 7323d4ecc1
commit 8079af7ed6
13 changed files with 528 additions and 17 deletions

View File

@@ -3,6 +3,14 @@
#include <vector>
#include <iostream>
#include <spawn.h>
#include "absl/strings/str_join.h"
#include "swift/xcode-autobuilder/XcodeBuildLogging.h"
static codeql::Logger& logger() {
static codeql::Logger ret{"build"};
return ret;
}
static int waitpid_status(pid_t child) {
int status;
@@ -52,13 +60,12 @@ void buildTarget(Target& target, bool dryRun) {
argv.push_back("CODE_SIGNING_ALLOWED=NO");
if (dryRun) {
for (auto& arg : argv) {
std::cout << arg + " ";
}
std::cout << "\n";
std::cout << absl::StrJoin(argv, " ") << "\n";
} else {
if (!exec(argv)) {
std::cerr << "Build failed\n";
DIAGNOSE_ERROR(build_command_failed, "The detected build command failed (tried {})",
absl::StrJoin(argv, " "));
codeql::Log::flush();
exit(1);
}
}