Skip to content

Commit 19bb8fe

Browse files
committed
Bazel: use bzlmod
1 parent b2ee580 commit 19bb8fe

File tree

9 files changed

+67
-96
lines changed

9 files changed

+67
-96
lines changed

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
common --enable_platform_specific_config
1+
common --enable_platform_specific_config --experimental_enable_bzlmod
22

33
build --repo_env=CC=clang --repo_env=CXX=clang++
44

MODULE.bazel

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module(
2+
name = "codeql",
3+
version = "0.0",
4+
)
5+
6+
# see https://registry.bazel.build/ for a list of available packages
7+
8+
bazel_dep(name = "platforms", version = "0.0.8")
9+
bazel_dep(name = "rules_pkg", version = "0.9.1")
10+
bazel_dep(name = "rules_python", version = "0.29.0")
11+
bazel_dep(name = "bazel_skylib", version = "1.5.0")
12+
bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "absl")
13+
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
14+
bazel_dep(name = "fmt", version = "10.0.0")
15+
16+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
17+
pip.parse(
18+
hub_name = "codegen_deps",
19+
python_version = "3.11",
20+
requirements_lock = "//misc/codegen:requirements_lock.txt",
21+
)
22+
use_repo(pip, "codegen_deps")
23+
24+
swift_deps = use_extension("//swift/third_party:load.bzl", "swift_deps")
25+
use_repo(
26+
swift_deps,
27+
"binlog",
28+
"picosha2",
29+
"swift_prebuilt_darwin_x86_64",
30+
"swift_prebuilt_linux",
31+
"swift_toolchain_linux",
32+
"swift_toolchain_macos",
33+
)

WORKSPACE.bazel

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,3 @@
22
# and for internal use only.
33

44
workspace(name = "codeql")
5-
6-
load("//misc/bazel:workspace.bzl", "codeql_workspace")
7-
8-
codeql_workspace()
9-
10-
load("//misc/bazel:workspace_deps.bzl", "codeql_workspace_deps")
11-
12-
codeql_workspace_deps()

misc/bazel/workspace.bzl

Lines changed: 0 additions & 45 deletions
This file was deleted.

misc/bazel/workspace_deps.bzl

Lines changed: 0 additions & 11 deletions
This file was deleted.
File renamed without changes.

misc/codegen/requirements_lock.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# This file is autogenerated by pip-compile with Python 3.11
3+
# by the following command:
4+
#
5+
# pip-compile --output-file=misc/codegen/requirements_lock.txt misc/codegen/requirements_in.txt
6+
#
7+
inflection==0.5.1
8+
# via -r misc/codegen/requirements_in.txt
9+
iniconfig==2.0.0
10+
# via pytest
11+
packaging==23.2
12+
# via pytest
13+
pluggy==1.4.0
14+
# via pytest
15+
pystache==0.6.5
16+
# via -r misc/codegen/requirements_in.txt
17+
pytest==8.0.0
18+
# via -r misc/codegen/requirements_in.txt
19+
pyyaml==6.0.1
20+
# via -r misc/codegen/requirements_in.txt
21+
toposort==1.10
22+
# via -r misc/codegen/requirements_in.txt

swift/extractor/remapping/SwiftFileInterception.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <mutex>
99
#include <optional>
1010
#include <cassert>
11+
#include <cstdarg>
1112
#include <iostream>
1213

1314
#include <picosha2.h>

swift/third_party/load.bzl

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _get_toolchain_url(info):
4040
info.extension,
4141
)
4242

43-
def _toolchains(workspace_name):
43+
def _toolchains():
4444
rules = {
4545
"tar.gz": http_archive,
4646
"pkg": _pkg_archive,
@@ -51,7 +51,7 @@ def _toolchains(workspace_name):
5151
name = "swift_toolchain_%s" % arch,
5252
url = _get_toolchain_url(info),
5353
sha256 = info.sha,
54-
build_file = _build(workspace_name, "swift-toolchain-%s" % arch),
54+
build_file = _build % ("swift-toolchain-%s" % arch),
5555
strip_prefix = "%s-%s" % (_swift_version, info.suffix),
5656
)
5757

@@ -109,10 +109,9 @@ def _github_archive(*, name, repository, commit, build_file = None, sha256 = Non
109109
sha256 = sha256,
110110
)
111111

112-
def _build(workspace_name, package):
113-
return "@%s//swift/third_party:BUILD.%s.bazel" % (workspace_name, package)
112+
_build = "@codeql//swift/third_party:BUILD.%s.bazel"
114113

115-
def load_dependencies(workspace_name):
114+
def _load_dependencies(_):
116115
for repo_arch, arch in _swift_arch_map.items():
117116
sha256 = _swift_sha_map[repo_arch]
118117

@@ -122,54 +121,34 @@ def load_dependencies(workspace_name):
122121
_swift_prebuilt_version,
123122
repo_arch,
124123
),
125-
build_file = _build(workspace_name, "swift-llvm-support"),
124+
build_file = _build % "swift-llvm-support",
126125
sha256 = sha256,
127126
patch_args = ["-p1"],
128127
patches = [
129-
"@%s//swift/third_party/swift-llvm-support:patches/%s.patch" % (workspace_name, patch_name)
128+
"@codeql//swift/third_party/swift-llvm-support:patches/%s.patch" % patch_name
130129
for patch_name in (
131130
"remove-redundant-operators",
132131
"add-constructor-to-Compilation",
133132
)
134133
],
135134
)
136135

137-
_toolchains(workspace_name)
136+
_toolchains()
138137

139138
_github_archive(
140139
name = "picosha2",
141-
build_file = _build(workspace_name, "picosha2"),
140+
build_file = _build % "picosha2",
142141
repository = "okdshin/PicoSHA2",
143142
commit = "27fcf6979298949e8a462e16d09a0351c18fcaf2",
144143
sha256 = "d6647ca45a8b7bdaf027ecb68d041b22a899a0218b7206dee755c558a2725abb",
145144
)
146145

147146
_github_archive(
148147
name = "binlog",
149-
build_file = _build(workspace_name, "binlog"),
148+
build_file = _build % "binlog",
150149
repository = "morganstanley/binlog",
151150
commit = "3fef8846f5ef98e64211e7982c2ead67e0b185a6",
152151
sha256 = "f5c61d90a6eff341bf91771f2f465be391fd85397023e1b391c17214f9cbd045",
153152
)
154153

155-
_github_archive(
156-
name = "absl",
157-
repository = "abseil/abseil-cpp",
158-
commit = "d2c5297a3c3948de765100cb7e5cccca1210d23c",
159-
sha256 = "735a9efc673f30b3212bfd57f38d5deb152b543e35cd58b412d1363b15242049",
160-
)
161-
162-
_github_archive(
163-
name = "json",
164-
repository = "nlohmann/json",
165-
commit = "6af826d0bdb55e4b69e3ad817576745335f243ca",
166-
sha256 = "702bb0231a5e21c0374230fed86c8ae3d07ee50f34ffd420e7f8249854b7d85b",
167-
)
168-
169-
_github_archive(
170-
name = "fmt",
171-
repository = "fmtlib/fmt",
172-
build_file = _build(workspace_name, "fmt"),
173-
commit = "a0b8a92e3d1532361c2f7feb63babc5c18d00ef2",
174-
sha256 = "ccf872fd4aa9ab3d030d62cffcb258ca27f021b2023a0244b2cf476f984be955",
175-
)
154+
swift_deps = module_extension(_load_dependencies)

0 commit comments

Comments
 (0)