Skip to content

Add load statements after disabling autoloads #391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
common --noincompatible_check_sharding_support
common --incompatible_disable_autoloads_in_main_repo

# Remove once proto toolchainization becomes the default
# - https://bazel.build/reference/command-line-reference#flag--incompatible_enable_proto_toolchain_resolution
Expand Down
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,5 @@ scala_protoc = use_extension(
dev_dependency = True,
)
use_repo(scala_protoc, "rules_scala_protoc_toolchains")

bazel_dep(name = "rules_shell", version = "0.4.1")
3 changes: 2 additions & 1 deletion MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions buck2/cpp/platforms/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ platforms = rule(
attrs = {
"cpu_configuration": attrs.dep(providers = [ConfigurationInfo]),
"os_configuration": attrs.dep(providers = [ConfigurationInfo]),
},
impl = _platforms
},
impl = _platforms,
)

action_keys = rule(
attrs = {
attrs = {
"cell": attrs.string(),
"mode": attrs.string(),
},
impl = _action_keys
},
impl = _action_keys,
)
8 changes: 4 additions & 4 deletions buck2/golang/platforms/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ def _action_keys(ctx):

platforms = rule(
attrs = {},
impl = _platforms
impl = _platforms,
)

action_keys = rule(
attrs = {
attrs = {
"cell": attrs.string(),
"mode": attrs.string(),
},
impl = _action_keys
},
impl = _action_keys,
)
5 changes: 2 additions & 3 deletions buck2/golang/toolchains/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load("@prelude//go_bootstrap:go_bootstrap.bzl", "GoBootstrapToolchainInfo")
load("@prelude//utils:cmd_script.bzl", "ScriptOs", "cmd_script")

def _remote_go_bootstrap_toolchain_impl(ctx):
go_arch = "amd64"
go_arch = "amd64"
go_os = "linux"

script_os = ScriptOs("unix")
Expand Down Expand Up @@ -47,7 +47,7 @@ remote_go_bootstrap_toolchain = rule(
)

def _remote_go_toolchain_impl(ctx):
go_arch = "amd64"
go_arch = "amd64"
go_os = "linux"

script_os = ScriptOs("unix")
Expand Down Expand Up @@ -76,7 +76,6 @@ def _remote_go_toolchain_impl(ctx):
compiler_flags = [],
),
]


remote_go_toolchain = rule(
impl = _remote_go_toolchain_impl,
Expand Down
8 changes: 4 additions & 4 deletions buck2/python/platforms/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def _action_keys(ctx):

platforms = rule(
attrs = {},
impl = _platforms
impl = _platforms,
)

action_keys = rule(
attrs = {
attrs = {
"cell": attrs.string(),
"mode": attrs.string(),
},
impl = _action_keys
},
impl = _action_keys,
)
1 change: 0 additions & 1 deletion buck2/python/toolchains/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ remote_python_toolchain = rule(
"_make_source_db": attrs.default_only(attrs.dep(providers = [RunInfo], default = "prelude//python/tools:make_source_db")),
"_make_source_db_no_deps": attrs.default_only(attrs.dep(providers = [RunInfo], default = "prelude//python/tools:make_source_db_no_deps")),
"_runtime_library": attrs.default_only(attrs.dep(providers = [ArtifactGroupInfo], default = "prelude//python/runtime:bootstrap_files")),

},
is_toolchain_rule = True,
)
10 changes: 5 additions & 5 deletions buck2/rust/platforms/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ platforms = rule(
attrs = {
"cpu_configuration": attrs.dep(providers = [ConfigurationInfo]),
"os_configuration": attrs.dep(providers = [ConfigurationInfo]),
},
impl = _platforms
},
impl = _platforms,
)

action_keys = rule(
attrs = {
attrs = {
"cell": attrs.string(),
"mode": attrs.string(),
},
impl = _action_keys
},
impl = _action_keys,
)
4 changes: 2 additions & 2 deletions buck2/rust/toolchains/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@prelude//cxx:cxx_toolchain_types.bzl", "LinkerType")
load("@prelude//rust:rust_toolchain.bzl", "PanicRuntime", "RustToolchainInfo")
load("@prelude//rust/tools:attrs.bzl", "internal_tool_attrs")
load("@prelude//cxx:cxx_toolchain_types.bzl", "LinkerType")
load("@prelude//toolchains:cxx.bzl", "CxxToolsInfo")

# This def is similar to the one in https://github.com/facebook/buck2/blob/804d62242214455d51787f7c8c96a1e12c75ec32/prelude/toolchains/cxx/clang/tools.bzl
Expand Down Expand Up @@ -42,7 +42,7 @@ path_clang_tools = rule(
attrs = {},
)

def _remote_rust_toolchain_impl(ctx):
def _remote_rust_toolchain_impl(ctx):
return [
DefaultInfo(),
RustToolchainInfo(
Expand Down
56 changes: 29 additions & 27 deletions bzlmod/canonical-repo-name-injection/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
# License for the specific language governing permissions and limitations under
# the License.

load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_js//js:defs.bzl", "js_binary")
load(
"//:repo-names.bzl",
"canonical_repo",
"workspace_root",
"repo_name_variable",
"repo_dir_variable",
"gen_js_constants",
"repo_dir_variable",
"repo_name_variable",
"workspace_root",
)
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_js//js:defs.bzl", "js_binary")

# This value propagates through the rules below.
# Try it with other targets of your choosing!
Expand All @@ -37,8 +37,10 @@ genrule(
name = "repo-macros",
outs = ["repo-macros.txt"],
cmd = "printf '%s\n canonical_name: %s\n workspace_root: %s\n' >$@" % (
repo_target, canonical_repo(repo_target), workspace_root(repo_target)
)
repo_target,
canonical_repo(repo_target),
workspace_root(repo_target),
),
)

# Demonstrates the custom Make variable-based approach. Depends on the
Expand All @@ -54,7 +56,7 @@ genrule(
toolchains = [
":repo-name",
":repo-dir",
]
],
)

# This alias demonstrates how the rules from `repo-names.bzl` work with resolved
Expand Down Expand Up @@ -97,34 +99,34 @@ repo_dir_variable(
# - where the repo dir is found when running under `bazel run` vs `node`
js_binary(
name = "repo-dir-check",
entry_point = "repo-dir-check.mjs",
data = [
":constants-impl",
repo_target,
":constants-impl",
repo_target,
],
entry_point = "repo-dir-check.mjs",
)

# Determines which rule generates the `constants.js` module used by
# `:repo-dir-check`, based on the value of the `--//:constants` flag.
genrule(
name = "constants-impl",
outs = ["constants.js"],
srcs = select({
":genrule": [":genrule-constants"],
":genrule": [":genrule-constants"],
":custom-rule": [":custom-rule-constants"],
}),
outs = ["constants.js"],
cmd = "cp $< $@",
)

# The `--//:constants` command line flag determines whether `:constants-impl`
# selects `:genrule-constants` or `:custom-rule-constants` as input.
string_flag(
name = "constants",
build_setting_default = "genrule",
values = [
"genrule",
"custom-rule",
],
build_setting_default = "genrule",
)

config_setting(
Expand Down Expand Up @@ -152,7 +154,7 @@ genrule(
name = "genrule-constants",
srcs = [":repo-target"],
outs = ["genrule-constants.js"],
cmd = r"""printf 'module.exports.%%s;\n' \
cmd = r"""printf 'module.exports.%%s;\n' \
'ruleName = "genrule-constants"' \
'target = "%s"' \
'binDir = "$(BINDIR)"' \
Expand All @@ -161,10 +163,10 @@ genrule(
'macroDir = "%s"' \
'repoName = "$(repo-name)"' \
'repoDir = "$(repo-dir)"' >$@""" % (
repo_target,
canonical_repo(repo_target),
workspace_root(repo_target)
),
repo_target,
canonical_repo(repo_target),
workspace_root(repo_target),
),
toolchains = [
":repo-name",
":repo-dir",
Expand All @@ -191,14 +193,14 @@ genrule(
# Replacing `repo_target` with the string ":repo-target" in the macros below
# will produce the empty string, since the macros won't see the resolved alias.
gen_js_constants(
name = "custom-rule-constants",
deps = [":repo-target"],
vars = {
"target": repo_target,
"location": "$(rlocationpaths :repo-target)",
name = "custom-rule-constants",
repo_dirs = {":repo-target": "repoDir"},
repo_names = {":repo-target": "repoName"},
vars = {
"target": repo_target,
"location": "$(rlocationpaths :repo-target)",
"macroName": canonical_repo(repo_target),
"macroDir": workspace_root(repo_target),
"macroDir": workspace_root(repo_target),
},
repo_names = {":repo-target": "repoName"},
repo_dirs = {":repo-target": "repoDir"},
deps = [":repo-target"],
)
5 changes: 4 additions & 1 deletion bzlmod/canonical-repo-name-injection/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"""Example module for canonical repo name injection"""

# Main module
module(name = "frobozz", version = "1.2.3")
module(
name = "frobozz",
version = "1.2.3",
)

# aspect_rules_js
bazel_dep(name = "aspect_rules_js", version = "2.0.1", repo_name = "rules_js")
Expand Down
12 changes: 7 additions & 5 deletions bzlmod/canonical-repo-name-injection/repo-names.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def _variable_info(ctx, value):

repo_name_variable = rule(
implementation = lambda ctx: _variable_info(
ctx, ctx.attr.dep.label.repo_name
ctx,
ctx.attr.dep.label.repo_name,
),
doc = "Defines a custom variable for its dependency's repository name",
attrs = {
Expand All @@ -50,7 +51,8 @@ repo_name_variable = rule(

repo_dir_variable = rule(
implementation = lambda ctx: _variable_info(
ctx, ctx.attr.dep.label.workspace_root
ctx,
ctx.attr.dep.label.workspace_root,
),
doc = "Defines a custom variable for its dependency's repository dir",
attrs = {
Expand Down Expand Up @@ -96,7 +98,7 @@ def _runfiles(ctx, sources, deps):

def _gen_js_constants_impl(ctx):
"""Generate a JavaScript module exporting specified constants."""
items = {"ruleName": ctx.attr.name, "binDir": ctx.bin_dir.path}
items = {"ruleName": ctx.attr.name, "binDir": ctx.bin_dir.path}
items |= {k: ctx.expand_location(v) for k, v in ctx.attr.vars.items()}
items |= {v: k.label.repo_name for k, v in ctx.attr.repo_names.items()}
items |= {v: k.label.workspace_root for k, v in ctx.attr.repo_dirs.items()}
Expand All @@ -108,8 +110,8 @@ def _gen_js_constants_impl(ctx):

sources = depset([outfile])
deps = ctx.attr.deps + \
ctx.attr.repo_names.keys() + \
ctx.attr.repo_dirs.keys()
ctx.attr.repo_names.keys() + \
ctx.attr.repo_dirs.keys()

return [
_js_info(ctx.label, sources, deps),
Expand Down
6 changes: 5 additions & 1 deletion cpp/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

cc_binary(
name = "cpp",
srcs = ["main.cc"],
Expand All @@ -14,7 +18,7 @@ cc_library(

cc_test(
name = "cpp_test",
size = "small",
srcs = ["hello_test.cc"],
deps = [":cpp_lib"],
size = "small",
)
3 changes: 3 additions & 0 deletions docker/network/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_java//java:java_test.bzl", "java_test")
load("@rules_java//java/toolchains:java_runtime.bzl", "java_runtime")

# Built from "Dockerfile"
# TODO: edit this value to match your Docker registry, image name, and digest
DOCKER_JDK_PSQL = "docker://gcr.io/YOUR-IMAGE-NAME@sha256:b6ed8f68abd6e23409ee7a500c2c50a8064cea11071ac447a59b88e6afa4c220"
Expand Down
3 changes: 3 additions & 0 deletions docker/sandbox/BUILD
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_java//java:java_binary.bzl", "java_binary")

genrule(
name = "hello",
srcs = ["dep%d" % i for i in range(3)],
Expand Down
6 changes: 4 additions & 2 deletions docker/sysbox/dind_test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_shell//shell:sh_test.bzl", "sh_test")

sh_test(
name = "check_docker",
srcs = ["check_docker.sh"],
exec_properties = {
# Replace the container-image below to use the one you created.
"container-image": "docker://645088952840.dkr.ecr.eu-west-1.amazonaws.com/engflow-ci/debian12-dind-x64@sha256:e9715893e041427c283808db96760634b47b276d35bef4fc2af3990553f94262",
"dockerRuntime": "sysbox-runc",
"Pool": "ci_sysbox_x64", # this can change depending on what pool has sysbox enabled
"Pool": "ci_sysbox_x64", # this can change depending on what pool has sysbox enabled
"dockerNetwork": "standard",
# DO NOT ENABLE!!! "dockerSiblingContainers": "True",
# it will cause the worker to mount /var/run/docker.sock
Expand All @@ -28,5 +30,5 @@ sh_test(
# DO NOT ENABLE!!! "dockerPrivileged": "True",
# sysbox containers will refuse to start
},
tags = ["manual"]
tags = ["manual"],
)
Loading