Files
comaps/qt/build_style/build_statistics.cpp
Chris H. Meyer d6c93f5206 [desktop] Fix designer
Signed-off-by: Chris H. Meyer <christian.h.meyer@t-online.de>
Co-authored-by: Yannik Bloscheck <git@yannikbloscheck.com>
Co-authored-by: Chris H. Meyer <christian.h.meyer@t-online.de>
Co-committed-by: Chris H. Meyer <christian.h.meyer@t-online.de>
2026-01-13 17:51:45 +01:00

57 lines
1.8 KiB
C++

#include "build_statistics.h"
#include "build_common.h"
#include "platform/platform.hpp"
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QProcessEnvironment>
#include <exception>
#include <string>
namespace build_style
{
QString GetStyleStatistics(QString const & mapcssMappingFile, QString const & drulesFile)
{
if (!QFile(mapcssMappingFile).exists())
throw std::runtime_error("mapcss-mapping file does not exist at " + mapcssMappingFile.toStdString());
if (!QFile(drulesFile).exists())
throw std::runtime_error("drawing-rules file does not exist at " + drulesFile.toStdString());
// Add path to the protobuf EGG in the PROTOBUF_EGG_PATH environment variable.
QProcessEnvironment env{QProcessEnvironment::systemEnvironment()};
env.insert("PROTOBUF_EGG_PATH", GetProtobufEggPath());
// Run the script.
#if defined(OMIM_OS_MAC)
return ExecProcess("python3",
{
GetExternalPath("drules_info.py", "kothic/src", "../tools/python/stylesheet"),
mapcssMappingFile,
drulesFile,
},
&env);
#else
return ExecProcess("python",
{
GetExternalPath("drules_info.py", "kothic/src", "../tools/python/stylesheet"),
mapcssMappingFile,
drulesFile,
},
&env);
#endif
}
QString GetCurrentStyleStatistics()
{
QString const resourceDir = GetPlatform().ResourcesDir().c_str();
QString const mappingPath = JoinPathQt({resourceDir, "mapcss-mapping.csv"});
QString const drulesPath = JoinPathQt({resourceDir, "drules_proto_design.bin"});
return GetStyleStatistics(mappingPath, drulesPath);
}
} // namespace build_style