зеркало из https://github.com/github/codeql.git
Go: create whole extractor pack with bazel
This commit is contained in:
Родитель
3ad9c026a5
Коммит
925a2cca7e
|
@ -0,0 +1,59 @@
|
|||
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
|
||||
load("@rules_pkg//pkg:install.bzl", "pkg_install")
|
||||
load("//:defs.bzl", "codeql_platform")
|
||||
|
||||
pkg_files(
|
||||
name = "resources",
|
||||
srcs = [
|
||||
"LICENSE",
|
||||
"codeql-extractor.yml",
|
||||
"ql/lib/go.dbscheme",
|
||||
"ql/lib/go.dbscheme.stats",
|
||||
],
|
||||
)
|
||||
|
||||
pkg_filegroup(
|
||||
name = "extractor-pack-generic",
|
||||
srcs = [
|
||||
":resources",
|
||||
"//go/codeql-tools",
|
||||
"//go/downgrades",
|
||||
"//go/extractor:tokenizer",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "extractor-pack-arch",
|
||||
srcs = [
|
||||
"//go/extractor/cli/go-autobuilder",
|
||||
"//go/extractor/cli/go-bootstrap",
|
||||
"//go/extractor/cli/go-build-runner",
|
||||
"//go/extractor/cli/go-extractor",
|
||||
"//go/extractor/cli/go-gen-dbscheme",
|
||||
"//go/extractor/cli/go-tokenizer",
|
||||
],
|
||||
prefix = "tools/" + codeql_platform,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_filegroup(
|
||||
name = "extractor-pack",
|
||||
srcs = [
|
||||
":extractor-pack-arch",
|
||||
":extractor-pack-generic",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
pkg_install(
|
||||
name = "_create_extractor_pack",
|
||||
srcs = [":extractor-pack"],
|
||||
)
|
||||
|
||||
py_binary(
|
||||
name = "create-extractor-pack",
|
||||
srcs = ["create_extractor_pack.py"],
|
||||
main = "create_extractor_pack.py",
|
||||
deps = [":_create_extractor_pack"],
|
||||
)
|
|
@ -0,0 +1,28 @@
|
|||
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files")
|
||||
|
||||
pkg_files(
|
||||
name = "executables",
|
||||
srcs = glob(["*.sh"]),
|
||||
attributes = pkg_attributes(mode = "0755"),
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "non-executables",
|
||||
srcs = glob(
|
||||
["*"],
|
||||
exclude = [
|
||||
"*.sh",
|
||||
"BUILD.bazel",
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
pkg_filegroup(
|
||||
name = "codeql-tools",
|
||||
srcs = [
|
||||
":executables",
|
||||
":non-executables",
|
||||
],
|
||||
prefix = "tools",
|
||||
visibility = ["//go:__pkg__"],
|
||||
)
|
|
@ -0,0 +1,16 @@
|
|||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
import sys
|
||||
from go._create_extractor_pack_install_script import main
|
||||
|
||||
try:
|
||||
workspace_dir = pathlib.Path(os.environ['BUILD_WORKSPACE_DIRECTORY'])
|
||||
except KeyError:
|
||||
print("this should be run with bazel run", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
dest_dir = workspace_dir / 'go' / 'build' / 'codeql-extractor-go'
|
||||
shutil.rmtree(dest_dir, ignore_errors=True)
|
||||
os.environ['DESTDIR'] = str(dest_dir)
|
||||
main(sys.argv)
|
|
@ -0,0 +1,12 @@
|
|||
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
|
||||
|
||||
pkg_files(
|
||||
name = "downgrades",
|
||||
srcs = glob(
|
||||
["**"],
|
||||
exclude = ["BUILD.bazel"],
|
||||
),
|
||||
prefix = "downgrades",
|
||||
strip_prefix = strip_prefix.from_pkg(),
|
||||
visibility = ["//go:__pkg__"],
|
||||
)
|
|
@ -1,4 +1,5 @@
|
|||
load("@rules_go//go:def.bzl", "go_library")
|
||||
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
|
||||
|
||||
# gazelle:prefix github.com/github/codeql-go/extractor
|
||||
# gazelle:map_kind go_binary codeql_go_binary //go:rules.bzl
|
||||
|
@ -22,3 +23,33 @@ go_library(
|
|||
"//go/extractor/vendor/golang.org/x/tools/go/packages",
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "tokenizer-deps",
|
||||
srcs = [
|
||||
"net/sourceforge/pmd/cpd/AbstractLanguage.java",
|
||||
"net/sourceforge/pmd/cpd/SourceCode.java",
|
||||
"net/sourceforge/pmd/cpd/TokenEntry.java",
|
||||
"net/sourceforge/pmd/cpd/Tokenizer.java",
|
||||
],
|
||||
)
|
||||
|
||||
java_library(
|
||||
name = "tokenizer-jar",
|
||||
srcs = [
|
||||
"net/sourceforge/pmd/cpd/GoLanguage.java",
|
||||
"opencsv/CSVParser.java",
|
||||
"opencsv/CSVReader.java",
|
||||
],
|
||||
deps = [":tokenizer-deps"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "tokenizer",
|
||||
srcs = [":tokenizer-jar"],
|
||||
prefix = "tools",
|
||||
renames = {
|
||||
":tokenizer-jar": "tokenizer.jar",
|
||||
},
|
||||
visibility = ["//go:__pkg__"],
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче