1load("//bazel:defs.bzl", "compatible_with_rp2") 2 3package(default_visibility = ["//visibility:public"]) 4 5# This is split between the headers and a link-time requirement to fix issues 6# with circular dependencies introduced by the implementations. 7alias( 8 name = "pico_clib_interface", 9 actual = select({ 10 "//bazel/constraint:pico_clib_llvm_libc_enabled": ":llvm_libc_interface", 11 "//bazel/constraint:pico_clib_newlib_enabled": ":newlib_interface", 12 "//bazel/constraint:pico_clib_picolibc_enabled": ":picolibc_interface", 13 "//conditions:default": ":pico_clib_interface_auto", 14 }), 15) 16 17alias( 18 name = "pico_clib_interface_link", 19 actual = select({ 20 "//bazel/constraint:pico_clib_llvm_libc_enabled": ":llvm_libc_interface_link", 21 "//bazel/constraint:pico_clib_newlib_enabled": ":newlib_interface_link", 22 "//bazel/constraint:pico_clib_picolibc_enabled": ":picolibc_interface_link", 23 "//conditions:default": ":pico_clib_interface_auto_link", 24 }), 25) 26 27# TODO: Provide a way to hook up Arm Compiler for Embedded into the automagic 28# flow. 29alias( 30 name = "pico_clib_interface_auto", 31 actual = select({ 32 "//bazel/constraint:pico_toolchain_clang_enabled": ":llvm_libc_interface", 33 "//conditions:default": ":newlib_interface", 34 }), 35) 36 37alias( 38 name = "pico_clib_interface_auto_link", 39 actual = select({ 40 "//bazel/constraint:pico_toolchain_clang_enabled": ":llvm_libc_interface_link", 41 "//conditions:default": ":newlib_interface_link", 42 }), 43) 44 45cc_library( 46 name = "llvm_libc_interface", 47 hdrs = [ 48 "include/llvm_libc/sys/cdefs.h", 49 "include/llvm_libc/sys/stat.h", 50 "include/llvm_libc/sys/time.h", 51 "include/llvm_libc/sys/times.h", 52 "include/llvm_libc/sys/types.h", 53 "include/llvm_libc/time.h", 54 "include/llvm_libc/unistd.h", 55 ], 56 includes = ["include/llvm_libc"], 57 # It's hard to properly constrain compatibility since `auto` may select this, 58 # so just tag as manual. 59 tags = ["manual"], 60 target_compatible_with = compatible_with_rp2(), 61) 62 63cc_library( 64 name = "llvm_libc_interface_link", 65 srcs = ["llvm_libc_interface.c"], 66 implementation_deps = [ 67 ":llvm_libc_interface", 68 "//src/rp2_common/pico_atomic", 69 "//src/rp2_common/pico_bootrom", 70 "//src/rp2_common/pico_runtime_init", 71 "//src/rp2_common/pico_stdio:pico_stdio_headers", 72 ], 73 # It's hard to properly constrain compatibility since `auto` may select this, 74 # so just tag as manual. 75 tags = ["manual"], 76 target_compatible_with = compatible_with_rp2(), 77) 78 79# For now, newlib doesn't need to provide any headers. 80alias( 81 name = "newlib_interface", 82 actual = "//bazel:empty_cc_lib", 83) 84 85cc_library( 86 name = "newlib_interface_link", 87 srcs = ["newlib_interface.c"], 88 implementation_deps = [ 89 "//src/common/pico_time", 90 "//src/rp2_common/pico_bootrom", 91 "//src/rp2_common/pico_printf", 92 "//src/rp2_common/pico_runtime_init", 93 "//src/rp2_common/pico_stdio:pico_stdio_headers", 94 ], 95 # It's hard to properly constrain compatibility since `auto` may select this, 96 # so just tag as manual. 97 tags = ["manual"], 98 target_compatible_with = compatible_with_rp2(), 99) 100 101# For now, picolibc doesn't need to provide any headers. 102alias( 103 name = "picolibc_interface", 104 actual = "//bazel:empty_cc_lib", 105) 106 107cc_library( 108 name = "picolibc_interface_link", 109 srcs = ["picolibc_interface.c"], 110 implementation_deps = [ 111 "//src/common/pico_time", 112 "//src/rp2_common/pico_bootrom", 113 "//src/rp2_common/pico_printf", 114 "//src/rp2_common/pico_runtime_init", 115 "//src/rp2_common/pico_stdio:pico_stdio_headers", 116 ], 117 # It's hard to properly constrain compatibility since `auto` may select this, 118 # so just tag as manual. 119 tags = ["manual"], 120 target_compatible_with = compatible_with_rp2(), 121) 122