diff --git a/.bazelci/config.yaml b/.bazelci/config.yaml index 9a96608..f130ae7 100644 --- a/.bazelci/config.yaml +++ b/.bazelci/config.yaml @@ -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: @@ -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" @@ -116,14 +105,15 @@ 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 @@ -131,15 +121,18 @@ tasks: 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 diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index 55fcdef..cfc70e7 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -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" diff --git a/BUILD.bazel b/BUILD.bazel index 1770786..499a98d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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", +) + +gazelle_binary( + name = "gazelle_bin", + languages = DEFAULT_LANGUAGES + [ + "@bazel_skylib_gazelle_plugin//bzl", + ], ) bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]) + [ - "@bazel_tools//tools:bzl_srcs", - ], + name = "version", + srcs = ["version.bzl"], visibility = ["//visibility:public"], - deps = [ - ":bazel_tools_bzl_srcs", - "//foreign_cc:bzl_srcs", - "//toolchains:bzl_srcs", - ], ) diff --git a/MODULE.bazel b/MODULE.bazel index da990d8..e3a9643 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -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", diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index a082739..7079c0a 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -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") @@ -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") diff --git a/docs/.bazelrc b/docs/.bazelrc index dc6a3f7..9eb0697 100644 --- a/docs/.bazelrc +++ b/docs/.bazelrc @@ -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 diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index ac11cd8..48e4e4f 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -14,14 +14,25 @@ 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( @@ -29,7 +40,7 @@ stardoc( 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( @@ -37,7 +48,7 @@ stardoc( 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( @@ -45,7 +56,7 @@ stardoc( 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( @@ -53,7 +64,7 @@ stardoc( 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( @@ -61,7 +72,7 @@ stardoc( 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( @@ -69,7 +80,7 @@ stardoc( 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 = [ @@ -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 @@ -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}/" \ diff --git a/docs/WORKSPACE.bazel b/docs/WORKSPACE.bazel index 4de80bb..5fba825 100644 --- a/docs/WORKSPACE.bazel +++ b/docs/WORKSPACE.bazel @@ -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") diff --git a/docs/root/src/index.md b/docs/root/src/index.md index 3d13d0b..8aeb084 100644 --- a/docs/root/src/index.md +++ b/docs/root/src/index.md @@ -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) diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 2b6a3ca..eb72db7 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -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", ) diff --git a/examples/WORKSPACE.bazel b/examples/WORKSPACE.bazel index df3b36a..2cebbb1 100644 --- a/examples/WORKSPACE.bazel +++ b/examples/WORKSPACE.bazel @@ -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( diff --git a/examples/requirements_lock.txt b/examples/requirements_lock.txt index dc3976b..d34a81d 100644 --- a/examples/requirements_lock.txt +++ b/examples/requirements_lock.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.9 +# This file is autogenerated by pip-compile with Python 3.10 # by the following command: # # bazel run //:requirements.update diff --git a/foreign_cc/BUILD.bazel b/foreign_cc/BUILD.bazel index 40aee9b..36ff308 100644 --- a/foreign_cc/BUILD.bazel +++ b/foreign_cc/BUILD.bazel @@ -6,15 +6,130 @@ exports_files( ) bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]), - visibility = ["//:__subpackages__"], + name = "boost_build", + srcs = ["boost_build.bzl"], + visibility = ["//visibility:public"], deps = [ - "//foreign_cc/built_tools:bzl_srcs", - "//foreign_cc/private:bzl_srcs", - "@bazel_skylib//lib:collections", - "@bazel_skylib//lib:paths", - "@bazel_skylib//lib:versions", - "@rules_python//docs:defs", + "//foreign_cc/private:detect_root", + "//foreign_cc/private:framework", ], ) + +bzl_library( + name = "cmake", + srcs = ["cmake.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//foreign_cc/private:cc_toolchain_util", + "//foreign_cc/private:cmake_script", + "//foreign_cc/private:detect_root", + "//foreign_cc/private:framework", + "//foreign_cc/private:transitions", + "//foreign_cc/private/framework:platform", + "//toolchains/native_tools:tool_access", + ], +) + +bzl_library( + name = "configure", + srcs = ["configure.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//foreign_cc/private:cc_toolchain_util", + "//foreign_cc/private:configure_script", + "//foreign_cc/private:detect_root", + "//foreign_cc/private:framework", + "//foreign_cc/private:transitions", + "//toolchains/native_tools:tool_access", + ], +) + +bzl_library( + name = "defs", + srcs = ["defs.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":boost_build", + ":cmake", + ":configure", + ":make", + ":meson", + ":ninja", + ":utils", + ], +) + +bzl_library( + name = "extensions", + srcs = ["extensions.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":repositories", + "//toolchains:prebuilt_toolchains", + ], +) + +bzl_library( + name = "make", + srcs = ["make.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//foreign_cc/private:cc_toolchain_util", + "//foreign_cc/private:detect_root", + "//foreign_cc/private:framework", + "//foreign_cc/private:make_script", + "//foreign_cc/private:transitions", + "//toolchains/native_tools:tool_access", + ], +) + +bzl_library( + name = "meson", + srcs = ["meson.bzl"], + visibility = ["//visibility:public"], + deps = [ + ":utils", + "//foreign_cc/built_tools:meson_build", + "//foreign_cc/private:detect_root", + "//foreign_cc/private:framework", + "//foreign_cc/private:make_script", + "//foreign_cc/private:transitions", + "//toolchains/native_tools:native_tools_toolchain", + "//toolchains/native_tools:tool_access", + ], +) + +bzl_library( + name = "ninja", + srcs = ["ninja.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//foreign_cc/private:detect_root", + "//foreign_cc/private:framework", + "//toolchains/native_tools:tool_access", + ], +) + +bzl_library( + name = "repositories", + srcs = ["repositories.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//foreign_cc/private/framework:toolchain", + "//toolchains", + "@bazel_tools//tools/build_defs/repo:http.bzl", + "@bazel_tools//tools/build_defs/repo:utils.bzl", + ], +) + +bzl_library( + name = "providers", + srcs = ["providers.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "utils", + srcs = ["utils.bzl"], + visibility = ["//visibility:public"], +) diff --git a/foreign_cc/built_tools/BUILD.bazel b/foreign_cc/built_tools/BUILD.bazel index 8d2354e..29f8d06 100644 --- a/foreign_cc/built_tools/BUILD.bazel +++ b/foreign_cc/built_tools/BUILD.bazel @@ -1,10 +1,48 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]), - visibility = ["//:__subpackages__"], + name = "cmake_build", + srcs = ["cmake_build.bzl"], + visibility = ["//visibility:public"], + deps = ["//foreign_cc:defs"], +) + +bzl_library( + name = "make_build", + srcs = ["make_build.bzl"], + visibility = ["//visibility:public"], deps = [ - "//foreign_cc/built_tools/private:bzl_srcs", + "//foreign_cc/built_tools/private:built_tools_framework", + "//foreign_cc/private:cc_toolchain_util", + "//foreign_cc/private/framework:platform", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", + ], +) + +bzl_library( + name = "meson_build", + srcs = ["meson_build.bzl"], + visibility = ["//visibility:public"], + deps = ["@rules_python//python:defs_bzl"], +) + +bzl_library( + name = "ninja_build", + srcs = ["ninja_build.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//foreign_cc/built_tools/private:built_tools_framework", + "//foreign_cc/private/framework:platform", + ], +) + +bzl_library( + name = "pkgconfig_build", + srcs = ["pkgconfig_build.bzl"], + visibility = ["//visibility:public"], + deps = [ + "//foreign_cc:defs", + "//foreign_cc/built_tools/private:built_tools_framework", + "//toolchains/native_tools:tool_access", ], ) diff --git a/foreign_cc/built_tools/private/BUILD.bazel b/foreign_cc/built_tools/private/BUILD.bazel index e4db260..c549654 100644 --- a/foreign_cc/built_tools/private/BUILD.bazel +++ b/foreign_cc/built_tools/private/BUILD.bazel @@ -1,7 +1,14 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]), - visibility = ["//:__subpackages__"], + name = "built_tools_framework", + srcs = ["built_tools_framework.bzl"], + visibility = ["//foreign_cc/built_tools:__subpackages__"], + deps = [ + "//foreign_cc/private:cc_toolchain_util", + "//foreign_cc/private:detect_root", + "//foreign_cc/private:framework", + "//foreign_cc/private/framework:helpers", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", + ], ) diff --git a/foreign_cc/private/BUILD.bazel b/foreign_cc/private/BUILD.bazel index 4f1acab..ccbe9db 100644 --- a/foreign_cc/private/BUILD.bazel +++ b/foreign_cc/private/BUILD.bazel @@ -5,10 +5,84 @@ exports_files([ ]) bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]), - visibility = ["//:__subpackages__"], + name = "cc_toolchain_util", + srcs = ["cc_toolchain_util.bzl"], + visibility = ["//foreign_cc:__subpackages__"], deps = [ - "//foreign_cc/private/framework:bzl_srcs", + "@bazel_skylib//lib:collections", + "@bazel_tools//tools/build_defs/cc:action_names.bzl", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", ], ) + +bzl_library( + name = "cmake_script", + srcs = ["cmake_script.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [":cc_toolchain_util"], +) + +bzl_library( + name = "configure_script", + srcs = ["configure_script.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [ + ":make_env_vars", + ":make_script", + ], +) + +bzl_library( + name = "framework", + srcs = ["framework.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [ + ":cc_toolchain_util", + ":detect_root", + ":run_shell_file_utils", + "//foreign_cc:providers", + "//foreign_cc/private/framework:helpers", + "@bazel_skylib//lib:collections", + "@bazel_skylib//lib:paths", + "@bazel_tools//tools/cpp:toolchain_utils.bzl", + ], +) + +bzl_library( + name = "make_env_vars", + srcs = ["make_env_vars.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [ + ":cc_toolchain_util", + ":framework", + ], +) + +bzl_library( + name = "make_script", + srcs = ["make_script.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [":make_env_vars"], +) + +bzl_library( + name = "transitions", + srcs = ["transitions.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = ["//foreign_cc:providers"], +) + +bzl_library( + name = "detect_root", + srcs = ["detect_root.bzl"], + visibility = [ + "//foreign_cc:__subpackages__", + "//test:__subpackages__", + ], +) + +bzl_library( + name = "run_shell_file_utils", + srcs = ["run_shell_file_utils.bzl"], + visibility = ["//foreign_cc:__subpackages__"], +) diff --git a/foreign_cc/private/framework/BUILD.bazel b/foreign_cc/private/framework/BUILD.bazel index e7c6a0c..e412561 100644 --- a/foreign_cc/private/framework/BUILD.bazel +++ b/foreign_cc/private/framework/BUILD.bazel @@ -6,11 +6,30 @@ toolchain_type( visibility = ["//visibility:public"], ) +framework_platform_info() + bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]), - visibility = ["//:__subpackages__"], - deps = ["//foreign_cc/private/framework/toolchains:bzl_srcs"], + name = "helpers", + srcs = ["helpers.bzl"], + visibility = [ + "//foreign_cc:__subpackages__", + "//test:__subpackages__", + ], + deps = [ + "//foreign_cc/private/framework/toolchains:access", + "//foreign_cc/private/framework/toolchains:commands", + ], ) -framework_platform_info() +bzl_library( + name = "toolchain", + srcs = ["toolchain.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = ["//foreign_cc/private/framework/toolchains:mappings"], +) + +bzl_library( + name = "platform", + srcs = ["platform.bzl"], + visibility = ["//foreign_cc:__subpackages__"], +) diff --git a/foreign_cc/private/framework/toolchains/BUILD.bazel b/foreign_cc/private/framework/toolchains/BUILD.bazel index e4db260..0c2dc6b 100644 --- a/foreign_cc/private/framework/toolchains/BUILD.bazel +++ b/foreign_cc/private/framework/toolchains/BUILD.bazel @@ -1,7 +1,48 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]), - visibility = ["//:__subpackages__"], + name = "access", + srcs = ["access.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [":commands"], +) + +bzl_library( + name = "freebsd_commands", + srcs = ["freebsd_commands.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [":commands"], +) + +bzl_library( + name = "linux_commands", + srcs = ["linux_commands.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [":commands"], +) + +bzl_library( + name = "macos_commands", + srcs = ["macos_commands.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [":commands"], +) + +bzl_library( + name = "windows_commands", + srcs = ["windows_commands.bzl"], + visibility = ["//foreign_cc:__subpackages__"], + deps = [":commands"], +) + +bzl_library( + name = "commands", + srcs = ["commands.bzl"], + visibility = ["//foreign_cc:__subpackages__"], +) + +bzl_library( + name = "mappings", + srcs = ["mappings.bzl"], + visibility = ["//foreign_cc:__subpackages__"], ) diff --git a/test/BUILD.bazel b/test/BUILD.bazel index 710da2c..9521ec4 100644 --- a/test/BUILD.bazel +++ b/test/BUILD.bazel @@ -1,3 +1,4 @@ +load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_skylib//rules:diff_test.bzl", "diff_test") load(":cmake_text_tests.bzl", "cmake_script_test_suite") load(":convert_shell_script_test.bzl", "shell_script_conversion_suite") @@ -71,3 +72,20 @@ diff_test( }), file2 = ":symlink_dirs", ) + +bzl_library( + name = "shell_script_helper_test_rule", + srcs = ["shell_script_helper_test_rule.bzl"], + visibility = ["//visibility:public"], + deps = ["//foreign_cc/private/framework:helpers"], +) + +bzl_library( + name = "symlink_contents_to_dir_test_rule", + srcs = ["symlink_contents_to_dir_test_rule.bzl"], + visibility = ["//visibility:public"], + deps = [ + "@rules_foreign_cc//foreign_cc/private:detect_root", + "@rules_foreign_cc//foreign_cc/private/framework:helpers", + ], +) diff --git a/toolchains/BUILD.bazel b/toolchains/BUILD.bazel index e41886b..d1a2a5a 100644 --- a/toolchains/BUILD.bazel +++ b/toolchains/BUILD.bazel @@ -334,10 +334,40 @@ native_tool_toolchain( ) bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]), - visibility = ["//:__subpackages__"], + name = "built_toolchains", + srcs = ["built_toolchains.bzl"], deps = [ - "//toolchains/native_tools:bzl_srcs", + "@bazel_tools//tools/build_defs/repo:http.bzl", + "@bazel_tools//tools/build_defs/repo:utils.bzl", + "@rules_foreign_cc//toolchains:cmake_versions", ], ) + +bzl_library( + name = "prebuilt_toolchains", + srcs = ["prebuilt_toolchains.bzl"], + deps = [ + "@bazel_tools//tools/build_defs/repo:http.bzl", + "@bazel_tools//tools/build_defs/repo:utils.bzl", + "@rules_foreign_cc//toolchains:prebuilt_toolchains_repository", + ], +) + +bzl_library( + name = "toolchains", + srcs = ["toolchains.bzl"], + deps = [ + ":built_toolchains", + ":prebuilt_toolchains", + ], +) + +bzl_library( + name = "cmake_versions", + srcs = ["cmake_versions.bzl"], +) + +bzl_library( + name = "prebuilt_toolchains_repository", + srcs = ["prebuilt_toolchains_repository.bzl"], +) diff --git a/toolchains/native_tools/BUILD.bazel b/toolchains/native_tools/BUILD.bazel index d42fc71..0991ecb 100644 --- a/toolchains/native_tools/BUILD.bazel +++ b/toolchains/native_tools/BUILD.bazel @@ -1,7 +1,13 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") bzl_library( - name = "bzl_srcs", - srcs = glob(["**/*.bzl"]), + name = "native_tools_toolchain", + srcs = ["native_tools_toolchain.bzl"], + visibility = ["//visibility:public"], +) + +bzl_library( + name = "tool_access", + srcs = ["tool_access.bzl"], visibility = ["//visibility:public"], )