1# Copyright 2023 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") 16import("$dir_pw_build/error.gni") 17import("$dir_pw_build/target_types.gni") 18import("$dir_pw_chrono/backend.gni") 19import("$dir_pw_docgen/docs.gni") 20import("$dir_pw_unit_test/test.gni") 21import("chre.gni") 22 23# This file defines a GN source_set for an external installation of chre. 24# To use, checkout the chre source into a directory, then set the build arg 25# dir_pw_third_party_chre to point to that directory. The chre library 26# will be available in GN at "$dir_pw_third_party/chre". 27if (dir_pw_third_party_chre == "") { 28} else { 29 config("disable_warnings") { 30 cflags = [ 31 "-Wno-cast-qual", 32 "-Wno-int-in-bool-context", 33 "-Wno-thread-safety-analysis", 34 "-Wno-vla", 35 ] 36 visibility = [ ":*" ] 37 } 38 39 config("default_chre_config_defines") { 40 cflags = [ 41 "-DCHRE_MESSAGE_TO_HOST_MAX_SIZE=2048", 42 "-DCHRE_MINIMUM_LOG_LEVEL=CHRE_LOG_LEVEL_DEBUG", 43 "-DCHRE_ASSERTIONS_DISABLED", 44 "-DCHRE_FILENAME=__FILE__", 45 "-DCHRE_PATCH_VERSION=1", 46 "-DCHRE_PLATFORM_ID=1", 47 "-DCHRE_FIRST_SUPPORTED_API_VERSION=CHRE_API_VERSION_1_1", 48 "-DCHRE_VARIANT_SUPPLIES_STATIC_NANOAPP_LIST", 49 "-DCHRE_NANOAPP_INTERNAL", 50 ] 51 } 52 53 pw_source_set("default_chre_config") { 54 public_configs = [ ":default_chre_config_defines" ] 55 } 56 57 pw_source_set("config") { 58 public_deps = [ pw_chre_CONFIG ] 59 } 60 61 config("public_includes") { 62 include_dirs = [ 63 "$dir_pw_third_party_chre/core/include", 64 "$dir_pw_third_party_chre/chre_api/include", 65 "$dir_pw_third_party_chre/chre_api/include/chre_api", 66 "$dir_pw_third_party_chre/pal/include", 67 "$dir_pw_third_party_chre/platform/include", 68 "$dir_pw_third_party_chre/platform/shared/include", 69 "$dir_pw_third_party_chre/util/include", 70 "$dir_pw_third_party_chre/apps/include", 71 ] 72 visibility = [ ":*" ] 73 } 74 75 pw_source_set("chre_headers") { 76 public_configs = [ ":public_includes" ] 77 public_deps = [ ":config" ] 78 } 79 80 pw_source_set("shared_platform") { 81 public_configs = [ ":disable_warnings" ] 82 sources = [ 83 "$dir_pw_third_party_chre/platform/shared/chre_api_core.cc", 84 "$dir_pw_third_party_chre/platform/shared/chre_api_re.cc", 85 "$dir_pw_third_party_chre/platform/shared/chre_api_user_settings.cc", 86 "$dir_pw_third_party_chre/platform/shared/chre_api_version.cc", 87 "$dir_pw_third_party_chre/platform/shared/memory_manager.cc", 88 "$dir_pw_third_party_chre/platform/shared/nanoapp/nanoapp_dso_util.cc", 89 "$dir_pw_third_party_chre/platform/shared/system_time.cc", 90 ] 91 92 # CHRE does not compile on MacOS, so work around this. 93 if (current_os == "mac") { 94 sources += [ "version.cc" ] 95 } else { 96 sources += [ "$dir_pw_third_party_chre/platform/shared/version.cc" ] 97 } 98 99 public_deps = [ 100 ":chre_headers", 101 "$pw_chre_PLATFORM_BACKEND_HEADERS", 102 ] 103 remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] 104 } 105 106 pw_source_set("chre") { 107 public_configs = [ ":disable_warnings" ] 108 sources = [ 109 "$dir_pw_third_party_chre/core/debug_dump_manager.cc", 110 "$dir_pw_third_party_chre/core/event.cc", 111 "$dir_pw_third_party_chre/core/event_loop.cc", 112 "$dir_pw_third_party_chre/core/event_loop_manager.cc", 113 "$dir_pw_third_party_chre/core/event_ref_queue.cc", 114 "$dir_pw_third_party_chre/core/host_comms_manager.cc", 115 "$dir_pw_third_party_chre/core/init.cc", 116 "$dir_pw_third_party_chre/core/log.cc", 117 "$dir_pw_third_party_chre/core/nanoapp.cc", 118 "$dir_pw_third_party_chre/core/settings.cc", 119 "$dir_pw_third_party_chre/core/static_nanoapps.cc", 120 "$dir_pw_third_party_chre/core/timer_pool.cc", 121 "$dir_pw_third_party_chre/util/buffer_base.cc", 122 "$dir_pw_third_party_chre/util/dynamic_vector_base.cc", 123 "$dir_pw_third_party_chre/util/system/debug_dump.cc", 124 "$dir_pw_third_party_chre/util/system/event_callbacks.cc", 125 ] 126 127 public_deps = [ 128 ":chre_headers", 129 "$pw_chre_PLATFORM_BACKEND", 130 ] 131 remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] 132 } 133 134 pw_source_set("example_apps") { 135 sources = [ 136 "$dir_pw_third_party_chre/apps/debug_dump_world/debug_dump_world.cc", 137 "$dir_pw_third_party_chre/apps/hello_world/hello_world.cc", 138 "$dir_pw_third_party_chre/apps/message_world/message_world.cc", 139 "$dir_pw_third_party_chre/apps/spammer/spammer.cc", 140 "$dir_pw_third_party_chre/apps/timer_world/timer_world.cc", 141 "$dir_pw_third_party_chre/apps/unload_tester/unload_tester.cc", 142 ] 143 public_deps = [ ":chre" ] 144 } 145 146 config("test_includes") { 147 include_dirs = [ 148 "$dir_pw_third_party_chre/platform/shared", 149 "$dir_pw_third_party_chre/test/simulation/inc", 150 ] 151 visibility = [ ":*" ] 152 } 153 154 config("tests_disable_warnings") { 155 cflags = [ "-Wno-sign-compare" ] 156 visibility = [ ":*" ] 157 } 158 159 pw_test("unit_tests") { 160 enable_if = 161 dir_pw_third_party_chre != "" && pw_chrono_SYSTEM_CLOCK_BACKEND != "" 162 sources = [ 163 "$dir_pw_third_party_chre/util/tests/blocking_queue_test.cc", 164 "$dir_pw_third_party_chre/util/tests/buffer_test.cc", 165 "$dir_pw_third_party_chre/util/tests/conditional_lock_guard_test.cc", 166 "$dir_pw_third_party_chre/util/tests/debug_dump_test.cc", 167 "$dir_pw_third_party_chre/util/tests/lock_guard_test.cc", 168 "$dir_pw_third_party_chre/util/tests/optional_test.cc", 169 "$dir_pw_third_party_chre/util/tests/ref_base_test.cc", 170 "$dir_pw_third_party_chre/util/tests/shared_ptr_test.cc", 171 "$dir_pw_third_party_chre/util/tests/singleton_test.cc", 172 "$dir_pw_third_party_chre/util/tests/time_test.cc", 173 "$dir_pw_third_party_chre/util/tests/unique_ptr_test.cc", 174 ] 175 public_deps = [ ":chre" ] 176 public_configs = [ ":tests_disable_warnings" ] 177 remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] 178 } 179 180 pw_test("integration_tests") { 181 enable_if = 182 dir_pw_third_party_chre != "" && pw_chrono_SYSTEM_CLOCK_BACKEND != "" 183 sources = [ 184 "$dir_pw_third_party_chre/test/simulation/memory_test.cc", 185 "$dir_pw_third_party_chre/test/simulation/test_util.cc", 186 "$dir_pw_third_party_chre/test/simulation/timer_test.cc", 187 "integration_test.cc", 188 ] 189 190 public_deps = [ ":chre" ] 191 public_configs = [ 192 ":test_includes", 193 ":tests_disable_warnings", 194 ] 195 remove_configs = [ "$dir_pw_build:internal_strict_warnings" ] 196 } 197} 198