Skip to content

Commit

Permalink
Merge pull request #55 from pennam/generic_config
Browse files Browse the repository at this point in the history
Build configuration: use a more flexible and already used pattern
  • Loading branch information
pennam authored Jan 29, 2024
2 parents 1f0e05d + 8d705de commit 00930c6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 24 deletions.
18 changes: 4 additions & 14 deletions src/utility/ECCX08UtilsConfig.h → src/ECCX08Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,13 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef _ECCX08_UTILS_CONFIG_H_
#define _ECCX08_UTILS_CONFIG_H_
#ifndef _ECCX08_CONFIG_H_
#define _ECCX08_CONFIG_H_

#if defined __has_include
#if !__has_include ("ArduinoIoTCloud.h")
#define ECCX08_ENABLE_ASN1 1
#define ECCX08_ENABLE_CSR 1
#define ECCX08_ENABLE_JWS 1
#define ECCX08_ENABLE_SSC 1
#define ECCX08_ENABLE_PEM 1
#if __has_include (<ArduinoECCX08Config.h>)
#include <ArduinoECCX08Config.h>
#endif
#else
#define ECCX08_ENABLE_ASN1 1
#define ECCX08_ENABLE_CSR 1
#define ECCX08_ENABLE_JWS 1
#define ECCX08_ENABLE_SSC 1
#define ECCX08_ENABLE_PEM 1
#endif

#endif
4 changes: 2 additions & 2 deletions src/utility/ASN1Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "ECCX08Config.h"
#include "ASN1Utils.h"

int ASN1UtilsClass::versionLength()
Expand Down Expand Up @@ -410,7 +411,6 @@ int ASN1UtilsClass::appendEcdsaWithSHA256(byte out[])
return 12;
}

#include "ECCX08UtilsConfig.h"
#if defined(ECCX08_ENABLE_ASN1)
#if !defined(ECCX08_DISABLE_ASN1)
ASN1UtilsClass ASN1Utils;
#endif
4 changes: 2 additions & 2 deletions src/utility/ECCX08CSR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "ECCX08Config.h"
#include "ArduinoECCX08.h"

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

#include "ECCX08UtilsConfig.h"
#if defined(ECCX08_ENABLE_CSR)
#if !defined(ECCX08_DISABLE_CSR)
ECCX08CSRClass ECCX08CSR;
#endif
4 changes: 2 additions & 2 deletions src/utility/ECCX08JWS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "ECCX08Config.h"
#include "ECCX08.h"

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

#include "ECCX08UtilsConfig.h"
#if defined(ECCX08_ENABLE_JWS)
#if !defined(ECCX08_DISABLE_JWS)
ECCX08JWSClass ECCX08JWS;
#endif
4 changes: 2 additions & 2 deletions src/utility/ECCX08SelfSignedCert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "ECCX08Config.h"
#include "ArduinoECCX08.h"

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

#include "ECCX08UtilsConfig.h"
#if defined(ECCX08_ENABLE_SSC)
#if !defined(ECCX08_DISABLE_SSC)
ECCX08SelfSignedCertClass ECCX08SelfSignedCert;
#endif
4 changes: 2 additions & 2 deletions src/utility/PEMUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "ECCX08Config.h"
#include "PEMUtils.h"

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

#include "ECCX08UtilsConfig.h"
#if defined(ECCX08_ENABLE_PEM)
#if !defined(ECCX08_DISABLE_PEM)
PEMUtilsClass PEMUtils;
#endif

0 comments on commit 00930c6

Please sign in to comment.