Skip to content

Commit 0a521fb

Browse files
committed
Siwft: first skeleton extractor
This adds a first dummy extractor for swift. Running `bazel run //swift:install will create an `extractor_pack` directory in `swift`. From that moment providing `--search-path=swift` will pick up the extractor.
1 parent 4eaec39 commit 0a521fb

20 files changed

+216
-3
lines changed

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build --copt="-std=c++17"
2+
3+
try-import %workspace%/local.bazelrc

BUILD.bazel

Whitespace-only changes.

WORKSPACE.bazel

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,45 @@
11
# Please notice that any bazel targets and definitions in this repository are currently experimental
22
# and for internal use only.
3+
4+
workspace(name = "ql")
5+
6+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
7+
8+
http_archive(
9+
name = "rules_pkg",
10+
sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66",
11+
urls = [
12+
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
13+
"https://github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
14+
],
15+
)
16+
17+
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
18+
19+
rules_pkg_dependencies()
20+
21+
http_archive(
22+
name = "platforms",
23+
sha256 = "460caee0fa583b908c622913334ec3c1b842572b9c23cf0d3da0c2543a1a157d",
24+
urls = [
25+
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
26+
"https://github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
27+
],
28+
)
29+
30+
http_archive(
31+
name = "bazel_skylib",
32+
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
33+
urls = [
34+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
35+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
36+
],
37+
)
38+
39+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
40+
41+
bazel_skylib_workspace()
42+
43+
load("@ql//:defs.bzl", "ql_utils")
44+
45+
ql_utils(name = "utils")

cpp/BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ load("@rules_pkg//:mappings.bzl", "pkg_filegroup")
44

55
alias(
66
name = "dbscheme",
7-
actual = "//cpp/ql/lib:dbscheme",
7+
actual = "@ql//cpp/ql/lib:dbscheme",
88
)
99

1010
pkg_filegroup(
1111
name = "db-files",
1212
srcs = [
1313
":dbscheme",
14-
"//cpp/downgrades",
15-
"//cpp/ql/lib:dbscheme-stats",
14+
"@ql//cpp/downgrades",
15+
"@ql//cpp/ql/lib:dbscheme-stats",
1616
],
1717
)

defs.bzl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
codeql_platform = select({
2+
"@platforms//os:linux": "linux64",
3+
"@platforms//os:macos": "osx64",
4+
"@platforms//os:windows": "win64",
5+
})
6+
7+
_paths_bzl = """
8+
def source_dir():
9+
return '%s/' + native.package_name()
10+
"""
11+
12+
def _ql_utils_impl(repository_ctx):
13+
root = repository_ctx.path(Label("@ql//:WORKSPACE.bazel")).realpath.dirname
14+
repository_ctx.file("BUILD.bazel")
15+
repository_ctx.file("paths.bzl", content = _paths_bzl % root)
16+
17+
ql_utils = repository_rule(
18+
implementation = _ql_utils_impl,
19+
)

swift/.clang-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BasedOnStyle: Chromium
2+
ColumnLimit: 100
3+
IndentWidth: 2
4+
SortIncludes: false
5+
AllowShortIfStatementsOnASingleLine: WithoutElse
6+
AlwaysBreakBeforeMultilineStrings: false
7+
Standard: c++17

swift/.codeqlmanifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"provide": [
3+
"ql/lib/qlpack.yml",
4+
"ql/test/qlpack.yml",
5+
"extractor_pack/codeql-extractor.yml"
6+
]
7+
}

swift/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extractor_pack

swift/BUILD.bazel

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files")
2+
load("@rules_pkg//:install.bzl", "pkg_install")
3+
load("@ql//:defs.bzl", "codeql_platform")
4+
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
5+
load("@utils//:paths.bzl", "source_dir")
6+
7+
pkg_files(
8+
name = "dbscheme",
9+
srcs = [
10+
"ql/lib/swift.dbscheme",
11+
"ql/lib/swift.dbscheme.stats",
12+
],
13+
)
14+
15+
pkg_files(
16+
name = "qltest",
17+
srcs = ["tools/qltest.sh"],
18+
attributes = pkg_attributes(mode = "0755"),
19+
prefix = "tools",
20+
)
21+
22+
pkg_files(
23+
name = "manifest",
24+
srcs = ["codeql-extractor.yml"],
25+
)
26+
27+
pkg_filegroup(
28+
name = "extractor-pack-generic",
29+
srcs = [
30+
":dbscheme",
31+
":manifest",
32+
":qltest",
33+
],
34+
visibility = ["//visibility:public"],
35+
)
36+
37+
pkg_files(
38+
name = "extractor",
39+
srcs = ["//swift/extractor"],
40+
attributes = pkg_attributes(mode = "0755"),
41+
prefix = "tools/" + codeql_platform,
42+
)
43+
44+
pkg_filegroup(
45+
name = "extractor-pack-arch",
46+
srcs = [":extractor"],
47+
visibility = ["//visibility:public"],
48+
)
49+
50+
pkg_filegroup(
51+
name = "extractor-pack",
52+
srcs = [
53+
":extractor-pack-arch",
54+
":extractor-pack-generic",
55+
],
56+
visibility = ["//visibility:public"],
57+
)
58+
59+
pkg_install(
60+
name = "install-extractor",
61+
srcs = [":extractor-pack"],
62+
args = [
63+
"--destdir",
64+
source_dir() + "/extractor_pack",
65+
],
66+
)

swift/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Warning
2+
3+
The Swift codeql package is an experimental and unsupported work in progress.
4+
5+
## Usage
6+
7+
Run `bazel run //swift:install-extractor`, which will install `swift/extractor_pack`. Using `--search-path=swift` will
8+
then pick up the Swift extractor.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy