1 2# Copyright 2023 The Fuchsia Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5# buildifier: disable=load-on-top 6load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 7# Set up bazel skylib and its dependencies 8http_archive( 9 name = "bazel_skylib", 10 sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728", 11 urls = [ 12 "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz", 13 "https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz", 14 ], 15) 16load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace") 17bazel_skylib_workspace() 18# The fuchsia_infra repository provides rules which allow us to work inside of 19# fuchsia's infrastructure. 20local_repository( 21 name = "fuchsia_infra", 22 path = "fuchsia-build/third_party/fuchsia-infra-bazel-rules", 23) 24load("@fuchsia_infra//:workspace.bzl", "fuchsia_infra_workspace") 25load("@fuchsia_infra//cipd:defs.bzl", "cipd_repository", "cipd_tool_repository") 26fuchsia_infra_workspace() 27# Create a common cipd binary which will be used to download prebuilts 28cipd_tool_repository( 29 name = "cipd_tool", 30) 31# Fetch the Fuchsia SDK and register it as a repostiory. The version that is 32# used is stored in the manifests/bazel_sdk.ensure file so it can be updated by 33# our autoroller infrastructure. When the version changes bazel will fetch the 34# new prebuilts. 35cipd_repository( 36 name = "fuchsia_sdk", 37 cipd_bin = "@cipd_tool//:cipd", 38 ensure_file = "//fuchsia-build/manifests:bazel_sdk.ensure", 39) 40load( 41 "@fuchsia_sdk//fuchsia:deps.bzl", 42 "rules_fuchsia_deps", 43) 44rules_fuchsia_deps() 45# The fuchsia toolchain contains tools like ffx and fidlc. 46register_toolchains("@fuchsia_sdk//:fuchsia_toolchain_sdk") 47load( 48 "@fuchsia_sdk//fuchsia:products.bzl", 49 "fuchsia_products_repository", 50) 51fuchsia_products_repository( 52 name = "fuchsia_products", 53 cipd_bin = "@cipd_tool//:cipd", 54 ensure_file = "//fuchsia-build/manifests:product_bundles.ensure", 55) 56load( 57 "@fuchsia_sdk//fuchsia:clang.bzl", 58 "fuchsia_clang_repository", 59) 60# Set up our clang repository. 61fuchsia_clang_repository( 62 name = "fuchsia_clang", 63 cipd_bin = "@cipd_tool//:cipd", 64 cipd_ensure_file = "//fuchsia-build/manifests:clang.ensure", 65) 66load("@fuchsia_clang//:defs.bzl", "register_clang_toolchains") 67# Register a clang toolchain which will be used to compile fuchsia targets 68register_clang_toolchains() 69load("@fuchsia_infra//infra:host_toolchains.bzl", "configure_fuchsia_clang_host_toolchain") 70# Configure a host toolchain for local execution. This is not used to compile 71# fuchsia targets but is made available so we don't try to access the host gcc 72# which is not available in infrastructure builds. This call must happen after 73# you create a fuchsia_clang repository. 74configure_fuchsia_clang_host_toolchain(name = "host_clang_toolchain") 75# gTest. 76local_repository( 77 name = "com_google_googletest", 78 path = "third_party/googletest", 79) 80local_repository( 81 name = "zlib", 82 path = "fuchsia-build/third_party/zlib-1.3.1", 83) 84