2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2014-05-15 21:12:40 +04:00
|
|
|
#include "cmInstalledFile.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2015-03-08 15:37:44 +03:00
|
|
|
#include "cmAlgorithms.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmListFileCache.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmSystemTools.h"
|
2014-05-15 21:12:40 +04:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <cmConfigure.h>
|
|
|
|
#include <utility>
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmInstalledFile::cmInstalledFile()
|
2016-06-27 23:44:16 +03:00
|
|
|
: NameExpression(CM_NULLPTR)
|
2014-05-15 21:12:40 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmInstalledFile::~cmInstalledFile()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (NameExpression) {
|
2014-05-15 21:12:40 +04:00
|
|
|
delete NameExpression;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 21:12:40 +04:00
|
|
|
}
|
|
|
|
|
2015-03-08 15:37:44 +03:00
|
|
|
cmInstalledFile::Property::Property()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmInstalledFile::Property::~Property()
|
|
|
|
{
|
|
|
|
cmDeleteAll(this->ValueExpressions);
|
|
|
|
}
|
|
|
|
|
2014-05-15 21:12:40 +04:00
|
|
|
void cmInstalledFile::SetName(cmMakefile* mf, const std::string& name)
|
|
|
|
{
|
2014-05-23 22:41:46 +04:00
|
|
|
cmListFileBacktrace backtrace = mf->GetBacktrace();
|
2015-07-09 00:52:51 +03:00
|
|
|
cmGeneratorExpression ge(backtrace);
|
2014-05-15 21:12:40 +04:00
|
|
|
|
|
|
|
this->Name = name;
|
|
|
|
this->NameExpression = ge.Parse(name).release();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string const& cmInstalledFile::GetName() const
|
|
|
|
{
|
|
|
|
return this->Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCompiledGeneratorExpression const& cmInstalledFile::GetNameExpression() const
|
|
|
|
{
|
|
|
|
return *(this->NameExpression);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstalledFile::RemoveProperty(const std::string& prop)
|
|
|
|
{
|
|
|
|
this->Properties.erase(prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstalledFile::SetProperty(cmMakefile const* mf,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& prop, const char* value)
|
2014-05-15 21:12:40 +04:00
|
|
|
{
|
|
|
|
this->RemoveProperty(prop);
|
|
|
|
this->AppendProperty(mf, prop, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmInstalledFile::AppendProperty(cmMakefile const* mf,
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& prop,
|
|
|
|
const char* value, bool /*asString*/)
|
2014-05-15 21:12:40 +04:00
|
|
|
{
|
2014-05-23 22:41:46 +04:00
|
|
|
cmListFileBacktrace backtrace = mf->GetBacktrace();
|
2015-07-09 00:52:51 +03:00
|
|
|
cmGeneratorExpression ge(backtrace);
|
2014-05-15 21:12:40 +04:00
|
|
|
|
|
|
|
Property& property = this->Properties[prop];
|
|
|
|
property.ValueExpressions.push_back(ge.Parse(value).release());
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmInstalledFile::HasProperty(const std::string& prop) const
|
2014-09-27 19:34:39 +04:00
|
|
|
{
|
|
|
|
return this->Properties.find(prop) != this->Properties.end();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmInstalledFile::GetProperty(const std::string& prop,
|
|
|
|
std::string& value) const
|
2014-05-15 21:12:40 +04:00
|
|
|
{
|
|
|
|
PropertyMapType::const_iterator i = this->Properties.find(prop);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (i == this->Properties.end()) {
|
2014-05-15 21:12:40 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 21:12:40 +04:00
|
|
|
|
|
|
|
Property const& property = i->second;
|
|
|
|
|
|
|
|
std::string output;
|
|
|
|
std::string separator;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (ExpressionVectorType::const_iterator j =
|
|
|
|
property.ValueExpressions.begin();
|
|
|
|
j != property.ValueExpressions.end(); ++j) {
|
2014-05-15 21:12:40 +04:00
|
|
|
output += separator;
|
|
|
|
output += (*j)->GetInput();
|
|
|
|
separator = ";";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-05-15 21:12:40 +04:00
|
|
|
|
|
|
|
value = output;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const
|
|
|
|
{
|
|
|
|
std::string value;
|
|
|
|
bool isSet = this->GetProperty(prop, value);
|
|
|
|
return isSet && cmSystemTools::IsOn(value.c_str());
|
|
|
|
}
|
2014-08-09 16:50:49 +04:00
|
|
|
|
|
|
|
void cmInstalledFile::GetPropertyAsList(const std::string& prop,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>& list) const
|
2014-08-09 16:50:49 +04:00
|
|
|
{
|
|
|
|
std::string value;
|
|
|
|
this->GetProperty(prop, value);
|
|
|
|
|
|
|
|
list.clear();
|
|
|
|
cmSystemTools::ExpandListArgument(value, list);
|
|
|
|
}
|