Skip to content

Commit b81667b

Browse files
committed
Wrap entire utility classed by __has_include.
This is very complicated. Because of this class library is a collection, entire library will be build even some are not used. In the cae certain hardwaer/xxx library in the Pico SDK, depending class in this collection will be fail to compile. So, we need to wrap the utility classes by __has_include to avoid this problem.
1 parent c9311f0 commit b81667b

10 files changed

Lines changed: 31 additions & 0 deletions

src/codec/adau1361.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Created on: 2018/05/11
55
* Author: Seiichi "Suikan" Horie
66
*/
7+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
78

89
// GCC/Clang : Promote the switch-enum warning to error.
910
// MSVC : ignored.
@@ -134,3 +135,5 @@ void ::rpp_driver::Adau1361::Mute(CodecChannel channel, bool mute) {
134135
}
135136
CODEC_SYSLOG("Leave.")
136137
}
138+
139+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)

src/codec/adau1361.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#ifndef PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_
1111
#define PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_
12+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
1213

1314
#include <i2c/i2cmaster.hpp>
1415

@@ -217,4 +218,6 @@ class MockAdau1361 : public Adau1361 {
217218

218219
} // namespace rpp_driver
219220

221+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
222+
220223
#endif /* PICO_DRIVER_SRC_CODEC_ADAU1361_HPP_ */

src/codec/adau1361lower.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
2+
13
#include "adau1361lower.hpp"
24

35
#include <assert.h>
@@ -765,3 +767,5 @@ void ::rpp_driver::Adau1361Lower::SetHpOutputGain(float left_gain,
765767
// SET RHPVOL : R30
766768
SendCommand(txbuf, 3);
767769
}
770+
771+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)

src/codec/adau1361lower.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#ifndef PICO_DRIVER_SRC_CODEC_ADAU1361LOWER_HPP_
1111
#define PICO_DRIVER_SRC_CODEC_ADAU1361LOWER_HPP_
12+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
1213

1314
#include "i2c/i2cmaster.hpp"
1415

@@ -260,4 +261,6 @@ class MockAdau1361Lower : public Adau1361Lower {
260261
// GCOVR_EXCL_STOP
261262
} // namespace rpp_driver
262263

264+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
265+
263266
#endif /* PICO_DRIVER_SRC_CODEC_ADAU1361LOWER_HPP_ */

src/codec/umbadau1361lower.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
2+
13
#include "umbadau1361lower.hpp"
24

35
#include <assert.h>
@@ -34,3 +36,5 @@ void ::rpp_driver::UmbAdau1361Lower::ConfigureSignalPath() {
3436
config_UMB_ADAU1361A,
3537
sizeof(config_UMB_ADAU1361A) / 3); // init UMB-ADAU1361 as default state.
3638
}
39+
40+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)

src/codec/umbadau1361lower.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#ifndef PICO_DRIVER_SRC_CODEC_UMBADAU1361LOWER_HPP_
1111
#define PICO_DRIVER_SRC_CODEC_UMBADAU1361LOWER_HPP_
12+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
1213

1314
#include "codec/adau1361lower.hpp"
1415
#include "i2c/i2cmaster.hpp"
@@ -49,5 +50,6 @@ class UmbAdau1361Lower : public Adau1361Lower {
4950
};
5051

5152
} // namespace rpp_driver
53+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
5254

5355
#endif /* PICO_DRIVER_SRC_CODEC_UMBADAU1361LOWER_HPP_ */

src/i2c/i2cmaster.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
2+
13
#include "i2cmaster.hpp"
24

35
::rpp_driver::I2cMaster::I2cMaster(SdkWrapper& sdk, i2c_inst_t& i2c,
@@ -31,3 +33,4 @@ bool rpp_driver::I2cMaster::IsDeviceExisting(uint8_t addr) {
3133
return (PICO_ERROR_GENERIC !=
3234
ReadBlocking(addr, dummy_buf, sizeof(dummy_buf), false));
3335
}
36+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)

src/i2c/i2cmaster.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#ifndef PICO_DRIVER_SRC_I2C_I2CMASATER_HPP_
1212
#define PICO_DRIVER_SRC_I2C_I2CMASATER_HPP_
13+
#if __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
1314

1415
#include <stdint.h>
1516

@@ -161,5 +162,6 @@ class MockI2cMaster : public I2cMaster {
161162
#endif // __has_include(<gmock/gmock.h>)
162163

163164
}; // namespace rpp_driver
165+
#endif // __has_include(<hardware/i2c.h>) || __has_include(<gmock/gmock.h>)
164166

165167
#endif /* PICO_DRIVER_SRC_I2C_I2CMASATER_HPP_ */

src/i2s/i2sslaveduplex.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if __has_include(<hardware/pio.h>) || __has_include(<gmock/gmock.h>)
2+
13
#include "i2s/i2sslaveduplex.hpp"
24

35
#include "sdk/sdkwrapper.hpp"
@@ -130,3 +132,5 @@ void rpp_driver::I2sSlaveDuplex::Stop() {
130132
// We don't unclaim the state machine.
131133
// The SM will be unclaimed by destructor.
132134
}
135+
136+
#endif // __has_include(<hardware/pio.h>) || __has_include(<gmock/gmock.h>)

src/i2s/i2sslaveduplex.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#ifndef PICO_DRIVER_SRC_I2S_DUPLEXSLAVEI2S_HPP_
77
#define PICO_DRIVER_SRC_I2S_DUPLEXSLAVEI2S_HPP_
8+
#if __has_include(<hardware/pio.h>) || __has_include(<gmock/gmock.h>)
89

910
#if __has_include(<hardware/pio.h>)
1011
#include "hardware/pio.h"
@@ -194,4 +195,6 @@ class MockI2sSlaveDuplex : public I2sSlaveDuplex {
194195
#endif // __has_include(<gmock/gmock.h>)
195196
} // namespace rpp_driver
196197

198+
#endif // __has_include(<hardware/pio.h>) || __has_include(<gmock/gmock.h>)
199+
197200
#endif // PICO_DRIVER_SRC_I2S_DUPLEXSLAVEI2S_HPP_

0 commit comments

Comments
 (0)