Bazel: reference (and locally stub) internal module

This commit is contained in:
Paolo Tranquilli
2024-02-12 15:58:43 +01:00
parent 53539226a8
commit c0eeb7a34e
6 changed files with 14 additions and 4 deletions

View File

@@ -1,5 +1,9 @@
common --enable_platform_specific_config --experimental_enable_bzlmod
# when using repo standalone, we want still to unlock loading the internal repository module
# actually using things from that module will obviously end up in an error
common --override_module=codeql_internal=%workspace%/misc/bazel/codeql_internal_stub
build --repo_env=CC=clang --repo_env=CXX=clang++
build:linux --cxxopt=-std=c++20

View File

@@ -3,6 +3,8 @@ module(
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 = "codeql_internal", version = "0.0")
local_path_override(
module_name = "codeql_internal",

View File

@@ -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

View File

@@ -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})

View File

@@ -0,0 +1,4 @@
module(
name = "codeql_internal",
version = "0.0",
)