mirror of
https://github.com/github/codeql.git
synced 2025-12-16 00:33:11 +01:00
We've been observing some performance issues using crate_universe on CI. Therefore, we're moving to vendor the auto-generated BUILD files in our repository. This should provide a nice speed boost, while getting rid of the complexity of the "rust cache" job we've been using when we had a lot of git dependencies. This PR includes a vendor script, and I'll put up a CI job internally that runs that vendor script on Cargo.toml and Cargo.lock changes, to check that the vendored files are in sync.
48 lines
1.7 KiB
Python
Generated
48 lines
1.7 KiB
Python
Generated
"""Alias that transitions its target to `compilation_mode=opt`. Use `transition_alias="opt"` to enable."""
|
|
|
|
load("@rules_cc//cc:defs.bzl", "CcInfo")
|
|
load("@rules_rust//rust:rust_common.bzl", "COMMON_PROVIDERS")
|
|
|
|
def _transition_alias_impl(ctx):
|
|
# `ctx.attr.actual` is a list of 1 item due to the transition
|
|
providers = [ctx.attr.actual[0][provider] for provider in COMMON_PROVIDERS]
|
|
if CcInfo in ctx.attr.actual[0]:
|
|
providers.append(ctx.attr.actual[0][CcInfo])
|
|
return providers
|
|
|
|
def _change_compilation_mode(compilation_mode):
|
|
def _change_compilation_mode_impl(_settings, _attr):
|
|
return {
|
|
"//command_line_option:compilation_mode": compilation_mode,
|
|
}
|
|
|
|
return transition(
|
|
implementation = _change_compilation_mode_impl,
|
|
inputs = [],
|
|
outputs = [
|
|
"//command_line_option:compilation_mode",
|
|
],
|
|
)
|
|
|
|
def _transition_alias_rule(compilation_mode):
|
|
return rule(
|
|
implementation = _transition_alias_impl,
|
|
provides = COMMON_PROVIDERS,
|
|
attrs = {
|
|
"actual": attr.label(
|
|
mandatory = True,
|
|
doc = "`rust_library()` target to transition to `compilation_mode=opt`.",
|
|
providers = COMMON_PROVIDERS,
|
|
cfg = _change_compilation_mode(compilation_mode),
|
|
),
|
|
"_allowlist_function_transition": attr.label(
|
|
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
|
|
),
|
|
},
|
|
doc = "Transitions a Rust library crate to the `compilation_mode=opt`.",
|
|
)
|
|
|
|
transition_alias_dbg = _transition_alias_rule("dbg")
|
|
transition_alias_fastbuild = _transition_alias_rule("fastbuild")
|
|
transition_alias_opt = _transition_alias_rule("opt")
|