mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
stringapi: Use strings for source names
This commit is contained in:
parent
24e8b929ee
commit
310ef08fed
@ -2060,9 +2060,8 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name)
|
||||
}
|
||||
|
||||
cmSourceFile*
|
||||
cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const
|
||||
cmMakefile::LinearGetSourceFileWithOutput(const std::string& name) const
|
||||
{
|
||||
std::string name = cname;
|
||||
std::string out;
|
||||
|
||||
// look through all the source files that have custom commands
|
||||
@ -2096,15 +2095,14 @@ cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) const
|
||||
cmSourceFile *cmMakefile::GetSourceFileWithOutput(
|
||||
const std::string& name) const
|
||||
{
|
||||
std::string name = cname;
|
||||
|
||||
// If the queried path is not absolute we use the backward compatible
|
||||
// linear-time search for an output with a matching suffix.
|
||||
if(!cmSystemTools::FileIsFullPath(cname))
|
||||
if(!cmSystemTools::FileIsFullPath(name.c_str()))
|
||||
{
|
||||
return LinearGetSourceFileWithOutput(cname);
|
||||
return LinearGetSourceFileWithOutput(name.c_str());
|
||||
}
|
||||
// Otherwise we use an efficient lookup map.
|
||||
OutputToSourceMap::const_iterator o = this->OutputToSource.find(name);
|
||||
@ -2149,15 +2147,12 @@ cmMakefile::GetSourceGroup(const std::vector<std::string>&name) const
|
||||
return sg;
|
||||
}
|
||||
|
||||
void cmMakefile::AddSourceGroup(const char* name,
|
||||
void cmMakefile::AddSourceGroup(const std::string& name,
|
||||
const char* regex)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
std::vector<std::string> nameVector;
|
||||
nameVector.push_back(name);
|
||||
AddSourceGroup(nameVector, regex);
|
||||
}
|
||||
std::vector<std::string> nameVector;
|
||||
nameVector.push_back(name);
|
||||
AddSourceGroup(nameVector, regex);
|
||||
}
|
||||
|
||||
void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
|
||||
@ -3011,9 +3006,9 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
|
||||
cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
|
||||
{
|
||||
cmSourceFileLocation sfl(this, sourceName);
|
||||
cmSourceFileLocation sfl(this, sourceName.c_str());
|
||||
for(std::vector<cmSourceFile*>::const_iterator
|
||||
sfi = this->SourceFiles.begin();
|
||||
sfi != this->SourceFiles.end(); ++sfi)
|
||||
@ -3028,7 +3023,7 @@ cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
|
||||
cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
|
||||
bool generated)
|
||||
{
|
||||
if(cmSourceFile* esf = this->GetSource(sourceName))
|
||||
@ -3037,7 +3032,7 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
|
||||
}
|
||||
else
|
||||
{
|
||||
cmSourceFile* sf = new cmSourceFile(this, sourceName);
|
||||
cmSourceFile* sf = new cmSourceFile(this, sourceName.c_str());
|
||||
if(generated)
|
||||
{
|
||||
sf->SetProperty("GENERATED", "1");
|
||||
|
@ -332,7 +332,7 @@ public:
|
||||
/**
|
||||
* Add a root source group for consideration when adding a new source.
|
||||
*/
|
||||
void AddSourceGroup(const char* name, const char* regex=0);
|
||||
void AddSourceGroup(const std::string& name, const char* regex=0);
|
||||
|
||||
/**
|
||||
* Add a source group for consideration when adding a new source.
|
||||
@ -555,14 +555,14 @@ public:
|
||||
/** Get a cmSourceFile pointer for a given source name, if the name is
|
||||
* not found, then a null pointer is returned.
|
||||
*/
|
||||
cmSourceFile* GetSource(const char* sourceName) const;
|
||||
cmSourceFile* GetSource(const std::string& sourceName) const;
|
||||
|
||||
/** Get a cmSourceFile pointer for a given source name, if the name is
|
||||
* not found, then create the source file and return it. generated
|
||||
* indicates if it is a generated file, this is used in determining
|
||||
* how to create the source file instance e.g. name
|
||||
*/
|
||||
cmSourceFile* GetOrCreateSource(const char* sourceName,
|
||||
cmSourceFile* GetOrCreateSource(const std::string& sourceName,
|
||||
bool generated = false);
|
||||
|
||||
/**
|
||||
@ -773,7 +773,7 @@ public:
|
||||
* Is there a source file that has the provided source file as an output?
|
||||
* if so then return it
|
||||
*/
|
||||
cmSourceFile *GetSourceFileWithOutput(const char *outName) const;
|
||||
cmSourceFile *GetSourceFileWithOutput(const std::string& outName) const;
|
||||
|
||||
/**
|
||||
* Add a macro to the list of macros. The arguments should be name of the
|
||||
@ -1030,12 +1030,12 @@ private:
|
||||
|
||||
bool GeneratingBuildSystem;
|
||||
/**
|
||||
* Old version of GetSourceFileWithOutput(const char*) kept for
|
||||
* Old version of GetSourceFileWithOutput(const std::string&) kept for
|
||||
* backward-compatibility. It implements a linear search and support
|
||||
* relative file paths. It is used as a fall back by
|
||||
* GetSourceFileWithOutput(const char*).
|
||||
* GetSourceFileWithOutput(const std::string&).
|
||||
*/
|
||||
cmSourceFile *LinearGetSourceFileWithOutput(const char *cname) const;
|
||||
cmSourceFile *LinearGetSourceFileWithOutput(const std::string& cname) const;
|
||||
|
||||
// A map for fast output to input look up.
|
||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "cmake.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name):
|
||||
cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name):
|
||||
Location(mf, name)
|
||||
{
|
||||
this->CustomCommand = 0;
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
* Construct with the makefile storing the source and the initial
|
||||
* name referencing it.
|
||||
*/
|
||||
cmSourceFile(cmMakefile* mf, const char* name);
|
||||
cmSourceFile(cmMakefile* mf, const std::string& name);
|
||||
|
||||
~cmSourceFile();
|
||||
|
||||
|
@ -18,9 +18,10 @@
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmSourceFileLocation
|
||||
::cmSourceFileLocation(cmMakefile const* mf, const char* name): Makefile(mf)
|
||||
::cmSourceFileLocation(cmMakefile const* mf, const std::string& name)
|
||||
: Makefile(mf)
|
||||
{
|
||||
this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name);
|
||||
this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str());
|
||||
this->AmbiguousExtension = true;
|
||||
this->Directory = cmSystemTools::GetFilenamePath(name);
|
||||
this->Name = cmSystemTools::GetFilenameName(name);
|
||||
@ -28,7 +29,7 @@ cmSourceFileLocation
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmSourceFileLocation::Update(const char* name)
|
||||
void cmSourceFileLocation::Update(const std::string& name)
|
||||
{
|
||||
if(this->AmbiguousDirectory)
|
||||
{
|
||||
@ -80,7 +81,7 @@ void cmSourceFileLocation::DirectoryUseBinary()
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmSourceFileLocation::UpdateExtension(const char* name)
|
||||
void cmSourceFileLocation::UpdateExtension(const std::string& name)
|
||||
{
|
||||
// Check the extension.
|
||||
std::string ext = cmSystemTools::GetFilenameLastExtension(name);
|
||||
@ -136,10 +137,10 @@ void cmSourceFileLocation::UpdateExtension(const char* name)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmSourceFileLocation::UpdateDirectory(const char* name)
|
||||
void cmSourceFileLocation::UpdateDirectory(const std::string& name)
|
||||
{
|
||||
// If a full path was given we know the directory.
|
||||
if(cmSystemTools::FileIsFullPath(name))
|
||||
if(cmSystemTools::FileIsFullPath(name.c_str()))
|
||||
{
|
||||
this->Directory = cmSystemTools::GetFilenamePath(name);
|
||||
this->AmbiguousDirectory = false;
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
* Construct for a source file created in a given cmMakefile
|
||||
* instance with an initial name.
|
||||
*/
|
||||
cmSourceFileLocation(cmMakefile const* mf, const char* name);
|
||||
cmSourceFileLocation(cmMakefile const* mf, const std::string& name);
|
||||
|
||||
/**
|
||||
* Return whether the givne source file location could refers to the
|
||||
@ -93,9 +93,9 @@ private:
|
||||
|
||||
// Update the location with additional knowledge.
|
||||
void Update(cmSourceFileLocation const& loc);
|
||||
void Update(const char* name);
|
||||
void UpdateExtension(const char* name);
|
||||
void UpdateDirectory(const char* name);
|
||||
void Update(const std::string& name);
|
||||
void UpdateExtension(const std::string& name);
|
||||
void UpdateDirectory(const std::string& name);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -73,7 +73,7 @@ void cmSourceGroup::SetGroupRegex(const char* regex)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void cmSourceGroup::AddGroupFile(const char* name)
|
||||
void cmSourceGroup::AddGroupFile(const std::string& name)
|
||||
{
|
||||
this->GroupFiles.insert(name);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
/**
|
||||
* Add a file name to the explicit list of files for this group.
|
||||
*/
|
||||
void AddGroupFile(const char* name);
|
||||
void AddGroupFile(const std::string& name);
|
||||
|
||||
/**
|
||||
* Add child to this sourcegroup
|
||||
|
@ -592,7 +592,7 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
cmSourceFile* cmTarget::AddSource(const char* s)
|
||||
cmSourceFile* cmTarget::AddSource(const std::string& s)
|
||||
{
|
||||
std::string src = s;
|
||||
|
||||
|
@ -143,7 +143,7 @@ public:
|
||||
* Add sources to the target.
|
||||
*/
|
||||
void AddSources(std::vector<std::string> const& srcs);
|
||||
cmSourceFile* AddSource(const char* src);
|
||||
cmSourceFile* AddSource(const std::string& src);
|
||||
|
||||
enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user