1*61c4878aSAndroid Build Coastguard Worker# Copyright 2023 The Pigweed Authors 2*61c4878aSAndroid Build Coastguard Worker# 3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of 5*61c4878aSAndroid Build Coastguard Worker# the License at 6*61c4878aSAndroid Build Coastguard Worker# 7*61c4878aSAndroid Build Coastguard Worker# https://www.apache.org/licenses/LICENSE-2.0 8*61c4878aSAndroid Build Coastguard Worker# 9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under 13*61c4878aSAndroid Build Coastguard Worker# the License. 14*61c4878aSAndroid Build Coastguard Worker 15*61c4878aSAndroid Build Coastguard Worker"""Dependency registration helpers for users of Pigweed. 16*61c4878aSAndroid Build Coastguard Worker 17*61c4878aSAndroid Build Coastguard WorkerBefore loading this bzl file, you must first: 18*61c4878aSAndroid Build Coastguard Worker 19*61c4878aSAndroid Build Coastguard Worker* Declare the Pigweed repository. 20*61c4878aSAndroid Build Coastguard Worker* Declare the pw_toolchain repository. 21*61c4878aSAndroid Build Coastguard Worker* Initialize the CIPD client repository. 22*61c4878aSAndroid Build Coastguard Worker""" 23*61c4878aSAndroid Build Coastguard Worker 24*61c4878aSAndroid Build Coastguard Workerload("//pw_env_setup/bazel/cipd_setup:cipd_rules.bzl", "cipd_repository") 25*61c4878aSAndroid Build Coastguard Workerload("//pw_toolchain:xcode.bzl", "xcode_sdk_repository") 26*61c4878aSAndroid Build Coastguard Worker 27*61c4878aSAndroid Build Coastguard Worker_ALL_TOOLCHAINS = [ 28*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain:cc_toolchain_cortex-m0", 29*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain:cc_toolchain_cortex-m0plus", 30*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain:cc_toolchain_cortex-m33", 31*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain/arm_gcc:arm_gcc_cc_toolchain_cortex-m3", 32*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain/arm_gcc:arm_gcc_cc_toolchain_cortex-m4", 33*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain/arm_gcc:arm_gcc_cc_toolchain_cortex-m4+nofp", 34*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain/arm_gcc:arm_gcc_cc_toolchain_cortex-m7", 35*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain/arm_gcc:arm_gcc_cc_toolchain_cortex-m33", 36*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain/arm_gcc:arm_gcc_cc_toolchain_cortex-m33+nofp", 37*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain/host_clang:host_cc_toolchain_linux", 38*61c4878aSAndroid Build Coastguard Worker "//pw_toolchain/host_clang:host_cc_toolchain_macos", 39*61c4878aSAndroid Build Coastguard Worker] 40*61c4878aSAndroid Build Coastguard Worker 41*61c4878aSAndroid Build Coastguard Worker# buildifier: disable=unnamed-macro 42*61c4878aSAndroid Build Coastguard Workerdef register_pigweed_cxx_toolchains( 43*61c4878aSAndroid Build Coastguard Worker toolchains = _ALL_TOOLCHAINS, 44*61c4878aSAndroid Build Coastguard Worker clang_tag = None, 45*61c4878aSAndroid Build Coastguard Worker arm_gcc_tag = None): 46*61c4878aSAndroid Build Coastguard Worker """This function registers Pigweed's upstream toolchains. 47*61c4878aSAndroid Build Coastguard Worker 48*61c4878aSAndroid Build Coastguard Worker WARNING: The configurations and permutations of these toolchains are subject 49*61c4878aSAndroid Build Coastguard Worker to change without notice. These changes may cause your build to break, so if 50*61c4878aSAndroid Build Coastguard Worker you want to minimize this churn, consider declaring your own toolchains to 51*61c4878aSAndroid Build Coastguard Worker have more control over the stability. 52*61c4878aSAndroid Build Coastguard Worker 53*61c4878aSAndroid Build Coastguard Worker Args: 54*61c4878aSAndroid Build Coastguard Worker toolchains: Toolchains from Pigweed to register after declaring the 55*61c4878aSAndroid Build Coastguard Worker prerequisite repositories. 56*61c4878aSAndroid Build Coastguard Worker clang_tag: The CIPD version tag to use when fetching clang. 57*61c4878aSAndroid Build Coastguard Worker arm_gcc_tag: The CIPD version tag to use when fetching 58*61c4878aSAndroid Build Coastguard Worker arm-none-eabi-gcc. 59*61c4878aSAndroid Build Coastguard Worker """ 60*61c4878aSAndroid Build Coastguard Worker 61*61c4878aSAndroid Build Coastguard Worker # Generate xcode repository on macOS. 62*61c4878aSAndroid Build Coastguard Worker xcode_sdk_repository( 63*61c4878aSAndroid Build Coastguard Worker name = "macos_sysroot", 64*61c4878aSAndroid Build Coastguard Worker build_file = "@pigweed//pw_toolchain/host_clang:macos_sysroot.BUILD", 65*61c4878aSAndroid Build Coastguard Worker ) 66*61c4878aSAndroid Build Coastguard Worker 67*61c4878aSAndroid Build Coastguard Worker # Fetch llvm toolchain for device. 68*61c4878aSAndroid Build Coastguard Worker cipd_repository( 69*61c4878aSAndroid Build Coastguard Worker name = "llvm_toolchain_device", 70*61c4878aSAndroid Build Coastguard Worker build_file = "@pigweed//pw_toolchain/build_external:llvm_clang.BUILD", 71*61c4878aSAndroid Build Coastguard Worker path = "fuchsia/third_party/clang/${os}-${arch}", 72*61c4878aSAndroid Build Coastguard Worker tag = "git_revision:8280651ad57cb9fb24a404cec2401040c28dec98" if not clang_tag else clang_tag, 73*61c4878aSAndroid Build Coastguard Worker ) 74*61c4878aSAndroid Build Coastguard Worker 75*61c4878aSAndroid Build Coastguard Worker # Fetch llvm toolchain for host. 76*61c4878aSAndroid Build Coastguard Worker cipd_repository( 77*61c4878aSAndroid Build Coastguard Worker name = "llvm_toolchain", 78*61c4878aSAndroid Build Coastguard Worker build_file = "@pigweed//pw_toolchain/build_external:llvm_clang.BUILD", 79*61c4878aSAndroid Build Coastguard Worker path = "fuchsia/third_party/clang/${os}-${arch}", 80*61c4878aSAndroid Build Coastguard Worker tag = "git_revision:8280651ad57cb9fb24a404cec2401040c28dec98" if not clang_tag else clang_tag, 81*61c4878aSAndroid Build Coastguard Worker ) 82*61c4878aSAndroid Build Coastguard Worker 83*61c4878aSAndroid Build Coastguard Worker # Fetch linux sysroot for host builds. 84*61c4878aSAndroid Build Coastguard Worker cipd_repository( 85*61c4878aSAndroid Build Coastguard Worker name = "linux_sysroot", 86*61c4878aSAndroid Build Coastguard Worker build_file = "@pigweed//pw_toolchain/host_clang:linux_sysroot.BUILD", 87*61c4878aSAndroid Build Coastguard Worker path = "fuchsia/third_party/sysroot/bionic", 88*61c4878aSAndroid Build Coastguard Worker tag = "git_revision:702eb9654703a7cec1cadf93a7e3aa269d053943", 89*61c4878aSAndroid Build Coastguard Worker ) 90*61c4878aSAndroid Build Coastguard Worker 91*61c4878aSAndroid Build Coastguard Worker # Fetch gcc-arm-none-eabi toolchain. 92*61c4878aSAndroid Build Coastguard Worker cipd_repository( 93*61c4878aSAndroid Build Coastguard Worker name = "gcc_arm_none_eabi_toolchain", 94*61c4878aSAndroid Build Coastguard Worker build_file = "@pigweed//pw_toolchain/build_external:arm_none_eabi_gcc.BUILD", 95*61c4878aSAndroid Build Coastguard Worker path = "fuchsia/third_party/armgcc/${os}-${arch}", 96*61c4878aSAndroid Build Coastguard Worker tag = "version:[email protected]" if not arm_gcc_tag else arm_gcc_tag, 97*61c4878aSAndroid Build Coastguard Worker ) 98*61c4878aSAndroid Build Coastguard Worker 99*61c4878aSAndroid Build Coastguard Worker # TODO: https://pwbug.dev/346388161 - Temporary migration shim. 100*61c4878aSAndroid Build Coastguard Worker cipd_repository( 101*61c4878aSAndroid Build Coastguard Worker name = "legacy_gcc_arm_none_eabi_toolchain", 102*61c4878aSAndroid Build Coastguard Worker build_file = "@pw_toolchain//build_external:gcc_arm_none_eabi.BUILD", 103*61c4878aSAndroid Build Coastguard Worker path = "fuchsia/third_party/armgcc/${os}-${arch}", 104*61c4878aSAndroid Build Coastguard Worker tag = "version:[email protected]" if not arm_gcc_tag else arm_gcc_tag, 105*61c4878aSAndroid Build Coastguard Worker ) 106*61c4878aSAndroid Build Coastguard Worker 107*61c4878aSAndroid Build Coastguard Worker native.register_toolchains(*toolchains) 108