| 34 | namespace build_style |
| 35 | { |
| 36 | void BuildAndApply(QString const & mapcssFile) |
| 37 | { |
| 38 | // Ensure mapcss exists |
| 39 | if (!QFile(mapcssFile).exists()) |
| 40 | throw std::runtime_error("mapcss files does not exist"); |
| 41 | |
| 42 | QDir const projectDir = QFileInfo(mapcssFile).absoluteDir(); |
| 43 | QString const styleDir = projectDir.absolutePath() + QDir::separator(); |
| 44 | QString const prioDir = styleDir + ".." + QDir::separator() + "include"; |
| 45 | QString const outputDir = styleDir + "out" + QDir::separator(); |
| 46 | |
| 47 | // Ensure output directory is clear |
| 48 | if (QDir(outputDir).exists() && !QDir(outputDir).removeRecursively()) |
| 49 | throw std::runtime_error("Unable to remove the output directory"); |
| 50 | if (!QDir().mkdir(outputDir)) |
| 51 | throw std::runtime_error("Unable to make the output directory"); |
| 52 | |
| 53 | bool const hasSymbols = QDir(styleDir + "symbols/").exists(); |
| 54 | if (hasSymbols) |
| 55 | { |
| 56 | auto future = std::async(std::launch::async, BuildSkins, styleDir, outputDir); |
| 57 | BuildDrawingRules(mapcssFile, outputDir, prioDir); |
| 58 | future.get(); // may rethrow exception from the BuildSkin |
| 59 | |
| 60 | ApplyDrawingRules(outputDir); |
| 61 | ApplySkins(outputDir); |
| 62 | } |
| 63 | else |
| 64 | { |
| 65 | BuildDrawingRules(mapcssFile, outputDir, prioDir); |
| 66 | ApplyDrawingRules(outputDir); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | void BuildIfNecessaryAndApply(QString const & mapcssFile) |
| 71 | { |
no test coverage detected