Skip to content

Commit 8d705de

Browse files
committed
Build configuration: use a more flexible and already used pattern
1 parent 1f0e05d commit 8d705de

File tree

6 files changed

+14
-24
lines changed

6 files changed

+14
-24
lines changed

src/utility/ECCX08UtilsConfig.h renamed to src/ECCX08Config.h

+4-14
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,13 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20-
#ifndef _ECCX08_UTILS_CONFIG_H_
21-
#define _ECCX08_UTILS_CONFIG_H_
20+
#ifndef _ECCX08_CONFIG_H_
21+
#define _ECCX08_CONFIG_H_
2222

2323
#if defined __has_include
24-
#if !__has_include ("ArduinoIoTCloud.h")
25-
#define ECCX08_ENABLE_ASN1 1
26-
#define ECCX08_ENABLE_CSR 1
27-
#define ECCX08_ENABLE_JWS 1
28-
#define ECCX08_ENABLE_SSC 1
29-
#define ECCX08_ENABLE_PEM 1
24+
#if __has_include (<ArduinoECCX08Config.h>)
25+
#include <ArduinoECCX08Config.h>
3026
#endif
31-
#else
32-
#define ECCX08_ENABLE_ASN1 1
33-
#define ECCX08_ENABLE_CSR 1
34-
#define ECCX08_ENABLE_JWS 1
35-
#define ECCX08_ENABLE_SSC 1
36-
#define ECCX08_ENABLE_PEM 1
3727
#endif
3828

3929
#endif

src/utility/ASN1Utils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20+
#include "ECCX08Config.h"
2021
#include "ASN1Utils.h"
2122

2223
int ASN1UtilsClass::versionLength()
@@ -410,7 +411,6 @@ int ASN1UtilsClass::appendEcdsaWithSHA256(byte out[])
410411
return 12;
411412
}
412413

413-
#include "ECCX08UtilsConfig.h"
414-
#if defined(ECCX08_ENABLE_ASN1)
414+
#if !defined(ECCX08_DISABLE_ASN1)
415415
ASN1UtilsClass ASN1Utils;
416416
#endif

src/utility/ECCX08CSR.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20+
#include "ECCX08Config.h"
2021
#include "ArduinoECCX08.h"
2122

2223
#include "ASN1Utils.h"
@@ -173,7 +174,6 @@ void ECCX08CSRClass::setCommonName(const char* commonName)
173174
_commonName = commonName;
174175
}
175176

176-
#include "ECCX08UtilsConfig.h"
177-
#if defined(ECCX08_ENABLE_CSR)
177+
#if !defined(ECCX08_DISABLE_CSR)
178178
ECCX08CSRClass ECCX08CSR;
179179
#endif

src/utility/ECCX08JWS.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20+
#include "ECCX08Config.h"
2021
#include "ECCX08.h"
2122

2223
#include "ASN1Utils.h"
@@ -160,7 +161,6 @@ String ECCX08JWSClass::sign(int slot, const String& header, const String& payloa
160161
return sign(slot, header.c_str(), payload.c_str());
161162
}
162163

163-
#include "ECCX08UtilsConfig.h"
164-
#if defined(ECCX08_ENABLE_JWS)
164+
#if !defined(ECCX08_DISABLE_JWS)
165165
ECCX08JWSClass ECCX08JWS;
166166
#endif

src/utility/ECCX08SelfSignedCert.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20+
#include "ECCX08Config.h"
2021
#include "ArduinoECCX08.h"
2122

2223
extern "C" {
@@ -406,7 +407,6 @@ void ECCX08SelfSignedCertClass::appendCertInfo(uint8_t publicKey[], uint8_t buff
406407
*out++ = 0x00;
407408
}
408409

409-
#include "ECCX08UtilsConfig.h"
410-
#if defined(ECCX08_ENABLE_SSC)
410+
#if !defined(ECCX08_DISABLE_SSC)
411411
ECCX08SelfSignedCertClass ECCX08SelfSignedCert;
412412
#endif

src/utility/PEMUtils.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
*/
1919

20+
#include "ECCX08Config.h"
2021
#include "PEMUtils.h"
2122

2223
String PEMUtilsClass::base64Encode(const byte in[], unsigned int length, const char* prefix, const char* suffix)
@@ -68,7 +69,6 @@ String PEMUtilsClass::base64Encode(const byte in[], unsigned int length, const c
6869
return out;
6970
}
7071

71-
#include "ECCX08UtilsConfig.h"
72-
#if defined(ECCX08_ENABLE_PEM)
72+
#if !defined(ECCX08_DISABLE_PEM)
7373
PEMUtilsClass PEMUtils;
7474
#endif

0 commit comments

Comments
 (0)