diff --git a/.bazelci/config.yaml b/.bazelci/config.yaml index 289015139..c673772a7 100644 --- a/.bazelci/config.yaml +++ b/.bazelci/config.yaml @@ -42,15 +42,12 @@ tasks: - "-//test:shell_method_symlink_contents_to_dir_test" - "-//test:shell_script_inner_fun_test" build_flags: - - "--noenable_bzlmod" - "--enable_workspace" test_flags: - - "--noenable_bzlmod" - "--enable_workspace" - - "--@aspect_rules_lint//lint:fail_on_violation" - ubuntu1804_examples_standalone: + ubuntu2204_examples_standalone: name: Examples (spawn_strategy=standalone) - platform: ubuntu1804 + platform: ubuntu2204 working_directory: examples linux_targets: &linux_targets_standalone - "//..." @@ -60,14 +57,12 @@ tasks: - "-c" - "dbg" - "--spawn_strategy=standalone" - - "--noenable_bzlmod" - "--enable_workspace" test_targets: *linux_targets_standalone test_flags: - "-c" - "dbg" - "--spawn_strategy=standalone" - - "--noenable_bzlmod" - "--enable_workspace" ubuntu2204_examples: name: Examples @@ -79,10 +74,8 @@ tasks: build_targets: *linux_targets test_targets: *linux_targets build_flags: - - "--noenable_bzlmod" - "--enable_workspace" test_flags: - - "--noenable_bzlmod" - "--enable_workspace" ubuntu2204_examples_bzlmod: name: Examples (bzlmod) @@ -106,10 +99,12 @@ tasks: - "//:third_party_examples_linux_rbe_tests" # Gives error: zipalign: error while loading shared libraries: /usr/local/lib/libc++.so: file too short - "-//cmake_android/..." - # Python requirements not supported on Ubuntu 16.04 - - "-//:requirements_test" build_targets: *rbe_targets test_targets: *rbe_targets + build_flags: + - "--enable_workspace" + test_flags: + - "--enable_workspace" macos_examples_standalone: name: Examples (spawn_strategy=standalone) platform: macos @@ -127,7 +122,6 @@ tasks: - "dbg" - "--spawn_strategy=standalone" - "--noincompatible_enable_cc_toolchain_resolution" - - "--noenable_bzlmod" - "--enable_workspace" test_targets: *macos_targets_standalone test_flags: @@ -135,7 +129,6 @@ tasks: - "dbg" - "--spawn_strategy=standalone" - "--noincompatible_enable_cc_toolchain_resolution" - - "--noenable_bzlmod" - "--enable_workspace" macos_examples: name: Examples @@ -151,12 +144,10 @@ tasks: build_targets: *macos_targets build_flags: - "--noincompatible_enable_cc_toolchain_resolution" - - "--noenable_bzlmod" - "--enable_workspace" test_targets: *macos_targets test_flags: - "--noincompatible_enable_cc_toolchain_resolution" - - "--noenable_bzlmod" - "--enable_workspace" windows_examples: name: Examples @@ -188,10 +179,8 @@ tasks: build_targets: *windows_targets test_targets: *windows_targets build_flags: - - "--noenable_bzlmod" - "--enable_workspace" test_flags: - - "--noenable_bzlmod" - "--enable_workspace" rbe_ubuntu2204_flags: name: Flags @@ -211,6 +200,12 @@ tasks: working_directory: test/standard_cxx_flags_test test_targets: - "//:flags_test" + macos_arm64_flags: + name: Flags (arm64) + platform: macos_arm64 + working_directory: test/standard_cxx_flags_test + test_targets: + - "//:flags_test" windows_flags: name: Flags platform: windows @@ -223,24 +218,50 @@ tasks: working_directory: test/detect_root_test test_targets: - "//:tests" + build_flags: + - "--enable_workspace" + test_flags: + - "--enable_workspace" ubuntu2204_detect_root: name: Detect root platform: ubuntu2204 working_directory: test/detect_root_test test_targets: - "//:tests" + build_flags: + - "--enable_workspace" + test_flags: + - "--enable_workspace" macos_detect_root: name: Detect root platform: macos working_directory: test/detect_root_test test_targets: - "//:tests" + build_flags: + - "--enable_workspace" + test_flags: + - "--enable_workspace" + macos_arm64_detect_root: + name: Detect root (arm64) + platform: macos_arm64 + working_directory: test/detect_root_test + test_targets: + - "//:tests" + build_flags: + - "--enable_workspace" + test_flags: + - "--enable_workspace" windows_detect_root: name: Detect root platform: windows working_directory: test/detect_root_test test_targets: - "//:tests" + build_flags: + - "--enable_workspace" + test_flags: + - "--enable_workspace" docs_linux: name: Docs platform: ubuntu2204 diff --git a/.bazelversion b/.bazelversion deleted file mode 100644 index 815da58b7..000000000 --- a/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -7.4.1 diff --git a/MODULE.bazel b/MODULE.bazel index 6528ebe2a..95449d804 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,9 +16,20 @@ bazel_dep(name = "rules_shell", version = "0.3.0") # 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) +rbe_preconfig = use_repo_rule( + "@bazel_ci_rules//:rbe_repo.bzl", + "rbe_preconfig", +) + +rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu2204", +) + python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain(python_version = "3.12") use_repo(python, "python_3_12") diff --git a/REPO.bazel b/REPO.bazel new file mode 100644 index 000000000..e69de29bb diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index ea64da343..3712534de 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -1,11 +1 @@ workspace(name = "rules_foreign_cc") - -load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") - -# Creates a default toolchain config for RBE. -# Use this as is if you are using the rbe_ubuntu16_04 container, -# otherwise refer to RBE docs. -rbe_preconfig( - name = "buildkite_config", - toolchain = "ubuntu1804-bazel-java11", -) diff --git a/examples/.bazelversion b/examples/.bazelversion deleted file mode 100644 index 815da58b7..000000000 --- a/examples/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -7.4.1 diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 97512a8a6..763d24ea5 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -1,4 +1,4 @@ -bazel_dep(name = "rules_foreign_cc", version = "0.0.0") +bazel_dep(name = "rules_foreign_cc") local_path_override( module_name = "rules_foreign_cc", path = "..", @@ -13,15 +13,19 @@ use_repo( ) bazel_dep(name = "platforms", version = "0.0.11") +bazel_dep(name = "bazel_skylib", version = "1.7.1") 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_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 = "rules_swift", version = "2.1.1", repo_name = "build_bazel_rules_swift") +bazel_dep(name = "rules_apple", version = "3.16.1", repo_name = "build_bazel_rules_apple") +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_cc", version = "0.1.1") bazel_dep(name = "rules_shell", version = "0.3.0") bazel_dep(name = "rules_perl", version = "0.2.5") +apple_cc_configure = use_extension("@build_bazel_apple_support//crosstool:setup.bzl", "apple_cc_configure_extension") +use_repo(apple_cc_configure, "local_config_apple_cc") + python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( configure_coverage_tool = True, @@ -38,6 +42,37 @@ pip.parse( ) use_repo(pip, "pip") +bazel_dep(name = "rules_android", version = "0.6.0") +bazel_dep(name = "rules_android_ndk", version = "0.1.2") +bazel_dep(name = "rules_jvm_external", version = "6.6") + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + name = "maven", + artifacts = [ + "com.android.support.constraint:constraint-layout:aar:1.1.2", + "com.android.support:appcompat-v7:aar:26.1.0", + ], + repositories = [ + "https://jcenter.bintray.com/", + "https://maven.google.com", + "https://repo1.maven.org/maven2", + ], +) +use_repo(maven, "maven") + +bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True) + +rbe_preconfig = use_repo_rule( + "@bazel_ci_rules//:rbe_repo.bzl", + "rbe_preconfig", +) + +rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu2004", +) + # https://bazelbuild.github.io/rules_rust/crate_universe_bzlmod.html rust_example = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") @@ -66,21 +101,3 @@ use_repo( rust_example, "rust_example", ) - -# bazel_dep(name = "rules_android", version = "0.1.1") -# bazel_dep(name = "rules_jvm_external", version = "5.1") -# -# maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") -# -# maven.install( -# name = "maven_deps", -# artifacts = [ -# "com.android.support.constraint:constraint-layout:aar:1.1.2", -# "com.android.support:appcompat-v7:aar:26.1.0", -# ], -# repositories = [ -# "https://jcenter.bintray.com/", -# "https://maven.google.com", -# "https://repo1.maven.org/maven2", -# ], -# ) diff --git a/examples/WORKSPACE.bazel b/examples/WORKSPACE.bazel index e47cec2c1..15b576dd5 100644 --- a/examples/WORKSPACE.bazel +++ b/examples/WORKSPACE.bazel @@ -13,6 +13,17 @@ load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") bazel_skylib_workspace() +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") + +maybe( + http_archive, + name = "rules_cc", + sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1", + strip_prefix = "rules_cc-0.0.17", + urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"], +) + load("//deps:repositories.bzl", "repositories") repositories() @@ -63,8 +74,6 @@ load("@rules_foreign_cc_examples_third_party//:setup.bzl", examples_third_party_ examples_third_party_setup() -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - http_archive( name = "bazelci_rules", sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e", @@ -122,8 +131,6 @@ load( apple_support_dependencies() -load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") - maybe( http_archive, name = "rules_rust", diff --git a/examples/WORKSPACE.bzlmod b/examples/WORKSPACE.bzlmod index 6cdd67680..8325f2c58 100644 --- a/examples/WORKSPACE.bzlmod +++ b/examples/WORKSPACE.bzlmod @@ -1,17 +1,5 @@ workspace(name = "rules_foreign_cc_examples") -load("//deps:repositories.bzl", "repositories") - -repositories() - -load("//deps:deps_android.bzl", "deps_android") - -deps_android() - -load("//deps:deps_jvm_external.bzl", "deps_jvm_external") - -deps_jvm_external() - local_repository( name = "rules_foreign_cc_examples_third_party", path = "third_party", @@ -20,26 +8,3 @@ local_repository( load("@rules_foreign_cc_examples_third_party//:repositories.bzl", examples_third_party_repositories = "repositories") examples_third_party_repositories() - -load("@rules_foreign_cc_examples_third_party//:setup.bzl", examples_third_party_setup = "setup") - -examples_third_party_setup() - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "bazelci_rules", - sha256 = "eca21884e6f66a88c358e580fd67a6b148d30ab57b1680f62a96c00f9bc6a07e", - strip_prefix = "bazelci_rules-1.0.0", - url = "https://github.com/bazelbuild/continuous-integration/releases/download/rules-1.0.0/bazelci_rules-1.0.0.tar.gz", -) - -load("@bazelci_rules//:rbe_repo.bzl", "rbe_preconfig") - -# Creates a default toolchain config for RBE. -# Use this as is if you are using the rbe_ubuntu16_04 container, -# otherwise refer to RBE docs. -rbe_preconfig( - name = "buildkite_config", - toolchain = "ubuntu1804-bazel-java11", -) diff --git a/examples/cmake_crosstool/.bazelversion b/examples/cmake_crosstool/.bazelversion deleted file mode 100644 index 815da58b7..000000000 --- a/examples/cmake_crosstool/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -7.4.1 diff --git a/examples/deps/deps_jvm_external.bzl b/examples/deps/deps_jvm_external.bzl index 2284e2827..3a15e8e4e 100644 --- a/examples/deps/deps_jvm_external.bzl +++ b/examples/deps/deps_jvm_external.bzl @@ -1,5 +1,8 @@ """A module for bringing in transitive dependencies of rules_jvm_external""" +# note that the following line is what is minimally required from protobuf for the java rules +# consider using the protobuf_deps() public API from @com_google_protobuf//:protobuf_deps.bzl +load("@com_google_protobuf//bazel/private:proto_bazel_features.bzl", "proto_bazel_features") # buildifier: disable=bzl-visibility load("@rules_jvm_external//:defs.bzl", "maven_install") def deps_jvm_external(): @@ -14,3 +17,4 @@ def deps_jvm_external(): "https://repo1.maven.org/maven2", ], ) + proto_bazel_features(name = "proto_bazel_features") diff --git a/examples/third_party/.bazelversion b/examples/third_party/.bazelversion deleted file mode 100644 index 815da58b7..000000000 --- a/examples/third_party/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -7.4.1 diff --git a/examples/third_party/gn/gn_repositories.bzl b/examples/third_party/gn/gn_repositories.bzl index b53a9e23c..9757b54a9 100644 --- a/examples/third_party/gn/gn_repositories.bzl +++ b/examples/third_party/gn/gn_repositories.bzl @@ -9,9 +9,21 @@ def gn_repositories(): name = "gn", build_file = Label("//gn:BUILD.gn.bazel"), commit = "dfcbc6fed0a8352696f92d67ccad54048ad182b3", - patch_args = [], - patch_tool = "bash", - patches = [Label("//gn:patch.gen_ninja.sh")], + patch_cmds = [ + "python3 build/gen.py --no-last-commit-position", + "cat > out/last_commit_position.h <> out/last_commit_position.h +echo "// Generated by @rules_foreign_cc_examples_third_party//gn:patch.gen_ninja.sh" > out/last_commit_position.h echo "" >> out/last_commit_position.h echo "#ifndef OUT_LAST_COMMIT_POSITION_H_" >> out/last_commit_position.h echo "#define OUT_LAST_COMMIT_POSITION_H_" >> out/last_commit_position.h diff --git a/examples/third_party/zlib/BUILD.bazel b/examples/third_party/zlib/BUILD.bazel index 2aeccc5e3..165dd414e 100644 --- a/examples/third_party/zlib/BUILD.bazel +++ b/examples/third_party/zlib/BUILD.bazel @@ -29,6 +29,7 @@ sh_test( srcs = ["test_zlib.sh"], data = [":zlib_usage_example"], visibility = ["//:__pkg__"], + deps = ["@bazel_tools//tools/bash/runfiles"], ) cmake( @@ -50,4 +51,5 @@ sh_test( srcs = ["test_shared_zlib.sh"], data = [":run-zlib-example"], visibility = ["//:__pkg__"], + deps = ["@bazel_tools//tools/bash/runfiles"], ) diff --git a/examples/third_party/zlib/test_shared_zlib.sh b/examples/third_party/zlib/test_shared_zlib.sh index 6bd09d695..ca8872946 100755 --- a/examples/third_party/zlib/test_shared_zlib.sh +++ b/examples/third_party/zlib/test_shared_zlib.sh @@ -1,3 +1,16 @@ #!/usr/bin/env bash +# --- begin runfiles.bash initialization v3 --- +# Copy-pasted from the Bazel Bash runfiles library v3. +set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash +# shellcheck disable=SC1090 +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v3 --- + + $(rlocation rules_foreign_cc/examples/cmake/zlib_shared_usage_example) diff --git a/examples/third_party/zlib/test_zlib.sh b/examples/third_party/zlib/test_zlib.sh index 7324ae2b8..48630f869 100755 --- a/examples/third_party/zlib/test_zlib.sh +++ b/examples/third_party/zlib/test_zlib.sh @@ -1,3 +1,16 @@ #!/usr/bin/env bash +# --- begin runfiles.bash initialization v3 --- +# Copy-pasted from the Bazel Bash runfiles library v3. +set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash +# shellcheck disable=SC1090 +source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ + source "$0.runfiles/$f" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ + { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e +# --- end runfiles.bash initialization v3 --- + + $(rlocation rules_foreign_cc/examples/cmake/zlib_usage_example) diff --git a/test/boostrap_tools/BUILD.bazel b/test/boostrap_tools/BUILD.bazel index 2bf052c15..894b6aacb 100644 --- a/test/boostrap_tools/BUILD.bazel +++ b/test/boostrap_tools/BUILD.bazel @@ -7,8 +7,10 @@ build_test( "manual", ], targets = [ - "//toolchains:make_tool", - "//toolchains:cmake_tool", - "//toolchains:ninja_tool", + "//toolchains/private:make_tool", + "//toolchains/private:cmake_tool", + "//toolchains/private:ninja_tool", + "//toolchains/private:meson_tool", + "//toolchains/private:pkgconfig_tool", ], ) diff --git a/test/detect_root_test/.bazelversion b/test/detect_root_test/.bazelversion deleted file mode 100644 index 815da58b7..000000000 --- a/test/detect_root_test/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -7.4.1 diff --git a/test/detect_root_test/MODULE.bazel b/test/detect_root_test/MODULE.bazel new file mode 100644 index 000000000..9fe1699ae --- /dev/null +++ b/test/detect_root_test/MODULE.bazel @@ -0,0 +1,24 @@ +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "rules_foreign_cc") +local_path_override( + module_name = "rules_foreign_cc", + path = "../..", +) + +bazel_dep(name = "platforms", version = "0.0.5") + +bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True) + +# note that this dev_dependency is only needed because bazel_ci_rules +# depends on it. If you are not using bazel_ci_rules; ideally we'd be able to remove this. +bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True) + +rbe_preconfig = use_repo_rule( + "@bazel_ci_rules//:rbe_repo.bzl", + "rbe_preconfig", +) + +rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu2004", +) diff --git a/test/detect_root_test/REPO.bazel b/test/detect_root_test/REPO.bazel new file mode 100644 index 000000000..e69de29bb diff --git a/test/standard_cxx_flags_test/.bazelversion b/test/standard_cxx_flags_test/.bazelversion deleted file mode 100644 index 815da58b7..000000000 --- a/test/standard_cxx_flags_test/.bazelversion +++ /dev/null @@ -1 +0,0 @@ -7.4.1 diff --git a/test/standard_cxx_flags_test/MODULE.bazel b/test/standard_cxx_flags_test/MODULE.bazel new file mode 100644 index 000000000..9fe1699ae --- /dev/null +++ b/test/standard_cxx_flags_test/MODULE.bazel @@ -0,0 +1,24 @@ +bazel_dep(name = "bazel_skylib", version = "1.7.1") +bazel_dep(name = "rules_foreign_cc") +local_path_override( + module_name = "rules_foreign_cc", + path = "../..", +) + +bazel_dep(name = "platforms", version = "0.0.5") + +bazel_dep(name = "bazel_ci_rules", version = "1.0.0", dev_dependency = True) + +# note that this dev_dependency is only needed because bazel_ci_rules +# depends on it. If you are not using bazel_ci_rules; ideally we'd be able to remove this. +bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True) + +rbe_preconfig = use_repo_rule( + "@bazel_ci_rules//:rbe_repo.bzl", + "rbe_preconfig", +) + +rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu2004", +) diff --git a/test/standard_cxx_flags_test/REPO.bazel b/test/standard_cxx_flags_test/REPO.bazel new file mode 100644 index 000000000..e69de29bb