Skip to content
Draft
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
25 changes: 19 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,31 @@ module(
compatibility_level = 1,
)

bazel_dep(name = "bazel_features", version = "1.21.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "bazel_features", version = "1.28.0")
bazel_dep(name = "bazel_skylib", version = "1.8.1")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.1.5")
bazel_dep(name = "rules_python", version = "1.2.0")
bazel_dep(name = "rules_shell", version = "0.3.0")
bazel_dep(name = "rules_shell", version = "0.5.0")
bazel_dep(name = "bazel_lib", version = "3.1.1")

# XXX https://github.com/bazel-contrib/bazel-lib/pull/1235
archive_override(
module_name = "bazel_lib",
integrity = "sha256-8u81hQmpvra/CqtXvddEjU0iYDp4FmYENUjwoAsX2DI=",
strip_prefix = "bazel-lib-e6420f3ec1503ccdd221a5c75d3dcf272feb4c20",
urls = [
"https://github.com/bazel-contrib/bazel-lib/archive/e6420f3ec1503ccdd221a5c75d3dcf272feb4c20.tar.gz",
],
)

# Dev dependencies
bazel_dep(name = "gazelle", version = "0.41.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.7.1", dev_dependency = True)
bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True)
bazel_dep(name = "aspect_rules_lint", version = "1.2.2", dev_dependency = True)

# Note: 1.13 requires nodeps bzlmod deps, which requires bazel 7.6.0
bazel_dep(name = "aspect_rules_lint", version = "1.12.0", dev_dependency = True)

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(python_version = "3.12")
Expand Down
21 changes: 7 additions & 14 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,18 @@ bazel_skylib_gazelle_plugin_setup()

gazelle_dependencies(go_repository_default_config = "//:WORKSPACE.bazel")

# Note: 1.13 requires nodeps bzlmod deps, which requires bazel 7.6.0
http_archive(
name = "aspect_rules_lint",
sha256 = "c90501db2548f4af27ed873e40adc6524fcd8472c25ff9946ba13aa77c767249",
strip_prefix = "rules_lint-1.2.2",
url = "https://github.com/aspect-build/rules_lint/releases/download/v1.2.2/rules_lint-v1.2.2.tar.gz",
sha256 = "a8a63bd071a39bd5be1f99d9f258eac674673c98505f9fc5b4c76587f67278cd",
strip_prefix = "rules_lint-1.12.0",
url = "https://github.com/aspect-build/rules_lint/releases/download/v1.12.0/rules_lint-v1.12.0.tar.gz",
)

# aspect_rules_lint depends on aspect_bazel_lib.
http_archive(
name = "aspect_bazel_lib",
sha256 = "6d758a8f646ecee7a3e294fbe4386daafbe0e5966723009c290d493f227c390b",
strip_prefix = "bazel-lib-2.7.7",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.7/bazel-lib-v2.7.7.tar.gz",
)

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies")
# aspect_rules_lint depends on bazel_lib.
load("@bazel_lib//lib:repositories.bzl", "bazel_lib_dependencies")

# aspect_bazel_lib depends on bazel_skylib
aspect_bazel_lib_dependencies()
bazel_lib_dependencies()

load(
"@aspect_rules_lint//format:repositories.bzl",
Expand Down
11 changes: 11 additions & 0 deletions docs/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,14 @@ bazel_dep(
version = "29.3",
repo_name = "com_google_protobuf",
)

# XXX https://github.com/bazel-contrib/bazel-lib/pull/1235
bazel_dep(name = "bazel_lib", version = "3.1.1")
archive_override(
module_name = "bazel_lib",
integrity = "sha256-8u81hQmpvra/CqtXvddEjU0iYDp4FmYENUjwoAsX2DI=",
strip_prefix = "bazel-lib-e6420f3ec1503ccdd221a5c75d3dcf272feb4c20",
urls = [
"https://github.com/bazel-contrib/bazel-lib/archive/e6420f3ec1503ccdd221a5c75d3dcf272feb4c20.tar.gz",
],
)
476 changes: 34 additions & 442 deletions docs/MODULE.bazel.lock

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use_repo(
"meson_src",
)

bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_rust", version = "0.56.0")
bazel_dep(name = "rules_swift", version = "1.6.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_swift", version = "1.17.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_apple", version = "3.4.0", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "apple_support", version = "1.12.0", repo_name = "build_bazel_apple_support")
bazel_dep(name = "apple_support", version = "1.17.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "rules_python", version = "1.2.0")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_shell", version = "0.3.0")
bazel_dep(name = "rules_cc", version = "0.1.5")
bazel_dep(name = "rules_shell", version = "0.5.0")
bazel_dep(name = "rules_perl", version = "0.2.5")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
Expand Down Expand Up @@ -67,6 +67,17 @@ use_repo(
"rust_example",
)

# XXX https://github.com/bazel-contrib/bazel-lib/pull/1235
bazel_dep(name = "bazel_lib", version = "3.1.1")
archive_override(
module_name = "bazel_lib",
integrity = "sha256-8u81hQmpvra/CqtXvddEjU0iYDp4FmYENUjwoAsX2DI=",
strip_prefix = "bazel-lib-e6420f3ec1503ccdd221a5c75d3dcf272feb4c20",
urls = [
"https://github.com/bazel-contrib/bazel-lib/archive/e6420f3ec1503ccdd221a5c75d3dcf272feb4c20.tar.gz",
],
)

# bazel_dep(name = "rules_android", version = "0.1.1")
# bazel_dep(name = "rules_jvm_external", version = "5.1")
#
Expand Down
72 changes: 42 additions & 30 deletions examples/make_simple/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,34 +1,46 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "make")

make(
name = "make_lib",
build_data = [
"//make_simple/code:cxx_wrapper.sh",
"README.md",
],
copts = [
"-DREQUIRED_DEFINE",
],
env = {
"CXX_WRAPPER": "$(execpath //make_simple/code:cxx_wrapper.sh)",
"README_DIR": "$$(dirname $(execpath README.md))",
},
lib_source = "//make_simple/code:srcs",
out_data_dirs = ["share"],
out_static_libs = ["liba.a"],
)
SIZES = [
"default",
"tiny",
]

cc_test(
name = "test_lib",
srcs = [
"test_libb.cpp",
],
copts = [
"-std=c++11",
],
tags = ["windows"],
deps = [
":make_lib",
],
)
[
make(
name = "make_lib_" + size,
build_data = [
"//make_simple/code:cxx_wrapper.sh",
"README.md",
],
copts = [
"-DREQUIRED_DEFINE",
],
env = {
"CXX_WRAPPER": "$(execpath //make_simple/code:cxx_wrapper.sh)",
"README_DIR": "$$(dirname $(execpath README.md))",
},
lib_source = "//make_simple/code:srcs",
out_data_dirs = ["share"],
out_static_libs = ["liba.a"],
resource_size = size,
)
for size in SIZES
]

[
cc_test(
name = "test_lib_" + size,
srcs = [
"test_libb.cpp",
],
copts = [
"-std=c++11",
],
tags = ["windows"],
deps = [
":make_lib_" + size,
],
)
for size in SIZES
]
62 changes: 37 additions & 25 deletions examples/meson_simple/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,44 @@ load("@rules_cc//cc:defs.bzl", "cc_test")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "meson")
load("@rules_shell//shell:sh_test.bzl", "sh_test")

meson(
name = "meson_lib",
build_data = ["//meson_simple/code:clang_wrapper.sh"],
env = select({
"//:windows": {
"CLANG_WRAPPER": "$(execpath //meson_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "/MD",
},
"//conditions:default": {
"CLANG_WRAPPER": "$(execpath //meson_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "-fPIC",
},
}),
lib_source = "//meson_simple/code:srcs",
out_static_libs = ["liba.a"],
)
SIZES = [
"default",
"tiny",
]

cc_test(
name = "test_lib",
srcs = [
"test_libb.cpp",
],
deps = [
":meson_lib",
],
)
[
meson(
name = "meson_lib_" + size,
build_data = ["//meson_simple/code:clang_wrapper.sh"],
env = select({
"//:windows": {
"CLANG_WRAPPER": "$(execpath //meson_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "/MD",
},
"//conditions:default": {
"CLANG_WRAPPER": "$(execpath //meson_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "-fPIC",
},
}),
lib_source = "//meson_simple/code:srcs",
out_static_libs = ["liba.a"],
resource_size = size,
)
for size in SIZES
]

[
cc_test(
name = "test_lib_" + size,
srcs = [
"test_libb.cpp",
],
deps = [
":meson_lib_" + size,
],
)
for size in SIZES
]

meson(
name = "meson_lib-introspect",
Expand Down
70 changes: 41 additions & 29 deletions examples/ninja_simple/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
load("@rules_cc//cc:defs.bzl", "cc_test")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "ninja")

ninja(
name = "ninja_lib",
build_data = ["//ninja_simple/code:clang_wrapper.sh"],
env = select({
"//:windows": {
"CLANG_WRAPPER": "$(execpath //ninja_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "/MD",
},
"//conditions:default": {
"CLANG_WRAPPER": "$(execpath //ninja_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "-fPIC",
},
}),
lib_source = "//ninja_simple/code:srcs",
out_static_libs = ["liba.a"],
targets = [
"",
"install",
],
)
SIZES = [
"default",
"tiny",
]

cc_test(
name = "test_lib",
srcs = [
"test_libb.cpp",
],
deps = [
":ninja_lib",
],
)
[
ninja(
name = "ninja_lib_" + size,
build_data = ["//ninja_simple/code:clang_wrapper.sh"],
env = select({
"//:windows": {
"CLANG_WRAPPER": "$(execpath //ninja_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "/MD",
},
"//conditions:default": {
"CLANG_WRAPPER": "$(execpath //ninja_simple/code:clang_wrapper.sh)",
"CXX_FLAGS": "-fPIC",
},
}),
lib_source = "//ninja_simple/code:srcs",
out_static_libs = ["liba.a"],
resource_size = size,
targets = [
"",
"install",
],
)
for size in SIZES
]

[
cc_test(
name = "test_lib_" + size,
srcs = [
"test_libb.cpp",
],
deps = [
":ninja_lib_" + size,
],
)
for size in SIZES
]
6 changes: 6 additions & 0 deletions foreign_cc/built_tools/private/built_tools_framework.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
load("//foreign_cc/private:cc_toolchain_util.bzl", "absolutize_path_in_str")
load("//foreign_cc/private:detect_root.bzl", "detect_root")
load("//foreign_cc/private:framework.bzl", "get_env_prelude", "wrap_outputs")
load("//foreign_cc/private:resource_sets.bzl", "SIZE_ATTRIBUTES", "get_resource_env_vars")
load("//foreign_cc/private/framework:helpers.bzl", "convert_shell_script", "shebang")
load("//foreign_cc/private/framework:platform.bzl", "PLATFORM_CONSTRAINTS_RULE_ATTRIBUTES")

Expand Down Expand Up @@ -35,6 +36,7 @@ FOREIGN_CC_BUILT_TOOLS_ATTRS = {

# this would be cleaner as x | y, but that's not supported in bazel 5.4.0
FOREIGN_CC_BUILT_TOOLS_ATTRS.update(PLATFORM_CONSTRAINTS_RULE_ATTRIBUTES)
FOREIGN_CC_BUILT_TOOLS_ATTRS.update(SIZE_ATTRIBUTES)

# Common fragments for all built_tool rules
FOREIGN_CC_BUILT_TOOLS_FRAGMENTS = [
Expand Down Expand Up @@ -153,6 +155,8 @@ def built_tool_rule_impl(ctx, script_lines, out_dir, mnemonic, additional_tools
if additional_tools:
tools = depset(transitive = [tools, additional_tools])

resource_set, env = get_resource_env_vars(ctx.attr)

# The use of `run_shell` here is intended to ensure bash is correctly setup on windows
# environments. This should not be replaced with `run` until a cross platform implementation
# is found that guarantees bash exists or appropriately errors out.
Expand All @@ -161,6 +165,8 @@ def built_tool_rule_impl(ctx, script_lines, out_dir, mnemonic, additional_tools
inputs = ctx.attr.srcs.files,
outputs = [out_dir, wrapped_outputs.log_file],
tools = tools,
env = env,
resource_set = resource_set,
use_default_shell_env = True,
command = wrapped_outputs.wrapper_script_file.path,
execution_requirements = {"block-network": ""},
Expand Down
Loading
Loading