Skip to content

Commit e83baeb

Browse files
committed
Add library build configuration file
ECCX08UtilsConfig.h file can be used to include/exclude utility library objects from the build process. By default all the utilities are built unless ArduinoIoTCloud.h file is included
1 parent aa3932f commit e83baeb

File tree

6 files changed

+54
-1
lines changed

6 files changed

+54
-1
lines changed

src/utility/ASN1Utils.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,7 @@ int ASN1UtilsClass::appendEcdsaWithSHA256(byte out[])
410410
return 12;
411411
}
412412

413+
#include "ECCX08UtilsConfig.h"
414+
#if defined(ECCX08_ENABLE_ASN1)
413415
ASN1UtilsClass ASN1Utils;
416+
#endif

src/utility/ECCX08CSR.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,7 @@ void ECCX08CSRClass::setCommonName(const char* commonName)
173173
_commonName = commonName;
174174
}
175175

176-
176+
#include "ECCX08UtilsConfig.h"
177+
#if defined(ECCX08_ENABLE_CSR)
177178
ECCX08CSRClass ECCX08CSR;
179+
#endif

src/utility/ECCX08JWS.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,7 @@ String ECCX08JWSClass::sign(int slot, const String& header, const String& payloa
160160
return sign(slot, header.c_str(), payload.c_str());
161161
}
162162

163+
#include "ECCX08UtilsConfig.h"
164+
#if defined(ECCX08_ENABLE_JWS)
163165
ECCX08JWSClass ECCX08JWS;
166+
#endif

src/utility/ECCX08SelfSignedCert.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,7 @@ void ECCX08SelfSignedCertClass::appendCertInfo(uint8_t publicKey[], uint8_t buff
406406
*out++ = 0x00;
407407
}
408408

409+
#include "ECCX08UtilsConfig.h"
410+
#if defined(ECCX08_ENABLE_SSC)
409411
ECCX08SelfSignedCertClass ECCX08SelfSignedCert;
412+
#endif

src/utility/ECCX08UtilsConfig.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
This file is part of the ArduinoECCX08 library.
3+
Copyright (c) 2023 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#ifndef _ECCX08_UTILS_CONFIG_H_
21+
#define _ECCX08_UTILS_CONFIG_H_
22+
23+
#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
30+
#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
37+
#endif
38+
39+
#endif

src/utility/PEMUtils.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,7 @@ String PEMUtilsClass::base64Encode(const byte in[], unsigned int length, const c
6868
return out;
6969
}
7070

71+
#include "ECCX08UtilsConfig.h"
72+
#if defined(ECCX08_ENABLE_PEM)
7173
PEMUtilsClass PEMUtils;
74+
#endif

0 commit comments

Comments
 (0)