summaryrefslogtreecommitdiffstats
path: root/xbmc/CompileInfo.cpp.in
blob: 131f519f0da35cf553bb5a217a432967d92271d8 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 *  Copyright (C) 2014-2018 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#include "CompileInfo.h"
#include "addons/AddonRepoInfo.h"
#include "utils/StringUtils.h"

#include <algorithm>
#include <cstddef>
#include <string>

int CCompileInfo::GetMajor()
{
  return @APP_VERSION_MAJOR@;
}

int CCompileInfo::GetMinor()
{
  return @APP_VERSION_MINOR@;
}

const char* CCompileInfo::GetPackage()
{
  return "@APP_PACKAGE@";
}

const char* CCompileInfo::GetClass()
{
  static std::string s_classname;

  if (s_classname.empty())
  {
    s_classname = CCompileInfo::GetPackage();
    std::replace(s_classname.begin(), s_classname.end(), '.', '/');
  }
  return s_classname.c_str();
}

const char* CCompileInfo::GetAppName()
{
  return "@APP_NAME@";
}

const char* CCompileInfo::GetSuffix()
{
  return "@APP_VERSION_TAG@";
}

const char* CCompileInfo::GetSCMID()
{
  return "@APP_SCMID@";
}

std::string CCompileInfo::GetSharedLibrarySuffix()
{
  return "@APP_SHARED_LIBRARY_SUFFIX@";
}

const char* CCompileInfo::GetCopyrightYears()
{
  return "@APP_COPYRIGHT_YEARS@";
}

std::string CCompileInfo::GetBuildDate()
{
  const std::string bdate = "@APP_BUILD_DATE@";
  if (!bdate.empty())
  {
    std::string datestamp = bdate.substr(0, 4) + "-" + bdate.substr(4, 2) + "-" + bdate.substr(6, 2);
    return datestamp;
  }
  return "1970-01-01";
}

const char*  CCompileInfo::GetVersionCode()
{
  return "@APP_VERSION_CODE@";
}

std::vector<ADDON::RepoInfo> CCompileInfo::LoadOfficialRepoInfos()
{
  const std::vector<std::string> officialAddonRepos =
      StringUtils::Split("@APP_ADDON_REPOS@", ',');

  std::vector<ADDON::RepoInfo> officialRepoInfos;
  ADDON::RepoInfo newRepoInfo;

  for (const auto& addonRepo : officialAddonRepos)
  {
    const std::vector<std::string> tmpRepoInfo = StringUtils::Split(addonRepo, '|');
    newRepoInfo.m_repoId = tmpRepoInfo.front();
    newRepoInfo.m_origin = tmpRepoInfo.back();
    officialRepoInfos.emplace_back(newRepoInfo);
  }

  return officialRepoInfos;
}

std::vector<std::string> CCompileInfo::GetAvailableWindowSystems()
{
  return StringUtils::Split("@CORE_PLATFORM_NAME_LC@", ' ');
}

// Return version of python built against as format MAJOR.MINOR
std::string CCompileInfo::GetPythonVersion()
{
  return "@PYTHON_VERSION@";
}

std::vector<std::string> CCompileInfo::GetWebserverExtraWhitelist()
{
  return StringUtils::Split("@KODI_WEBSERVER_EXTRA_WHITELIST@", ',');
}