mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #15583 from github/redsun82/bzlmod
Bazel: use bzlmod
This commit is contained in:
8
.bazelrc
8
.bazelrc
@@ -1,4 +1,12 @@
|
||||
common --enable_platform_specific_config
|
||||
common --enable_bzlmod
|
||||
# because we use --override_module with `%workspace%`, the lock file is not stable
|
||||
common --lockfile_mode=off
|
||||
|
||||
# when building from this repository in isolation, the internal repository will not be found at ..
|
||||
# where `MODULE.bazel` looks for it. The following will get us past the module loading phase, so
|
||||
# that we can build things that do not rely on that
|
||||
common --override_module=semmle_code=%workspace%/misc/bazel/semmle_code_stub
|
||||
|
||||
build --repo_env=CC=clang --repo_env=CXX=clang++
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.3.1
|
||||
6.5.0
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
# Bazel (excluding BUILD.bazel files)
|
||||
WORKSPACE.bazel @github/codeql-ci-reviewers
|
||||
MODULE.bazel @github/codeql-ci-reviewers
|
||||
.bazelversion @github/codeql-ci-reviewers
|
||||
.bazelrc @github/codeql-ci-reviewers
|
||||
**/*.bzl @github/codeql-ci-reviewers
|
||||
|
||||
53
MODULE.bazel
Normal file
53
MODULE.bazel
Normal file
@@ -0,0 +1,53 @@
|
||||
module(
|
||||
name = "codeql",
|
||||
version = "0.0",
|
||||
)
|
||||
|
||||
# this points to our internal repository when `codeql` is checked out as a submodule thereof
|
||||
# when building things from `codeql` independently this is stubbed out in `.bazelrc`
|
||||
bazel_dep(name = "semmle_code", version = "0.0")
|
||||
local_path_override(
|
||||
module_name = "semmle_code",
|
||||
path = "..",
|
||||
)
|
||||
|
||||
# see https://registry.bazel.build/ for a list of available packages
|
||||
|
||||
bazel_dep(name = "platforms", version = "0.0.8")
|
||||
bazel_dep(name = "rules_pkg", version = "0.9.1")
|
||||
bazel_dep(name = "rules_nodejs", version = "6.0.3")
|
||||
bazel_dep(name = "rules_python", version = "0.31.0")
|
||||
bazel_dep(name = "bazel_skylib", version = "1.5.0")
|
||||
bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "absl")
|
||||
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
|
||||
bazel_dep(name = "fmt", version = "10.0.0")
|
||||
|
||||
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
|
||||
pip.parse(
|
||||
hub_name = "codegen_deps",
|
||||
python_version = "3.11",
|
||||
requirements_lock = "//misc/codegen:requirements_lock.txt",
|
||||
)
|
||||
use_repo(pip, "codegen_deps")
|
||||
|
||||
swift_deps = use_extension("//swift/third_party:load.bzl", "swift_deps")
|
||||
use_repo(
|
||||
swift_deps,
|
||||
"binlog",
|
||||
"picosha2",
|
||||
"swift_prebuilt_darwin_x86_64",
|
||||
"swift_prebuilt_linux",
|
||||
"swift_toolchain_linux",
|
||||
"swift_toolchain_macos",
|
||||
)
|
||||
|
||||
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
|
||||
node.toolchain(
|
||||
name = "nodejs",
|
||||
node_version = "18.15.0",
|
||||
)
|
||||
use_repo(node, "nodejs", "nodejs_toolchains")
|
||||
|
||||
register_toolchains(
|
||||
"@nodejs_toolchains//:all",
|
||||
)
|
||||
@@ -1,12 +1,2 @@
|
||||
# Please notice that any bazel targets and definitions in this repository are currently experimental
|
||||
# and for internal use only.
|
||||
|
||||
workspace(name = "codeql")
|
||||
|
||||
load("//misc/bazel:workspace.bzl", "codeql_workspace")
|
||||
|
||||
codeql_workspace()
|
||||
|
||||
load("//misc/bazel:workspace_deps.bzl", "codeql_workspace_deps")
|
||||
|
||||
codeql_workspace_deps()
|
||||
# please use MODULE.bazel to add dependencies
|
||||
# this empty file is required by internal repositories, don't remove it
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
load("@//:dist.bzl", "dist")
|
||||
load("@semmle_code//:dist.bzl", "dist")
|
||||
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
|
||||
load("@//buildutils-internal:zipmerge.bzl", "zipmerge")
|
||||
load("@semmle_code//buildutils-internal:zipmerge.bzl", "zipmerge")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
@@ -30,7 +30,7 @@ dist(
|
||||
"//javascript/downgrades",
|
||||
"//javascript/externs",
|
||||
"//javascript/extractor:tools-extractor",
|
||||
"@//language-packs/javascript:resources",
|
||||
"@semmle_code//language-packs/javascript:resources",
|
||||
],
|
||||
prefix = "javascript",
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@//:dist.bzl", "pack_zip")
|
||||
load("@semmle_code//:dist.bzl", "pack_zip")
|
||||
|
||||
pack_zip(
|
||||
name = "downgrades",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@//:dist.bzl", "pack_zip")
|
||||
load("@semmle_code//:dist.bzl", "pack_zip")
|
||||
|
||||
pack_zip(
|
||||
name = "externs",
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
load("@//:common.bzl", "codeql_fat_jar", "codeql_java_project")
|
||||
load("@semmle_code//:common.bzl", "codeql_fat_jar", "codeql_java_project")
|
||||
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
|
||||
|
||||
java_library(
|
||||
name = "deps",
|
||||
visibility = [":__subpackages__"],
|
||||
exports = [
|
||||
"@//extractor:html",
|
||||
"@//extractor:yaml",
|
||||
"@//resources/lib/java:commons-compress",
|
||||
"@//resources/lib/java:gson",
|
||||
"@//resources/lib/java:jericho-html",
|
||||
"@//resources/lib/java:slf4j-api",
|
||||
"@//resources/lib/java:snakeyaml",
|
||||
"@//third_party:jackson",
|
||||
"@//third_party:logback",
|
||||
"@//util-java7",
|
||||
"@//util-java8",
|
||||
"@semmle_code//extractor:html",
|
||||
"@semmle_code//extractor:yaml",
|
||||
"@semmle_code//resources/lib/java:commons-compress",
|
||||
"@semmle_code//resources/lib/java:gson",
|
||||
"@semmle_code//resources/lib/java:jericho-html",
|
||||
"@semmle_code//resources/lib/java:slf4j-api",
|
||||
"@semmle_code//resources/lib/java:snakeyaml",
|
||||
"@semmle_code//third_party:jackson",
|
||||
"@semmle_code//third_party:logback",
|
||||
"@semmle_code//util-java7",
|
||||
"@semmle_code//util-java8",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -36,18 +36,18 @@ codeql_fat_jar(
|
||||
name = "extractor-javascript",
|
||||
srcs = [
|
||||
":extractor",
|
||||
"@//extractor:html",
|
||||
"@//extractor:xml-trap-writer",
|
||||
"@//extractor:yaml",
|
||||
"@//resources/lib/java:commons-compress",
|
||||
"@//resources/lib/java:gson",
|
||||
"@//resources/lib/java:jericho-html",
|
||||
"@//resources/lib/java:slf4j-api",
|
||||
"@//resources/lib/java:snakeyaml",
|
||||
"@//third_party:jackson",
|
||||
"@//third_party:logback",
|
||||
"@//util-java7",
|
||||
"@//util-java8",
|
||||
"@semmle_code//extractor:html",
|
||||
"@semmle_code//extractor:xml-trap-writer",
|
||||
"@semmle_code//extractor:yaml",
|
||||
"@semmle_code//resources/lib/java:commons-compress",
|
||||
"@semmle_code//resources/lib/java:gson",
|
||||
"@semmle_code//resources/lib/java:jericho-html",
|
||||
"@semmle_code//resources/lib/java:slf4j-api",
|
||||
"@semmle_code//resources/lib/java:snakeyaml",
|
||||
"@semmle_code//third_party:jackson",
|
||||
"@semmle_code//third_party:logback",
|
||||
"@semmle_code//util-java7",
|
||||
"@semmle_code//util-java8",
|
||||
],
|
||||
files = [":javascript-extractor-resources"],
|
||||
main_class = "com.semmle.js.extractor.Main",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
load("@//:common.bzl", "on_windows")
|
||||
load("@semmle_code//:common.bzl", "on_windows")
|
||||
|
||||
# Builds a zip file of the compiled typscript-parser-wrapper and its dependencies.
|
||||
genrule(
|
||||
|
||||
@@ -7,15 +7,15 @@ java_test(
|
||||
"//javascript/extractor/tests",
|
||||
"@nodejs//:node_bin",
|
||||
],
|
||||
test_class = "com.semmle.js.extractor.test.AllTests",
|
||||
deps = [
|
||||
"//javascript/extractor",
|
||||
"//javascript/extractor:deps",
|
||||
"@//resources/lib/java/DO_NOT_DISTRIBUTE:junit",
|
||||
"@bazel_tools//tools/java/runfiles",
|
||||
],
|
||||
env = {
|
||||
"NODE_BIN": "$(rlocationpath @nodejs//:node_bin)",
|
||||
"TS_WRAPPER_ZIP": "$(rlocationpath //javascript/extractor/lib/typescript)",
|
||||
},
|
||||
test_class = "com.semmle.js.extractor.test.AllTests",
|
||||
deps = [
|
||||
"//javascript/extractor",
|
||||
"//javascript/extractor:deps",
|
||||
"@bazel_tools//tools/java/runfiles",
|
||||
"@semmle_code//resources/lib/java/DO_NOT_DISTRIBUTE:junit",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -1 +1 @@
|
||||
**/ql/javascript/extractor/tests/*/input//
|
||||
**/*ql*/javascript/extractor/tests/*/input//
|
||||
|
||||
@@ -22,7 +22,9 @@ CmakeInfo = provider(
|
||||
)
|
||||
|
||||
def _cmake_name(label):
|
||||
ret = ("%s_%s_%s" % (label.workspace_name, label.package, label.name)).replace("/", "_")
|
||||
# strip away the bzlmod module version for now
|
||||
workspace_name, _, _ = label.workspace_name.partition("~")
|
||||
ret = ("%s_%s_%s" % (workspace_name, label.package, label.name)).replace("/", "_")
|
||||
internal_transition_suffix = "_INTERNAL_TRANSITION"
|
||||
if ret.endswith(internal_transition_suffix):
|
||||
ret = ret[:-len(internal_transition_suffix)]
|
||||
@@ -120,7 +122,6 @@ def _cmake_aspect_impl(target, ctx):
|
||||
prefix, # source
|
||||
"${BAZEL_EXEC_ROOT}/%s/%s" % (ctx.var["BINDIR"], prefix), # generated
|
||||
]
|
||||
|
||||
deps = [dep[CmakeInfo] for dep in deps if CmakeInfo in dep]
|
||||
|
||||
# by the book this should be done with depsets, but so far the performance implication is negligible
|
||||
|
||||
@@ -19,8 +19,7 @@ endmacro()
|
||||
bazel(info workspace OUTPUT_VARIABLE BAZEL_WORKSPACE)
|
||||
|
||||
bazel(info output_base OUTPUT_VARIABLE BAZEL_OUTPUT_BASE)
|
||||
string(REPLACE "-" "_" BAZEL_EXEC_ROOT ${PROJECT_NAME})
|
||||
set(BAZEL_EXEC_ROOT ${BAZEL_OUTPUT_BASE}/execroot/${BAZEL_EXEC_ROOT})
|
||||
set(BAZEL_EXEC_ROOT ${BAZEL_OUTPUT_BASE}/execroot/_main)
|
||||
|
||||
macro(include_generated BAZEL_TARGET)
|
||||
bazel(build ${BAZEL_TARGET})
|
||||
|
||||
4
misc/bazel/semmle_code_stub/MODULE.bazel
Normal file
4
misc/bazel/semmle_code_stub/MODULE.bazel
Normal file
@@ -0,0 +1,4 @@
|
||||
module(
|
||||
name = "semmle_code",
|
||||
version = "0.0",
|
||||
)
|
||||
0
misc/bazel/semmle_code_stub/WORKSPACE.bazel
Normal file
0
misc/bazel/semmle_code_stub/WORKSPACE.bazel
Normal file
@@ -3,7 +3,7 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
||||
load("//swift/third_party:load.bzl", load_swift_dependencies = "load_dependencies")
|
||||
|
||||
def codeql_workspace(repository_name = "codeql"):
|
||||
load_swift_dependencies(repository_name)
|
||||
load_swift_dependencies(repository_name = repository_name)
|
||||
maybe(
|
||||
repo_rule = http_archive,
|
||||
name = "rules_pkg",
|
||||
|
||||
@@ -5,7 +5,7 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
|
||||
def codeql_workspace_deps(repository_name = "codeql"):
|
||||
pip_install(
|
||||
name = "codegen_deps",
|
||||
requirements = "@%s//misc/codegen:requirements.txt" % repository_name,
|
||||
requirements = "@%s//misc/codegen:requirements_lock.txt" % repository_name,
|
||||
)
|
||||
bazel_skylib_workspace()
|
||||
rules_pkg_dependencies()
|
||||
|
||||
22
misc/codegen/requirements_lock.txt
Normal file
22
misc/codegen/requirements_lock.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# This file is autogenerated by pip-compile with Python 3.11
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile --output-file=misc/codegen/requirements_lock.txt misc/codegen/requirements_in.txt
|
||||
#
|
||||
inflection==0.5.1
|
||||
# via -r misc/codegen/requirements_in.txt
|
||||
iniconfig==2.0.0
|
||||
# via pytest
|
||||
packaging==23.2
|
||||
# via pytest
|
||||
pluggy==1.4.0
|
||||
# via pytest
|
||||
pystache==0.6.5
|
||||
# via -r misc/codegen/requirements_in.txt
|
||||
pytest==8.0.0
|
||||
# via -r misc/codegen/requirements_in.txt
|
||||
pyyaml==6.0.1
|
||||
# via -r misc/codegen/requirements_in.txt
|
||||
toposort==1.10
|
||||
# via -r misc/codegen/requirements_in.txt
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <iostream>
|
||||
|
||||
#include <picosha2.h>
|
||||
|
||||
2
swift/third_party/BUILD.picosha2.bazel
vendored
2
swift/third_party/BUILD.picosha2.bazel
vendored
@@ -1,6 +1,6 @@
|
||||
cc_library(
|
||||
name = "picosha2",
|
||||
hdrs = glob(["*.h"]),
|
||||
strip_include_prefix = ".",
|
||||
includes = ["."],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
62
swift/third_party/load.bzl
vendored
62
swift/third_party/load.bzl
vendored
@@ -40,7 +40,7 @@ def _get_toolchain_url(info):
|
||||
info.extension,
|
||||
)
|
||||
|
||||
def _toolchains(workspace_name):
|
||||
def _toolchains(repository_name):
|
||||
rules = {
|
||||
"tar.gz": http_archive,
|
||||
"pkg": _pkg_archive,
|
||||
@@ -51,7 +51,7 @@ def _toolchains(workspace_name):
|
||||
name = "swift_toolchain_%s" % arch,
|
||||
url = _get_toolchain_url(info),
|
||||
sha256 = info.sha,
|
||||
build_file = _build(workspace_name, "swift-toolchain-%s" % arch),
|
||||
build_file = _build(repository_name, "swift-toolchain-%s" % arch),
|
||||
strip_prefix = "%s-%s" % (_swift_version, info.suffix),
|
||||
)
|
||||
|
||||
@@ -109,10 +109,10 @@ def _github_archive(*, name, repository, commit, build_file = None, sha256 = Non
|
||||
sha256 = sha256,
|
||||
)
|
||||
|
||||
def _build(workspace_name, package):
|
||||
return "@%s//swift/third_party:BUILD.%s.bazel" % (workspace_name, package)
|
||||
def _build(repository_name, package):
|
||||
return "@%s//swift/third_party:BUILD.%s.bazel" % (repository_name, package)
|
||||
|
||||
def load_dependencies(workspace_name):
|
||||
def load_dependencies(module_ctx = None, repository_name = "codeql"):
|
||||
for repo_arch, arch in _swift_arch_map.items():
|
||||
sha256 = _swift_sha_map[repo_arch]
|
||||
|
||||
@@ -122,11 +122,11 @@ def load_dependencies(workspace_name):
|
||||
_swift_prebuilt_version,
|
||||
repo_arch,
|
||||
),
|
||||
build_file = _build(workspace_name, "swift-llvm-support"),
|
||||
build_file = _build(repository_name, "swift-llvm-support"),
|
||||
sha256 = sha256,
|
||||
patch_args = ["-p1"],
|
||||
patches = [
|
||||
"@%s//swift/third_party/swift-llvm-support:patches/%s.patch" % (workspace_name, patch_name)
|
||||
"@%s//swift/third_party/swift-llvm-support:patches/%s.patch" % (repository_name, patch_name)
|
||||
for patch_name in (
|
||||
"remove-redundant-operators",
|
||||
"add-constructor-to-Compilation",
|
||||
@@ -134,11 +134,11 @@ def load_dependencies(workspace_name):
|
||||
],
|
||||
)
|
||||
|
||||
_toolchains(workspace_name)
|
||||
_toolchains(repository_name)
|
||||
|
||||
_github_archive(
|
||||
name = "picosha2",
|
||||
build_file = _build(workspace_name, "picosha2"),
|
||||
build_file = _build(repository_name, "picosha2"),
|
||||
repository = "okdshin/PicoSHA2",
|
||||
commit = "27fcf6979298949e8a462e16d09a0351c18fcaf2",
|
||||
sha256 = "d6647ca45a8b7bdaf027ecb68d041b22a899a0218b7206dee755c558a2725abb",
|
||||
@@ -146,30 +146,34 @@ def load_dependencies(workspace_name):
|
||||
|
||||
_github_archive(
|
||||
name = "binlog",
|
||||
build_file = _build(workspace_name, "binlog"),
|
||||
build_file = _build(repository_name, "binlog"),
|
||||
repository = "morganstanley/binlog",
|
||||
commit = "3fef8846f5ef98e64211e7982c2ead67e0b185a6",
|
||||
sha256 = "f5c61d90a6eff341bf91771f2f465be391fd85397023e1b391c17214f9cbd045",
|
||||
)
|
||||
|
||||
_github_archive(
|
||||
name = "absl",
|
||||
repository = "abseil/abseil-cpp",
|
||||
commit = "d2c5297a3c3948de765100cb7e5cccca1210d23c",
|
||||
sha256 = "735a9efc673f30b3212bfd57f38d5deb152b543e35cd58b412d1363b15242049",
|
||||
)
|
||||
if module_ctx == None:
|
||||
# legacy workspace loading, remove when transition is complete
|
||||
_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 = "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",
|
||||
)
|
||||
_github_archive(
|
||||
name = "fmt",
|
||||
repository = "fmtlib/fmt",
|
||||
build_file = _build(repository_name, "fmt"),
|
||||
commit = "a0b8a92e3d1532361c2f7feb63babc5c18d00ef2",
|
||||
sha256 = "ccf872fd4aa9ab3d030d62cffcb258ca27f021b2023a0244b2cf476f984be955",
|
||||
)
|
||||
|
||||
swift_deps = module_extension(load_dependencies)
|
||||
|
||||
Reference in New Issue
Block a user