1*61c4878aSAndroid Build Coastguard Worker# Copyright 2021 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 Workerload("@bazel_skylib//lib:selects.bzl", "selects") 16*61c4878aSAndroid Build Coastguard Workerload("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 17*61c4878aSAndroid Build Coastguard Worker 18*61c4878aSAndroid Build Coastguard Workerpackage(default_visibility = ["//visibility:public"]) 19*61c4878aSAndroid Build Coastguard Worker 20*61c4878aSAndroid Build Coastguard Workerlicenses(["notice"]) 21*61c4878aSAndroid Build Coastguard Worker 22*61c4878aSAndroid Build Coastguard Workercc_library( 23*61c4878aSAndroid Build Coastguard Worker name = "config", 24*61c4878aSAndroid Build Coastguard Worker hdrs = ["public/pw_function/config.h"], 25*61c4878aSAndroid Build Coastguard Worker strip_include_prefix = "public", 26*61c4878aSAndroid Build Coastguard Worker deps = [":config_override"], 27*61c4878aSAndroid Build Coastguard Worker) 28*61c4878aSAndroid Build Coastguard Worker 29*61c4878aSAndroid Build Coastguard Workerlabel_flag( 30*61c4878aSAndroid Build Coastguard Worker name = "config_override", 31*61c4878aSAndroid Build Coastguard Worker build_setting_default = "//pw_build:default_module_config", 32*61c4878aSAndroid Build Coastguard Worker) 33*61c4878aSAndroid Build Coastguard Worker 34*61c4878aSAndroid Build Coastguard Workercc_library( 35*61c4878aSAndroid Build Coastguard Worker name = "pw_function", 36*61c4878aSAndroid Build Coastguard Worker hdrs = ["public/pw_function/function.h"], 37*61c4878aSAndroid Build Coastguard Worker strip_include_prefix = "public", 38*61c4878aSAndroid Build Coastguard Worker deps = [ 39*61c4878aSAndroid Build Coastguard Worker ":config", 40*61c4878aSAndroid Build Coastguard Worker "//pw_assert", 41*61c4878aSAndroid Build Coastguard Worker "//pw_preprocessor", 42*61c4878aSAndroid Build Coastguard Worker "//third_party/fuchsia:fit", 43*61c4878aSAndroid Build Coastguard Worker ], 44*61c4878aSAndroid Build Coastguard Worker) 45*61c4878aSAndroid Build Coastguard Worker 46*61c4878aSAndroid Build Coastguard Workerpw_cc_test( 47*61c4878aSAndroid Build Coastguard Worker name = "function_test", 48*61c4878aSAndroid Build Coastguard Worker srcs = ["function_test.cc"], 49*61c4878aSAndroid Build Coastguard Worker deps = [ 50*61c4878aSAndroid Build Coastguard Worker ":pw_function", 51*61c4878aSAndroid Build Coastguard Worker "//pw_compilation_testing:negative_compilation_testing", 52*61c4878aSAndroid Build Coastguard Worker ], 53*61c4878aSAndroid Build Coastguard Worker) 54*61c4878aSAndroid Build Coastguard Worker 55*61c4878aSAndroid Build Coastguard Workercc_library( 56*61c4878aSAndroid Build Coastguard Worker name = "pointer", 57*61c4878aSAndroid Build Coastguard Worker hdrs = [ 58*61c4878aSAndroid Build Coastguard Worker "public/pw_function/internal/static_invoker.h", 59*61c4878aSAndroid Build Coastguard Worker "public/pw_function/pointer.h", 60*61c4878aSAndroid Build Coastguard Worker ], 61*61c4878aSAndroid Build Coastguard Worker strip_include_prefix = "public", 62*61c4878aSAndroid Build Coastguard Worker) 63*61c4878aSAndroid Build Coastguard Worker 64*61c4878aSAndroid Build Coastguard Workerpw_cc_test( 65*61c4878aSAndroid Build Coastguard Worker name = "pointer_test", 66*61c4878aSAndroid Build Coastguard Worker srcs = ["pointer_test.cc"], 67*61c4878aSAndroid Build Coastguard Worker deps = [ 68*61c4878aSAndroid Build Coastguard Worker ":pointer", 69*61c4878aSAndroid Build Coastguard Worker ":pw_function", 70*61c4878aSAndroid Build Coastguard Worker ], 71*61c4878aSAndroid Build Coastguard Worker) 72*61c4878aSAndroid Build Coastguard Worker 73*61c4878aSAndroid Build Coastguard Workercc_library( 74*61c4878aSAndroid Build Coastguard Worker name = "scope_guard", 75*61c4878aSAndroid Build Coastguard Worker hdrs = ["public/pw_function/scope_guard.h"], 76*61c4878aSAndroid Build Coastguard Worker strip_include_prefix = "public", 77*61c4878aSAndroid Build Coastguard Worker) 78*61c4878aSAndroid Build Coastguard Worker 79*61c4878aSAndroid Build Coastguard Workerpw_cc_test( 80*61c4878aSAndroid Build Coastguard Worker name = "scope_guard_test", 81*61c4878aSAndroid Build Coastguard Worker srcs = ["scope_guard_test.cc"], 82*61c4878aSAndroid Build Coastguard Worker deps = [ 83*61c4878aSAndroid Build Coastguard Worker ":pw_function", 84*61c4878aSAndroid Build Coastguard Worker ":scope_guard", 85*61c4878aSAndroid Build Coastguard Worker ], 86*61c4878aSAndroid Build Coastguard Worker) 87*61c4878aSAndroid Build Coastguard Worker 88*61c4878aSAndroid Build Coastguard Worker# pw_function config for upstream builds. 89*61c4878aSAndroid Build Coastguard Worker# 90*61c4878aSAndroid Build Coastguard Worker# See https://pigweed.dev/pw_function/#dynamic-allocation for more context. 91*61c4878aSAndroid Build Coastguard Workeralias( 92*61c4878aSAndroid Build Coastguard Worker name = "upstream_default_config", 93*61c4878aSAndroid Build Coastguard Worker actual = selects.with_or({ 94*61c4878aSAndroid Build Coastguard Worker ( 95*61c4878aSAndroid Build Coastguard Worker "@platforms//os:android", 96*61c4878aSAndroid Build Coastguard Worker "@platforms//os:chromiumos", 97*61c4878aSAndroid Build Coastguard Worker "@platforms//os:fuchsia", 98*61c4878aSAndroid Build Coastguard Worker "@platforms//os:linux", 99*61c4878aSAndroid Build Coastguard Worker "@platforms//os:macos", 100*61c4878aSAndroid Build Coastguard Worker "@platforms//os:windows", 101*61c4878aSAndroid Build Coastguard Worker ): ":config_for_host", 102*61c4878aSAndroid Build Coastguard Worker "//conditions:default": "//pw_build:default_module_config", 103*61c4878aSAndroid Build Coastguard Worker }), 104*61c4878aSAndroid Build Coastguard Worker visibility = ["//visibility:private"], 105*61c4878aSAndroid Build Coastguard Worker) 106*61c4878aSAndroid Build Coastguard Worker 107*61c4878aSAndroid Build Coastguard Workercc_library( 108*61c4878aSAndroid Build Coastguard Worker name = "config_for_host", 109*61c4878aSAndroid Build Coastguard Worker defines = [ 110*61c4878aSAndroid Build Coastguard Worker "PW_FUNCTION_ENABLE_DYNAMIC_ALLOCATION=1", 111*61c4878aSAndroid Build Coastguard Worker ], 112*61c4878aSAndroid Build Coastguard Worker visibility = ["//visibility:private"], 113*61c4878aSAndroid Build Coastguard Worker) 114*61c4878aSAndroid Build Coastguard Worker 115*61c4878aSAndroid Build Coastguard Workerfilegroup( 116*61c4878aSAndroid Build Coastguard Worker name = "doxygen", 117*61c4878aSAndroid Build Coastguard Worker srcs = [ 118*61c4878aSAndroid Build Coastguard Worker "public/pw_function/function.h", 119*61c4878aSAndroid Build Coastguard Worker "public/pw_function/pointer.h", 120*61c4878aSAndroid Build Coastguard Worker "public/pw_function/scope_guard.h", 121*61c4878aSAndroid Build Coastguard Worker ], 122*61c4878aSAndroid Build Coastguard Worker) 123