Skip to content

Commit c0eeb7a

Browse files
committed
Bazel: reference (and locally stub) internal module
1 parent 5353922 commit c0eeb7a

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

.bazelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
common --enable_platform_specific_config --experimental_enable_bzlmod
22

3+
# when using repo standalone, we want still to unlock loading the internal repository module
4+
# actually using things from that module will obviously end up in an error
5+
common --override_module=codeql_internal=%workspace%/misc/bazel/codeql_internal_stub
6+
37
build --repo_env=CC=clang --repo_env=CXX=clang++
48

59
build:linux --cxxopt=-std=c++20

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module(
33
version = "0.0",
44
)
55

6+
# this points to our internal repository when `codeql` is checked out as a submodule thereof
7+
# when building things from `codeql` independently this is stubbed out in `.bazelrc`
68
bazel_dep(name = "codeql_internal", version = "0.0")
79
local_path_override(
810
module_name = "codeql_internal",

misc/bazel/cmake/cmake.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ CmakeInfo = provider(
2222
)
2323

2424
def _cmake_name(label):
25-
ret = ("%s_%s_%s" % (label.workspace_name, label.package, label.name)).replace("/", "_")
25+
# strip away the bzlmod module version for now
26+
workspace_name, _, _ = label.workspace_name.partition("~")
27+
ret = ("%s_%s_%s" % (workspace_name, label.package, label.name)).replace("/", "_")
2628
internal_transition_suffix = "_INTERNAL_TRANSITION"
2729
if ret.endswith(internal_transition_suffix):
2830
ret = ret[:-len(internal_transition_suffix)]
@@ -120,7 +122,6 @@ def _cmake_aspect_impl(target, ctx):
120122
prefix, # source
121123
"${BAZEL_EXEC_ROOT}/%s/%s" % (ctx.var["BINDIR"], prefix), # generated
122124
]
123-
124125
deps = [dep[CmakeInfo] for dep in deps if CmakeInfo in dep]
125126

126127
# by the book this should be done with depsets, but so far the performance implication is negligible

misc/bazel/cmake/setup.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ endmacro()
1919
bazel(info workspace OUTPUT_VARIABLE BAZEL_WORKSPACE)
2020

2121
bazel(info output_base OUTPUT_VARIABLE BAZEL_OUTPUT_BASE)
22-
string(REPLACE "-" "_" BAZEL_EXEC_ROOT ${PROJECT_NAME})
23-
set(BAZEL_EXEC_ROOT ${BAZEL_OUTPUT_BASE}/execroot/${BAZEL_EXEC_ROOT})
22+
set(BAZEL_EXEC_ROOT ${BAZEL_OUTPUT_BASE}/execroot/_main)
2423

2524
macro(include_generated BAZEL_TARGET)
2625
bazel(build ${BAZEL_TARGET})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module(
2+
name = "codeql_internal",
3+
version = "0.0",
4+
)

misc/bazel/codeql_internal_stub/WORKSPACE.bazel

Whitespace-only changes.

0 commit comments

Comments
 (0)