1# Copyright 2019 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load( 16 "//pw_build:pigweed.bzl", 17 "pw_cc_binary_with_map", 18 "pw_cc_blob_info", 19 "pw_cc_blob_library", 20 "pw_cc_test", 21) 22 23package(default_visibility = ["//visibility:public"]) 24 25licenses(["notice"]) 26 27config_setting( 28 name = "kythe", 29 values = { 30 "define": "kythe_corpus=pigweed.googlesource.com/pigweed/pigweed", 31 }, 32) 33 34pw_cc_blob_info( 35 name = "test_blob_aligned", 36 alignas = "512", 37 file_path = "test_blob_0123.bin", 38 symbol_name = "kFirstBlob0123", 39) 40 41pw_cc_blob_info( 42 name = "test_blob_unaligned", 43 file_path = "test_blob_0123.bin", 44 symbol_name = "kSecondBlob0123", 45) 46 47pw_cc_blob_library( 48 name = "test_blob", 49 blobs = [ 50 ":test_blob_aligned", 51 ":test_blob_unaligned", 52 ], 53 namespace = "test::ns", 54 out_header = "pw_build/test_blob.h", 55) 56 57pw_cc_test( 58 name = "cc_blob_library_test", 59 srcs = ["cc_blob_library_test.cc"], 60 deps = [":test_blob"], 61) 62 63pw_cc_binary_with_map( 64 name = "cc_binary_with_map", 65 srcs = ["empty_main.cc"], 66 # Only enable on platforms that support -Map linker flag 67 target_compatible_with = select({ 68 "@platforms//os:macos": ["@platforms//:incompatible"], 69 "@platforms//os:windows": ["@platforms//:incompatible"], 70 "//conditions:default": [], 71 }), 72) 73 74# Bazel produces root-relative file paths without the -ffile-prefix-map option. 75pw_cc_test( 76 name = "file_prefix_map_test", 77 srcs = [ 78 "file_prefix_map_test.cc", 79 "pw_build_private/file_prefix_map_test.h", 80 ], 81 defines = [ 82 "PW_BUILD_EXPECTED_HEADER_PATH=\\\"pw_build/pw_build_private/file_prefix_map_test.h\\\"", 83 "PW_BUILD_EXPECTED_SOURCE_PATH=\\\"pw_build/file_prefix_map_test.cc\\\"", 84 ], 85) 86 87label_flag( 88 name = "default_module_config", 89 # The default module config is empty. 90 build_setting_default = ":empty_cc_library", 91) 92 93cc_library( 94 name = "test_module_config", 95 defines = [ 96 "PW_THREAD_FREERTOS_CONFIG_JOINING_ENABLED=1", 97 ], 98) 99 100pw_cc_test( 101 name = "module_config_test", 102 srcs = ["module_config_test.cc"], 103 # This test requires a special configuration. It's run in CI, and can be 104 # run manually via, 105 # 106 # bazel build \ 107 # --//pw_thread_freertos:config_override=//pw_build:test_module_config \ 108 # --platforms=//pw_build/platforms:testonly_freertos \ 109 # //pw_build:module_config_test 110 tags = ["manual"], 111 deps = ["//pw_thread:thread"], 112) 113 114# This empty library is used as a placeholder for label flags that need to 115# point to a library of some kind, but don't actually need the dependency to 116# amount to anything. 117cc_library( 118 name = "empty_cc_library", 119) 120 121# A special target used instead of a cc_library as the default condition in 122# backend multiplexer select statements to signal that a facade is in an 123# unconfigured state. This produces better error messages than e.g. using an 124# invalid label. 125# 126# If you're a user whose build errored out because a library transitively 127# depended on this target: the platform you're targeting did not specify which 128# backend to use for some facade. Look at the previous step in the dependency 129# chain (printed with the error) to figure out which one. 130cc_library( 131 name = "unspecified_backend", 132 target_compatible_with = ["@platforms//:incompatible"], 133) 134 135# Additional libraries that all binaries using Pigweed should be linked against. 136# 137# This is analogous to GN's pw_build_LINK_DEPS. See 138# https://pigweed.dev/build_system.html#docs-build-system-bazel-link-extra-lib 139# for more details. 140cc_library( 141 name = "default_link_extra_lib", 142 deps = [ 143 "//pw_assert:backend_impl", 144 "//pw_log:backend_impl", 145 ], 146) 147 148# Linker script utility PW_MUST_PLACE 149cc_library( 150 name = "must_place", 151 hdrs = ["public/pw_build/must_place.ld.h"], 152 includes = ["public"], 153) 154