Skip to content

Commit

Permalink
Merge branch 'main' into platform_bazelrc
Browse files Browse the repository at this point in the history
  • Loading branch information
jsharpe authored Dec 21, 2023
2 parents 99699ff + 18dcce5 commit 91d515e
Show file tree
Hide file tree
Showing 21 changed files with 514 additions and 95 deletions.
19 changes: 6 additions & 13 deletions .bazelci/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,18 @@ tasks:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
rbe_ubuntu1604:
platform: rbe_ubuntu1604
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
macos:
platform: macos
build_targets:
- "//..."
test_targets:
- "//..."
build_flags:
- "--noenable_bzlmod"
test_flags:
- "--noenable_bzlmod"
windows:
platform: windows
build_targets:
Expand Down Expand Up @@ -108,6 +96,7 @@ tasks:
macos_targets: &macos_targets_standalone
- "//..."
- "//:third_party_examples_macos_tests"
- "-//cmake_android/..."
# Remove tests that depend on shared libraries, which currently doesn't work on MacOS - https://github.com/bazelbuild/bazel/issues/10254
- "-@rules_foreign_cc_examples_third_party//curl:curl_test"
- "-@rules_foreign_cc_examples_third_party//openssl:openssl_test"
Expand All @@ -116,30 +105,34 @@ tasks:
- "-c"
- "dbg"
- "--spawn_strategy=standalone"
- "-k"
- "--noincompatible_enable_cc_toolchain_resolution"
- "--noenable_bzlmod"
test_targets: *macos_targets_standalone
test_flags:
- "-c"
- "dbg"
- "--spawn_strategy=standalone"
- "--noincompatible_enable_cc_toolchain_resolution"
- "--noenable_bzlmod"
macos_examples:
name: Examples
platform: macos
working_directory: examples
macos_targets: &macos_targets
- "//..."
- "//:third_party_examples_macos_tests"
- "-//cmake_android/..."
# Remove tests that depend on shared libraries, which currently doesn't work on MacOS - https://github.com/bazelbuild/bazel/issues/10254
- "-@rules_foreign_cc_examples_third_party//curl:curl_test"
- "-@rules_foreign_cc_examples_third_party//openssl:openssl_test"
build_targets: *macos_targets
build_flags:
- "--noincompatible_enable_cc_toolchain_resolution"
- "--noenable_bzlmod"
test_targets: *macos_targets
test_flags:
- "--noincompatible_enable_cc_toolchain_resolution"
- "--noenable_bzlmod"
windows_examples:
name: Examples
platform: windows
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
# Create a job for release
include:
- ref: main
- ref: "0.10.1"
- ref: "0.9.0"
- ref: "0.8.0"
- ref: "0.7.1"
Expand Down
26 changes: 13 additions & 13 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")

# "@bazel_tools//tools:bzl_srcs" is a filegroup. Convert define a `bzl_library` for it
bzl_library(
name = "bazel_tools_bzl_srcs",
srcs = ["@bazel_tools//tools:bzl_srcs"],
gazelle(
name = "gazelle",
gazelle = ":gazelle_bin",
)

bzl_library(
name = "bzl_srcs",
srcs = glob(["**/*.bzl"]) + [
"@bazel_tools//tools:bzl_srcs",
gazelle_binary(
name = "gazelle_bin",
languages = DEFAULT_LANGUAGES + [
"@bazel_skylib_gazelle_plugin//bzl",
],
)

bzl_library(
name = "version",
srcs = ["version.bzl"],
visibility = ["//visibility:public"],
deps = [
":bazel_tools_bzl_srcs",
"//foreign_cc:bzl_srcs",
"//toolchains:bzl_srcs",
],
)
10 changes: 9 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,21 @@ module(

bazel_dep(name = "bazel_skylib", version = "1.1.1")
bazel_dep(name = "platforms", version = "0.0.5")
bazel_dep(name = "rules_python", version = "0.20.0")
bazel_dep(name = "rules_python", version = "0.23.0")

bazel_dep(name = "gazelle", version = "0.34.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.5.6", dev_dependency = True, repo_name = "io_bazel_stardoc")
bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)

tools = use_extension("@rules_foreign_cc//foreign_cc:extensions.bzl", "tools")
use_repo(
tools,
"cmake_3.23.2_toolchains",
"cmake_src",
"gettext_runtime",
"glib_dev",
"glib_src",
"gnumake_src",
"meson_src",
"ninja_1.11.1_toolchains",
Expand Down
35 changes: 33 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ bazel_skylib_workspace()
load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python3_9",
python_version = "3.9",
name = "python3_10",
python_version = "3.10",
)

load("//:docs/stardoc_repository.bzl", "stardoc_repository")
Expand All @@ -41,3 +41,34 @@ rbe_preconfig(
name = "buildkite_config",
toolchain = "ubuntu1804-bazel-java11",
)

# Gazelle dependencies

http_archive(
name = "bazel_gazelle",
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)

http_archive(
name = "bazel_skylib_gazelle_plugin",
sha256 = "747addf3f508186234f6232674dd7786743efb8c68619aece5fb0cac97b8f415",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz",
],
)

load("@bazel_skylib_gazelle_plugin//:workspace.bzl", "bazel_skylib_gazelle_plugin_workspace")

bazel_skylib_gazelle_plugin_workspace()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@bazel_skylib_gazelle_plugin//:setup.bzl", "bazel_skylib_gazelle_plugin_setup")

bazel_skylib_gazelle_plugin_setup()

gazelle_dependencies(go_repository_default_config = "//:WORKSPACE.bazel")
6 changes: 5 additions & 1 deletion docs/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Bazel configuration flags for rules_foregin_cc_docs
# Bazel configuration flags for rules_foreign_cc_docs

# https://github.com/bazelbuild/stardoc/issues/112
common --incompatible_allow_tags_propagation

common --noenable_bzlmod
build --workspace_status_command=tools/workspace_status.sh
32 changes: 22 additions & 10 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,73 @@ genrule(

# Note that the stardoc `out` files are prefixed with `stardoc_` so the
# `diff_test` targets which ensure documentation is up to date can access the
# committed markdown files instead ouf the `out` targets from the stardoc rules
# committed markdown files instead of the `out` targets from the stardoc rules

stardoc(
name = "flatten_docs",
out = "stardoc_flatten.md",
header_template = ":flatten_header_vm",
input = "docs.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
tags = ["no-sandbox"], # https://github.com/bazelbuild/stardoc/issues/112
deps = [
"@rules_foreign_cc//foreign_cc:defs",
"@rules_foreign_cc//foreign_cc:repositories",
] + [
"@rules_foreign_cc//foreign_cc:cmake",
"@rules_foreign_cc//foreign_cc:configure",
"@rules_foreign_cc//foreign_cc:make",
"@rules_foreign_cc//foreign_cc:meson",
"@rules_foreign_cc//foreign_cc:ninja",
"@rules_foreign_cc//foreign_cc:providers",
],
)

stardoc(
name = "cmake_docs",
out = "stardoc_cmake.md",
header_template = "common_header.vm",
input = "@rules_foreign_cc//foreign_cc:cmake.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
deps = ["@rules_foreign_cc//foreign_cc:cmake"],
)

stardoc(
name = "make_docs",
out = "stardoc_make.md",
header_template = "common_header.vm",
input = "@rules_foreign_cc//foreign_cc:make.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
deps = ["@rules_foreign_cc//foreign_cc:make"],
)

stardoc(
name = "ninja_docs",
out = "stardoc_ninja.md",
header_template = "common_header.vm",
input = "@rules_foreign_cc//foreign_cc:ninja.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
deps = ["@rules_foreign_cc//foreign_cc:ninja"],
)

stardoc(
name = "configure_make_docs",
out = "stardoc_configure_make.md",
header_template = "common_header.vm",
input = "@rules_foreign_cc//foreign_cc:configure.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
deps = ["@rules_foreign_cc//foreign_cc:configure"],
)

stardoc(
name = "meson_docs",
out = "stardoc_meson.md",
header_template = "common_header.vm",
input = "@rules_foreign_cc//foreign_cc:meson.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
deps = ["@rules_foreign_cc//foreign_cc:meson"],
)

stardoc(
name = "providers_docs",
out = "stardoc_providers.md",
header_template = "common_header.vm",
input = "@rules_foreign_cc//foreign_cc:providers.bzl",
deps = ["@rules_foreign_cc//:bzl_srcs"],
deps = ["@rules_foreign_cc//foreign_cc:providers"],
)

DOCS_TARGETS = [
Expand Down Expand Up @@ -110,7 +121,7 @@ release="$${RELEASE}"
release_archive="$${RELEASE}"
# TODO: If a release is set, we assume it's set to a branch name.
# thus we defautl the archive value to a commit. This is likely
# thus we default the archive value to a commit. This is likely
# only appropriate when publishing on the branch in specified
# and a smarter solution should be found to avoid unexpected behavior.
if [[ -n "\\$${RELEASE:-}" ]]; then
Expand All @@ -123,9 +134,10 @@ cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:flatten_docs) > \\$${BUILD_WOR
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:cmake_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/src/cmake.md
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:ninja_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/src/ninja.md
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:make_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/src/make.md
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:meson_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/src/meson.md
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:configure_make_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/src/configure_make.md
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(location //:providers_docs) > \\$${BUILD_WORKSPACE_DIRECTORY}/src/providers.md
# Non generated sourrces
# Non generated sources
cp \\$${BUILD_WORKSPACE_DIRECTORY}/$(rootpath rules.md) \\$${BUILD_WORKSPACE_DIRECTORY}/src/rules.md
cat \\$${BUILD_WORKSPACE_DIRECTORY}/$(rootpath index.md) \
| sed "s/{short_commit}/\\$${short_commit}/" \
Expand Down
33 changes: 33 additions & 0 deletions docs/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,36 @@ stardoc_repository()
load("//:stardoc_deps.bzl", "stardoc_deps")

stardoc_deps()

# Gazelle dependencies

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "bazel_gazelle",
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
],
)

http_archive(
name = "bazel_skylib_gazelle_plugin",
sha256 = "747addf3f508186234f6232674dd7786743efb8c68619aece5fb0cac97b8f415",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-gazelle-plugin-1.5.0.tar.gz",
],
)

load("@bazel_skylib_gazelle_plugin//:workspace.bzl", "bazel_skylib_gazelle_plugin_workspace")

bazel_skylib_gazelle_plugin_workspace()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("@bazel_skylib_gazelle_plugin//:setup.bzl", "bazel_skylib_gazelle_plugin_setup")

bazel_skylib_gazelle_plugin_setup()

gazelle_dependencies(go_repository_default_config = "//:WORKSPACE.bazel")
1 change: 1 addition & 0 deletions docs/root/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Rules for building C/C++ projects using foreign build systems (non Bazel) inside
## Versions

- [main](main/index.md)
- [0.10.1](0.10.1/index.md)
- [0.9.0](0.9.0/index.md)
- [0.8.0](0.8.0/index.md)
- [0.7.1](0.7.1/index.md)
Expand Down
22 changes: 5 additions & 17 deletions examples/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,19 @@ bazel_dep(name = "platforms", version = "0.0.6")
bazel_dep(name = "rules_swift", version = "1.6.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_apple", version = "3.0.0-rc1", repo_name = "build_bazel_rules_apple")
bazel_dep(name = "apple_support", version = "1.4.1", repo_name = "build_bazel_apple_support")
bazel_dep(name = "rules_python", version = "0.22.0")
bazel_dep(name = "rules_python", version = "0.23.0")

python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
name = "python3_9",
python_version = "3.9",
configure_coverage_tool = True,
# Only set when you have mulitple toolchain versions.
is_default = True,
python_version = "3.10",
)
use_repo(python, "python3_9")
use_repo(python, "python3_9_toolchains")

register_toolchains(
"@python3_9_toolchains//:all",
)

interpreter = use_extension("@rules_python//python/extensions:interpreter.bzl", "interpreter")
interpreter.install(
name = "interpreter_python3_9",
python_name = "python3_9",
)
use_repo(interpreter, "interpreter_python3_9")

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
pip.parse(
name = "pip",
python_interpreter_target = "@interpreter_python3_9//:python",
requirements_lock = "//:requirements_lock.txt",
requirements_windows = "//:requirements_windows.txt",
)
Expand Down
6 changes: 3 additions & 3 deletions examples/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ deps_jvm_external()
load("@rules_python//python:repositories.bzl", "python_register_toolchains")

python_register_toolchains(
name = "python3_9",
python_version = "3.9",
name = "python3_10",
python_version = "3.10",
)

load("@python3_9//:defs.bzl", py3_interpreter = "interpreter")
load("@python3_10//:defs.bzl", py3_interpreter = "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

pip_parse(
Expand Down
Loading

0 comments on commit 91d515e

Please sign in to comment.