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