mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Swift: improve diagnostics for OS incompatibility
* do not mention any more that one might make analysis happen on Linux with advanced setup * say that outright Swift analysis is only supported on macOS, not just autobuild. * emit the error diagnostics even for traced builds, not only for autobuilds (by using a dummy `extractor` executable).
This commit is contained in:
@@ -26,8 +26,14 @@ filegroup(
|
||||
)
|
||||
|
||||
codeql_pkg_files(
|
||||
name = "autobuilder-incompatible-os",
|
||||
exes = ["//swift/tools/diagnostics:autobuilder-incompatible-os"],
|
||||
name = "incompatible-os",
|
||||
exes = ["//swift/tools/incompatible-os"],
|
||||
renames = select_os(
|
||||
otherwise = {},
|
||||
windows = {
|
||||
"//swift/tools/incompatible-os": "extractor.exe",
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
codeql_pkg_runfiles(
|
||||
@@ -42,7 +48,7 @@ pkg_filegroup(
|
||||
":autobuilder-files",
|
||||
],
|
||||
otherwise = [
|
||||
":autobuilder-incompatible-os",
|
||||
":incompatible-os",
|
||||
],
|
||||
),
|
||||
prefix = "tools/{CODEQL_PLATFORM}",
|
||||
@@ -64,6 +70,13 @@ pkg_filegroup(
|
||||
prefix = "tools/{CODEQL_PLATFORM}",
|
||||
)
|
||||
|
||||
pkg_filegroup(
|
||||
name = "incompatible-linux-extractor",
|
||||
srcs = ["//swift/extractor:incompatible"],
|
||||
prefix = "tools/{CODEQL_PLATFORM}",
|
||||
target_compatible_with = ["@platforms//os:linux"],
|
||||
)
|
||||
|
||||
codeql_pkg_files(
|
||||
name = "root-files",
|
||||
srcs = [
|
||||
@@ -86,7 +99,7 @@ zip_map = {
|
||||
":tools",
|
||||
"//swift/downgrades",
|
||||
] + select_os(
|
||||
linux = [":extractor"] if linux_included else [],
|
||||
linux = [":extractor"] if linux_included else [":incompatible-linux-extractor"],
|
||||
macos = [":extractor"],
|
||||
windows = [],
|
||||
),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
|
||||
load("//misc/bazel:pkg.bzl", "codeql_pkg_runfiles")
|
||||
load("//misc/bazel:pkg.bzl", "codeql_pkg_files", "codeql_pkg_runfiles")
|
||||
load("//swift:rules.bzl", "swift_cc_binary")
|
||||
|
||||
swift_cc_binary(
|
||||
@@ -36,3 +36,11 @@ codeql_pkg_runfiles(
|
||||
exes = [":extractor"],
|
||||
visibility = ["//swift:__pkg__"],
|
||||
)
|
||||
|
||||
codeql_pkg_files(
|
||||
name = "incompatible",
|
||||
exes = ["incompatible-extractor.sh"],
|
||||
renames = {"incompatible-extractor.sh": "extractor"},
|
||||
target_compatible_with = ["@platforms//os:linux"],
|
||||
visibility = ["//swift:__pkg__"],
|
||||
)
|
||||
|
||||
3
swift/extractor/incompatible-extractor.sh
Executable file
3
swift/extractor/incompatible-extractor.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec -a "$0" "$(dirname $0)/incompatible-os"
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"markdownMessage": "Currently, `autobuild` for Swift analysis is only supported on macOS.\n\n[Change the Actions runner][1] to run on macOS.\n\nYou may be able to run analysis on Linux by setting up a [manual build command][2].\n\n[1]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on\n[2]: https://docs.github.com/en/enterprise-server/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-compiled-language",
|
||||
"markdownMessage": "Currently, Swift analysis is only supported on macOS.\n\n[Change the Actions runner][1] to run on macOS.\n\n[1]: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on",
|
||||
"severity": "error",
|
||||
"source": {
|
||||
"extractorName": "swift",
|
||||
"id": "swift/autobuilder/incompatible-os",
|
||||
"id": "swift/extractor/incompatible-os",
|
||||
"name": "Incompatible operating system (expected macOS)"
|
||||
},
|
||||
"visibility": {
|
||||
|
||||
@@ -1 +1 @@
|
||||
"%CODEQL_EXTRACTOR_SWIFT_ROOT%/tools/%CODEQL_PLATFORM%/autobuilder-incompatible-os.exe"
|
||||
"%CODEQL_EXTRACTOR_SWIFT_ROOT%/tools/%CODEQL_PLATFORM%/exctractor.exe"
|
||||
|
||||
@@ -5,5 +5,5 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
export CODEQL_SWIFT_POD_EXEC=`which pod`
|
||||
exec "${CODEQL_EXTRACTOR_SWIFT_ROOT}/tools/${CODEQL_PLATFORM}/swift-autobuilder"
|
||||
else
|
||||
exec "${CODEQL_EXTRACTOR_SWIFT_ROOT}/tools/${CODEQL_PLATFORM}/autobuilder-incompatible-os"
|
||||
exec "${CODEQL_EXTRACTOR_SWIFT_ROOT}/tools/${CODEQL_PLATFORM}/incompatible-os"
|
||||
fi
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
// Unconditionally emits a diagnostic about running the autobuilder on an incompatible, non-macOS OS
|
||||
// and exits with an error code.
|
||||
//
|
||||
// This is implemented as a C++ binary instead of a hardcoded JSON file so we can leverage existing
|
||||
// diagnostic machinery for emitting correct timestamps, generating correct file names, etc.
|
||||
|
||||
#include "swift/logging/SwiftLogging.h"
|
||||
|
||||
const std::string_view codeql::programName = "autobuilder";
|
||||
const std::string_view codeql::extractorName = "swift";
|
||||
|
||||
constexpr codeql::Diagnostic incompatibleOs{
|
||||
.id = "incompatible-os",
|
||||
.name = "Incompatible operating system (expected macOS)",
|
||||
.action =
|
||||
"[Change the Actions runner][1] to run on macOS.\n"
|
||||
"\n"
|
||||
"You may be able to run analysis on Linux by setting up a [manual build command][2].\n"
|
||||
"\n"
|
||||
"[1]: "
|
||||
"https://docs.github.com/en/actions/using-workflows/"
|
||||
"workflow-syntax-for-github-actions#jobsjob_idruns-on\n"
|
||||
"[2]: "
|
||||
"https://docs.github.com/en/enterprise-server/code-security/code-scanning/"
|
||||
"automatically-scanning-your-code-for-vulnerabilities-and-errors/"
|
||||
"configuring-the-codeql-workflow-for-compiled-languages#adding-build-steps-for-a-"
|
||||
"compiled-"
|
||||
"language"};
|
||||
|
||||
static codeql::Logger& logger() {
|
||||
static codeql::Logger ret{"main"};
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main() {
|
||||
DIAGNOSE_ERROR(incompatibleOs,
|
||||
"Currently, `autobuild` for Swift analysis is only supported on macOS.");
|
||||
return 1;
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
load("//swift:rules.bzl", "swift_cc_binary")
|
||||
|
||||
swift_cc_binary(
|
||||
name = "autobuilder-incompatible-os",
|
||||
srcs = ["AutobuilderIncompatibleOs.cpp"],
|
||||
name = "incompatible-os",
|
||||
srcs = ["IncompatibleOs.cpp"],
|
||||
# No restrictions (Windows allowed)
|
||||
target_compatible_with = [],
|
||||
visibility = ["//swift:__subpackages__"],
|
||||
28
swift/tools/incompatible-os/IncompatibleOs.cpp
Normal file
28
swift/tools/incompatible-os/IncompatibleOs.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Unconditionally emits a diagnostic about running the autobuilder on an incompatible, non-macOS OS
|
||||
// and exits with an error code.
|
||||
//
|
||||
// This is implemented as a C++ binary instead of a hardcoded JSON file so we can leverage existing
|
||||
// diagnostic machinery for emitting correct timestamps, generating correct file names, etc.
|
||||
|
||||
#include "swift/logging/SwiftLogging.h"
|
||||
|
||||
const std::string_view codeql::programName = "extractor";
|
||||
const std::string_view codeql::extractorName = "swift";
|
||||
|
||||
constexpr codeql::Diagnostic incompatibleOs{
|
||||
.id = "incompatible-os",
|
||||
.name = "Incompatible operating system (expected macOS)",
|
||||
.action = "[Change the Actions runner][1] to run on macOS.\n\n"
|
||||
"[1]: "
|
||||
"https://docs.github.com/en/actions/using-workflows/"
|
||||
"workflow-syntax-for-github-actions#jobsjob_idruns-on"};
|
||||
|
||||
static codeql::Logger& logger() {
|
||||
static codeql::Logger ret{"main"};
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main() {
|
||||
DIAGNOSE_ERROR(incompatibleOs, "Currently, Swift analysis is only supported on macOS.");
|
||||
return 1;
|
||||
}
|
||||
Reference in New Issue
Block a user