1# Copyright 2021 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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/target_types.gni") 18import("$dir_pw_docgen/docs.gni") 19import("$dir_pw_unit_test/test.gni") 20 21config("public_include_path") { 22 include_dirs = [ "public" ] 23} 24 25group("pw_spi") { 26 deps = [ 27 ":chip_selector", 28 ":device", 29 ":initiator", 30 ] 31 if (host_os == "linux") { 32 deps += [ ":linux_spi" ] 33 } 34} 35 36pw_source_set("initiator") { 37 public_configs = [ ":public_include_path" ] 38 public = [ "public/pw_spi/initiator.h" ] 39 public_deps = [ 40 "$dir_pw_assert", 41 "$dir_pw_bytes", 42 "$dir_pw_status", 43 ] 44} 45 46pw_source_set("chip_selector") { 47 public_configs = [ ":public_include_path" ] 48 public = [ "public/pw_spi/chip_selector.h" ] 49 public_deps = [ "$dir_pw_status" ] 50} 51 52pw_source_set("device") { 53 public_configs = [ ":public_include_path" ] 54 public = [ "public/pw_spi/device.h" ] 55 public_deps = [ 56 ":chip_selector", 57 ":initiator", 58 "$dir_pw_bytes", 59 "$dir_pw_status", 60 "$dir_pw_sync:borrow", 61 ] 62} 63 64pw_source_set("mock") { 65 public_configs = [ ":public_include_path" ] 66 public = [ 67 "public/pw_spi/chip_selector_mock.h", 68 "public/pw_spi/initiator_mock.h", 69 ] 70 sources = [ "initiator_mock.cc" ] 71 public_deps = [ 72 ":chip_selector", 73 ":initiator", 74 "$dir_pw_bytes", 75 "$dir_pw_containers:to_array", 76 ] 77 deps = [ 78 "$dir_pw_assert", 79 "$dir_pw_containers", 80 "$dir_pw_unit_test", 81 ] 82} 83 84# Linux-specific spidev implementation. 85pw_source_set("linux_spi") { 86 public_configs = [ ":public_include_path" ] 87 public = [ "public/pw_spi/linux_spi.h" ] 88 public_deps = [ 89 ":device", 90 "$dir_pw_bytes", 91 "$dir_pw_log", 92 "$dir_pw_status", 93 "$dir_pw_sync:borrow", 94 "$dir_pw_sync:mutex", 95 ] 96 sources = [ "linux_spi.cc" ] 97} 98 99pw_test_group("tests") { 100 tests = [ 101 ":spi_test", 102 ":initiator_mock_test", 103 ] 104} 105 106pw_test("spi_test") { 107 sources = [ "spi_test.cc" ] 108 deps = [ 109 ":device", 110 "$dir_pw_sync:mutex", 111 ] 112} 113 114pw_test("initiator_mock_test") { 115 sources = [ "initiator_mock_test.cc" ] 116 deps = [ 117 ":mock", 118 "$dir_pw_containers", 119 ] 120} 121 122pw_doc_group("docs") { 123 sources = [ "docs.rst" ] 124} 125