check_includes_config.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #
  2. # Copyright (c) 2022 Project CHIP Authors
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. """Configuration for #include checking."""
  17. from typing import Dict, Set
  18. # IGNORE lists source files that are not checked at all.
  19. #
  20. # Each entry is a string giving a Python regular expression,
  21. # un-anchored and case sensitive.
  22. IGNORE: Set[str] = {
  23. '/examples/',
  24. '/java/',
  25. '/Jni',
  26. '/pybindings/',
  27. '/python/',
  28. '/Test',
  29. '/tests/',
  30. '/tools/',
  31. # Platforms can opt in or out.
  32. '/darwin/',
  33. '/platform/Ameba/',
  34. '/platform/android/',
  35. '/platform/Beken/',
  36. '/platform/Infineon/CYW30739/',
  37. '/platform/Darwin/',
  38. '/platform/silabs/',
  39. '/platform/ESP32/',
  40. '/platform/fake/',
  41. '/platform/Linux/',
  42. '/platform/nxp/',
  43. '/platform/Tizen/',
  44. '/platform/Infineon/PSOC6/',
  45. '/platform/bouffalolab/BL602',
  46. '/platform/webos/',
  47. '/platform/mt793x/',
  48. '/platform/ASR/',
  49. r'POSIX\.h$',
  50. }
  51. # DENY lists disallowed include files.
  52. DENY: Set[str] = {
  53. # C++ headers often unsuitable for small platforms.
  54. 'chrono',
  55. 'clocale',
  56. 'coroutine',
  57. 'deque',
  58. 'exception',
  59. 'forward_list',
  60. 'fstream',
  61. 'iomanip',
  62. 'ios',
  63. 'iostream',
  64. 'istream',
  65. 'list',
  66. 'locale',
  67. 'locale.h',
  68. 'map',
  69. 'multimap',
  70. 'multiset',
  71. 'ostream',
  72. 'queue',
  73. 'set',
  74. 'sstream',
  75. 'stdexcept',
  76. 'streambuf',
  77. 'string',
  78. 'string_view',
  79. 'syncstream',
  80. 'unordered_map',
  81. 'unordered_set',
  82. 'vector',
  83. # CHIP headers using STL containers.
  84. 'lib/support/CHIPListUtils.h', # uses std::set
  85. 'src/platform/DeviceSafeQueue.h', # uses std::deque
  86. }
  87. # ALLOW describes exceptions to DENY.
  88. #
  89. # The dictionary key is the name of the file performing the #include.
  90. # The value is a set of names allowed to be included from that file
  91. # despite being in DENY.
  92. ALLOW: Dict[str, Set[str]] = {
  93. # Not intended for embedded clients (#11705).
  94. 'src/app/ClusterStateCache.h': {'list', 'map', 'set', 'vector', 'queue'},
  95. 'src/app/BufferedReadCallback.h': {'vector'},
  96. 'src/lib/support/IniEscaping.cpp': {'string'},
  97. 'src/lib/support/IniEscaping.h': {'string'},
  98. # Itself in DENY.
  99. 'src/lib/support/CHIPListUtils.h': {'set'},
  100. 'src/platform/DeviceSafeQueue.h': {'queue'},
  101. # Only uses <chrono> for zero-cost types.
  102. 'src/system/SystemClock.h': {'chrono'},
  103. 'src/platform/mbed/MbedEventTimeout.h': {'chrono'},
  104. 'src/app/app-platform/ContentApp.h': {'list', 'string'},
  105. 'src/app/clusters/application-basic-server/application-basic-delegate.h': {'list'},
  106. 'src/app/clusters/application-basic-server/application-basic-server.cpp': {'list'},
  107. 'src/app/clusters/application-launcher-server/application-launcher-delegate.h': {'list'},
  108. 'src/app/clusters/audio-output-server/audio-output-delegate.h': {'list'},
  109. 'src/app/clusters/channel-server/channel-delegate.h': {'list'},
  110. 'src/app/clusters/content-launch-server/content-launch-delegate.h': {'list'},
  111. 'src/app/clusters/content-launch-server/content-launch-server.cpp': {'list'},
  112. 'src/app/clusters/media-input-server/media-input-delegate.h': {'list'},
  113. 'src/app/clusters/media-playback-server/media-playback-delegate.h': {'list'},
  114. 'src/app/clusters/target-navigator-server/target-navigator-delegate.h': {'list'},
  115. 'src/credentials/attestation_verifier/FileAttestationTrustStore.h': {'vector'},
  116. 'src/credentials/attestation_verifier/FileAttestationTrustStore.cpp': {'string'},
  117. 'src/setup_payload/AdditionalDataPayload.h': {'string'},
  118. 'src/setup_payload/AdditionalDataPayloadParser.cpp': {'vector'},
  119. 'src/setup_payload/Base38Decode.h': {'string', 'vector'},
  120. 'src/setup_payload/ManualSetupPayloadGenerator.h': {'string'},
  121. 'src/setup_payload/ManualSetupPayloadParser.cpp': {'string', 'vector'},
  122. 'src/setup_payload/ManualSetupPayloadParser.h': {'string'},
  123. 'src/setup_payload/QRCodeSetupPayloadParser.cpp': {'vector'},
  124. 'src/setup_payload/QRCodeSetupPayloadParser.h': {'string'},
  125. 'src/setup_payload/SetupPayloadHelper.cpp': {'fstream'},
  126. 'src/setup_payload/SetupPayloadHelper.h': {'string'},
  127. 'src/setup_payload/SetupPayload.h': {'map', 'string', 'vector'},
  128. # Uses platform-define to switch between list and array
  129. 'src/lib/dnssd/minimal_mdns/ResponseSender.h': {'list'},
  130. # Not really for embedded consumers; uses std::deque to keep track
  131. # of a list of discovered things.
  132. 'src/controller/SetUpCodePairer.h': {'deque'},
  133. 'src/controller/ExamplePersistentStorage.cpp': {'fstream'},
  134. # Library meant for non-embedded
  135. 'src/tracing/json/json_tracing.cpp': {'string', 'sstream'},
  136. 'src/tracing/json/json_tracing.h': {'fstream'},
  137. # Not intended for embedded clients
  138. 'src/lib/support/jsontlv/JsonToTlv.cpp': {'sstream'},
  139. 'src/lib/support/jsontlv/JsonToTlv.h': {'string'},
  140. 'src/lib/support/jsontlv/TlvToJson.h': {'string'}
  141. }