CMake/Source/cmXCodeObject.h

169 lines
4.7 KiB
C
Raw Normal View History

Simplify CMake per-source license notices Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
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. */
2005-01-25 01:35:54 +03:00
#ifndef cmXCodeObject_h
#define cmXCodeObject_h
#include <cmConfigure.h>
2005-01-22 00:25:36 +03:00
#include "cmStandardIncludes.h"
2015-10-19 22:23:29 +03:00
class cmGeneratorTarget;
2005-01-22 00:25:36 +03:00
class cmXCodeObject
{
public:
enum Type
{
OBJECT_LIST,
STRING,
ATTRIBUTE_GROUP,
OBJECT_REF,
OBJECT
};
enum PBXType
{
PBXGroup,
PBXBuildStyle,
PBXProject,
PBXHeadersBuildPhase,
PBXSourcesBuildPhase,
PBXFrameworksBuildPhase,
PBXNativeTarget,
PBXFileReference,
PBXBuildFile,
PBXContainerItemProxy,
PBXTargetDependency,
PBXShellScriptBuildPhase,
PBXResourcesBuildPhase,
PBXApplicationReference,
PBXExecutableFileReference,
PBXLibraryReference,
PBXToolTarget,
PBXLibraryTarget,
PBXAggregateTarget,
XCBuildConfiguration,
XCConfigurationList,
PBXCopyFilesBuildPhase,
None
};
class StringVec : public std::vector<std::string>
{
2005-01-22 00:25:36 +03:00
};
static const char* PBXTypeNames[];
2005-09-05 17:17:59 +04:00
virtual ~cmXCodeObject();
2005-01-22 00:25:36 +03:00
cmXCodeObject(PBXType ptype, Type type);
2016-06-04 02:38:52 +03:00
Type GetType() const { return this->TypeValue; }
PBXType GetIsA() const { return this->IsA; }
2005-09-03 00:29:32 +04:00
bool IsEmpty() const;
void SetString(const std::string& s);
2016-06-04 02:38:52 +03:00
const std::string& GetString() const { return this->String; }
void AddAttribute(const std::string& name, cmXCodeObject* value)
{
this->ObjectAttributes[name] = value;
}
void AddAttributeIfNotEmpty(const std::string& name, cmXCodeObject* value)
{
if (value && !value->IsEmpty()) {
AddAttribute(name, value);
}
}
void SetObject(cmXCodeObject* value) { this->Object = value; }
cmXCodeObject* GetObject() { return this->Object; }
void AddObject(cmXCodeObject* value) { this->List.push_back(value); }
2016-06-04 02:38:52 +03:00
bool HasObject(cmXCodeObject* o) const
2006-05-12 22:36:39 +04:00
{
return !(std::find(this->List.begin(), this->List.end(), o) ==
this->List.end());
2006-05-12 22:36:39 +04:00
}
void AddUniqueObject(cmXCodeObject* value)
2006-05-12 22:36:39 +04:00
{
if (std::find(this->List.begin(), this->List.end(), value) ==
this->List.end()) {
2006-05-12 22:36:39 +04:00
this->List.push_back(value);
}
2006-05-12 22:36:39 +04:00
}
2005-01-25 01:35:54 +03:00
static void Indent(int level, std::ostream& out);
2005-01-22 00:25:36 +03:00
void Print(std::ostream& out);
void PrintAttribute(std::ostream& out, const int level,
const std::string separator, const int factor,
const std::string& name, const cmXCodeObject* object,
const cmXCodeObject* parent);
2015-10-22 01:49:54 +03:00
virtual void PrintComment(std::ostream&) {}
2005-09-03 00:29:32 +04:00
static void PrintList(std::vector<cmXCodeObject*> const&, std::ostream& out);
2016-06-04 02:38:52 +03:00
const std::string& GetId() const { return this->Id; }
void SetId(const std::string& id) { this->Id = id; }
2016-06-04 02:38:52 +03:00
cmGeneratorTarget* GetTarget() const { return this->Target; }
void SetTarget(cmGeneratorTarget* t) { this->Target = t; }
2016-06-04 02:38:52 +03:00
const std::string& GetComment() const { return this->Comment; }
bool HasComment() const { return (!this->Comment.empty()); }
cmXCodeObject* GetObject(const char* name) const
{
2016-06-04 02:38:52 +03:00
std::map<std::string, cmXCodeObject*>::const_iterator i =
this->ObjectAttributes.find(name);
if (i != this->ObjectAttributes.end()) {
return i->second;
2005-02-04 01:42:55 +03:00
}
return 0;
}
2015-10-22 01:50:12 +03:00
// search the attribute list for an object of the specified type
2016-06-04 02:38:52 +03:00
cmXCodeObject* GetObject(cmXCodeObject::PBXType t) const
{
2016-06-04 02:38:52 +03:00
for (std::vector<cmXCodeObject*>::const_iterator i = this->List.begin();
i != this->List.end(); ++i) {
cmXCodeObject* o = *i;
if (o->IsA == t) {
return o;
}
2005-02-05 01:58:58 +03:00
}
return 0;
}
void CopyAttributes(cmXCodeObject*);
void AddDependLibrary(const std::string& configName, const std::string& l)
{
this->DependLibraries[configName].push_back(l);
}
2016-06-04 02:38:52 +03:00
std::map<std::string, StringVec> const& GetDependLibraries() const
{
return this->DependLibraries;
}
void AddDependTarget(const std::string& configName, const std::string& tName)
{
this->DependTargets[configName].push_back(tName);
}
2016-06-04 02:38:52 +03:00
std::map<std::string, StringVec> const& GetDependTargets() const
{
return this->DependTargets;
}
2016-06-04 02:38:52 +03:00
std::vector<cmXCodeObject*> const& GetObjectList() const
{
return this->List;
}
void SetComment(const std::string& c) { this->Comment = c; }
static void PrintString(std::ostream& os, std::string String);
2005-09-03 00:29:32 +04:00
protected:
void PrintString(std::ostream& os) const;
2015-10-19 22:23:29 +03:00
cmGeneratorTarget* Target;
2006-03-15 19:38:47 +03:00
Type TypeValue;
std::string Id;
2006-03-15 19:02:08 +03:00
PBXType IsA;
int Version;
std::string Comment;
std::string String;
2006-03-15 19:02:08 +03:00
cmXCodeObject* Object;
std::vector<cmXCodeObject*> List;
std::map<std::string, StringVec> DependLibraries;
std::map<std::string, StringVec> DependTargets;
std::map<std::string, cmXCodeObject*> ObjectAttributes;
2005-01-22 00:25:36 +03:00
};
2005-01-25 01:35:54 +03:00
#endif