blob: 00985fc8ae2dd95a271a88811763a53f37878a53 [file] [log] [blame]
# Copyright 2022 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
This file will appear as MODULE.bazel in the top-level Bazel workspace
used by the Fuchsia platform build.
NOTE: If you update any of the dependencies in this file, or introduce new
dependencies, make sure to run `fx update-bazel-vendor-dir` to update the Bazel
vendor directory. See `fx help update-bazel-vendor-dir` for details.
"""
module(
name = "main",
version = "1",
)
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.1")
bazel_dep(name = "rules_go", version = "0.54.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_license", version = "1.0.0")
bazel_dep(name = "rules_python", version = "1.4.0")
bazel_dep(name = "rules_rust", version = "0.64.0")
bazel_dep(name = "protobuf", version = "", repo_name = "com_google_protobuf")
local_path_override(
module_name = "protobuf",
path = "third_party/protobuf",
)
bazel_dep(name = "abseil-cpp", version = "head")
local_path_override(
module_name = "abseil-cpp",
path = "third_party/abseil-cpp",
)
bazel_dep(name = "emboss", version = "", repo_name = "com_google_emboss")
local_path_override(
module_name = "emboss",
path = "third_party/github.com/google/emboss/src",
)
# Create @fuchsia_build_config which contains host_prebuilts/xxxx symlinks
# to access host prebuilts without an explicit fuchsia_host_tag in their path.
bazel_dep(name = "fuchsia_sdk_common", version = "")
local_path_override(
module_name = "fuchsia_sdk_common",
path = "build/bazel/local_repositories/fuchsia_sdk_common",
)
bazel_dep(name = "fuchsia_build_info", version = "")
local_path_override(
module_name = "fuchsia_build_info",
# LINT.IfChange
path = "fuchsia_build_generated/fuchsia_build_info",
# LINT.ThenChange(//build/bazel/scripts/workspace_utils.py)
)
# TODO(https://fxbug.dev/131788): Use //third_party/re2 when it's upgraded to this version.
bazel_dep(name = "re2", version = "2024-07-02.bcr.1")
bazel_dep(name = "rapidjson", version = "")
local_path_override(
module_name = "rapidjson",
path = "third_party/rapidjson",
)
# fuchsia_build_generated/gn_target_dir is a symlink to the content
# of the @gn_targets repository. At `fx gen` time, it will point to
# an empty repository, but bazel_action.py will update it just before
# invoking Bazel to point to a directory whose content matches the
# current `bazel_action()` target.
bazel_dep(name = "gn_targets", version = "")
local_path_override(
module_name = "gn_targets",
# LINT.IfChange(gn_targets_dir)
path = "fuchsia_build_generated/gn_targets_dir",
# LINT.ThenChange(//build/bazel/scripts/bazel_action.py:gn_targets_dir, //build/assembly/scripts/packages_from_product_assembler.py:gn_targets_dir, //build/bazel/scripts/workspace_utils.py:gn_targets_dir_symlink)
)
fuchsia_build_config_ext = use_extension("@fuchsia_sdk_common//common:fuchsia_platform_build.bzl", "fuchsia_build_config_ext")
use_repo(fuchsia_build_config_ext, "fuchsia_build_config")
go_sdk = use_extension("@io_bazel_rules_go//go:extensions.bzl", "go_sdk")
go_sdk.wrap(root_file = "@fuchsia_build_config//:host_prebuilts/go/README.md")
bazel_dep(name = "googletest", version = "1.17.0", repo_name = "com_google_googletest")
local_path_override(
module_name = "googletest",
path = "third_party/googletest/src",
)
bazel_dep(name = "rules_fuchsia", version = "", repo_name = "rules_fuchsia")
local_path_override(
module_name = "rules_fuchsia",
path = "build/bazel_sdk/bazel_rules_fuchsia",
)
fuchsia_idk = use_extension(
"//build/bazel:module_extensions/fuchsia_idk_extensions.bzl",
"fuchsia_idk",
)
fuchsia_idk.in_tree_repository(path = "fuchsia_build_generated/fuchsia_in_tree_idk")
use_repo(fuchsia_idk, "fuchsia_in_tree_idk")
fuchsia_idk_repository = use_repo_rule(
"//build/bazel/fuchsia_idk:repository_rules.bzl",
"fuchsia_idk_repository",
)
# A repository that wraps //sdk:bazel_internal_only_idk in the Bazel graph.
# This is used to populate the @internal_sdk repository only.
fuchsia_idk_repository(
name = "fuchsia_internal_only_idk",
# LINT.IfChange(fuchsia_internal_only_idk_hash)
content_hash_file = "//:fuchsia_build_generated/fuchsia_internal_only_idk.hash",
# LINT.ThenChange(//build/bazel/scripts/workspace_utils.py)
idk_export_dir = "fuchsia_build_generated/ninja_root_build_dir/sdk/exported/bazel_internal_only_idk",
ninja_build_dir = "fuchsia_build_generated/ninja_root_build_dir",
python_executable = "@@fuchsia_sdk_common++fuchsia_build_config_ext+fuchsia_build_config//:host_prebuilts/python3/bin/python3",
)
fuchsia_sdk_ext = use_extension(
"@rules_fuchsia//fuchsia/workspace:fuchsia_sdk_repository.bzl",
"fuchsia_sdk_ext",
)
fuchsia_sdk_ext.local(
buildifier = "@fuchsia_build_config//:host_prebuilts/buildifier",
# The @fuchsia_sdk repository is populated from the same content as @fuchsia_in_tree_idk.
# LINT.IfChange
local_sdk_version_file = "//:fuchsia_build_generated/fuchsia_in_tree_idk.hash",
# LINT.ThenChange(//build/bazel/scripts/workspace_utils.py)
path = "@@+fuchsia_idk+fuchsia_in_tree_idk",
visibility_templates = {
"hlcpp": [
# Limit the scope of hlcpp to the sdk itself
"@@+_repo_rules+internal_sdk//:__subpackages__",
"@@rules_fuchsia++fuchsia_sdk_ext+fuchsia_sdk//:__subpackages__",
"@@//vendor/*/build:hlcpp_allowlist",
],
},
)
use_repo(fuchsia_sdk_ext, "fuchsia_sdk")
fuchsia_sdk_repository = use_repo_rule(
"@rules_fuchsia//fuchsia:deps.bzl",
"fuchsia_sdk_repository",
)
# A repository used to expose SDK atoms that are not yet ready to be
# distributed to partners, but required by some Fuchsia in-tree targets.
#
# TODO(https://fxbug.dev/333907192): Remove this
fuchsia_sdk_repository(
name = "internal_sdk",
local_paths = ["@@+_repo_rules+fuchsia_internal_only_idk"],
# The @internal_sdk repository is populated from the same content as @fuchsia_internal_only_idk.
# LINT.IfChange
local_sdk_version_file = "//:fuchsia_build_generated/fuchsia_internal_only_idk.hash",
# LINT.ThenChange(//build/bazel/scripts/workspace_utils.py)
# NOTE: It's unclear why @@rules_fuchsia++fuchsia_sdk_ext+fuchsia_sdk does
# NOT work here. Leaving it as-is for now since this target is planned to be
# removed.
parent_sdk = "@@fuchsia_sdk",
parent_sdk_local_paths = ["@@+fuchsia_idk+fuchsia_in_tree_idk"],
visibility_templates = {
"hlcpp": [
# Limit the scope of hlcpp to the sdk itself
"@@+_repo_rules+internal_sdk//:__subpackages__",
"@@rules_fuchsia++fuchsia_sdk_ext+fuchsia_sdk//:__subpackages__",
"@@//vendor/*/build:hlcpp_allowlist",
],
},
)
fuchsia_clang_ext = use_extension(
"@rules_fuchsia//fuchsia/workspace:fuchsia_clang_repository.bzl",
"fuchsia_clang_ext",
)
fuchsia_clang_ext.local(
local_path = "@@fuchsia_sdk_common++fuchsia_build_config_ext+fuchsia_build_config//:host_prebuilts/clang",
local_version_file = "//:fuchsia_build_generated/content_hashes/fuchsia_clang.hash",
extra_target_compatible_with = ["//build/bazel/platforms:fuchsia_artifacts_build_with_sdk_rules"],
)
use_repo(fuchsia_clang_ext, "fuchsia_clang")
register_toolchains("@fuchsia_clang//:all")
# `@fuchsia_clang` is hardcoded when generating SDK build files, so it is
# necessary to inject it into `fuchsia_sdk_ext`. Without this, the SDK
# repository can only refer to `@fuchsia_clang` with its canonical name, and
# builds will fail with `@fuchsia_clang` not visible.
inject_repo(fuchsia_sdk_ext, "fuchsia_clang")
fake_fuchsia_sdk = use_extension("@com_google_googletest//:fake_fuchsia_sdk.bzl", "fuchsia_sdk")
override_repo(fake_fuchsia_sdk, "fuchsia_sdk")
compact_python_runtime_repository = use_repo_rule(
"@rules_fuchsia//common:toolchains/python/repository_rule.bzl",
"compact_python_runtime_repository",
)
compact_python_runtime_repository(
name = "prebuilt_python",
# LINT.IfChange
content_hash_file = "fuchsia_build_generated/content_hashes/prebuilt_python.hash",
# LINT.ThenChange(scripts/workspace_utils.py)
)
register_toolchains("@prebuilt_python//:all")
# Create the @fuchsia_icu_config repository which contains the constants.bzl file
# exporting generating configuration constants related to the ICU library flavors
fuchsia_icu_config_repository = use_repo_rule(
"//build/bazel/icu:repository_rules.bzl",
"fuchsia_icu_config_repository",
)
fuchsia_icu_config_repository(
name = "fuchsia_icu_config",
# LINT.IfChange
content_hash_file = "fuchsia_build_generated/content_hashes/fuchsia_icu_config.hash",
# LINT.ThenChange(scripts/workspace_utils.py)
)
generate_prebuilt_rust_toolchain_repository = use_repo_rule(
"//build/bazel/toolchains/rust:repository_rules.bzl",
"generate_prebuilt_rust_toolchain_repository",
)
generate_prebuilt_rust_toolchain_repository(
name = "fuchsia_prebuilt_rust",
rust_install_dir = "@@fuchsia_sdk_common++fuchsia_build_config_ext+fuchsia_build_config//:host_prebuilts/rust",
)
register_toolchains("@fuchsia_prebuilt_rust//:all")
assembly_developer_overrides_repository = use_repo_rule(
"//build/bazel/assembly:developer_overrides/repository_rules.bzl",
"assembly_developer_overrides_repository",
)
assembly_developer_overrides_repository(
name = "assembly_developer_overrides",
overrides_map_from_gn = "fuchsia_build_generated/assembly_developer_overrides.json",
)
boringssl_repository = use_repo_rule(
"//build/bazel/repository_rules:boringssl_repository.bzl",
"boringssl_repository",
)
boringssl_repository(
name = "boringssl",
# LINT.IfChange
content_hash_file = "fuchsia_build_generated/content_hashes/boringssl.hash",
# LINT.ThenChange(scripts/workspace_utils.py)
)
generate_prebuilt_clang_toolchain_repository = use_repo_rule(
"//build/bazel/toolchains/clang:repository_rules.bzl",
"generate_prebuilt_clang_toolchain_repository",
)
generate_prebuilt_clang_toolchain_repository(
name = "prebuilt_clang",
clang_install_dir = "@@fuchsia_sdk_common++fuchsia_build_config_ext+fuchsia_build_config//:host_prebuilts/clang",
# LINT.IfChange
repository_version_file = "fuchsia_build_generated/content_hashes/prebuilt_clang.hash",
# LINT.ThenChange(scripts/workspace_utils.py)
)
register_toolchains("@prebuilt_clang//:all")
generate_prebuilt_llvm_repository = use_repo_rule(
"//build/bazel/toolchains/clang:repository_rules.bzl",
"generate_prebuilt_llvm_repository",
)
generate_prebuilt_llvm_repository(
name = "prebuilt_llvm",
# NOTE: We don't have Fuchsia variant of LLVM libraries yet, so always use
# host_platform's prebuilts for now. Currently, this repository is only used
# to expose headers from prebuilt LLVM, so it should make no difference as
# headers are the same across different platforms.
#
# See https://cs.opensource.google/fuchsia/fuchsia/+/main:src/lib/llvm/BUILD.gn;l=51;drc=468d94479b10f5613ca928d782990e5340e943a4
llvm_install_dir = "@@fuchsia_sdk_common++fuchsia_build_config_ext+fuchsia_build_config//:host_prebuilts/llvm",
)
register_toolchains("//:fuchsia_sdk_devicetree_toolchain")