From 38b48cd88b7ff832bc854c4752aa8e01313a62c8 Mon Sep 17 00:00:00 2001 From: Matthias Suess Date: Tue, 12 Sep 2023 15:25:47 +0200 Subject: [PATCH 01/22] support for boost/filesystem.hpp Signed-off-by: Matthias Suess --- CMakeLists.txt | 6 ++ include/ocpp/common/pki_handler.hpp | 78 +++++++++++-------- include/ocpp/common/schemas.hpp | 18 ++++- include/ocpp/v16/charge_point.hpp | 20 +++-- .../ocpp/v16/charge_point_configuration.hpp | 12 ++- include/ocpp/v16/charge_point_impl.hpp | 20 +++-- include/ocpp/v16/database_handler.hpp | 12 ++- include/ocpp/v201/database_handler.hpp | 10 ++- .../ocpp/v201/device_model_storage_sqlite.hpp | 14 +++- lib/CMakeLists.txt | 20 ++++- lib/ocpp/common/pki_handler.cpp | 64 +++++++-------- lib/ocpp/common/schemas.cpp | 12 +-- lib/ocpp/common/websocket/websocket_tls.cpp | 8 +- lib/ocpp/v16/charge_point.cpp | 8 +- lib/ocpp/v16/charge_point_configuration.cpp | 8 +- lib/ocpp/v16/charge_point_impl.cpp | 10 +-- lib/ocpp/v16/database_handler.cpp | 8 +- 17 files changed, 216 insertions(+), 112 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3127ae9b3..c3ff33121 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,12 @@ option(BUILD_TESTING "Run unit tests" OFF) option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF) option(LIBOCPP_BUILD_EXAMPLES "Build charge_point and central_system binaries." OFF) option(OCPP_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT}) +option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) + +if(BOOSTFILESYSTEM) + add_definitions(-DBOOSTFILESYSTEM) +endif() + # dependencies find_package(Boost COMPONENTS program_options regex system thread REQUIRED) diff --git a/include/ocpp/common/pki_handler.hpp b/include/ocpp/common/pki_handler.hpp index 0502fadb9..8b85fbd1b 100644 --- a/include/ocpp/common/pki_handler.hpp +++ b/include/ocpp/common/pki_handler.hpp @@ -3,7 +3,11 @@ #ifndef OCPP_COMMON_PKI_HANDLER #define OCPP_COMMON_PKI_HANDLER -#include +#ifndef BOOSTFILESYSTEM + +#else +#include +#endif #include #include #include @@ -17,6 +21,12 @@ #include +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + namespace ocpp { enum class PkiEnum { @@ -51,21 +61,21 @@ using X509_STORE_CTX_ptr = std::unique_ptr; // filenames of ca certificates -const std::filesystem::path CSMS_ROOT_CA("CSMS_ROOT_CA.pem"); -const std::filesystem::path CSMS_ROOT_CA_BACKUP("CSMS_ROOT_CA_BACKUP.pem"); +const fs::path CSMS_ROOT_CA("CSMS_ROOT_CA.pem"); +const fs::path CSMS_ROOT_CA_BACKUP("CSMS_ROOT_CA_BACKUP.pem"); // filenames of leaf certificates, csrs and private keys -const std::filesystem::path CSMS_LEAF("CSMS_LEAF.pem"); -const std::filesystem::path CSMS_LEAF_KEY("CSMS_LEAF.key"); -const std::filesystem::path CSMS_LEAF_KEY_BACKUP("CSMS_LEAF_BACKUP.key"); -const std::filesystem::path CSMS_CSR("CSMS_CSR.pem"); -const std::filesystem::path V2G_LEAF("SECC_LEAF.pem"); // SECC_LEAF in ISO15118 -const std::filesystem::path V2G_LEAF_KEY("SECC_LEAF.key"); -const std::filesystem::path V2G_LEAF_KEY_BACKUP("SECC_LEAF_BACKUP.key"); -const std::filesystem::path V2G_CSR("SECC_CSR.pem"); +const fs::path CSMS_LEAF("CSMS_LEAF.pem"); +const fs::path CSMS_LEAF_KEY("CSMS_LEAF.key"); +const fs::path CSMS_LEAF_KEY_BACKUP("CSMS_LEAF_BACKUP.key"); +const fs::path CSMS_CSR("CSMS_CSR.pem"); +const fs::path V2G_LEAF("SECC_LEAF.pem"); // SECC_LEAF in ISO15118 +const fs::path V2G_LEAF_KEY("SECC_LEAF.key"); +const fs::path V2G_LEAF_KEY_BACKUP("SECC_LEAF_BACKUP.key"); +const fs::path V2G_CSR("SECC_CSR.pem"); struct X509Certificate { - std::filesystem::path path; + fs::path path; X509* x509; std::string str; CertificateType type; @@ -73,13 +83,13 @@ struct X509Certificate { int validTo; // seconds. If < 0 cert has expired X509Certificate(){}; - X509Certificate(std::filesystem::path path, X509* x509, std::string str); + X509Certificate(fs::path path, X509* x509, std::string str); ~X509Certificate(); /// \brief writes the X509 certificate to the path set bool write(); /// \brief writes the X509 certificate to the given \p path - bool write(const std::filesystem::path& path); + bool write(const fs::path& path); /// \brief Gets CN of certificate std::string getCommonName(); @@ -100,11 +110,11 @@ struct X509Certificate { OCSPRequestData getOCSPRequestData(); }; /// \brief loads a X509Certificate from the given \p pat -std::shared_ptr loadFromFile(const std::filesystem::path& path); +std::shared_ptr loadFromFile(const fs::path& path); /// \brief loads a X509Certificate from the given \p st std::shared_ptr loadFromString(std::string& str); /// \brief reads a file from the given \p path to a strin -std::string readFileToString(const std::filesystem::path& path); +std::string readFileToString(const fs::path& path); /// \brief Handler for verifying, installing, deleting and managing certificates and security related operations. /// Requires CA files to be located inside the following directory structure according to their use: @@ -123,18 +133,18 @@ std::string readFileToString(const std::filesystem::path& path); class PkiHandler { private: - std::filesystem::path certsPath; - std::filesystem::path caPath; - std::filesystem::path caCsmsPath; - std::filesystem::path caCsoPath; - std::filesystem::path caCpsPath; - std::filesystem::path caMfPath; - std::filesystem::path caMoPath; - std::filesystem::path caOemPath; - std::filesystem::path caV2gPath; - - std::filesystem::path clientCsmsPath; - std::filesystem::path clientCsoPath; + fs::path certsPath; + fs::path caPath; + fs::path caCsmsPath; + fs::path caCsoPath; + fs::path caCpsPath; + fs::path caMfPath; + fs::path caMoPath; + fs::path caOemPath; + fs::path caV2gPath; + + fs::path clientCsmsPath; + fs::path clientCsoPath; bool useRootCaFallback; @@ -159,13 +169,13 @@ class PkiHandler { std::vector> getCertificatesFromChain(const std::string& certChain); /// \brief Returns the path where the ca certificates of the given \p pki are located - std::filesystem::path getCaPath(const PkiEnum& pki); + fs::path getCaPath(const PkiEnum& pki); /// \brief Executes "openssl rehash" for the given \p caPath - void execOpenSSLRehash(const std::filesystem::path caPath); + void execOpenSSLRehash(const fs::path caPath); /// \brief Returns the file path of the CSMS root CA file - std::optional getCsmsCaFilePath(); + std::optional getCsmsCaFilePath(); /// \brief Returns the number of installed CSMS CA certificates int getNumberOfCsmsCaCertificates(); @@ -181,10 +191,10 @@ class PkiHandler { bool isCaCertificateAlreadyInstalled(const std::shared_ptr& certificate); public: - explicit PkiHandler(const std::filesystem::path& certsPath, const bool multipleCsmsCaNotAllowed); + explicit PkiHandler(const fs::path& certsPath, const bool multipleCsmsCaNotAllowed); /// \brief Returns the path where the certificates are located - std::filesystem::path getCaCsmsPath(); + fs::path getCaCsmsPath(); /// \brief Verifies the given \p certificate and the \p charge_box_serial_number using the /// CentralSystemRootCertificate This method verifies the certificate chain, the signature, and the period when the @@ -239,7 +249,7 @@ class PkiHandler { std::shared_ptr getLeafCertificate(const CertificateSigningUseEnum& certificate_signing_use); /// \brief Get the leaf private key of the given \p certificate_signing_use - std::filesystem::path getLeafPrivateKeyPath(const CertificateSigningUseEnum& certificate_signing_use); + fs::path getLeafPrivateKeyPath(const CertificateSigningUseEnum& certificate_signing_use); /// \brief Removes a fallback central system root certificate if present void removeCentralSystemFallbackCa(); diff --git a/include/ocpp/common/schemas.hpp b/include/ocpp/common/schemas.hpp index 65a901d7e..16c6c0f98 100644 --- a/include/ocpp/common/schemas.hpp +++ b/include/ocpp/common/schemas.hpp @@ -9,7 +9,11 @@ #include #include -#include +#ifndef BOOSTFILESYSTEM + +#else +#include +#endif #include #include @@ -17,6 +21,12 @@ using json = nlohmann::json; using json_uri = nlohmann::json_uri; using json_validator = nlohmann::json_schema::json_validator; +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + namespace ocpp { /// \brief Contains the json schema validation for the libocpp config @@ -24,8 +34,8 @@ class Schemas { private: json schema; std::shared_ptr validator; - std::filesystem::path schemas_path; - std::set available_schemas_paths; + fs::path schemas_path; + std::set available_schemas_paths; const static std::vector profiles; const static std::regex date_time_regex; @@ -37,7 +47,7 @@ class Schemas { public: /// \brief Creates a new Schemas object looking for the root schema file in relation to the provided \p main_dir - explicit Schemas(std::filesystem::path schemas_path); + explicit Schemas(fs::path schemas_path); /// \brief Provides the config schema /// \returns the config schema as as json object diff --git a/include/ocpp/v16/charge_point.hpp b/include/ocpp/v16/charge_point.hpp index 57a0fc7d3..a1efc96fd 100644 --- a/include/ocpp/v16/charge_point.hpp +++ b/include/ocpp/v16/charge_point.hpp @@ -2,7 +2,11 @@ // Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest #ifndef OCPP_V16_CHARGE_POINT_HPP #define OCPP_V16_CHARGE_POINT_HPP -#include +#ifndef BOOSTFILESYSTEM + +#else +#include +#endif #include #include @@ -25,6 +29,12 @@ #include #include +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + namespace ocpp { namespace v16 { class ChargePointImpl; @@ -56,10 +66,10 @@ class ChargePoint { /// \param certs_path this points to the directory where certificates used by libocpp are located, these are used /// for the "Improved security for OCPP 1.6-J" whitepaper (eg. Security Profile 3 TLS with Client Side Certificates) /// as well as for Plug & Charge. - explicit ChargePoint(const std::string& config, const std::filesystem::path& share_path, - const std::filesystem::path& user_config_path, const std::filesystem::path& database_path, - const std::filesystem::path& sql_init_path, const std::filesystem::path& message_log_path, - const std::filesystem::path& certs_path); + explicit ChargePoint(const std::string& config, const fs::path& share_path, + const fs::path& user_config_path, const fs::path& database_path, + const fs::path& sql_init_path, const fs::path& message_log_path, + const fs::path& certs_path); ~ChargePoint(); diff --git a/include/ocpp/v16/charge_point_configuration.hpp b/include/ocpp/v16/charge_point_configuration.hpp index 7a12d8a27..c21ebe9a8 100644 --- a/include/ocpp/v16/charge_point_configuration.hpp +++ b/include/ocpp/v16/charge_point_configuration.hpp @@ -8,6 +8,12 @@ #include #include +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + namespace ocpp { namespace v16 { @@ -15,7 +21,7 @@ namespace v16 { class ChargePointConfiguration { private: json config; - std::filesystem::path user_config_path; + fs::path user_config_path; std::set supported_feature_profiles; std::map> supported_measurands; @@ -33,8 +39,8 @@ class ChargePointConfiguration { bool isConnectorPhaseRotationValid(std::string str); public: - ChargePointConfiguration(const std::string& config, const std::filesystem::path& ocpp_main_path, - const std::filesystem::path& user_config_path); + ChargePointConfiguration(const std::string& config, const fs::path& ocpp_main_path, + const fs::path& user_config_path); // Internal config options std::string getChargePointId(); diff --git a/include/ocpp/v16/charge_point_impl.hpp b/include/ocpp/v16/charge_point_impl.hpp index 164f148a5..886cfb7b9 100644 --- a/include/ocpp/v16/charge_point_impl.hpp +++ b/include/ocpp/v16/charge_point_impl.hpp @@ -6,7 +6,11 @@ #include #include #include -#include +#ifndef BOOSTFILESYSTEM + +#else +#include +#endif #include #include #include @@ -78,6 +82,12 @@ #include #include +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + namespace ocpp { namespace v16 { @@ -314,10 +324,10 @@ class ChargePointImpl : ocpp::ChargingStationBase { /// \param certs_path this points to the directory where certificates used by libocpp are located, these are used /// for the "Improved security for OCPP 1.6-J" whitepaper (eg. Security Profile 3 TLS with Client Side Certificates) /// as well as for Plug & Charge. - explicit ChargePointImpl(const std::string& config, const std::filesystem::path& share_path, - const std::filesystem::path& user_config_path, const std::filesystem::path& database_path, - const std::filesystem::path& sql_init_path, const std::filesystem::path& message_log_path, - const std::filesystem::path& certs_path); + explicit ChargePointImpl(const std::string& config, const fs::path& share_path, + const fs::path& user_config_path, const fs::path& database_path, + const fs::path& sql_init_path, const fs::path& message_log_path, + const fs::path& certs_path); ~ChargePointImpl() { } diff --git a/include/ocpp/v16/database_handler.hpp b/include/ocpp/v16/database_handler.hpp index 58299f5ec..dc732af88 100644 --- a/include/ocpp/v16/database_handler.hpp +++ b/include/ocpp/v16/database_handler.hpp @@ -4,7 +4,11 @@ #define OCPP_V16_DATABASE_HANDLER_HPP #include "sqlite3.h" -#include +#ifndef BOOSTFILESYSTEM + +#else +#include +#endif #include #include @@ -14,6 +18,12 @@ #include #include +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + namespace ocpp { namespace v16 { diff --git a/include/ocpp/v201/database_handler.hpp b/include/ocpp/v201/database_handler.hpp index 436d4dd89..d200a9b67 100644 --- a/include/ocpp/v201/database_handler.hpp +++ b/include/ocpp/v201/database_handler.hpp @@ -5,7 +5,11 @@ #include "sqlite3.h" #include -#include +#ifndef BOOSTFILESYSTEM + +#else +#include +#endif #include #include @@ -14,7 +18,11 @@ #include +#ifndef BOOSTFILESYSTEM namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif namespace ocpp { namespace v201 { diff --git a/include/ocpp/v201/device_model_storage_sqlite.hpp b/include/ocpp/v201/device_model_storage_sqlite.hpp index c736376c5..617c69269 100644 --- a/include/ocpp/v201/device_model_storage_sqlite.hpp +++ b/include/ocpp/v201/device_model_storage_sqlite.hpp @@ -4,11 +4,21 @@ #ifndef DEVICE_MODEL_STORAGE_SQLITE_HPP #define DEVICE_MODEL_STORAGE_SQLITE_HPP -#include +#ifndef BOOSTFILESYSTEM + +#else +#include +#endif #include #include +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + namespace ocpp { namespace v201 { @@ -24,7 +34,7 @@ class DeviceModelStorageSqlite : public DeviceModelStorage { public: /// \brief Opens SQLite connection at given \p db_path /// \param db_path path to database - explicit DeviceModelStorageSqlite(const std::filesystem::path& db_path); + explicit DeviceModelStorageSqlite(const fs::path& db_path); std::map> get_device_model() final; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 588bd2a36..806787bd4 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -74,13 +74,30 @@ endif() ############# # End logging configuration ############# - + +if(NOT BOOSTFILESYSTEM) +target_link_libraries(ocpp + PUBLIC + everest::timer + websocketpp::websocketpp + nlohmann_json_schema_validator + PRIVATE + OpenSSL::SSL + OpenSSL::Crypto + SQLite::SQLite3 + Threads::Threads + + nlohmann_json::nlohmann_json + date::date-tz +) +else() target_link_libraries(ocpp PUBLIC everest::timer websocketpp::websocketpp nlohmann_json_schema_validator PRIVATE + Boost::filesystem OpenSSL::SSL OpenSSL::Crypto SQLite::SQLite3 @@ -89,6 +106,7 @@ target_link_libraries(ocpp nlohmann_json::nlohmann_json date::date-tz ) +endif() # FIXME (aw): right now nlohmann_json and boost::optional don't compile # with gcc 10.x and C++11/14, so we need to publish the diff --git a/lib/ocpp/common/pki_handler.cpp b/lib/ocpp/common/pki_handler.cpp index b4c769a5e..f54a5f1af 100644 --- a/lib/ocpp/common/pki_handler.cpp +++ b/lib/ocpp/common/pki_handler.cpp @@ -10,7 +10,7 @@ namespace ocpp { -X509Certificate::X509Certificate(std::filesystem::path path, X509* x509, std::string str) { +X509Certificate::X509Certificate(fs::path path, X509* x509, std::string str) { this->path = path; this->x509 = x509; this->str = str; @@ -139,7 +139,7 @@ CertificateType getRootCertificateTypeFromPki(const PkiEnum& pki) { } } -std::shared_ptr loadFromFile(const std::filesystem::path& path) { +std::shared_ptr loadFromFile(const fs::path& path) { try { X509* x509; std::string fileStr; @@ -196,7 +196,7 @@ std::shared_ptr loadFromString(const std::string& str) { return cert; } -PkiHandler::PkiHandler(const std::filesystem::path& certsPath, const bool multipleCsmsCaNotAllowed) : +PkiHandler::PkiHandler(const fs::path& certsPath, const bool multipleCsmsCaNotAllowed) : certsPath(certsPath) { this->caPath = this->certsPath / "ca"; @@ -228,7 +228,7 @@ PkiHandler::PkiHandler(const std::filesystem::path& certsPath, const bool multip std::vector pkis = {PkiEnum::CSO, PkiEnum::CSMS, PkiEnum::MF, PkiEnum::MO, PkiEnum::OEM, PkiEnum::V2G}; for (const auto& pki : pkis) { const auto caPath = this->getCaPath(pki); - if (std::filesystem::exists(caPath)) { + if (fs::exists(caPath)) { this->execOpenSSLRehash(caPath); } else { EVLOG_warning << "Certificate directory does not exist: " << caPath; @@ -236,13 +236,13 @@ PkiHandler::PkiHandler(const std::filesystem::path& certsPath, const bool multip } } -std::filesystem::path PkiHandler::getCaCsmsPath() { +fs::path PkiHandler::getCaCsmsPath() { return this->caCsmsPath; } int PkiHandler::getNumberOfCsmsCaCertificates() { int fileCounter = 0; - for (const auto& entry : std::filesystem::directory_iterator(this->caCsmsPath)) { + for (const auto& entry : fs::directory_iterator(this->caCsmsPath)) { if (entry.path().extension().string() == ".pem") { fileCounter++; } @@ -309,7 +309,7 @@ void PkiHandler::writeClientCertificate(const std::string& certificateChain, } else { auto leafCert = certificates.at(0); std::string newPath; - std::filesystem::path leafPath; + fs::path leafPath; if (certificate_use == CertificateSigningUseEnum::ChargingStationCertificate) { leafPath = this->clientCsmsPath / CSMS_LEAF; @@ -317,7 +317,7 @@ void PkiHandler::writeClientCertificate(const std::string& certificateChain, leafPath = this->clientCsoPath / V2G_LEAF; } - if (std::filesystem::exists(leafPath)) { + if (fs::exists(leafPath)) { const auto oldLeafPath = leafPath.parent_path() / (leafPath.filename().string().substr(0, leafPath.filename().string().find_last_of(".")) + @@ -341,8 +341,8 @@ std::string PkiHandler::generateCsr(const CertificateSigningUseEnum& certificate EC_KEY* ecKey = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); X509_NAME* x509Name = X509_REQ_get_subject_name(x509ReqPtr.get()); - std::filesystem::path csrFile; - std::filesystem::path privateKeyFile; + fs::path csrFile; + fs::path privateKeyFile; // FIXME(piet): This just overrides the private key and in case no valid certificate will be delivered by a future // CertificateSigned.req from CSMS for this CSR the private key is lost @@ -453,19 +453,19 @@ std::string PkiHandler::generateCsr(const CertificateSigningUseEnum& certificate } bool PkiHandler::isCentralSystemRootCertificateInstalled() { - return !std::filesystem::is_empty(this->getCaPath(PkiEnum::CSMS)); + return !fs::is_empty(this->getCaPath(PkiEnum::CSMS)); } bool PkiHandler::isV2GRootCertificateInstalled() { - return !std::filesystem::is_empty(this->getCaPath(PkiEnum::V2G)); + return !fs::is_empty(this->getCaPath(PkiEnum::V2G)); } bool PkiHandler::isManufacturerRootCertificateInstalled() { - return !std::filesystem::is_empty(this->getCaPath(PkiEnum::MF)); + return !fs::is_empty(this->getCaPath(PkiEnum::MF)); } bool PkiHandler::isCsmsLeafCertificateInstalled() { - return std::filesystem::exists(this->clientCsmsPath / CSMS_LEAF); + return fs::exists(this->clientCsmsPath / CSMS_LEAF); } std::optional> @@ -561,7 +561,7 @@ DeleteCertificateResult PkiHandler::deleteRootCertificate(CertificateHashDataTyp return DeleteCertificateResult::Failed; } found = true; - if (!std::filesystem::remove(cert->path)) { + if (!fs::remove(cert->path)) { removeFailed = true; } } @@ -652,7 +652,7 @@ PkiHandler::getLeafCertificate(const CertificateSigningUseEnum& certificate_sign std::shared_ptr cert = nullptr; int validIn = INT_MIN; - std::filesystem::path leafPath; + fs::path leafPath; if (certificate_signing_use == CertificateSigningUseEnum::ChargingStationCertificate) { leafPath = this->clientCsmsPath / CSMS_LEAF; } else { @@ -660,7 +660,7 @@ PkiHandler::getLeafCertificate(const CertificateSigningUseEnum& certificate_sign } // TODO(piet): Client certificate could be V2G_LEAF or CSMS_LEAF, possibly only one cert is set - for (const auto& dirEntry : std::filesystem::directory_iterator(leafPath.parent_path())) { + for (const auto& dirEntry : fs::directory_iterator(leafPath.parent_path())) { if (dirEntry.path().string().find(leafPath.filename().c_str()) != std::string::npos) { std::shared_ptr c = loadFromFile(dirEntry.path()); if (c != nullptr && c->validIn < 0 && c->validIn > validIn) { @@ -671,7 +671,7 @@ PkiHandler::getLeafCertificate(const CertificateSigningUseEnum& certificate_sign return cert; } -std::filesystem::path PkiHandler::getLeafPrivateKeyPath(const CertificateSigningUseEnum& certificate_signing_use) { +fs::path PkiHandler::getLeafPrivateKeyPath(const CertificateSigningUseEnum& certificate_signing_use) { if (certificate_signing_use == CertificateSigningUseEnum::ChargingStationCertificate) { return this->clientCsmsPath / CSMS_LEAF_KEY; } else { @@ -684,9 +684,9 @@ void PkiHandler::removeCentralSystemFallbackCa() { } void PkiHandler::useCsmsFallbackRoot() { - if (std::filesystem::exists(this->caCsmsPath / CSMS_ROOT_CA_BACKUP)) { + if (fs::exists(this->caCsmsPath / CSMS_ROOT_CA_BACKUP)) { std::remove((this->caCsmsPath / CSMS_ROOT_CA).c_str()); // remove recently installed ca - std::filesystem::path new_path = this->caCsmsPath / CSMS_ROOT_CA; + fs::path new_path = this->caCsmsPath / CSMS_ROOT_CA; std::rename((this->caCsmsPath / CSMS_ROOT_CA_BACKUP).c_str(), new_path.c_str()); this->execOpenSSLRehash(this->caCsmsPath); } else { @@ -719,8 +719,8 @@ void PkiHandler::updateOcspCache(const OCSPRequestData& ocspRequestData, const s cert->getSerialNumber() == ocspRequestData.serialNumber) { EVLOG_info << "Writing OCSP Response to filesystem"; const auto ocspPath = cert->path.parent_path() / "ocsp"; - if (!std::filesystem::exists(ocspPath)) { - std::filesystem::create_directories(ocspPath); + if (!fs::exists(ocspPath)) { + fs::create_directories(ocspPath); } const auto ocspFilePath = ocspPath / cert->path.filename().replace_extension(".ocsp.der"); std::ofstream fs(ocspFilePath.string()); @@ -886,7 +886,7 @@ bool PkiHandler::isCaCertificateAlreadyInstalled(const std::shared_ptrcaCsmsPath; @@ -907,10 +907,10 @@ std::filesystem::path PkiHandler::getCaPath(const PkiEnum& pki) { } } -void PkiHandler::execOpenSSLRehash(const std::filesystem::path caPath) { - for (const auto& entry : std::filesystem::directory_iterator(caPath)) { - if (std::filesystem::is_symlink(entry.path())) { - std::filesystem::remove(entry.path()); +void PkiHandler::execOpenSSLRehash(const fs::path caPath) { + for (const auto& entry : fs::directory_iterator(caPath)) { + if (fs::is_symlink(entry.path())) { + fs::remove(entry.path()); } } @@ -920,9 +920,9 @@ void PkiHandler::execOpenSSLRehash(const std::filesystem::path caPath) { } } -std::optional PkiHandler::getCsmsCaFilePath() { - std::optional csmsCaFilePath; - for (const auto& entry : std::filesystem::directory_iterator(this->caCsmsPath)) { +std::optional PkiHandler::getCsmsCaFilePath() { + std::optional csmsCaFilePath; + for (const auto& entry : fs::directory_iterator(this->caCsmsPath)) { if (entry.path().extension().string() == ".pem") { csmsCaFilePath.emplace(entry.path()); } @@ -937,8 +937,8 @@ PkiHandler::getCaCertificates(const PkiEnum& pki, const CertificateType& type, c const auto caPath = this->getCaPath(pki); - if (std::filesystem::exists(caPath)) { - for (const auto& dirEntry : std::filesystem::directory_iterator(caPath)) { + if (fs::exists(caPath)) { + for (const auto& dirEntry : fs::directory_iterator(caPath)) { if (dirEntry.path().extension().string() != ".ocsp" and (includeSymlinks or dirEntry.path().extension().string() == ".pem")) { auto cert = loadFromFile(dirEntry.path()); diff --git a/lib/ocpp/common/schemas.cpp b/lib/ocpp/common/schemas.cpp index 80e7b59cc..2588fcf72 100644 --- a/lib/ocpp/common/schemas.cpp +++ b/lib/ocpp/common/schemas.cpp @@ -9,12 +9,12 @@ namespace ocpp { -Schemas::Schemas(std::filesystem::path schemas_path) : schemas_path(schemas_path) { - if (!std::filesystem::exists(this->schemas_path) || !std::filesystem::is_directory(this->schemas_path)) { +Schemas::Schemas(fs::path schemas_path) : schemas_path(schemas_path) { + if (!fs::exists(this->schemas_path) || !fs::is_directory(this->schemas_path)) { EVLOG_error << this->schemas_path << " does not exist"; // FIXME(kai): exception? } else { - for (auto file : std::filesystem::directory_iterator(this->schemas_path)) { + for (auto file : fs::directory_iterator(this->schemas_path)) { available_schemas_paths.insert(file.path()); } this->load_root_schema(); @@ -22,9 +22,9 @@ Schemas::Schemas(std::filesystem::path schemas_path) : schemas_path(schemas_path } void Schemas::load_root_schema() { - std::filesystem::path config_schema_path = this->schemas_path / "Config.json"; + fs::path config_schema_path = this->schemas_path / "Config.json"; - EVLOG_debug << "parsing root schema file: " << std::filesystem::canonical(config_schema_path); + EVLOG_debug << "parsing root schema file: " << fs::canonical(config_schema_path); std::ifstream ifs(config_schema_path.c_str()); std::string schema_file((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); @@ -53,7 +53,7 @@ void Schemas::loader(const json_uri& uri, json& schema) { location.erase(0, 1); } - std::filesystem::path schema_path = this->schemas_path / std::filesystem::path(location); + fs::path schema_path = this->schemas_path / fs::path(location); if (available_schemas_paths.count(schema_path) != 0) { std::ifstream ifs(schema_path.string().c_str()); std::string schema_file((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); diff --git a/lib/ocpp/common/websocket/websocket_tls.cpp b/lib/ocpp/common/websocket/websocket_tls.cpp index ed2819839..ecb3c3619 100644 --- a/lib/ocpp/common/websocket/websocket_tls.cpp +++ b/lib/ocpp/common/websocket/websocket_tls.cpp @@ -7,6 +7,12 @@ #include #include +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + namespace ocpp { WebsocketTLS::WebsocketTLS(const WebsocketConnectionOptions& connection_options, @@ -300,7 +306,7 @@ void WebsocketTLS::on_fail_tls(tls_client* c, websocketpp::connection_hdl hdl) { // TODO(piet): Trigger SecurityEvent in case InvalidCentralSystemCertificate - if (std::filesystem::exists(this->pki_handler->getCaCsmsPath() / CSMS_ROOT_CA_BACKUP)) { + if (fs::exists(this->pki_handler->getCaCsmsPath() / CSMS_ROOT_CA_BACKUP)) { // if a fallback ca exists, we move back to it and delete the new ca certificate EVLOG_warning << "Connection with new CA was not successful - Falling back to old CA"; this->pki_handler->useCsmsFallbackRoot(); diff --git a/lib/ocpp/v16/charge_point.cpp b/lib/ocpp/v16/charge_point.cpp index 97fa544a7..a1f8a755a 100644 --- a/lib/ocpp/v16/charge_point.cpp +++ b/lib/ocpp/v16/charge_point.cpp @@ -10,10 +10,10 @@ namespace ocpp { namespace v16 { -ChargePoint::ChargePoint(const std::string& config, const std::filesystem::path& share_path, - const std::filesystem::path& user_config_path, const std::filesystem::path& database_path, - const std::filesystem::path& sql_init_path, const std::filesystem::path& message_log_path, - const std::filesystem::path& certs_path) { +ChargePoint::ChargePoint(const std::string& config, const fs::path& share_path, + const fs::path& user_config_path, const fs::path& database_path, + const fs::path& sql_init_path, const fs::path& message_log_path, + const fs::path& certs_path) { this->charge_point = std::make_unique(config, share_path, user_config_path, database_path, sql_init_path, message_log_path, certs_path); } diff --git a/lib/ocpp/v16/charge_point_configuration.cpp b/lib/ocpp/v16/charge_point_configuration.cpp index 4fcdabc6d..af5d39a5d 100644 --- a/lib/ocpp/v16/charge_point_configuration.cpp +++ b/lib/ocpp/v16/charge_point_configuration.cpp @@ -16,11 +16,11 @@ namespace ocpp { namespace v16 { ChargePointConfiguration::ChargePointConfiguration(const std::string& config, - const std::filesystem::path& ocpp_main_path, - const std::filesystem::path& user_config_path) { + const fs::path& ocpp_main_path, + const fs::path& user_config_path) { this->user_config_path = user_config_path; - if (!std::filesystem::exists(this->user_config_path)) { + if (!fs::exists(this->user_config_path)) { EVLOG_critical << "User config file does not exist"; throw std::runtime_error("User config file does not exist"); } @@ -166,7 +166,7 @@ ChargePointConfiguration::ChargePointConfiguration(const std::string& config, } json ChargePointConfiguration::get_user_config() { - if (std::filesystem::exists(this->user_config_path)) { + if (fs::exists(this->user_config_path)) { // reading from and overriding to existing user config std::fstream ifs(user_config_path.c_str()); std::string user_config_file((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index 7e56f8d9c..db01d6c76 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -19,11 +19,11 @@ const auto V2G_CERTIFICATE_TIMER_INTERVAL = std::chrono::hours(12); const auto INITIAL_CERTIFICATE_REQUESTS_DELAY = std::chrono::seconds(60); const auto WEBSOCKET_INIT_DELAY = std::chrono::seconds(2); -ChargePointImpl::ChargePointImpl(const std::string& config, const std::filesystem::path& share_path, - const std::filesystem::path& user_config_path, - const std::filesystem::path& database_path, const std::filesystem::path& sql_init_path, - const std::filesystem::path& message_log_path, - const std::filesystem::path& certs_path) : +ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& share_path, + const fs::path& user_config_path, + const fs::path& database_path, const fs::path& sql_init_path, + const fs::path& message_log_path, + const fs::path& certs_path) : ocpp::ChargingStationBase(), boot_notification_callerror(false), initialized(false), diff --git a/lib/ocpp/v16/database_handler.cpp b/lib/ocpp/v16/database_handler.cpp index 3a8d8701f..af0e7a6cc 100644 --- a/lib/ocpp/v16/database_handler.cpp +++ b/lib/ocpp/v16/database_handler.cpp @@ -9,12 +9,12 @@ namespace ocpp { namespace v16 { -DatabaseHandler::DatabaseHandler(const std::string& chargepoint_id, const std::filesystem::path& database_path, - const std::filesystem::path& init_script_path) : +DatabaseHandler::DatabaseHandler(const std::string& chargepoint_id, const fs::path& database_path, + const fs::path& init_script_path) : ocpp::common::DatabaseHandlerBase() { const auto sqlite_db_filename = chargepoint_id + ".db"; - if (!std::filesystem::exists(database_path)) { - std::filesystem::create_directories(database_path); + if (!fs::exists(database_path)) { + fs::create_directories(database_path); } this->db_path = database_path / sqlite_db_filename; this->init_script_path = init_script_path; From cef629d3d8f79a9d71203714b400dc8f5de832d7 Mon Sep 17 00:00:00 2001 From: MS <> Date: Tue, 12 Sep 2023 16:11:50 +0200 Subject: [PATCH 02/22] Use CMAKE_CXX_STANDARD to decide over the filesystem library selection Signed-off-by: Matthias Suess --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3ff33121..434ced43a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,10 +15,12 @@ option(BUILD_TESTING "Run unit tests" OFF) option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF) option(LIBOCPP_BUILD_EXAMPLES "Build charge_point and central_system binaries." OFF) option(OCPP_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT}) -option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) -if(BOOSTFILESYSTEM) - add_definitions(-DBOOSTFILESYSTEM) +if (${CMAKE_CXX_STANDARD} LESS_EQUAL 17) + option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" ON) + add_definitions(-DUSE_BOOST_FILESYSTEM) +else() + option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) endif() From 4038f7fcfb8eb3e3a4fe0303315ab383b33fc65d Mon Sep 17 00:00:00 2001 From: MS <> Date: Tue, 12 Sep 2023 16:24:14 +0200 Subject: [PATCH 03/22] fix on define Signed-off-by: Matthias Suess --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 434ced43a..9e1ed4926 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ option(OCPP_INSTALL "Install the library (shared data might be installed anyway) if (${CMAKE_CXX_STANDARD} LESS_EQUAL 17) option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" ON) - add_definitions(-DUSE_BOOST_FILESYSTEM) + add_definitions(-DBOOSTFILESYSTEM) else() option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) endif() From ab604839762f8033a91c80ab348e9c34bb658a24 Mon Sep 17 00:00:00 2001 From: MS <> Date: Tue, 12 Sep 2023 16:48:20 +0200 Subject: [PATCH 04/22] Fix related messagelogging when using boost Signed-off-by: Matthias Suess --- lib/ocpp/v16/charge_point_impl.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index db01d6c76..5f0228ecd 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -32,7 +32,11 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar diagnostics_status(DiagnosticsStatus::Idle), firmware_status(FirmwareStatus::Idle), log_status(UploadLogStatusEnumType::Idle), - message_log_path(message_log_path), + #ifndef BOOSTFILESYSTEM + message_log_path(message_log_path), + #else + message_log_path(message_log_path.string()), + #endif switch_security_profile_callback(nullptr) { this->configuration = std::make_shared(config, share_path, user_config_path); this->pki_handler = std::make_shared( @@ -56,9 +60,15 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar bool log_to_html = std::find(log_formats.begin(), log_formats.end(), "html") != log_formats.end(); bool session_logging = std::find(log_formats.begin(), log_formats.end(), "session_logging") != log_formats.end(); + #ifndef BOOSTFILESYSTEM this->logging = std::make_shared( - this->configuration->getLogMessages(), message_log_path, DateTime().to_rfc3339(), log_to_console, - detailed_log_to_console, log_to_file, log_to_html, session_logging); + this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, + detailed_log_to_console, log_to_file, log_to_html, session_logging); + #else + this->logging = std::make_shared( + this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, + detailed_log_to_console, log_to_file, log_to_html, session_logging); + #endif this->boot_notification_timer = std::make_unique(&this->io_service, [this]() { this->boot_notification(); }); From 578271d596687f54c5f75d030197d453338df326 Mon Sep 17 00:00:00 2001 From: Matthias Suess Date: Wed, 20 Sep 2023 12:29:23 +0200 Subject: [PATCH 05/22] Factored out include to support older c++ Signed-off-by: Matthias Suess --- CMakeLists.txt | 4 ++- include/ocpp/common/pki_handler.hpp | 12 +-------- include/ocpp/common/schemas.hpp | 12 +-------- include/ocpp/common/sqlite_statement.hpp | 4 +-- .../common/support_older_c++_versions.hpp | 26 +++++++++++++++++++ include/ocpp/v16/charge_point.hpp | 12 +-------- .../ocpp/v16/charge_point_configuration.hpp | 7 ++--- include/ocpp/v16/charge_point_impl.hpp | 12 +-------- include/ocpp/v16/database_handler.hpp | 19 ++++---------- include/ocpp/v201/database_handler.hpp | 12 +-------- include/ocpp/v201/device_model_storage.hpp | 2 +- .../ocpp/v201/device_model_storage_sqlite.hpp | 11 -------- lib/CMakeLists.txt | 18 +++---------- lib/ocpp/common/websocket/websocket_tls.cpp | 6 ----- lib/ocpp/v16/charge_point_configuration.cpp | 2 +- lib/ocpp/v201/database_handler.cpp | 1 - lib/ocpp/v201/device_model_storage_sqlite.cpp | 2 +- src/charge_point.cpp | 24 ++++++++--------- 18 files changed, 63 insertions(+), 123 deletions(-) create mode 100644 include/ocpp/common/support_older_c++_versions.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 75f54b0be..0c065c1cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,9 +16,11 @@ option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF) option(LIBOCPP_BUILD_EXAMPLES "Build charge_point and central_system binaries." OFF) option(OCPP_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT}) -if (${CMAKE_CXX_STANDARD} LESS_EQUAL 17) +if (${CMAKE_CXX_COMPILER_VERSION} LESS_EQUAL 7.3.0) + #message(${CMAKE_CXX_STANDARD}) option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" ON) add_definitions(-DBOOSTFILESYSTEM) + add_definitions(-DBOOST_FILESYSTEM_VERSION=3) else() option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) endif() diff --git a/include/ocpp/common/pki_handler.hpp b/include/ocpp/common/pki_handler.hpp index 8b85fbd1b..c4f10cce6 100644 --- a/include/ocpp/common/pki_handler.hpp +++ b/include/ocpp/common/pki_handler.hpp @@ -3,11 +3,7 @@ #ifndef OCPP_COMMON_PKI_HANDLER #define OCPP_COMMON_PKI_HANDLER -#ifndef BOOSTFILESYSTEM - -#else -#include -#endif +#include #include #include #include @@ -21,12 +17,6 @@ #include -#ifndef BOOSTFILESYSTEM -namespace fs = std::filesystem; -#else -namespace fs = boost::filesystem; -#endif - namespace ocpp { enum class PkiEnum { diff --git a/include/ocpp/common/schemas.hpp b/include/ocpp/common/schemas.hpp index 16c6c0f98..1ad35b7be 100644 --- a/include/ocpp/common/schemas.hpp +++ b/include/ocpp/common/schemas.hpp @@ -9,11 +9,7 @@ #include #include -#ifndef BOOSTFILESYSTEM - -#else -#include -#endif +#include #include #include @@ -21,12 +17,6 @@ using json = nlohmann::json; using json_uri = nlohmann::json_uri; using json_validator = nlohmann::json_schema::json_validator; -#ifndef BOOSTFILESYSTEM -namespace fs = std::filesystem; -#else -namespace fs = boost::filesystem; -#endif - namespace ocpp { /// \brief Contains the json schema validation for the libocpp config diff --git a/include/ocpp/common/sqlite_statement.hpp b/include/ocpp/common/sqlite_statement.hpp index 4e4dc2831..1fea6d06b 100644 --- a/include/ocpp/common/sqlite_statement.hpp +++ b/include/ocpp/common/sqlite_statement.hpp @@ -4,10 +4,10 @@ #ifndef SQLITE_STATEMENT_HPP #define SQLITE_STATEMENT_HPP -#include #include #include +#include "support_older_c++_versions.hpp" namespace ocpp { @@ -103,4 +103,4 @@ class SQLiteStatement { } // namespace ocpp -#endif // DEVICE_MODEL_STORAGE_SQLITE_HPP \ No newline at end of file +#endif // DEVICE_MODEL_STORAGE_SQLITE_HPP diff --git a/include/ocpp/common/support_older_c++_versions.hpp b/include/ocpp/common/support_older_c++_versions.hpp new file mode 100644 index 000000000..011fd7630 --- /dev/null +++ b/include/ocpp/common/support_older_c++_versions.hpp @@ -0,0 +1,26 @@ +/* + * support_older_c++-versions.hpp + * + * Created on: 20.09.2023 + * Author: matthias_suess + */ + +#ifndef LIB_LIBOCPPMYFORK_INCLUDE_OCPP_COMMON_SUPPORT_OLDER_C___VERSIONS_HPP_ +#define LIB_LIBOCPPMYFORK_INCLUDE_OCPP_COMMON_SUPPORT_OLDER_C___VERSIONS_HPP_ + +#ifndef BOOSTFILESYSTEM +#include +#else +#include +#endif + +#ifndef BOOSTFILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + + + + +#endif /* LIB_LIBOCPPMYFORK_INCLUDE_OCPP_COMMON_SUPPORT_OLDER_C___VERSIONS_HPP_ */ diff --git a/include/ocpp/v16/charge_point.hpp b/include/ocpp/v16/charge_point.hpp index 85b29d68c..ee312ce33 100644 --- a/include/ocpp/v16/charge_point.hpp +++ b/include/ocpp/v16/charge_point.hpp @@ -2,12 +2,8 @@ // Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest #ifndef OCPP_V16_CHARGE_POINT_HPP #define OCPP_V16_CHARGE_POINT_HPP -#ifndef BOOSTFILESYSTEM - -#else -#include -#endif +#include #include #include #include @@ -30,12 +26,6 @@ #include #include -#ifndef BOOSTFILESYSTEM -namespace fs = std::filesystem; -#else -namespace fs = boost::filesystem; -#endif - namespace ocpp { namespace v16 { class ChargePointImpl; diff --git a/include/ocpp/v16/charge_point_configuration.hpp b/include/ocpp/v16/charge_point_configuration.hpp index 541b43245..38bdae8a7 100644 --- a/include/ocpp/v16/charge_point_configuration.hpp +++ b/include/ocpp/v16/charge_point_configuration.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace ocpp { namespace v16 { @@ -16,7 +17,7 @@ class ChargePointConfiguration { private: json config; json custom_schema; - std::filesystem::path user_config_path; + fs::path user_config_path; std::set supported_feature_profiles; std::map> supported_measurands; @@ -34,8 +35,8 @@ class ChargePointConfiguration { bool isConnectorPhaseRotationValid(std::string str); public: - ChargePointConfiguration(const std::string& config, const std::filesystem::path& ocpp_main_path, - const std::filesystem::path& user_config_path); + ChargePointConfiguration(const std::string& config, const fs::path& ocpp_main_path, + const fs::path& user_config_path); // Internal config options std::string getChargePointId(); diff --git a/include/ocpp/v16/charge_point_impl.hpp b/include/ocpp/v16/charge_point_impl.hpp index f2cd2080b..6760374be 100644 --- a/include/ocpp/v16/charge_point_impl.hpp +++ b/include/ocpp/v16/charge_point_impl.hpp @@ -6,11 +6,7 @@ #include #include #include -#ifndef BOOSTFILESYSTEM - -#else -#include -#endif +#include #include #include #include @@ -82,12 +78,6 @@ #include #include -#ifndef BOOSTFILESYSTEM -namespace fs = std::filesystem; -#else -namespace fs = boost::filesystem; -#endif - namespace ocpp { namespace v16 { diff --git a/include/ocpp/v16/database_handler.hpp b/include/ocpp/v16/database_handler.hpp index dc732af88..fdbca93b7 100644 --- a/include/ocpp/v16/database_handler.hpp +++ b/include/ocpp/v16/database_handler.hpp @@ -4,25 +4,16 @@ #define OCPP_V16_DATABASE_HANDLER_HPP #include "sqlite3.h" -#ifndef BOOSTFILESYSTEM - -#else -#include -#endif #include #include +#include #include #include #include #include #include -#ifndef BOOSTFILESYSTEM -namespace fs = std::filesystem; -#else -namespace fs = boost::filesystem; -#endif namespace ocpp { namespace v16 { @@ -50,16 +41,16 @@ struct TransactionEntry { /// \brief This class handles the connection and operations of the SQLite database class DatabaseHandler : public ocpp::common::DatabaseHandlerBase { private: - std::filesystem::path db_path; // directory where the database file is located - std::filesystem::path init_script_path; // full path of init sql script + fs::path db_path; // directory where the database file is located + fs::path init_script_path; // full path of init sql script void run_sql_init(); bool clear_table(const std::string& table_name); void init_connector_table(int32_t number_of_connectors); public: - DatabaseHandler(const std::string& chargepoint_id, const std::filesystem::path& database_path, - const std::filesystem::path& init_script_path); + DatabaseHandler(const std::string& chargepoint_id, const fs::path& database_path, + const fs::path& init_script_path); ~DatabaseHandler(); /// \brief Opens the database connection, runs initialization script and initializes the CONNECTORS and diff --git a/include/ocpp/v201/database_handler.hpp b/include/ocpp/v201/database_handler.hpp index d200a9b67..ea8b2b7a1 100644 --- a/include/ocpp/v201/database_handler.hpp +++ b/include/ocpp/v201/database_handler.hpp @@ -5,11 +5,7 @@ #include "sqlite3.h" #include -#ifndef BOOSTFILESYSTEM - -#else -#include -#endif +#include #include #include @@ -18,12 +14,6 @@ #include -#ifndef BOOSTFILESYSTEM -namespace fs = std::filesystem; -#else -namespace fs = boost::filesystem; -#endif - namespace ocpp { namespace v201 { diff --git a/include/ocpp/v201/device_model_storage.hpp b/include/ocpp/v201/device_model_storage.hpp index cce54f48f..9ec242f21 100644 --- a/include/ocpp/v201/device_model_storage.hpp +++ b/include/ocpp/v201/device_model_storage.hpp @@ -4,7 +4,7 @@ #ifndef OCPP_V201_DEVICE_MODEL_STORAGE_HPP #define OCPP_V201_DEVICE_MODEL_STORAGE_HPP -#include +#include #include #include #include diff --git a/include/ocpp/v201/device_model_storage_sqlite.hpp b/include/ocpp/v201/device_model_storage_sqlite.hpp index 617c69269..9a5a69375 100644 --- a/include/ocpp/v201/device_model_storage_sqlite.hpp +++ b/include/ocpp/v201/device_model_storage_sqlite.hpp @@ -4,20 +4,9 @@ #ifndef DEVICE_MODEL_STORAGE_SQLITE_HPP #define DEVICE_MODEL_STORAGE_SQLITE_HPP -#ifndef BOOSTFILESYSTEM - -#else -#include -#endif #include - #include -#ifndef BOOSTFILESYSTEM -namespace fs = std::filesystem; -#else -namespace fs = boost::filesystem; -#endif namespace ocpp { namespace v201 { diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 806787bd4..f1d0bb431 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -74,8 +74,7 @@ endif() ############# # End logging configuration ############# - -if(NOT BOOSTFILESYSTEM) + target_link_libraries(ocpp PUBLIC everest::timer @@ -90,24 +89,13 @@ target_link_libraries(ocpp nlohmann_json::nlohmann_json date::date-tz ) -else() + +if(BOOSTFILESYSTEM) target_link_libraries(ocpp - PUBLIC - everest::timer - websocketpp::websocketpp - nlohmann_json_schema_validator PRIVATE Boost::filesystem - OpenSSL::SSL - OpenSSL::Crypto - SQLite::SQLite3 - Threads::Threads - - nlohmann_json::nlohmann_json - date::date-tz ) endif() - # FIXME (aw): right now nlohmann_json and boost::optional don't compile # with gcc 10.x and C++11/14, so we need to publish the # C++17 standard diff --git a/lib/ocpp/common/websocket/websocket_tls.cpp b/lib/ocpp/common/websocket/websocket_tls.cpp index ecb3c3619..998fd42a2 100644 --- a/lib/ocpp/common/websocket/websocket_tls.cpp +++ b/lib/ocpp/common/websocket/websocket_tls.cpp @@ -7,12 +7,6 @@ #include #include -#ifndef BOOSTFILESYSTEM -namespace fs = std::filesystem; -#else -namespace fs = boost::filesystem; -#endif - namespace ocpp { WebsocketTLS::WebsocketTLS(const WebsocketConnectionOptions& connection_options, diff --git a/lib/ocpp/v16/charge_point_configuration.cpp b/lib/ocpp/v16/charge_point_configuration.cpp index fb1af5cd6..487049e5c 100644 --- a/lib/ocpp/v16/charge_point_configuration.cpp +++ b/lib/ocpp/v16/charge_point_configuration.cpp @@ -32,7 +32,7 @@ ChargePointConfiguration::ChargePointConfiguration(const std::string& config, try { this->config = json::parse(config); const auto custom_schema_path = schemas_path / "Custom.json"; - if (std::filesystem::exists(custom_schema_path)) { + if (fs::exists(custom_schema_path)) { std::ifstream ifs(custom_schema_path.c_str()); std::string custom_schema_file((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); this->custom_schema = json::parse(custom_schema_file); diff --git a/lib/ocpp/v201/database_handler.cpp b/lib/ocpp/v201/database_handler.cpp index 58876bcbd..53f0daf2a 100644 --- a/lib/ocpp/v201/database_handler.cpp +++ b/lib/ocpp/v201/database_handler.cpp @@ -7,7 +7,6 @@ #include #include -namespace fs = std::filesystem; namespace ocpp { namespace v201 { diff --git a/lib/ocpp/v201/device_model_storage_sqlite.cpp b/lib/ocpp/v201/device_model_storage_sqlite.cpp index b5405bf94..f1dc4d5fb 100644 --- a/lib/ocpp/v201/device_model_storage_sqlite.cpp +++ b/lib/ocpp/v201/device_model_storage_sqlite.cpp @@ -9,7 +9,7 @@ namespace ocpp { namespace v201 { -DeviceModelStorageSqlite::DeviceModelStorageSqlite(const std::filesystem::path& db_path) { +DeviceModelStorageSqlite::DeviceModelStorageSqlite(const fs::path& db_path) { if (sqlite3_open(db_path.c_str(), &this->db) != SQLITE_OK) { EVLOG_error << "Could not open database at provided path: " << db_path; EVLOG_AND_THROW(std::runtime_error("Could not open device model database at provided path.")); diff --git a/src/charge_point.cpp b/src/charge_point.cpp index a324b67f7..d6e1515e5 100644 --- a/src/charge_point.cpp +++ b/src/charge_point.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include @@ -55,12 +55,12 @@ int main(int argc, char* argv[]) { } const auto database_path = "/tmp/ocpp"; - const auto share_path = std::filesystem::path(maindir) / "share" / "everest" / "modules" / "OCPP"; + const auto share_path = fs::path(maindir) / "share" / "everest" / "modules" / "OCPP"; // initialize logging as early as possible auto logging_config = share_path / "logging.ini"; if (vm.count("logconf") != 0) { - logging_config = std::filesystem::path(vm["logconf"].as()); + logging_config = fs::path(vm["logconf"].as()); } Everest::Logging::init(logging_config.string(), "charge_point"); @@ -69,8 +69,8 @@ int main(int argc, char* argv[]) { conf = vm["conf"].as(); } - std::filesystem::path config_path = share_path / conf; - if (!std::filesystem::exists(config_path)) { + fs::path config_path = share_path / conf; + if (!fs::exists(config_path)) { EVLOG_error << "Could not find config at: " << config_path; return 1; } @@ -79,9 +79,9 @@ int main(int argc, char* argv[]) { auto json_config = json::parse(config_file); json_config["Internal"]["LogMessagesFormat"][0] = "console_detailed"; - auto user_config_path = std::filesystem::path("/tmp") / "user_config.json"; + auto user_config_path = fs::path("/tmp") / "user_config.json"; - if (std::filesystem::exists(user_config_path)) { + if (fs::exists(user_config_path)) { std::ifstream ifs(user_config_path.c_str()); std::string user_config_file((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); auto user_config = json::parse(user_config_file); @@ -93,17 +93,17 @@ int main(int argc, char* argv[]) { fs.close(); } - const std::filesystem::path sql_init_path = share_path / "init.sql"; + const fs::path sql_init_path = share_path / "init.sql"; // create the cso_path - const std::filesystem::path cso_path = "/tmp/client/cso"; - if (!std::filesystem::exists(cso_path)) { - std::filesystem::create_directories(cso_path); + const fs::path cso_path = "/tmp/client/cso"; + if (!fs::exists(cso_path)) { + fs::create_directories(cso_path); } charge_point = new ocpp::v16::ChargePoint(json_config.dump(), share_path, user_config_path, database_path, sql_init_path, - std::filesystem::path("/tmp"), std::filesystem::path("/tmp")); + fs::path("/tmp"), fs::path("/tmp")); /************************************** START REGISTERING CALLBACKS /**************************************/ From a7de53ee3a0f34d49f726aa2821c0507ae2f0cd8 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Wed, 20 Sep 2023 17:26:03 +0200 Subject: [PATCH 06/22] lib: add `find_package(Boost)` `cmake` failed with CMake Error at lib/CMakeLists.txt:94 (target_link_libraries): Target "ocpp" links to: Boost::filesystem but the target was not found. Possible reasons include: * There is a typo in the target name. * A find_package call is missing for an IMPORTED target. * An ALIAS target is missing. Signed-off-by: Dominik K --- lib/CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index f1d0bb431..8d2499236 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -90,12 +90,14 @@ target_link_libraries(ocpp date::date-tz ) -if(BOOSTFILESYSTEM) -target_link_libraries(ocpp - PRIVATE - Boost::filesystem -) +if(BOOSTFILESYSTEM) + find_package(Boost REQUIRED COMPONENTS filesystem) + target_link_libraries(ocpp + PRIVATE + Boost::filesystem + ) endif() + # FIXME (aw): right now nlohmann_json and boost::optional don't compile # with gcc 10.x and C++11/14, so we need to publish the # C++17 standard From eff3cb8a3151fa9930e9901a49d847764a1b1552 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Wed, 20 Sep 2023 18:08:21 +0200 Subject: [PATCH 07/22] `clang-format` fixes Signed-off-by: Dominik K --- include/ocpp/common/pki_handler.hpp | 2 +- include/ocpp/common/schemas.hpp | 2 +- include/ocpp/common/sqlite_statement.hpp | 2 +- .../common/support_older_c++_versions.hpp | 3 -- include/ocpp/v16/charge_point.hpp | 7 ++--- .../ocpp/v16/charge_point_configuration.hpp | 2 +- include/ocpp/v16/charge_point_impl.hpp | 9 +++--- include/ocpp/v16/database_handler.hpp | 6 ++-- include/ocpp/v201/database_handler.hpp | 2 +- include/ocpp/v201/device_model_storage.hpp | 2 +- .../ocpp/v201/device_model_storage_sqlite.hpp | 3 +- lib/ocpp/common/pki_handler.cpp | 3 +- lib/ocpp/common/websocket/websocket_plain.cpp | 2 +- lib/ocpp/v16/charge_point.cpp | 5 ++- lib/ocpp/v16/charge_point_configuration.cpp | 3 +- lib/ocpp/v16/charge_point_impl.cpp | 31 +++++++++---------- lib/ocpp/v201/database_handler.cpp | 1 - src/charge_point.cpp | 7 ++--- 18 files changed, 39 insertions(+), 53 deletions(-) diff --git a/include/ocpp/common/pki_handler.hpp b/include/ocpp/common/pki_handler.hpp index c4f10cce6..eedad7221 100644 --- a/include/ocpp/common/pki_handler.hpp +++ b/include/ocpp/common/pki_handler.hpp @@ -3,8 +3,8 @@ #ifndef OCPP_COMMON_PKI_HANDLER #define OCPP_COMMON_PKI_HANDLER -#include #include +#include #include #include #include diff --git a/include/ocpp/common/schemas.hpp b/include/ocpp/common/schemas.hpp index 1ad35b7be..a71c8158d 100644 --- a/include/ocpp/common/schemas.hpp +++ b/include/ocpp/common/schemas.hpp @@ -9,9 +9,9 @@ #include #include -#include #include #include +#include using json = nlohmann::json; using json_uri = nlohmann::json_uri; diff --git a/include/ocpp/common/sqlite_statement.hpp b/include/ocpp/common/sqlite_statement.hpp index 1fea6d06b..bff44cc01 100644 --- a/include/ocpp/common/sqlite_statement.hpp +++ b/include/ocpp/common/sqlite_statement.hpp @@ -6,8 +6,8 @@ #include -#include #include "support_older_c++_versions.hpp" +#include namespace ocpp { diff --git a/include/ocpp/common/support_older_c++_versions.hpp b/include/ocpp/common/support_older_c++_versions.hpp index 011fd7630..2a82d5c28 100644 --- a/include/ocpp/common/support_older_c++_versions.hpp +++ b/include/ocpp/common/support_older_c++_versions.hpp @@ -20,7 +20,4 @@ namespace fs = std::filesystem; namespace fs = boost::filesystem; #endif - - - #endif /* LIB_LIBOCPPMYFORK_INCLUDE_OCPP_COMMON_SUPPORT_OLDER_C___VERSIONS_HPP_ */ diff --git a/include/ocpp/v16/charge_point.hpp b/include/ocpp/v16/charge_point.hpp index ee312ce33..d8b24c57a 100644 --- a/include/ocpp/v16/charge_point.hpp +++ b/include/ocpp/v16/charge_point.hpp @@ -3,8 +3,8 @@ #ifndef OCPP_V16_CHARGE_POINT_HPP #define OCPP_V16_CHARGE_POINT_HPP -#include #include +#include #include #include @@ -57,9 +57,8 @@ class ChargePoint { /// \param certs_path this points to the directory where certificates used by libocpp are located, these are used /// for the "Improved security for OCPP 1.6-J" whitepaper (eg. Security Profile 3 TLS with Client Side Certificates) /// as well as for Plug & Charge. - explicit ChargePoint(const std::string& config, const fs::path& share_path, - const fs::path& user_config_path, const fs::path& database_path, - const fs::path& sql_init_path, const fs::path& message_log_path, + explicit ChargePoint(const std::string& config, const fs::path& share_path, const fs::path& user_config_path, + const fs::path& database_path, const fs::path& sql_init_path, const fs::path& message_log_path, const fs::path& certs_path); ~ChargePoint(); diff --git a/include/ocpp/v16/charge_point_configuration.hpp b/include/ocpp/v16/charge_point_configuration.hpp index 38bdae8a7..93441be33 100644 --- a/include/ocpp/v16/charge_point_configuration.hpp +++ b/include/ocpp/v16/charge_point_configuration.hpp @@ -5,9 +5,9 @@ #include +#include #include #include -#include namespace ocpp { namespace v16 { diff --git a/include/ocpp/v16/charge_point_impl.hpp b/include/ocpp/v16/charge_point_impl.hpp index 6760374be..a0bbba693 100644 --- a/include/ocpp/v16/charge_point_impl.hpp +++ b/include/ocpp/v16/charge_point_impl.hpp @@ -6,10 +6,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -317,10 +317,9 @@ class ChargePointImpl : ocpp::ChargingStationBase { /// \param certs_path this points to the directory where certificates used by libocpp are located, these are used /// for the "Improved security for OCPP 1.6-J" whitepaper (eg. Security Profile 3 TLS with Client Side Certificates) /// as well as for Plug & Charge. - explicit ChargePointImpl(const std::string& config, const fs::path& share_path, - const fs::path& user_config_path, const fs::path& database_path, - const fs::path& sql_init_path, const fs::path& message_log_path, - const fs::path& certs_path); + explicit ChargePointImpl(const std::string& config, const fs::path& share_path, const fs::path& user_config_path, + const fs::path& database_path, const fs::path& sql_init_path, + const fs::path& message_log_path, const fs::path& certs_path); ~ChargePointImpl() { } diff --git a/include/ocpp/v16/database_handler.hpp b/include/ocpp/v16/database_handler.hpp index fdbca93b7..eb1a27b14 100644 --- a/include/ocpp/v16/database_handler.hpp +++ b/include/ocpp/v16/database_handler.hpp @@ -7,14 +7,13 @@ #include #include -#include #include #include +#include #include #include #include - namespace ocpp { namespace v16 { @@ -49,8 +48,7 @@ class DatabaseHandler : public ocpp::common::DatabaseHandlerBase { void init_connector_table(int32_t number_of_connectors); public: - DatabaseHandler(const std::string& chargepoint_id, const fs::path& database_path, - const fs::path& init_script_path); + DatabaseHandler(const std::string& chargepoint_id, const fs::path& database_path, const fs::path& init_script_path); ~DatabaseHandler(); /// \brief Opens the database connection, runs initialization script and initializes the CONNECTORS and diff --git a/include/ocpp/v201/database_handler.hpp b/include/ocpp/v201/database_handler.hpp index ea8b2b7a1..b97d04566 100644 --- a/include/ocpp/v201/database_handler.hpp +++ b/include/ocpp/v201/database_handler.hpp @@ -5,9 +5,9 @@ #include "sqlite3.h" #include -#include #include #include +#include #include #include diff --git a/include/ocpp/v201/device_model_storage.hpp b/include/ocpp/v201/device_model_storage.hpp index 9ec242f21..ca72e5cbe 100644 --- a/include/ocpp/v201/device_model_storage.hpp +++ b/include/ocpp/v201/device_model_storage.hpp @@ -4,9 +4,9 @@ #ifndef OCPP_V201_DEVICE_MODEL_STORAGE_HPP #define OCPP_V201_DEVICE_MODEL_STORAGE_HPP -#include #include #include +#include #include #include diff --git a/include/ocpp/v201/device_model_storage_sqlite.hpp b/include/ocpp/v201/device_model_storage_sqlite.hpp index 9a5a69375..8725ecaa7 100644 --- a/include/ocpp/v201/device_model_storage_sqlite.hpp +++ b/include/ocpp/v201/device_model_storage_sqlite.hpp @@ -4,9 +4,8 @@ #ifndef DEVICE_MODEL_STORAGE_SQLITE_HPP #define DEVICE_MODEL_STORAGE_SQLITE_HPP -#include #include - +#include namespace ocpp { namespace v201 { diff --git a/lib/ocpp/common/pki_handler.cpp b/lib/ocpp/common/pki_handler.cpp index f54a5f1af..5b7c08afe 100644 --- a/lib/ocpp/common/pki_handler.cpp +++ b/lib/ocpp/common/pki_handler.cpp @@ -196,8 +196,7 @@ std::shared_ptr loadFromString(const std::string& str) { return cert; } -PkiHandler::PkiHandler(const fs::path& certsPath, const bool multipleCsmsCaNotAllowed) : - certsPath(certsPath) { +PkiHandler::PkiHandler(const fs::path& certsPath, const bool multipleCsmsCaNotAllowed) : certsPath(certsPath) { this->caPath = this->certsPath / "ca"; this->caCsmsPath = this->caPath / "csms"; diff --git a/lib/ocpp/common/websocket/websocket_plain.cpp b/lib/ocpp/common/websocket/websocket_plain.cpp index e07bb106c..998786dc0 100644 --- a/lib/ocpp/common/websocket/websocket_plain.cpp +++ b/lib/ocpp/common/websocket/websocket_plain.cpp @@ -159,7 +159,7 @@ void WebsocketPlain::connect_plain() { void WebsocketPlain::on_open_plain(client* c, websocketpp::connection_hdl hdl) { std::lock_guard lk(this->connection_mutex); - (void)c; // client is not used in this function + (void)c; // client is not used in this function EVLOG_info << "OCPP client successfully connected to plain websocket server"; this->connection_attempts = 1; // reset connection attempts this->m_is_connected = true; diff --git a/lib/ocpp/v16/charge_point.cpp b/lib/ocpp/v16/charge_point.cpp index 5b32fb001..92d15bafd 100644 --- a/lib/ocpp/v16/charge_point.cpp +++ b/lib/ocpp/v16/charge_point.cpp @@ -10,9 +10,8 @@ namespace ocpp { namespace v16 { -ChargePoint::ChargePoint(const std::string& config, const fs::path& share_path, - const fs::path& user_config_path, const fs::path& database_path, - const fs::path& sql_init_path, const fs::path& message_log_path, +ChargePoint::ChargePoint(const std::string& config, const fs::path& share_path, const fs::path& user_config_path, + const fs::path& database_path, const fs::path& sql_init_path, const fs::path& message_log_path, const fs::path& certs_path) { this->charge_point = std::make_unique(config, share_path, user_config_path, database_path, sql_init_path, message_log_path, certs_path); diff --git a/lib/ocpp/v16/charge_point_configuration.cpp b/lib/ocpp/v16/charge_point_configuration.cpp index 487049e5c..e012e80aa 100644 --- a/lib/ocpp/v16/charge_point_configuration.cpp +++ b/lib/ocpp/v16/charge_point_configuration.cpp @@ -15,8 +15,7 @@ namespace ocpp { namespace v16 { -ChargePointConfiguration::ChargePointConfiguration(const std::string& config, - const fs::path& ocpp_main_path, +ChargePointConfiguration::ChargePointConfiguration(const std::string& config, const fs::path& ocpp_main_path, const fs::path& user_config_path) { this->user_config_path = user_config_path; diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index 471f10d03..85c1b2a43 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -20,9 +20,8 @@ const auto INITIAL_CERTIFICATE_REQUESTS_DELAY = std::chrono::seconds(60); const auto WEBSOCKET_INIT_DELAY = std::chrono::seconds(2); ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& share_path, - const fs::path& user_config_path, - const fs::path& database_path, const fs::path& sql_init_path, - const fs::path& message_log_path, + const fs::path& user_config_path, const fs::path& database_path, + const fs::path& sql_init_path, const fs::path& message_log_path, const fs::path& certs_path) : ocpp::ChargingStationBase(), boot_notification_callerror(false), @@ -32,11 +31,11 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar diagnostics_status(DiagnosticsStatus::Idle), firmware_status(FirmwareStatus::Idle), log_status(UploadLogStatusEnumType::Idle), - #ifndef BOOSTFILESYSTEM - message_log_path(message_log_path), - #else - message_log_path(message_log_path.string()), - #endif +#ifndef BOOSTFILESYSTEM + message_log_path(message_log_path), +#else + message_log_path(message_log_path.string()), +#endif switch_security_profile_callback(nullptr) { this->configuration = std::make_shared(config, share_path, user_config_path); this->pki_handler = std::make_shared( @@ -60,15 +59,15 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar bool log_to_html = std::find(log_formats.begin(), log_formats.end(), "html") != log_formats.end(); bool session_logging = std::find(log_formats.begin(), log_formats.end(), "session_logging") != log_formats.end(); - #ifndef BOOSTFILESYSTEM +#ifndef BOOSTFILESYSTEM this->logging = std::make_shared( - this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, - detailed_log_to_console, log_to_file, log_to_html, session_logging); - #else - this->logging = std::make_shared( - this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, - detailed_log_to_console, log_to_file, log_to_html, session_logging); - #endif + this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, + detailed_log_to_console, log_to_file, log_to_html, session_logging); +#else + this->logging = std::make_shared( + this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, + detailed_log_to_console, log_to_file, log_to_html, session_logging); +#endif this->boot_notification_timer = std::make_unique(&this->io_service, [this]() { this->boot_notification(); }); diff --git a/lib/ocpp/v201/database_handler.cpp b/lib/ocpp/v201/database_handler.cpp index 53f0daf2a..6b4e5cbc0 100644 --- a/lib/ocpp/v201/database_handler.cpp +++ b/lib/ocpp/v201/database_handler.cpp @@ -7,7 +7,6 @@ #include #include - namespace ocpp { namespace v201 { diff --git a/src/charge_point.cpp b/src/charge_point.cpp index d6e1515e5..edd010985 100644 --- a/src/charge_point.cpp +++ b/src/charge_point.cpp @@ -5,10 +5,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -101,9 +101,8 @@ int main(int argc, char* argv[]) { fs::create_directories(cso_path); } - charge_point = - new ocpp::v16::ChargePoint(json_config.dump(), share_path, user_config_path, database_path, sql_init_path, - fs::path("/tmp"), fs::path("/tmp")); + charge_point = new ocpp::v16::ChargePoint(json_config.dump(), share_path, user_config_path, database_path, + sql_init_path, fs::path("/tmp"), fs::path("/tmp")); /************************************** START REGISTERING CALLBACKS /**************************************/ From 6bf3cbf07c314cd32d3dcf0071661c54b059bea0 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Wed, 20 Sep 2023 20:51:44 +0200 Subject: [PATCH 08/22] clang-format 16.0.0 (from Docker-image in GitHub Action) Signed-off-by: Dominik K --- lib/ocpp/common/websocket/websocket_plain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ocpp/common/websocket/websocket_plain.cpp b/lib/ocpp/common/websocket/websocket_plain.cpp index 998786dc0..e07bb106c 100644 --- a/lib/ocpp/common/websocket/websocket_plain.cpp +++ b/lib/ocpp/common/websocket/websocket_plain.cpp @@ -159,7 +159,7 @@ void WebsocketPlain::connect_plain() { void WebsocketPlain::on_open_plain(client* c, websocketpp::connection_hdl hdl) { std::lock_guard lk(this->connection_mutex); - (void)c; // client is not used in this function + (void)c; // client is not used in this function EVLOG_info << "OCPP client successfully connected to plain websocket server"; this->connection_attempts = 1; // reset connection attempts this->m_is_connected = true; From 9faaac0a0a43daf3d36e47761f0e8805e8ecdad3 Mon Sep 17 00:00:00 2001 From: Matthias Suess Date: Thu, 21 Sep 2023 06:58:33 +0200 Subject: [PATCH 09/22] Set SDPX format and changed define selection via option Signed-off-by: Matthias Suess --- CMakeLists.txt | 7 ++----- include/ocpp/common/support_older_c++_versions.hpp | 12 ++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c065c1cd..ddf0507a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,14 +15,11 @@ option(BUILD_TESTING "Run unit tests" OFF) option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF) option(LIBOCPP_BUILD_EXAMPLES "Build charge_point and central_system binaries." OFF) option(OCPP_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT}) +option(USE_NON_STD_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) -if (${CMAKE_CXX_COMPILER_VERSION} LESS_EQUAL 7.3.0) - #message(${CMAKE_CXX_STANDARD}) - option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" ON) +if (USE_NON_STD_FILESYSTEM) add_definitions(-DBOOSTFILESYSTEM) add_definitions(-DBOOST_FILESYSTEM_VERSION=3) -else() - option(BOOSTFILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) endif() diff --git a/include/ocpp/common/support_older_c++_versions.hpp b/include/ocpp/common/support_older_c++_versions.hpp index 2a82d5c28..f4d37e510 100644 --- a/include/ocpp/common/support_older_c++_versions.hpp +++ b/include/ocpp/common/support_older_c++_versions.hpp @@ -1,12 +1,8 @@ -/* - * support_older_c++-versions.hpp - * - * Created on: 20.09.2023 - * Author: matthias_suess - */ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest -#ifndef LIB_LIBOCPPMYFORK_INCLUDE_OCPP_COMMON_SUPPORT_OLDER_C___VERSIONS_HPP_ -#define LIB_LIBOCPPMYFORK_INCLUDE_OCPP_COMMON_SUPPORT_OLDER_C___VERSIONS_HPP_ +#ifndef OCPP_COMMON_SUPPORT_OLDER_CPP_VERSIONS_HPP_ +#define OCPP_COMMON_SUPPORT_OLDER_CPP_VERSIONS_HPP_ #ifndef BOOSTFILESYSTEM #include From b20b170f658b5e590ac9a60ce0a59c344e586cc8 Mon Sep 17 00:00:00 2001 From: Matthias Suess Date: Thu, 21 Sep 2023 07:00:27 +0200 Subject: [PATCH 10/22] Fixed header ending Signed-off-by: Matthias Suess --- include/ocpp/common/support_older_c++_versions.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ocpp/common/support_older_c++_versions.hpp b/include/ocpp/common/support_older_c++_versions.hpp index f4d37e510..f0be82a42 100644 --- a/include/ocpp/common/support_older_c++_versions.hpp +++ b/include/ocpp/common/support_older_c++_versions.hpp @@ -16,4 +16,4 @@ namespace fs = std::filesystem; namespace fs = boost::filesystem; #endif -#endif /* LIB_LIBOCPPMYFORK_INCLUDE_OCPP_COMMON_SUPPORT_OLDER_C___VERSIONS_HPP_ */ +#endif /* OCPP_COMMON_SUPPORT_OLDER_CPP_VERSIONS_HPP_ */ From 6d012c25f8dc4ba49dea4c66ca8009ee027c4082 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 21 Sep 2023 14:30:45 +0200 Subject: [PATCH 11/22] cmake: re-add `BOOSTFILESYSTEM` Signed-off-by: Dominik K --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddf0507a1..c1fb27179 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,11 @@ option(OCPP_INSTALL "Install the library (shared data might be installed anyway) option(USE_NON_STD_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) if (USE_NON_STD_FILESYSTEM) + set(BOOSTFILESYSTEM ON) add_definitions(-DBOOSTFILESYSTEM) add_definitions(-DBOOST_FILESYSTEM_VERSION=3) +else() + set(BOOSTFILESYSTEM OFF) endif() From 6ab07ee23ffd4cc38c50ecccebe8a3298a640d3f Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 21 Sep 2023 14:32:22 +0200 Subject: [PATCH 12/22] CP implementation: un-doubled `this->logging` Signed-off-by: Dominik K --- lib/ocpp/v16/charge_point_impl.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index 85c1b2a43..28d6cda50 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -59,15 +59,9 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar bool log_to_html = std::find(log_formats.begin(), log_formats.end(), "html") != log_formats.end(); bool session_logging = std::find(log_formats.begin(), log_formats.end(), "session_logging") != log_formats.end(); -#ifndef BOOSTFILESYSTEM - this->logging = std::make_shared( - this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, - detailed_log_to_console, log_to_file, log_to_html, session_logging); -#else this->logging = std::make_shared( this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, detailed_log_to_console, log_to_file, log_to_html, session_logging); -#endif this->boot_notification_timer = std::make_unique(&this->io_service, [this]() { this->boot_notification(); }); From 67890d5482519cd0c7676295c28b6ca0eac6150d Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 21 Sep 2023 14:36:03 +0200 Subject: [PATCH 13/22] CMakeLists.txt: space-indents instead tabs Signed-off-by: Dominik K --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c1fb27179..caa23f9c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,10 +19,10 @@ option(USE_NON_STD_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::fil if (USE_NON_STD_FILESYSTEM) set(BOOSTFILESYSTEM ON) - add_definitions(-DBOOSTFILESYSTEM) - add_definitions(-DBOOST_FILESYSTEM_VERSION=3) + add_definitions(-DBOOSTFILESYSTEM) + add_definitions(-DBOOST_FILESYSTEM_VERSION=3) else() - set(BOOSTFILESYSTEM OFF) + set(BOOSTFILESYSTEM OFF) endif() From f3343510fb7e93723295e66e6fd9f0a51f773bca Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 21 Sep 2023 15:00:34 +0200 Subject: [PATCH 14/22] CP implementation: one `message_log_path` initialisation Signed-off-by: Dominik K --- lib/ocpp/v16/charge_point_impl.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index 28d6cda50..ac06e290d 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -31,11 +31,7 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar diagnostics_status(DiagnosticsStatus::Idle), firmware_status(FirmwareStatus::Idle), log_status(UploadLogStatusEnumType::Idle), -#ifndef BOOSTFILESYSTEM - message_log_path(message_log_path), -#else - message_log_path(message_log_path.string()), -#endif + message_log_path(message_log_path.string()), // .string() for compatibility with boost::filesystem switch_security_profile_callback(nullptr) { this->configuration = std::make_shared(config, share_path, user_config_path); this->pki_handler = std::make_shared( From ccf1c5868bf8f5a4fa73d32d7b0b9f32a1ca54c7 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 21 Sep 2023 15:01:24 +0200 Subject: [PATCH 15/22] cmake: verbose message for troubleshooting Signed-off-by: Dominik K --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index caa23f9c4..5a387cfd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ option(OCPP_INSTALL "Install the library (shared data might be installed anyway) option(USE_NON_STD_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) if (USE_NON_STD_FILESYSTEM) + message(VERBOSE "INFO: using boost::filesystem instead std::filesystem (`USE_NON_STD_FILESYSTEM` set)") set(BOOSTFILESYSTEM ON) add_definitions(-DBOOSTFILESYSTEM) add_definitions(-DBOOST_FILESYSTEM_VERSION=3) From efac291e2e7f11fbdc2bef2700a274edd3bb01ee Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 21 Sep 2023 15:07:40 +0200 Subject: [PATCH 16/22] clang-format fix Signed-off-by: Dominik K --- lib/ocpp/v16/charge_point_impl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index ac06e290d..a6e8432cf 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -31,7 +31,7 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar diagnostics_status(DiagnosticsStatus::Idle), firmware_status(FirmwareStatus::Idle), log_status(UploadLogStatusEnumType::Idle), - message_log_path(message_log_path.string()), // .string() for compatibility with boost::filesystem + message_log_path(message_log_path.string()), // .string() for compatibility with boost::filesystem switch_security_profile_callback(nullptr) { this->configuration = std::make_shared(config, share_path, user_config_path); this->pki_handler = std::make_shared( @@ -56,7 +56,7 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar bool session_logging = std::find(log_formats.begin(), log_formats.end(), "session_logging") != log_formats.end(); this->logging = std::make_shared( - this->configuration->getLogMessages(), message_log_path.string(), DateTime().to_rfc3339(), log_to_console, + this->configuration->getLogMessages(), this->message_log_path, DateTime().to_rfc3339(), log_to_console, detailed_log_to_console, log_to_file, log_to_html, session_logging); this->boot_notification_timer = From 0060a3e962c26510f773844d66c7911702cd5a66 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 21 Sep 2023 15:11:43 +0200 Subject: [PATCH 17/22] charge_point.cpp: removed obsolete `#include` Signed-off-by: Dominik K --- src/charge_point.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/charge_point.cpp b/src/charge_point.cpp index edd010985..02cb8f762 100644 --- a/src/charge_point.cpp +++ b/src/charge_point.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include From 4a08048e110c04b83d1d72e8c24628776345051e Mon Sep 17 00:00:00 2001 From: Matthias Suess Date: Tue, 26 Sep 2023 17:20:33 +0200 Subject: [PATCH 18/22] Renamed include header and moved the option Signed-off-by: Matthias Suess --- include/ocpp/common/pki_handler.hpp | 2 +- include/ocpp/common/schemas.hpp | 2 +- include/ocpp/common/sqlite_statement.hpp | 2 +- ...rt_older_c++_versions.hpp => support_older_cpp_versions.hpp} | 0 4 files changed, 3 insertions(+), 3 deletions(-) rename include/ocpp/common/{support_older_c++_versions.hpp => support_older_cpp_versions.hpp} (100%) diff --git a/include/ocpp/common/pki_handler.hpp b/include/ocpp/common/pki_handler.hpp index eedad7221..d951633f8 100644 --- a/include/ocpp/common/pki_handler.hpp +++ b/include/ocpp/common/pki_handler.hpp @@ -4,7 +4,7 @@ #define OCPP_COMMON_PKI_HANDLER #include -#include +#include #include #include #include diff --git a/include/ocpp/common/schemas.hpp b/include/ocpp/common/schemas.hpp index a71c8158d..becbf7dac 100644 --- a/include/ocpp/common/schemas.hpp +++ b/include/ocpp/common/schemas.hpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include using json = nlohmann::json; using json_uri = nlohmann::json_uri; diff --git a/include/ocpp/common/sqlite_statement.hpp b/include/ocpp/common/sqlite_statement.hpp index bff44cc01..66c7f69ac 100644 --- a/include/ocpp/common/sqlite_statement.hpp +++ b/include/ocpp/common/sqlite_statement.hpp @@ -6,7 +6,7 @@ #include -#include "support_older_c++_versions.hpp" +#include "support_older_cpp_versions.hpp" #include namespace ocpp { diff --git a/include/ocpp/common/support_older_c++_versions.hpp b/include/ocpp/common/support_older_cpp_versions.hpp similarity index 100% rename from include/ocpp/common/support_older_c++_versions.hpp rename to include/ocpp/common/support_older_cpp_versions.hpp From 259ae11eb712be894c5a72fa0fbad1b370111a1f Mon Sep 17 00:00:00 2001 From: Matthias Suess Date: Wed, 27 Sep 2023 15:51:26 +0200 Subject: [PATCH 19/22] Renamed the include part and moved option Signed-off-by: Matthias Suess --- CMakeLists.txt | 11 ----------- include/ocpp/v16/charge_point.hpp | 2 +- include/ocpp/v16/charge_point_configuration.hpp | 2 +- include/ocpp/v16/charge_point_impl.hpp | 2 +- include/ocpp/v16/database_handler.hpp | 2 +- include/ocpp/v201/database_handler.hpp | 2 +- include/ocpp/v201/device_model_storage.hpp | 2 +- lib/CMakeLists.txt | 7 ++++++- 8 files changed, 12 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42cd1cddb..9e400e015 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,17 +15,6 @@ option(BUILD_TESTING "Run unit tests" OFF) option(CMAKE_RUN_CLANG_TIDY "Run clang-tidy" OFF) option(LIBOCPP_BUILD_EXAMPLES "Build charge_point and central_system binaries." OFF) option(OCPP_INSTALL "Install the library (shared data might be installed anyway)" ${EVC_MAIN_PROJECT}) -option(USE_NON_STD_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) - -if (USE_NON_STD_FILESYSTEM) - message(VERBOSE "INFO: using boost::filesystem instead std::filesystem (`USE_NON_STD_FILESYSTEM` set)") - set(BOOSTFILESYSTEM ON) - add_definitions(-DBOOSTFILESYSTEM) - add_definitions(-DBOOST_FILESYSTEM_VERSION=3) -else() - set(BOOSTFILESYSTEM OFF) -endif() - # dependencies find_package(Boost COMPONENTS program_options regex system thread REQUIRED) diff --git a/include/ocpp/v16/charge_point.hpp b/include/ocpp/v16/charge_point.hpp index 44c9b3061..70a5c94d8 100644 --- a/include/ocpp/v16/charge_point.hpp +++ b/include/ocpp/v16/charge_point.hpp @@ -4,7 +4,7 @@ #define OCPP_V16_CHARGE_POINT_HPP #include -#include +#include #include #include diff --git a/include/ocpp/v16/charge_point_configuration.hpp b/include/ocpp/v16/charge_point_configuration.hpp index 93441be33..7ab0dc363 100644 --- a/include/ocpp/v16/charge_point_configuration.hpp +++ b/include/ocpp/v16/charge_point_configuration.hpp @@ -5,7 +5,7 @@ #include -#include +#include #include #include diff --git a/include/ocpp/v16/charge_point_impl.hpp b/include/ocpp/v16/charge_point_impl.hpp index 85c2d5cea..d9a4f33f3 100644 --- a/include/ocpp/v16/charge_point_impl.hpp +++ b/include/ocpp/v16/charge_point_impl.hpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/ocpp/v16/database_handler.hpp b/include/ocpp/v16/database_handler.hpp index eb1a27b14..f55e04123 100644 --- a/include/ocpp/v16/database_handler.hpp +++ b/include/ocpp/v16/database_handler.hpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/ocpp/v201/database_handler.hpp b/include/ocpp/v201/database_handler.hpp index b97d04566..94d11f79b 100644 --- a/include/ocpp/v201/database_handler.hpp +++ b/include/ocpp/v201/database_handler.hpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/ocpp/v201/device_model_storage.hpp b/include/ocpp/v201/device_model_storage.hpp index ca72e5cbe..df1222cad 100644 --- a/include/ocpp/v201/device_model_storage.hpp +++ b/include/ocpp/v201/device_model_storage.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8d2499236..1621aa155 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -40,6 +40,7 @@ add_subdirectory(ocpp/common/websocket) add_subdirectory(ocpp/v16/messages) add_subdirectory(ocpp/v201/messages) +option(USE_NON_STD_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) target_include_directories(ocpp PUBLIC @@ -90,12 +91,16 @@ target_link_libraries(ocpp date::date-tz ) -if(BOOSTFILESYSTEM) +if(USE_NON_STD_FILESYSTEM) find_package(Boost REQUIRED COMPONENTS filesystem) target_link_libraries(ocpp PRIVATE Boost::filesystem ) + target_compile_definitions(log + PRIVATE + BOOSTFILESYSTEM + ) endif() # FIXME (aw): right now nlohmann_json and boost::optional don't compile From 97cc278b45237dec708a81bf83579bf5aeba2295 Mon Sep 17 00:00:00 2001 From: Matthias Suess Date: Thu, 28 Sep 2023 10:02:06 +0200 Subject: [PATCH 20/22] Renamed the option to select boost filesystem Signed-off-by: Matthias Suess --- lib/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 1621aa155..a95c4a93d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -40,7 +40,7 @@ add_subdirectory(ocpp/common/websocket) add_subdirectory(ocpp/v16/messages) add_subdirectory(ocpp/v201/messages) -option(USE_NON_STD_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) +option(LIBOCPP_USE_BOOST_FILESYSTEM "Usage of boost/filesystem.hpp instead of std::filesystem" OFF) target_include_directories(ocpp PUBLIC @@ -91,7 +91,7 @@ target_link_libraries(ocpp date::date-tz ) -if(USE_NON_STD_FILESYSTEM) +if(LIBOCPP_USE_BOOST_FILESYSTEM) find_package(Boost REQUIRED COMPONENTS filesystem) target_link_libraries(ocpp PRIVATE From 5e23594b7cd379f296c73935a81d52b2d12fbdc0 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 28 Sep 2023 10:46:08 +0200 Subject: [PATCH 21/22] removed unnecessary `#include` Signed-off-by: Dominik K --- .gitignore | 1 + include/ocpp/common/sqlite_statement.hpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2674aa109..fe793897e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *build* *vscode +.cache/ workspace.yaml CMakeLists.txt.user !doc/build-with-fetchcontent diff --git a/include/ocpp/common/sqlite_statement.hpp b/include/ocpp/common/sqlite_statement.hpp index 66c7f69ac..6a6ec7d5e 100644 --- a/include/ocpp/common/sqlite_statement.hpp +++ b/include/ocpp/common/sqlite_statement.hpp @@ -6,7 +6,6 @@ #include -#include "support_older_cpp_versions.hpp" #include namespace ocpp { From 6395c150b78ebe13413e951c2a5ac4347cc3f34a Mon Sep 17 00:00:00 2001 From: Dominik K Date: Thu, 28 Sep 2023 10:49:33 +0200 Subject: [PATCH 22/22] use `LIBOCPP_USE_BOOST_FILESYSTEM` also in macros Signed-off-by: Dominik K --- include/ocpp/common/support_older_cpp_versions.hpp | 4 ++-- lib/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/ocpp/common/support_older_cpp_versions.hpp b/include/ocpp/common/support_older_cpp_versions.hpp index f0be82a42..1c651d60d 100644 --- a/include/ocpp/common/support_older_cpp_versions.hpp +++ b/include/ocpp/common/support_older_cpp_versions.hpp @@ -4,13 +4,13 @@ #ifndef OCPP_COMMON_SUPPORT_OLDER_CPP_VERSIONS_HPP_ #define OCPP_COMMON_SUPPORT_OLDER_CPP_VERSIONS_HPP_ -#ifndef BOOSTFILESYSTEM +#ifndef LIBOCPP_USE_BOOST_FILESYSTEM #include #else #include #endif -#ifndef BOOSTFILESYSTEM +#ifndef LIBOCPP_USE_BOOST_FILESYSTEM namespace fs = std::filesystem; #else namespace fs = boost::filesystem; diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index a95c4a93d..fa3f4464f 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -99,7 +99,7 @@ if(LIBOCPP_USE_BOOST_FILESYSTEM) ) target_compile_definitions(log PRIVATE - BOOSTFILESYSTEM + LIBOCPP_USE_BOOST_FILESYSTEM ) endif()