Skip to content

Commit e17a8d0

Browse files
committed
Swift: add diagnostic for no project found
1 parent 08c43bc commit e17a8d0

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"helpLinks": [
3+
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning"
4+
],
5+
"plaintextMessage": "No Xcode project or workspace was found.\n\nSet up a manual build command.",
6+
"severity": "error",
7+
"source": {
8+
"extractorName": "swift",
9+
"id": "swift/autobuilder/no-project-found",
10+
"name": "No Xcode project or workspace detected"
11+
},
12+
"visibility": {
13+
"cliSummaryTable": true,
14+
"statusPage": true,
15+
"telemetry": true
16+
}
17+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from create_database_utils import *
2+
from diagnostics_test_utils import *
3+
4+
run_codeql_database_create([], lang='swift', keep_trap=True, db=None, runFunction=runUnsuccessfully)
5+
check_diagnostics()

swift/integration-tests/osx-only/autobuilder/no-build-system/x.swift

Whitespace-only changes.

swift/xcode-autobuilder/XcodeProjectParser.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#include "swift/xcode-autobuilder/XcodeProjectParser.h"
2-
#include "swift/xcode-autobuilder/XcodeWorkspaceParser.h"
3-
#include "swift/xcode-autobuilder/CFHelpers.h"
42

53
#include <iostream>
64
#include <filesystem>
@@ -9,8 +7,27 @@
97
#include <fstream>
108
#include <CoreFoundation/CoreFoundation.h>
119

10+
#include "swift/xcode-autobuilder/XcodeWorkspaceParser.h"
11+
#include "swift/xcode-autobuilder/CFHelpers.h"
12+
#include "swift/logging/SwiftLogging.h"
13+
14+
namespace codeql_diagnostics {
15+
constexpr codeql::SwiftDiagnosticsSource no_project_found{
16+
"no_project_found",
17+
"No Xcode project or workspace detected",
18+
"Set up a manual build command",
19+
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/"
20+
"automatically-scanning-your-code-for-vulnerabilities-and-errors/customizing-code-scanning",
21+
};
22+
} // namespace codeql_diagnostics
23+
1224
namespace fs = std::filesystem;
1325

26+
static codeql::Logger& logger() {
27+
static codeql::Logger ret{"project"};
28+
return ret;
29+
}
30+
1431
struct TargetData {
1532
std::string workspace;
1633
std::string project;
@@ -253,7 +270,7 @@ std::vector<Target> collectTargets(const std::string& workingDir) {
253270
// Getting a list of workspaces and the project that belong to them
254271
auto workspaces = collectWorkspaces(workingDir);
255272
if (workspaces.empty()) {
256-
std::cerr << "[xcode autobuilder] Xcode project or workspace not found\n";
273+
DIAGNOSE_ERROR(no_project_found, "No Xcode project or workspace was found");
257274
exit(1);
258275
}
259276

0 commit comments

Comments
 (0)