Skip to content

Commit 9966940

Browse files
authored
Force including <ble/Ble.h> umbrella header instead of specific headers (#33023)
* Improve iwyu-check.py helper script * Remove ifdef guards from BLE module sources * Fix includes in BLE lib with IWYU and force others to include this library via the umbrella header <ble/Ble.h>. * Include <ble/Ble.h> instead of specific headers * Fix BLE unit tests compilation
1 parent 511c974 commit 9966940

File tree

108 files changed

+261
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+261
-219
lines changed

examples/all-clusters-app/asr/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#pragma once
2020

2121
#include "AppEvent.h"
22-
#include <ble/BLEEndPoint.h>
22+
#include <ble/Ble.h>
2323
#include <lega_rtos_api.h>
2424
#include <platform/CHIPDeviceLayer.h>
2525
#include <stdbool.h>

examples/all-clusters-app/infineon/psoc6/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "AppEvent.h"
2727
#include "FreeRTOS.h"
2828
#include "timers.h" // provides FreeRTOS timer support
29-
#include <ble/BLEEndPoint.h>
29+
#include <ble/Ble.h>
3030
#include <platform/CHIPDeviceLayer.h>
3131

3232
// Application-defined error codes in the CHIP_ERROR space.

examples/all-clusters-minimal-app/asr/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "AppEvent.h"
2525
#include "FreeRTOS.h"
2626
#include "timers.h" // provides FreeRTOS timer support
27-
#include <ble/BLEEndPoint.h>
27+
#include <ble/Ble.h>
2828
#include <platform/CHIPDeviceLayer.h>
2929

3030
// Application-defined error codes in the CHIP_ERROR space.

examples/all-clusters-minimal-app/infineon/psoc6/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "AppEvent.h"
2727
#include "FreeRTOS.h"
2828
#include "timers.h" // provides FreeRTOS timer support
29-
#include <ble/BLEEndPoint.h>
29+
#include <ble/Ble.h>
3030
#include <platform/CHIPDeviceLayer.h>
3131

3232
// Application-defined error codes in the CHIP_ERROR space.

examples/chef/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "AppEvent.h"
3030
#include "BaseApplication.h"
31-
#include <ble/BLEEndPoint.h>
31+
#include <ble/Ble.h>
3232
#include <cmsis_os2.h>
3333
#include <lib/core/CHIPError.h>
3434
#include <platform/CHIPDeviceLayer.h>

examples/light-switch-app/asr/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "FreeRTOS.h"
2727
#include "timers.h" // provides FreeRTOS timer support
28-
#include <ble/BLEEndPoint.h>
28+
#include <ble/Ble.h>
2929
#include <platform/CHIPDeviceLayer.h>
3030

3131
// Application-defined error codes in the CHIP_ERROR space.

examples/light-switch-app/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "AppEvent.h"
3030
#include "BaseApplication.h"
31-
#include <ble/BLEEndPoint.h>
31+
#include <ble/Ble.h>
3232
#include <cmsis_os2.h>
3333
#include <lib/core/CHIPError.h>
3434
#include <platform/CHIPDeviceLayer.h>

examples/lighting-app/infineon/psoc6/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "FreeRTOS.h"
2929
#include "timers.h" // provides FreeRTOS timer support
30-
#include <ble/BLEEndPoint.h>
30+
#include <ble/Ble.h>
3131
#include <platform/CHIPDeviceLayer.h>
3232

3333
// Application-defined error codes in the CHIP_ERROR space.

examples/lighting-app/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "AppEvent.h"
3030
#include "BaseApplication.h"
3131
#include "LightingManager.h"
32-
#include <ble/BLEEndPoint.h>
32+
#include <ble/Ble.h>
3333
#include <cmsis_os2.h>
3434
#include <lib/core/CHIPError.h>
3535
#include <platform/CHIPDeviceLayer.h>

examples/lit-icd-app/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "AppEvent.h"
3030
#include "BaseApplication.h"
31-
#include <ble/BLEEndPoint.h>
31+
#include <ble/Ble.h>
3232
#include <cmsis_os2.h>
3333
#include <lib/core/CHIPError.h>
3434
#include <platform/CHIPDeviceLayer.h>

examples/lock-app/asr/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "FreeRTOS.h"
2929
#include "timers.h" // provides FreeRTOS timer support
30-
#include <ble/BLEEndPoint.h>
30+
#include <ble/Ble.h>
3131
#include <platform/CHIPDeviceLayer.h>
3232

3333
// Application-defined error codes in the CHIP_ERROR space.

examples/lock-app/esp32/main/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <lock/BoltLockManager.h>
2525

2626
#include "freertos/FreeRTOS.h"
27-
#include <ble/BLEEndPoint.h>
27+
#include <ble/Ble.h>
2828
#include <lib/support/CodeUtils.h>
2929
#include <platform/CHIPDeviceLayer.h>
3030

examples/lock-app/infineon/psoc6/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "FreeRTOS.h"
2929
#include "timers.h" // provides FreeRTOS timer support
30-
#include <ble/BLEEndPoint.h>
30+
#include <ble/Ble.h>
3131
#include <platform/CHIPDeviceLayer.h>
3232

3333
// Application-defined error codes in the CHIP_ERROR space.

examples/lock-app/qpg/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "FreeRTOS.h"
2929
#include "timers.h" // provides FreeRTOS timer support
30-
#include <ble/BLEEndPoint.h>
30+
#include <ble/Ble.h>
3131
#include <lib/core/CHIPError.h>
3232
#include <platform/CHIPDeviceLayer.h>
3333

examples/lock-app/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "AppEvent.h"
3030
#include "BaseApplication.h"
3131
#include "LockManager.h"
32-
#include <ble/BLEEndPoint.h>
32+
#include <ble/Ble.h>
3333
#include <cmsis_os2.h>
3434
#include <lib/core/CHIPError.h>
3535
#include <platform/CHIPDeviceLayer.h>

examples/platform/silabs/BaseApplication.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <app/clusters/identify-server/identify-server.h>
3131
#include <app/server/AppDelegate.h>
3232
#include <app/util/config.h>
33-
#include <ble/BLEEndPoint.h>
33+
#include <ble/Ble.h>
3434
#include <cmsis_os2.h>
3535
#include <lib/core/CHIPError.h>
3636
#include <platform/CHIPDeviceEvent.h>

examples/pump-app/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "AppEvent.h"
3030
#include "BaseApplication.h"
3131
#include "PumpManager.h"
32-
#include <ble/BLEEndPoint.h>
32+
#include <ble/Ble.h>
3333
#include <cmsis_os2.h>
3434
#include <lib/core/CHIPError.h>
3535
#include <platform/CHIPDeviceLayer.h>

examples/smoke-co-alarm-app/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "AppEvent.h"
2828
#include "BaseApplication.h"
2929
#include "SmokeCoAlarmManager.h"
30-
#include <ble/BLEEndPoint.h>
30+
#include <ble/Ble.h>
3131
#include <cmsis_os2.h>
3232
#include <lib/core/CHIPError.h>
3333
#include <platform/CHIPDeviceLayer.h>

examples/temperature-measurement-app/asr/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "AppEvent.h"
2525
#include "FreeRTOS.h"
2626
#include "timers.h" // provides FreeRTOS timer support
27-
#include <ble/BLEEndPoint.h>
27+
#include <ble/Ble.h>
2828
#include <platform/CHIPDeviceLayer.h>
2929

3030
// Application-defined error codes in the CHIP_ERROR space.

examples/thermostat/asr/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "SensorManager.h"
2727
#include "TemperatureManager.h"
2828
#include "timers.h" // provides FreeRTOS timer support
29-
#include <ble/BLEEndPoint.h>
29+
#include <ble/Ble.h>
3030
#include <platform/CHIPDeviceLayer.h>
3131

3232
#include <FreeRTOS.h>

examples/thermostat/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "BaseApplication.h"
3535
#include "SensorManager.h"
3636
#include "TemperatureManager.h"
37-
#include <ble/BLEEndPoint.h>
37+
#include <ble/Ble.h>
3838
#include <cmsis_os2.h>
3939
#include <lib/core/CHIPError.h>
4040
#include <platform/CHIPDeviceLayer.h>

examples/window-app/silabs/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <stdint.h>
2828

2929
#include "BaseApplication.h"
30-
#include <ble/BLEEndPoint.h>
30+
#include <ble/Ble.h>
3131
#include <cmsis_os2.h>
3232
#include <lib/core/CHIPError.h>
3333
#include <platform/CHIPDeviceLayer.h>

scripts/helpers/iwyu-check.py

+27-28
Original file line numberDiff line numberDiff line change
@@ -51,42 +51,38 @@ def find_program(names):
5151
@click.command()
5252
@click.option(
5353
'--log-level',
54-
default='INFO',
54+
show_default=True,
55+
default='info',
5556
type=click.Choice(__LOG_LEVELS__.keys(), case_sensitive=False),
56-
help='Determines the verbosity of script output.')
57+
help='Set the verbosity of script output.')
5758
@click.option(
5859
'--no-log-timestamps',
5960
default=False,
6061
is_flag=True,
61-
help='Skip timestamps in log output')
62+
help='Skip timestamps in log output.')
6263
@click.option(
6364
'--compile-commands-glob',
6465
show_default=True,
65-
default=os.path.join(proj_root_dir, "out", "debug", "compile_commands*.json"),
66-
help='Set global pattern for compile_commands.json files'
67-
)
68-
@click.option(
69-
'--scanning-destination',
70-
show_default=True,
71-
default=os.path.join(proj_root_dir, "src", "platform"),
72-
help='Set scanning destination file(s) or directory /ies in project'
73-
)
66+
default=os.path.join(proj_root_dir, "out", "debug",
67+
"compile_commands*.json"),
68+
help='Set global pattern for compile_commands.json files.')
7469
@click.option(
7570
'--mapping-file-dir',
76-
help='Set mapping file directory /ies manually. File should have name iwyu.imp'
77-
)
71+
help='Set directory with iwyu.imp mapping file.')
7872
@click.option(
7973
'--iwyu-args',
8074
show_default=True,
8175
default="-Xiwyu --no_fwd_decls",
82-
help='Set custom arg(s) for include what you use'
83-
)
76+
help='Set custom arg(s) for include what you use.')
8477
@click.option(
8578
'--clang-args',
8679
default="",
87-
help='Set custom arg(s) for clang'
88-
)
89-
def main(compile_commands_glob, scanning_destination, mapping_file_dir,
80+
help='Set custom arg(s) for clang.')
81+
@click.argument(
82+
'source',
83+
nargs=-1,
84+
type=click.Path(exists=True))
85+
def main(compile_commands_glob, source, mapping_file_dir,
9086
iwyu_args, clang_args, log_level, no_log_timestamps):
9187
# Ensures somewhat pretty logging of what is going on
9288
log_fmt = '%(asctime)s %(levelname)-7s %(message)s'
@@ -114,8 +110,10 @@ def main(compile_commands_glob, scanning_destination, mapping_file_dir,
114110
for compile_commands in compile_commands_glob:
115111

116112
compile_commands_path = os.path.dirname(compile_commands)
117-
compile_commands_file = os.path.join(compile_commands_path, "compile_commands.json")
118-
logging.debug("Copy compile command file %s to %s", compile_commands, compile_commands_file)
113+
compile_commands_file = os.path.join(
114+
compile_commands_path, "compile_commands.json")
115+
logging.debug("Copy compile command file %s to %s",
116+
compile_commands, compile_commands_file)
119117

120118
with contextlib.suppress(shutil.SameFileError):
121119
shutil.copyfile(compile_commands, compile_commands_file)
@@ -153,14 +151,14 @@ def main(compile_commands_glob, scanning_destination, mapping_file_dir,
153151

154152
command_arr = [
155153
iwyu,
156-
"-p", compile_commands_path, scanning_destination,
154+
"-p", compile_commands_path, *source,
157155
"--", iwyu_args,
158156
"-Xiwyu", "--mapping_file=" + mapping_file_dir + "/iwyu.imp",
159157
] + platform_clang_args + [clang_args]
160158

161159
logging.info("Used compile commands: %s", compile_commands)
162160
logging.info("Scanning includes for platform: %s", platform)
163-
logging.info("Scanning destination: %s", scanning_destination)
161+
logging.info("Scanning sources(s): %s", ", ".join(source))
164162

165163
logging.debug("Command: %s", " ".join(command_arr))
166164
status = subprocess.Popen(" ".join(command_arr),
@@ -175,13 +173,13 @@ def main(compile_commands_glob, scanning_destination, mapping_file_dir,
175173
for line in status.stdout:
176174
line = line.rstrip()
177175

178-
if re.match(r"^warning:.*$", line):
176+
if re.search(r"^warning:", line):
179177
logger = logging.warning
180-
elif re.match(r"^.*([A-Za-z0-9]+(/[A-Za-z0-9]+)+)\.cpp should [a-zA-Z]+ these lines:$", line):
178+
elif re.search(r"should (add|remove)? these lines:$", line):
181179
logger = logging.warning
182-
elif re.match(r"^.*([A-Za-z0-9]+(/[A-Za-z0-9]+)+)\.[a-zA-Z]+ has correct #includes/fwd-decls\)$", line):
180+
elif re.search(r"has correct #includes/fwd-decls\)$", line):
183181
logger = logging.info
184-
elif re.match(r"^The full include-list for .*$", line):
182+
elif re.search(r"^The full include-list for", line):
185183
logger = logging.warning
186184
warning_in_files += 1
187185

@@ -190,7 +188,8 @@ def main(compile_commands_glob, scanning_destination, mapping_file_dir,
190188
logging.info("============== IWYU output end ================")
191189

192190
if warning_in_files:
193-
logging.error("Number of files with include issues: %d", warning_in_files)
191+
logging.error("Number of files with include issues: %d",
192+
warning_in_files)
194193
sys.exit(2)
195194
else:
196195
logging.info("Every include looks good!")

src/app/server/Server.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <app/util/ember-compatibility-functions.h>
2828

2929
#if CONFIG_NETWORK_LAYER_BLE
30-
#include <ble/BLEEndPoint.h>
30+
#include <ble/Ble.h>
3131
#endif
3232
#include <inet/IPAddress.h>
3333
#include <inet/InetError.h>

src/ble/BLEEndPoint.cpp

+18-13
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,29 @@
2525
*
2626
*/
2727

28-
#include <stdint.h>
29-
#include <string.h>
28+
#define _CHIP_BLE_BLE_H
29+
#include "BLEEndPoint.h"
3030

31-
#include <ble/BleConfig.h>
32-
33-
#if CONFIG_NETWORK_LAYER_BLE
34-
#include <lib/core/CHIPConfig.h>
31+
#include <cstdint>
32+
#include <cstring>
33+
#include <utility>
3534

3635
#include <lib/support/BitFlags.h>
37-
#include <lib/support/CHIPFaultInjection.h>
3836
#include <lib/support/CodeUtils.h>
3937
#include <lib/support/logging/CHIPLogging.h>
40-
41-
#include <ble/BLEEndPoint.h>
42-
#include <ble/BleLayer.h>
43-
#include <ble/BtpEngine.h>
38+
#include <system/SystemClock.h>
39+
#include <system/SystemLayer.h>
40+
#include <system/SystemPacketBuffer.h>
41+
42+
#include "BleApplicationDelegate.h"
43+
#include "BleConfig.h"
44+
#include "BleError.h"
45+
#include "BleLayer.h"
46+
#include "BleLayerDelegate.h"
47+
#include "BlePlatformDelegate.h"
48+
#include "BleRole.h"
49+
#include "BleUUID.h"
50+
#include "BtpEngine.h"
4451

4552
// Define below to enable extremely verbose, BLE end point-specific debug logging.
4653
#undef CHIP_BLE_END_POINT_DEBUG_LOGGING_ENABLED
@@ -1498,5 +1505,3 @@ void BLEEndPoint::HandleUnsubscribeTimeout(chip::System::Layer * systemLayer, vo
14981505

14991506
} /* namespace Ble */
15001507
} /* namespace chip */
1501-
1502-
#endif /* CONFIG_NETWORK_LAYER_BLE */

0 commit comments

Comments
 (0)