mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-06 04:24:29 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -63,25 +63,15 @@ bool CopyFile(QString const & oldFile, QString const & newFile)
|
||||
void CopyFromResources(QString const & name, QString const & output)
|
||||
{
|
||||
QString const resourceDir = GetPlatform().ResourcesDir().c_str();
|
||||
if (!CopyFile(JoinPathQt({resourceDir, name}),
|
||||
JoinPathQt({output, name})))
|
||||
{
|
||||
throw std::runtime_error(std::string("Cannot copy file ") +
|
||||
name.toStdString() +
|
||||
" to " + output.toStdString());
|
||||
}
|
||||
if (!CopyFile(JoinPathQt({resourceDir, name}), JoinPathQt({output, name})))
|
||||
throw std::runtime_error(std::string("Cannot copy file ") + name.toStdString() + " to " + output.toStdString());
|
||||
}
|
||||
|
||||
void CopyToResources(QString const & name, QString const & input, QString const & newName)
|
||||
{
|
||||
QString const resourceDir = GetPlatform().ResourcesDir().c_str();
|
||||
if (!CopyFile(JoinPathQt({input, name}),
|
||||
JoinPathQt({resourceDir, newName.isEmpty() ? name : newName})))
|
||||
{
|
||||
throw std::runtime_error(std::string("Cannot copy file ") +
|
||||
name.toStdString() +
|
||||
" from " + input.toStdString());
|
||||
}
|
||||
if (!CopyFile(JoinPathQt({input, name}), JoinPathQt({resourceDir, newName.isEmpty() ? name : newName})))
|
||||
throw std::runtime_error(std::string("Cannot copy file ") + name.toStdString() + " from " + input.toStdString());
|
||||
}
|
||||
|
||||
QString JoinPathQt(std::initializer_list<QString> folders)
|
||||
@@ -102,8 +92,7 @@ QString JoinPathQt(std::initializer_list<QString> folders)
|
||||
return QDir::cleanPath(result);
|
||||
}
|
||||
|
||||
QString GetExternalPath(QString const & name, QString const & primaryPath,
|
||||
QString const & secondaryPath)
|
||||
QString GetExternalPath(QString const & name, QString const & primaryPath, QString const & secondaryPath)
|
||||
{
|
||||
QString const resourceDir = GetPlatform().ResourcesDir().c_str();
|
||||
QString path = JoinPathQt({resourceDir, primaryPath, name});
|
||||
|
||||
@@ -29,12 +29,17 @@ void BuildDrawingRulesImpl(QString const & mapcssFile, QString const & outputDir
|
||||
env.insert("PROTOBUF_EGG_PATH", GetProtobufEggPath());
|
||||
|
||||
// Run the script
|
||||
(void)ExecProcess("python", {
|
||||
GetExternalPath("libkomwm.py", "kothic/src", "../tools/kothic/src"),
|
||||
"-s", mapcssFile,
|
||||
"-o", outputTemplate,
|
||||
"-x", "True",
|
||||
}, &env);
|
||||
(void)ExecProcess("python",
|
||||
{
|
||||
GetExternalPath("libkomwm.py", "kothic/src", "../tools/kothic/src"),
|
||||
"-s",
|
||||
mapcssFile,
|
||||
"-o",
|
||||
outputTemplate,
|
||||
"-x",
|
||||
"True",
|
||||
},
|
||||
&env);
|
||||
|
||||
// Ensure that generated file is not empty.
|
||||
if (QFile(outputFile).size() == 0)
|
||||
|
||||
@@ -20,11 +20,8 @@ QString RunBuildingPhonePack(QString const & stylesDir, QString const & targetDi
|
||||
|
||||
if (!QDir(targetDir).exists())
|
||||
throw runtime_error("target directory does not exist" + targetDir.toStdString());
|
||||
|
||||
return ExecProcess("python", {
|
||||
GetExternalPath("generate_styles_override.py", "", "../tools/python"),
|
||||
stylesDir,
|
||||
targetDir
|
||||
});
|
||||
|
||||
return ExecProcess("python",
|
||||
{GetExternalPath("generate_styles_override.py", "", "../tools/python"), stylesDir, targetDir});
|
||||
}
|
||||
} // namespace build_style
|
||||
|
||||
@@ -31,30 +31,33 @@ enum SkinType
|
||||
SkinCount
|
||||
};
|
||||
|
||||
using SkinInfo = std::tuple<const char*, int, bool>;
|
||||
SkinInfo const g_skinInfo[SkinCount] =
|
||||
{
|
||||
std::make_tuple("mdpi", 18, false),
|
||||
std::make_tuple("hdpi", 27, false),
|
||||
std::make_tuple("xhdpi", 36, false),
|
||||
std::make_tuple("6plus", 43, false),
|
||||
std::make_tuple("xxhdpi", 54, false),
|
||||
std::make_tuple("xxxhdpi", 64, false),
|
||||
using SkinInfo = std::tuple<char const *, int, bool>;
|
||||
SkinInfo const g_skinInfo[SkinCount] = {
|
||||
std::make_tuple("mdpi", 18, false), std::make_tuple("hdpi", 27, false), std::make_tuple("xhdpi", 36, false),
|
||||
std::make_tuple("6plus", 43, false), std::make_tuple("xxhdpi", 54, false), std::make_tuple("xxxhdpi", 64, false),
|
||||
};
|
||||
|
||||
std::array<SkinType, SkinCount> const g_skinTypes =
|
||||
{{
|
||||
SkinMDPI,
|
||||
SkinHDPI,
|
||||
SkinXHDPI,
|
||||
Skin6Plus,
|
||||
SkinXXHDPI,
|
||||
SkinXXXHDPI,
|
||||
std::array<SkinType, SkinCount> const g_skinTypes = {{
|
||||
SkinMDPI,
|
||||
SkinHDPI,
|
||||
SkinXHDPI,
|
||||
Skin6Plus,
|
||||
SkinXXHDPI,
|
||||
SkinXXXHDPI,
|
||||
}};
|
||||
|
||||
inline const char * SkinSuffix(SkinType s) { return std::get<0>(g_skinInfo[s]); }
|
||||
inline int SkinSize(SkinType s) { return std::get<1>(g_skinInfo[s]); }
|
||||
inline bool SkinCoorrectColor(SkinType s) { return std::get<2>(g_skinInfo[s]); }
|
||||
inline char const * SkinSuffix(SkinType s)
|
||||
{
|
||||
return std::get<0>(g_skinInfo[s]);
|
||||
}
|
||||
inline int SkinSize(SkinType s)
|
||||
{
|
||||
return std::get<1>(g_skinInfo[s]);
|
||||
}
|
||||
inline bool SkinCoorrectColor(SkinType s)
|
||||
{
|
||||
return std::get<2>(g_skinInfo[s]);
|
||||
}
|
||||
|
||||
QString GetSkinGeneratorPath()
|
||||
{
|
||||
@@ -124,8 +127,8 @@ std::unordered_map<std::string, int> GetSkinSizes(QString const & file)
|
||||
return skinSizes;
|
||||
}
|
||||
|
||||
void BuildSkinImpl(QString const & styleDir, QString const & suffix,
|
||||
int size, bool colorCorrection, QString const & outputDir)
|
||||
void BuildSkinImpl(QString const & styleDir, QString const & suffix, int size, bool colorCorrection,
|
||||
QString const & outputDir)
|
||||
{
|
||||
QString const symbolsDir = JoinPathQt({styleDir, "symbols"});
|
||||
|
||||
@@ -152,13 +155,18 @@ void BuildSkinImpl(QString const & styleDir, QString const & suffix,
|
||||
QString const strSize = QString::number(size);
|
||||
// Run the script.
|
||||
(void)ExecProcess(GetSkinGeneratorPath(), {
|
||||
"--symbolWidth", strSize,
|
||||
"--symbolHeight", strSize,
|
||||
"--symbolsDir", symbolsDir,
|
||||
"--skinName", JoinPathQt({outputDir, "basic"}),
|
||||
"--skinSuffix=",
|
||||
"--colorCorrection", (colorCorrection ? "true" : "false"),
|
||||
});
|
||||
"--symbolWidth",
|
||||
strSize,
|
||||
"--symbolHeight",
|
||||
strSize,
|
||||
"--symbolsDir",
|
||||
symbolsDir,
|
||||
"--skinName",
|
||||
JoinPathQt({outputDir, "basic"}),
|
||||
"--skinSuffix=",
|
||||
"--colorCorrection",
|
||||
(colorCorrection ? "true" : "false"),
|
||||
});
|
||||
|
||||
// Check if files were created.
|
||||
if (QFile(JoinPathQt({outputDir, "symbols.png"})).size() == 0 ||
|
||||
@@ -178,7 +186,7 @@ void BuildSkins(QString const & styleDir, QString const & outputDir)
|
||||
{
|
||||
QString const suffix = SkinSuffix(s);
|
||||
QString const outputSkinDir = JoinPathQt({outputDir, "symbols", suffix, "design"});
|
||||
int const size = resolution2size.at(suffix.toStdString()); // SkinSize(s);
|
||||
int const size = resolution2size.at(suffix.toStdString()); // SkinSize(s);
|
||||
bool const colorCorrection = SkinCoorrectColor(s);
|
||||
|
||||
BuildSkinImpl(styleDir, suffix, size, colorCorrection, outputSkinDir);
|
||||
@@ -198,10 +206,8 @@ void ApplySkins(QString const & outputDir)
|
||||
if (!QFileInfo::exists(resourceSkinDir) && !QDir().mkdir(resourceSkinDir))
|
||||
throw std::runtime_error("Cannot create resource skin directory: " + resourceSkinDir.toStdString());
|
||||
|
||||
if (!CopyFile(JoinPathQt({outputSkinDir, "symbols.png"}),
|
||||
JoinPathQt({resourceSkinDir, "symbols.png"})) ||
|
||||
!CopyFile(JoinPathQt({outputSkinDir, "symbols.sdf"}),
|
||||
JoinPathQt({resourceSkinDir, "symbols.sdf"})))
|
||||
if (!CopyFile(JoinPathQt({outputSkinDir, "symbols.png"}), JoinPathQt({resourceSkinDir, "symbols.png"})) ||
|
||||
!CopyFile(JoinPathQt({outputSkinDir, "symbols.sdf"}), JoinPathQt({resourceSkinDir, "symbols.sdf"})))
|
||||
{
|
||||
throw std::runtime_error("Cannot copy skins files");
|
||||
}
|
||||
|
||||
@@ -27,11 +27,13 @@ QString GetStyleStatistics(QString const & mapcssMappingFile, QString const & dr
|
||||
env.insert("PROTOBUF_EGG_PATH", GetProtobufEggPath());
|
||||
|
||||
// Run the script.
|
||||
return ExecProcess("python", {
|
||||
GetExternalPath("drules_info.py", "kothic/src", "../tools/python/stylesheet"),
|
||||
mapcssMappingFile,
|
||||
drulesFile,
|
||||
}, &env);
|
||||
return ExecProcess("python",
|
||||
{
|
||||
GetExternalPath("drules_info.py", "kothic/src", "../tools/python/stylesheet"),
|
||||
mapcssMappingFile,
|
||||
drulesFile,
|
||||
},
|
||||
&env);
|
||||
}
|
||||
|
||||
QString GetCurrentStyleStatistics()
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
#include <future>
|
||||
#include <string>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QFile>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -54,7 +54,7 @@ void BuildAndApply(QString const & mapcssFile)
|
||||
{
|
||||
auto future = std::async(std::launch::async, BuildSkins, styleDir, outputDir);
|
||||
BuildDrawingRules(mapcssFile, outputDir);
|
||||
future.get(); // may rethrow exception from the BuildSkin
|
||||
future.get(); // may rethrow exception from the BuildSkin
|
||||
|
||||
ApplyDrawingRules(outputDir);
|
||||
ApplySkins(outputDir);
|
||||
@@ -108,13 +108,13 @@ void RunRecalculationGeometryScript(QString const & mapcssFile)
|
||||
CopyFromResources("types.txt", geometryToolResourceDir);
|
||||
|
||||
(void)ExecProcess("python", {
|
||||
GetRecalculateGeometryScriptPath(),
|
||||
resourceDir,
|
||||
writableDir,
|
||||
generatorToolPath,
|
||||
appPath,
|
||||
mapcssFile,
|
||||
});
|
||||
GetRecalculateGeometryScriptPath(),
|
||||
resourceDir,
|
||||
writableDir,
|
||||
generatorToolPath,
|
||||
appPath,
|
||||
mapcssFile,
|
||||
});
|
||||
}
|
||||
|
||||
bool NeedRecalculate = false;
|
||||
|
||||
@@ -11,12 +11,12 @@ std::pair<bool, QString> RunCurrentStyleTests()
|
||||
QString const program = GetExternalPath("style_tests", "style_tests.app/Contents/MacOS", "");
|
||||
QString const resourcesDir = QString::fromStdString(GetPlatform().ResourcesDir());
|
||||
QString const output = ExecProcess(program, {
|
||||
"--user_resource_path=" + resourcesDir,
|
||||
"--data_path=" + resourcesDir,
|
||||
});
|
||||
"--user_resource_path=" + resourcesDir,
|
||||
"--data_path=" + resourcesDir,
|
||||
});
|
||||
|
||||
// Unfortunately test process returns 0 even if some test failed,
|
||||
// therefore phrase 'All tests passed.' is looked to be sure that everything is OK.
|
||||
return std::make_pair(output.contains("All tests passed."), output);
|
||||
}
|
||||
} // namespace build_style
|
||||
} // namespace build_style
|
||||
|
||||
Reference in New Issue
Block a user