Skip to content

Commit 460ece0

Browse files
committed
Fix includes in BLE lib with IWYU and force others to include this
library via the umbrella header <ble/Ble.h>.
1 parent fcc11b8 commit 460ece0

17 files changed

+142
-62
lines changed

src/ble/BLEEndPoint.cpp

+18-9
Original file line numberDiff line numberDiff line change
@@ -25,20 +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>
31+
#include <cstdint>
32+
#include <cstring>
33+
#include <utility>
3234

33-
#include <lib/core/CHIPConfig.h>
3435
#include <lib/support/BitFlags.h>
35-
#include <lib/support/CHIPFaultInjection.h>
3636
#include <lib/support/CodeUtils.h>
3737
#include <lib/support/logging/CHIPLogging.h>
38-
39-
#include <ble/BLEEndPoint.h>
40-
#include <ble/BleLayer.h>
41-
#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"
4251

4352
// Define below to enable extremely verbose, BLE end point-specific debug logging.
4453
#undef CHIP_BLE_END_POINT_DEBUG_LOGGING_ENABLED

src/ble/BLEEndPoint.h

+15-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,23 @@
2727

2828
#pragma once
2929

30+
#ifndef _CHIP_BLE_BLE_H
31+
#error "Please include <ble/Ble.h> instead!"
32+
#endif
33+
34+
#include <cstdint>
35+
36+
#include <lib/core/CHIPError.h>
37+
#include <lib/support/BitFlags.h>
38+
#include <lib/support/DLLUtil.h>
3039
#include <system/SystemLayer.h>
40+
#include <system/SystemPacketBuffer.h>
3141

32-
#include <ble/BleRole.h>
33-
#include <ble/BtpEngine.h>
42+
#include "BleConnectionDelegate.h"
43+
#include "BleLayerDelegate.h"
44+
#include "BlePlatformDelegate.h"
45+
#include "BleRole.h"
46+
#include "BtpEngine.h"
3447

3548
namespace chip {
3649
namespace Ble {
@@ -46,8 +59,6 @@ enum
4659
// Forward declarations
4760
class BleLayer;
4861
class BleEndPointPool;
49-
// BLEEndPoint holds a pointer to BleLayerDelegate for messages, while BleLayerDelegate functions also accepts BLEEndPoint.
50-
class BleLayerDelegate;
5162

5263
class DLL_EXPORT BLEEndPoint
5364
{

src/ble/Ble.h

+8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@
2828

2929
#include <ble/BleConfig.h>
3030

31+
// Other includes check for the _CHIP_BLE_BLE_H define to ensure that the BLE
32+
// library is included correctly by others (via Ble.h umbrella header).
33+
#define _CHIP_BLE_BLE_H
34+
3135
#include <ble/BLEEndPoint.h>
3236
#include <ble/BleApplicationDelegate.h>
3337
#include <ble/BleConnectionDelegate.h>
3438
#include <ble/BleError.h>
3539
#include <ble/BleLayer.h>
40+
#include <ble/BleLayerDelegate.h>
3641
#include <ble/BlePlatformDelegate.h>
3742
#include <ble/BleUUID.h>
3843
#include <ble/BtpEngine.h>
44+
#include <ble/CHIPBleServiceData.h>
45+
46+
#undef _CHIP_BLE_BLE_H
3947

4048
/**
4149
* @namespace Ble

src/ble/BleApplicationDelegate.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@
2424

2525
#pragma once
2626

27-
#include <ble/BleConfig.h>
27+
#ifndef _CHIP_BLE_BLE_H
28+
#error "Please include <ble/Ble.h> instead!"
29+
#endif
2830

2931
#include <lib/support/DLLUtil.h>
3032

33+
#include "BleConfig.h"
34+
3135
namespace chip {
3236
namespace Ble {
3337

src/ble/BleConnectionDelegate.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@
2323

2424
#pragma once
2525

26-
#include <ble/BleConfig.h>
27-
#include <ble/BleError.h>
26+
#ifndef _CHIP_BLE_BLE_H
27+
#error "Please include <ble/Ble.h> instead!"
28+
#endif
2829

2930
#include <lib/support/DLLUtil.h>
3031
#include <lib/support/SetupDiscriminator.h>
3132

33+
#include "BleConfig.h"
34+
#include "BleError.h"
35+
3236
namespace chip {
3337
namespace Ble {
3438
class BleLayer;

src/ble/BleError.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
* This file contains functions for working with BLE Layer errors.
2222
*/
2323

24-
#include <stddef.h>
24+
#define _CHIP_BLE_BLE_H
25+
#include "BleError.h"
2526

26-
#include <ble/BleConfig.h>
27-
#include <ble/BleError.h>
28-
#include <ble/BleLayer.h>
27+
#include <lib/core/ErrorStr.h>
2928

3029
namespace chip {
3130
namespace Ble {

src/ble/BleError.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030

3131
#pragma once
3232

33-
#include "BleConfig.h"
33+
#ifndef _CHIP_BLE_BLE_H
34+
#error "Please include <ble/Ble.h> instead!"
35+
#endif
36+
37+
#include <cstdint>
3438

3539
#include <lib/core/CHIPError.h>
3640

src/ble/BleLayer.cpp

+17-8
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,28 @@
5050
* drive BLE data and control input up the stack.
5151
*/
5252

53-
#include <ble/BleConfig.h>
53+
#define _CHIP_BLE_BLE_H
54+
#include "BleLayer.h"
5455

55-
#include <string.h>
56-
57-
#include <ble/BLEEndPoint.h>
58-
#include <ble/BleApplicationDelegate.h>
59-
#include <ble/BleLayer.h>
60-
#include <ble/BlePlatformDelegate.h>
61-
#include <ble/BleUUID.h>
56+
#include <cstring>
57+
#include <utility>
6258

6359
#include <lib/core/CHIPEncoding.h>
6460
#include <lib/support/CodeUtils.h>
61+
#include <lib/support/SetupDiscriminator.h>
6562
#include <lib/support/logging/CHIPLogging.h>
63+
#include <system/SystemLayer.h>
64+
#include <system/SystemPacketBuffer.h>
65+
66+
#include "BLEEndPoint.h"
67+
#include "BleApplicationDelegate.h"
68+
#include "BleConfig.h"
69+
#include "BleConnectionDelegate.h"
70+
#include "BleError.h"
71+
#include "BleLayerDelegate.h"
72+
#include "BlePlatformDelegate.h"
73+
#include "BleRole.h"
74+
#include "BleUUID.h"
6675

6776
// Magic values expected in first 2 bytes of valid BLE transport capabilities request or response:
6877
#define CAPABILITIES_MSG_CHECK_BYTE_1 0b01100101

src/ble/BleLayer.h

+14-15
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,26 @@
4747

4848
#pragma once
4949

50-
#include <stdint.h>
50+
#ifndef _CHIP_BLE_BLE_H
51+
#error "Please include <ble/Ble.h> instead!"
52+
#endif
5153

52-
#include <ble/BleConfig.h>
54+
#include <cstddef>
55+
#include <cstdint>
5356

57+
#include <lib/core/CHIPError.h>
58+
#include <lib/support/DLLUtil.h>
5459
#include <lib/support/SetupDiscriminator.h>
5560
#include <system/SystemLayer.h>
5661
#include <system/SystemPacketBuffer.h>
5762

58-
#include <ble/BleApplicationDelegate.h>
59-
#include <ble/BleConnectionDelegate.h>
60-
#include <ble/BleError.h>
61-
#include <ble/BleLayerDelegate.h>
62-
#include <ble/BlePlatformDelegate.h>
63-
#include <ble/BleRole.h>
64-
#include <ble/BleUUID.h>
63+
#include "BleApplicationDelegate.h"
64+
#include "BleConfig.h"
65+
#include "BleConnectionDelegate.h"
66+
#include "BleLayerDelegate.h"
67+
#include "BlePlatformDelegate.h"
68+
#include "BleRole.h"
69+
#include "BleUUID.h"
6570

6671
namespace chip {
6772
namespace Ble {
@@ -78,10 +83,6 @@ namespace Ble {
7883
#define CHIP_BLE_TRANSPORT_PROTOCOL_MIN_SUPPORTED_VERSION kBleTransportProtocolVersion_V4
7984
#define CHIP_BLE_TRANSPORT_PROTOCOL_MAX_SUPPORTED_VERSION kBleTransportProtocolVersion_V4
8085

81-
/// Forward declarations.
82-
class BleLayer;
83-
class BLEEndPoint;
84-
8586
/// Enum defining versions of CHIP over BLE transport protocol.
8687
typedef enum
8788
{
@@ -344,5 +345,3 @@ class DLL_EXPORT BleLayer
344345

345346
} /* namespace Ble */
346347
} /* namespace chip */
347-
348-
#include "BLEEndPoint.h"

src/ble/BleLayerDelegate.h

+12-4
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,23 @@
2323

2424
#pragma once
2525

26-
#include <ble/BLEEndPoint.h>
27-
#include <ble/BleConfig.h>
28-
#include <ble/BleError.h>
29-
#include <ble/BleUUID.h>
26+
#ifndef _CHIP_BLE_BLE_H
27+
#error "Please include <ble/Ble.h> instead!"
28+
#endif
29+
3030
#include <system/SystemPacketBuffer.h>
3131

32+
#include "BleConfig.h"
33+
#include "BleError.h"
34+
#include "BleUUID.h"
35+
3236
namespace chip {
3337
namespace Ble {
3438

39+
// BLEEndPoint holds a pointer to BleLayerDelegate for messages,
40+
// while BleLayerDelegate functions also accepts BLEEndPoint.
41+
class BLEEndPoint;
42+
3543
class BleLayerDelegate
3644
{
3745
public:

src/ble/BlePlatformDelegate.h

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@
2424

2525
#pragma once
2626

27-
#include <ble/BleConfig.h>
28-
29-
#include <ble/BleUUID.h>
27+
#ifndef _CHIP_BLE_BLE_H
28+
#error "Please include <ble/Ble.h> instead!"
29+
#endif
3030

3131
#include <lib/support/DLLUtil.h>
3232
#include <system/SystemPacketBuffer.h>
3333

34+
#include "BleConfig.h"
35+
#include "BleUUID.h"
36+
3437
namespace chip {
3538
namespace Ble {
3639

src/ble/BleRole.h

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818

1919
#pragma once
2020

21+
#ifndef _CHIP_BLE_BLE_H
22+
#error "Please include <ble/Ble.h> instead!"
23+
#endif
24+
2125
namespace chip {
2226
namespace Ble {
2327

src/ble/BleUUID.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
#include <ble/BleConfig.h>
18+
19+
#define _CHIP_BLE_BLE_H
20+
#include "BleUUID.h"
1921

2022
#include <cctype>
2123
#include <cstdint>
2224
#include <cstring>
2325

24-
#include "BleUUID.h"
25-
2626
namespace chip {
2727
namespace Ble {
2828

src/ble/BleUUID.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18+
1819
#pragma once
1920

20-
#include <stdint.h>
21+
#ifndef _CHIP_BLE_BLE_H
22+
#error "Please include <ble/Ble.h> instead!"
23+
#endif
24+
25+
#include <cstdint>
2126

2227
namespace chip {
2328
namespace Ble {

src/ble/BtpEngine.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@
2525
*
2626
*/
2727

28-
#include <ble/BleConfig.h>
28+
#define _CHIP_BLE_BLE_H
29+
#include "BtpEngine.h"
2930

30-
#include <ble/BtpEngine.h>
31+
#include <utility>
3132

33+
#include <lib/core/CHIPConfig.h>
34+
#include <lib/support/BitFlags.h>
3235
#include <lib/support/BufferReader.h>
3336
#include <lib/support/CodeUtils.h>
3437
#include <lib/support/logging/CHIPLogging.h>
38+
#include <system/SystemPacketBuffer.h>
39+
40+
#include "BleError.h"
3541

3642
// Define below to enable extremely verbose BLE-specific debug logging.
3743
#undef CHIP_BTP_PROTOCOL_ENGINE_DEBUG_LOGGING_ENABLED

src/ble/BtpEngine.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727

2828
#pragma once
2929

30-
#include <stdint.h>
31-
#include <string.h>
30+
#ifndef _CHIP_BLE_BLE_H
31+
#error "Please include <ble/Ble.h> instead!"
32+
#endif
3233

33-
#include <ble/BleConfig.h>
34+
#include <cstdint>
35+
#include <cstring>
3436

35-
#include <ble/BleError.h>
36-
#include <lib/support/BitFlags.h>
37+
#include <lib/core/CHIPError.h>
3738
#include <system/SystemPacketBuffer.h>
3839

3940
namespace chip {

src/ble/CHIPBleServiceData.h

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323

2424
#pragma once
2525

26+
#ifndef _CHIP_BLE_BLE_H
27+
#error "Please include <ble/Ble.h> instead!"
28+
#endif
29+
30+
#include <cstdint>
31+
2632
#include <lib/core/CHIPEncoding.h>
2733

2834
namespace chip {

0 commit comments

Comments
 (0)