Welcome to mirror list, hosted at ThFree Co, Russian Federation.

build_phone_pack.cpp « build_style « qt - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 822ea803903090f0ac87bcd724097db5898d4d7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "build_statistics.h"

#include "build_common.h"

#include "platform/platform.hpp"

#include <QDir>
#include <QStringList>

#include <exception>

namespace
{
QString GetScriptPath()
{
  QString const kScriptName = "generate_styles_override.py";
  QString const resourceDir = GetPlatform().ResourcesDir().c_str();
  if (resourceDir.isEmpty())
    return kScriptName;
  return JoinFoldersToPath({resourceDir, kScriptName});
}
}  // namespace

namespace build_style
{
QString RunBuildingPhonePack(QString const & stylesFolder, QString const & targetFolder)
{
  if (!QDir(stylesFolder).exists())
    throw std::runtime_error("styles folder does not exist");

  if (!QDir(targetFolder).exists())
    throw std::runtime_error("target folder does not exist");

  QStringList params;
  params << "python" <<
         '"' + GetScriptPath() + '"' <<
         '"' + stylesFolder + '"' <<
         '"' + targetFolder + '"';
  QString const cmd = params.join(' ');
  auto const res = ExecProcess(cmd);
  if (res.first != 0)
  {
    QString msg = QString("System error ") + to_string(res.first).c_str();
    if (!res.second.isEmpty())
      msg = msg + "\n" + res.second;
    throw std::runtime_error(to_string(msg));
  }
  return res.second;
}
}  // namespace build_style