зеркало из https://github.com/github/codeql.git
Bazel: reorganization
* fixed 5.0.0 as bazel version * made dependencies better loadable * moved `//swift/install` to `//swift:create-extractor-pack` (following the clearer ruby naming) * renamed `extractor_pack` to `extractor-pack` for consistency with Ruby
This commit is contained in:
Родитель
13b2442fed
Коммит
a205b465ba
|
@ -0,0 +1 @@
|
|||
5.0.0
|
|
@ -3,30 +3,10 @@
|
|||
|
||||
workspace(name = "ql")
|
||||
|
||||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
|
||||
http_archive(
|
||||
name = "rules_pkg",
|
||||
sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
|
||||
|
||||
rules_pkg_dependencies()
|
||||
|
||||
http_archive(
|
||||
name = "platforms",
|
||||
sha256 = "460caee0fa583b908c622913334ec3c1b842572b9c23cf0d3da0c2543a1a157d",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
|
||||
"https://github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
load("@ql//misc/bazel:workspace.bzl", "ql_workspace")
|
||||
|
||||
ql_workspace()
|
||||
|
||||
load("@ql//misc/bazel:workspace_deps.bzl", "ql_workspace_deps")
|
||||
|
||||
ql_workspace_deps()
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
load("@//misc/bazel:toolchain.bzl", "codeql_cli_toolchain")
|
||||
|
||||
codeql_cli_toolchain(
|
||||
name = "codeql-cli",
|
||||
path = "{codeql_cli_path}",
|
||||
)
|
||||
|
||||
toolchain(
|
||||
name = "codeql-cli-toolchain",
|
||||
toolchain = ":codeql-cli",
|
||||
toolchain_type = "@//:toolchain_type",
|
||||
)
|
|
@ -0,0 +1,38 @@
|
|||
def _test_script_impl(ctx):
|
||||
output = ctx.actions.declare_file("%s.py" % ctx.label.name)
|
||||
codeql_cli_path = ctx.toolchains["//:toolchain_type"].codeql_cli.path
|
||||
ctx.actions.expand_template(
|
||||
template = ctx.file._template,
|
||||
output = output,
|
||||
substitutions = {
|
||||
"{codeql_cli_path}": codeql_cli_path,
|
||||
"{test_sources}": str([f.path for f in ctx.files.srcs]),
|
||||
},
|
||||
)
|
||||
return DefaultInfo(
|
||||
files = depset([output]),
|
||||
)
|
||||
|
||||
_test_script = rule(
|
||||
implementation = _test_script_impl,
|
||||
attrs = {
|
||||
"srcs": attr.label_list(allow_files = True),
|
||||
"_template": attr.label(default = "//misc/bazel:test.template.py", allow_single_file = True),
|
||||
},
|
||||
toolchains = ["//:toolchain_type"],
|
||||
)
|
||||
|
||||
def codeql_test(*, name, srcs, deps):
|
||||
srcs = native.glob(["test/**/*.ql", "test/**/*.qlref"])
|
||||
data = srcs + deps
|
||||
script = name + "-script"
|
||||
_test_script(
|
||||
name = script,
|
||||
srcs = srcs,
|
||||
)
|
||||
native.py_test(
|
||||
name = name,
|
||||
main = script + ".py",
|
||||
srcs = [script],
|
||||
data = data,
|
||||
)
|
|
@ -0,0 +1,3 @@
|
|||
import os
|
||||
|
||||
os.execl("{codeql_cli_path}", "test", "run", "--check-databases", "--", *{test_sources})
|
|
@ -1,3 +1,6 @@
|
|||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
||||
|
||||
def _ql_utils_impl(repository_ctx):
|
||||
root = repository_ctx.path(Label("//:WORKSPACE.bazel")).realpath.dirname
|
||||
repository_ctx.file("BUILD.bazel")
|
||||
|
@ -12,4 +15,24 @@ _ql_utils = repository_rule(
|
|||
)
|
||||
|
||||
def ql_workspace():
|
||||
_ql_utils(name = "utils")
|
||||
_ql_utils(name = "ql_utils")
|
||||
|
||||
maybe(
|
||||
repo_rule = http_archive,
|
||||
name = "rules_pkg",
|
||||
sha256 = "62eeb544ff1ef41d786e329e1536c1d541bb9bcad27ae984d57f18f314018e66",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
|
||||
"https://github.com/bazelbuild/rules_pkg/releases/download/0.6.0/rules_pkg-0.6.0.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
maybe(
|
||||
repo_rule = http_archive,
|
||||
name = "platforms",
|
||||
sha256 = "460caee0fa583b908c622913334ec3c1b842572b9c23cf0d3da0c2543a1a157d",
|
||||
urls = [
|
||||
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
|
||||
"https://github.com/bazelbuild/platforms/releases/download/0.0.3/platforms-0.0.3.tar.gz",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
|
||||
|
||||
def ql_workspace_deps():
|
||||
rules_pkg_dependencies()
|
|
@ -2,6 +2,6 @@
|
|||
"provide": [
|
||||
"ql/lib/qlpack.yml",
|
||||
"ql/test/qlpack.yml",
|
||||
"extractor_pack/codeql-extractor.yml"
|
||||
"extractor-pack/codeql-extractor.yml"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
extractor_pack
|
||||
extractor-pack
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
load("@rules_pkg//:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files")
|
||||
load("@rules_pkg//:install.bzl", "pkg_install")
|
||||
load("@ql//:defs.bzl", "codeql_platform")
|
||||
load("@ql_utils//:source_dir.bzl", "current_source_dir")
|
||||
|
||||
pkg_files(
|
||||
name = "dbscheme",
|
||||
|
@ -52,3 +54,12 @@ pkg_filegroup(
|
|||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_install(
|
||||
name = "create-extractor-pack",
|
||||
srcs = ["//swift:extractor-pack"],
|
||||
args = [
|
||||
"--destdir",
|
||||
current_source_dir() + "/extractor-pack",
|
||||
],
|
||||
)
|
||||
|
|
|
@ -4,5 +4,6 @@ The Swift codeql package is an experimental and unsupported work in progress.
|
|||
|
||||
## Usage
|
||||
|
||||
Run `bazel run //swift/install`, which will install `swift/extractor_pack`. Using `--search-path=swift` will then pick
|
||||
up the Swift extractor.
|
||||
Run `bazel run //swift:create-extractor-pack`, which will install `swift/extractor-pack`.
|
||||
Using `--search-path=swift/extractor-pack` will then pick up the Swift extractor. You can also use
|
||||
`--search-path=swift`, as the extractor pack is mentioned in `swift/.codeqlmanifest`.
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
load("@utils//:source_dir.bzl", "current_source_dir")
|
||||
load("@rules_pkg//:install.bzl", "pkg_install")
|
||||
|
||||
pkg_install(
|
||||
name = "install",
|
||||
srcs = ["//swift:extractor-pack"],
|
||||
args = [
|
||||
"--destdir",
|
||||
current_source_dir() + "/../extractor_pack",
|
||||
],
|
||||
)
|
Загрузка…
Ссылка в новой задаче