Change: make nlohmann a mandatory library to build OpenTTD (#11235)

This commit is contained in:
Patric Stout
2023-08-28 19:04:36 +02:00
committed by GitHub
parent 13b76b0243
commit a3d631ffed
8 changed files with 9 additions and 34 deletions

View File

@@ -31,9 +31,7 @@
#include "../base_media_base.h"
#include "../blitter/factory.hpp"
#ifdef WITH_NLOHMANN_JSON
#include <nlohmann/json.hpp>
#endif /* WITH_NLOHMANN_JSON */
#include "../safeguards.h"
@@ -41,8 +39,6 @@ extern std::string _savegame_id;
NetworkSurveyHandler _survey = {};
#ifdef WITH_NLOHMANN_JSON
NLOHMANN_JSON_SERIALIZE_ENUM(NetworkSurveyHandler::Reason, {
{NetworkSurveyHandler::Reason::PREVIEW, "preview"},
{NetworkSurveyHandler::Reason::LEAVE, "leave"},
@@ -334,8 +330,6 @@ std::string SurveyMemoryToText(uint64_t memory)
return fmt::format("{} MiB", Ceil(memory, 4));
}
#endif /* WITH_NLOHMANN_JSON */
/**
* Create the payload for the survey.
*
@@ -345,9 +339,6 @@ std::string SurveyMemoryToText(uint64_t memory)
*/
std::string NetworkSurveyHandler::CreatePayload(Reason reason, bool for_preview)
{
#ifndef WITH_NLOHMANN_JSON
return "";
#else
nlohmann::json survey;
survey["schema"] = NETWORK_SURVEY_VERSION;
@@ -381,7 +372,6 @@ std::string NetworkSurveyHandler::CreatePayload(Reason reason, bool for_preview)
/* For preview, we indent with 4 whitespaces to make things more readable. */
int indent = for_preview ? 4 : -1;
return survey.dump(indent);
#endif /* WITH_NLOHMANN_JSON */
}
/**

View File

@@ -36,12 +36,7 @@ public:
constexpr static bool IsSurveyPossible()
{
#ifndef WITH_NLOHMANN_JSON
/* Without JSON library, we cannot send a payload; so we disable the survey. */
return false;
#else
return true;
#endif /* WITH_NLOHMANN_JSON */
}
private:

View File

@@ -7,8 +7,6 @@
/** @file survey_osx.cpp OSX implementation of OS-specific survey information. */
#ifdef WITH_NLOHMANN_JSON
#include "../../stdafx.h"
#include "../../3rdparty/fmt/format.h"
@@ -38,5 +36,3 @@ void SurveyOS(nlohmann::json &json)
json["memory"] = SurveyMemoryToText(MacOSGetPhysicalMemory());
json["hardware_concurrency"] = std::thread::hardware_concurrency();
}
#endif /* WITH_NLOHMANN_JSON */

View File

@@ -7,8 +7,6 @@
/** @file survey_unix.cpp Unix implementation of OS-specific survey information. */
#ifdef WITH_NLOHMANN_JSON
#include "../../stdafx.h"
#include <nlohmann/json.hpp>
@@ -38,5 +36,3 @@ void SurveyOS(nlohmann::json &json)
json["memory"] = SurveyMemoryToText(pages * page_size);
json["hardware_concurrency"] = std::thread::hardware_concurrency();
}
#endif /* WITH_NLOHMANN_JSON */

View File

@@ -7,8 +7,6 @@
/** @file survey_win.cpp Windows implementation of OS-specific survey information. */
#ifdef WITH_NLOHMANN_JSON
#include "../../stdafx.h"
#include "../../3rdparty/fmt/format.h"
@@ -37,5 +35,3 @@ void SurveyOS(nlohmann::json &json)
json["memory"] = SurveyMemoryToText(status.ullTotalPhys);
json["hardware_concurrency"] = std::thread::hardware_concurrency();
}
#endif /* WITH_NLOHMANN_JSON */