mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
This required a bit of an overhaul of the original integration of
JSON diagnostics into binlog.
The problem is that it is quite hard to add a kind of metadata to
binlog entries without changing its code. Another problem is that when
wanting to avoid double evaluation of logging macro arguments one
cannot really add a separate "diagnose" step easily.
The proposed solution consists in two things:
* hook into a binlog plumbing function by providing a better overload
resolution match, which happens after logging macro expansion,
bypassing the problem of double evaluation
* in that hook, produce the diagnostic directly, without waiting to
reconstruct the diagnostics entry from the binlog serialized entry.
This allows to forgo the weird category to diagnostic mapping, and now a
diagnostics emission simply happens when a diagnostic source is given
as the first argument after the log format string. A flavour of
diganostics sources with locations is then added with the same
mechanism, allowing to write something like
```cpp
LOG_ERROR("[{}] ouch!", internalError.withLocation("foo.swift", 32));
```
81 lines
2.9 KiB
Python
81 lines
2.9 KiB
Python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
|
|
|
_swift_prebuilt_version = "swift-5.7.3-RELEASE.142"
|
|
_swift_sha_map = {
|
|
"Linux-X64": "398d8de54c8775c939dff95ed5bb0e04a9308a1982b4c1900cd4a5d01223f63b",
|
|
"macOS-ARM64": "397dd67ea99b9c9455794c6eb0f1664b6179fe542c7c1d3010314a3e8a905ae4",
|
|
"macOS-X64": "4b9d8e4e89f16a7c1e7edc7893aa189b37d5b4412be724a86ef59c49d11a6f75",
|
|
}
|
|
|
|
_swift_arch_map = {
|
|
"Linux-X64": "linux",
|
|
"macOS-X64": "darwin_x86_64",
|
|
}
|
|
|
|
def _github_archive(*, name, repository, commit, build_file = None, sha256 = None):
|
|
github_name = repository[repository.index("/") + 1:]
|
|
maybe(
|
|
repo_rule = http_archive,
|
|
name = name,
|
|
url = "https://github.com/%s/archive/%s.zip" % (repository, commit),
|
|
strip_prefix = "%s-%s" % (github_name, commit),
|
|
build_file = build_file,
|
|
sha256 = sha256,
|
|
)
|
|
|
|
def _build(workspace_name, package):
|
|
return "@%s//swift/third_party:BUILD.%s.bazel" % (workspace_name, package)
|
|
|
|
def load_dependencies(workspace_name):
|
|
for repo_arch, arch in _swift_arch_map.items():
|
|
sha256 = _swift_sha_map[repo_arch]
|
|
|
|
http_archive(
|
|
name = "swift_prebuilt_%s" % arch,
|
|
url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/%s/swift-prebuilt-%s.zip" % (
|
|
_swift_prebuilt_version,
|
|
repo_arch,
|
|
),
|
|
build_file = _build(workspace_name, "swift-llvm-support"),
|
|
sha256 = sha256,
|
|
)
|
|
|
|
_github_archive(
|
|
name = "picosha2",
|
|
build_file = _build(workspace_name, "picosha2"),
|
|
repository = "okdshin/PicoSHA2",
|
|
commit = "27fcf6979298949e8a462e16d09a0351c18fcaf2",
|
|
sha256 = "d6647ca45a8b7bdaf027ecb68d041b22a899a0218b7206dee755c558a2725abb",
|
|
)
|
|
|
|
_github_archive(
|
|
name = "binlog",
|
|
build_file = _build(workspace_name, "binlog"),
|
|
repository = "morganstanley/binlog",
|
|
commit = "3fef8846f5ef98e64211e7982c2ead67e0b185a6",
|
|
sha256 = "f5c61d90a6eff341bf91771f2f465be391fd85397023e1b391c17214f9cbd045",
|
|
)
|
|
|
|
_github_archive(
|
|
name = "absl",
|
|
repository = "abseil/abseil-cpp",
|
|
commit = "d2c5297a3c3948de765100cb7e5cccca1210d23c",
|
|
sha256 = "735a9efc673f30b3212bfd57f38d5deb152b543e35cd58b412d1363b15242049",
|
|
)
|
|
|
|
_github_archive(
|
|
name = "json",
|
|
repository = "nlohmann/json",
|
|
commit = "6af826d0bdb55e4b69e3ad817576745335f243ca",
|
|
sha256 = "702bb0231a5e21c0374230fed86c8ae3d07ee50f34ffd420e7f8249854b7d85b",
|
|
)
|
|
|
|
_github_archive(
|
|
name = "fmt",
|
|
repository = "fmtlib/fmt",
|
|
build_file = _build(workspace_name, "fmt"),
|
|
commit = "a0b8a92e3d1532361c2f7feb63babc5c18d00ef2",
|
|
sha256 = "ccf872fd4aa9ab3d030d62cffcb258ca27f021b2023a0244b2cf476f984be955",
|
|
)
|