ENH: Source and header file extensions are in variables in cmMakefile.
AUX_SOURCE_DIRECTORY will only add files that have a "source" extension.
This commit is contained in:
parent
fdfe7a357e
commit
e169953e92
@ -63,21 +63,30 @@ bool cmAuxSourceDirectoryCommand::InitialPass(std::vector<std::string>& args)
|
|||||||
for(int i =0; i < numfiles; ++i)
|
for(int i =0; i < numfiles; ++i)
|
||||||
{
|
{
|
||||||
std::string file = dir.GetFile(i);
|
std::string file = dir.GetFile(i);
|
||||||
// ignore files less than f.cxx in length
|
// Split the filename into base and extension
|
||||||
if(file.size() > 4)
|
std::string::size_type dotpos = file.rfind(".");
|
||||||
|
if( dotpos != std::string::npos )
|
||||||
{
|
{
|
||||||
// Remove the extension
|
std::string ext = file.substr(dotpos+1);
|
||||||
std::string::size_type dotpos = file.rfind(".");
|
|
||||||
file = file.substr(0, dotpos);
|
file = file.substr(0, dotpos);
|
||||||
std::string fullname = templateDirectory;
|
// Process only source files
|
||||||
fullname += "/";
|
if( file.size() != 0
|
||||||
fullname += file;
|
&& std::find( m_Makefile->GetSourceExtensions().begin(),
|
||||||
// add the file as a class file so
|
m_Makefile->GetSourceExtensions().end(), ext )
|
||||||
// depends can be done
|
!= m_Makefile->GetSourceExtensions().end() )
|
||||||
cmSourceFile cmfile;
|
{
|
||||||
cmfile.SetName(fullname.c_str(), m_Makefile->GetCurrentDirectory());
|
std::string fullname = templateDirectory;
|
||||||
cmfile.SetIsAnAbstractClass(false);
|
fullname += "/";
|
||||||
m_Makefile->AddSource(cmfile,args[1].c_str());
|
fullname += file;
|
||||||
|
// add the file as a class file so
|
||||||
|
// depends can be done
|
||||||
|
cmSourceFile cmfile;
|
||||||
|
cmfile.SetName(fullname.c_str(), m_Makefile->GetCurrentDirectory(),
|
||||||
|
m_Makefile->GetSourceExtensions(),
|
||||||
|
m_Makefile->GetHeaderExtensions());
|
||||||
|
cmfile.SetIsAnAbstractClass(false);
|
||||||
|
m_Makefile->AddSource(cmfile,args[1].c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,15 @@ cmMakefile::cmMakefile()
|
|||||||
m_IncludeFileRegularExpression = "^.*$";
|
m_IncludeFileRegularExpression = "^.*$";
|
||||||
// Setup the default include complaint regular expression (match nothing).
|
// Setup the default include complaint regular expression (match nothing).
|
||||||
m_ComplainFileRegularExpression = "^$";
|
m_ComplainFileRegularExpression = "^$";
|
||||||
|
// Source and header file extensions that we can handle
|
||||||
|
m_SourceFileExtensions.push_back( "cxx" );
|
||||||
|
m_SourceFileExtensions.push_back( "cpp" );
|
||||||
|
m_SourceFileExtensions.push_back( "txx" );
|
||||||
|
m_SourceFileExtensions.push_back( "c" );
|
||||||
|
m_SourceFileExtensions.push_back( "M" );
|
||||||
|
m_SourceFileExtensions.push_back( "m" );
|
||||||
|
|
||||||
|
m_HeaderFileExtensions.push_back( "h" );
|
||||||
|
|
||||||
m_DefineFlags = " ";
|
m_DefineFlags = " ";
|
||||||
m_MakefileGenerator = 0;
|
m_MakefileGenerator = 0;
|
||||||
|
@ -409,6 +409,17 @@ public:
|
|||||||
std::vector<std::string>& GetAuxSourceDirectories()
|
std::vector<std::string>& GetAuxSourceDirectories()
|
||||||
{return m_AuxSourceDirectories;}
|
{return m_AuxSourceDirectories;}
|
||||||
|
|
||||||
|
//@{
|
||||||
|
/**
|
||||||
|
* Return a list of extensions associated with source and header
|
||||||
|
* files
|
||||||
|
*/
|
||||||
|
const std::vector<std::string>& GetSourceExtensions() const
|
||||||
|
{return m_SourceFileExtensions;}
|
||||||
|
const std::vector<std::string>& GetHeaderExtensions() const
|
||||||
|
{return m_HeaderFileExtensions;}
|
||||||
|
//@}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given a variable name, return its value (as a string).
|
* Given a variable name, return its value (as a string).
|
||||||
*/
|
*/
|
||||||
@ -510,6 +521,8 @@ protected:
|
|||||||
|
|
||||||
std::string m_IncludeFileRegularExpression;
|
std::string m_IncludeFileRegularExpression;
|
||||||
std::string m_ComplainFileRegularExpression;
|
std::string m_ComplainFileRegularExpression;
|
||||||
|
std::vector<std::string> m_SourceFileExtensions;
|
||||||
|
std::vector<std::string> m_HeaderFileExtensions;
|
||||||
std::string m_DefineFlags;
|
std::string m_DefineFlags;
|
||||||
std::vector<cmSourceGroup> m_SourceGroups;
|
std::vector<cmSourceGroup> m_SourceGroups;
|
||||||
typedef std::map<std::string, cmCommand*> RegisteredCommandsMap;
|
typedef std::map<std::string, cmCommand*> RegisteredCommandsMap;
|
||||||
|
@ -48,7 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
// The class must be found in dir and end in name.cxx, name.txx,
|
// The class must be found in dir and end in name.cxx, name.txx,
|
||||||
// name.c or it will be considered a header file only class
|
// name.c or it will be considered a header file only class
|
||||||
// and not included in the build process
|
// and not included in the build process
|
||||||
void cmSourceFile::SetName(const char* name, const char* dir)
|
void cmSourceFile::SetName(const char* name, const char* dir,
|
||||||
|
const std::vector<std::string>& sourceExts,
|
||||||
|
const std::vector<std::string>& headerExts)
|
||||||
{
|
{
|
||||||
m_HeaderFileOnly = true;
|
m_HeaderFileOnly = true;
|
||||||
|
|
||||||
@ -94,81 +96,59 @@ void cmSourceFile::SetName(const char* name, const char* dir)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try various extentions
|
// Next, try the various source extensions
|
||||||
hname = pathname;
|
for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
|
||||||
hname += ".cxx";
|
ext != sourceExts.end(); ++ext )
|
||||||
if(cmSystemTools::FileExists(hname.c_str()))
|
|
||||||
{
|
{
|
||||||
m_SourceExtension = "cxx";
|
hname = pathname;
|
||||||
m_HeaderFileOnly = false;
|
hname += ".";
|
||||||
m_FullPath = hname;
|
hname += *ext;
|
||||||
return;
|
if(cmSystemTools::FileExists(hname.c_str()))
|
||||||
|
{
|
||||||
|
m_SourceExtension = *ext;
|
||||||
|
m_HeaderFileOnly = false;
|
||||||
|
m_FullPath = hname;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Finally, try the various header extensions
|
||||||
|
for( std::vector<std::string>::const_iterator ext = headerExts.begin();
|
||||||
|
ext != headerExts.end(); ++ext )
|
||||||
|
{
|
||||||
|
hname = pathname;
|
||||||
|
hname += ".";
|
||||||
|
hname += *ext;
|
||||||
|
if(cmSystemTools::FileExists(hname.c_str()))
|
||||||
|
{
|
||||||
|
m_SourceExtension = *ext;
|
||||||
|
m_FullPath = hname;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string errorMsg = "Tried";
|
||||||
|
for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
|
||||||
|
ext != sourceExts.end(); ++ext )
|
||||||
|
{
|
||||||
|
errorMsg += " .";
|
||||||
|
errorMsg += *ext;
|
||||||
|
}
|
||||||
|
for( std::vector<std::string>::const_iterator ext = headerExts.begin();
|
||||||
|
ext != headerExts.end(); ++ext )
|
||||||
|
{
|
||||||
|
errorMsg += " .";
|
||||||
|
errorMsg += *ext;
|
||||||
|
}
|
||||||
|
errorMsg += " for ";
|
||||||
|
|
||||||
hname = pathname;
|
cmSystemTools::Error("can not find file ", pathname.c_str());
|
||||||
hname += ".c";
|
cmSystemTools::Error(errorMsg.c_str(), pathname.c_str());
|
||||||
if(cmSystemTools::FileExists(hname.c_str()))
|
|
||||||
{
|
|
||||||
m_HeaderFileOnly = false;
|
|
||||||
m_SourceExtension = "c";
|
|
||||||
m_FullPath = hname;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hname = pathname;
|
|
||||||
hname += ".txx";
|
|
||||||
if(cmSystemTools::FileExists(hname.c_str()))
|
|
||||||
{
|
|
||||||
m_HeaderFileOnly = false;
|
|
||||||
m_SourceExtension = "txx";
|
|
||||||
m_FullPath = hname;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
hname = pathname;
|
|
||||||
hname += ".cpp";
|
|
||||||
if(cmSystemTools::FileExists(hname.c_str()))
|
|
||||||
{
|
|
||||||
m_SourceExtension = "cpp";
|
|
||||||
m_HeaderFileOnly = false;
|
|
||||||
m_FullPath = hname;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hname = pathname;
|
|
||||||
hname += ".m";
|
|
||||||
if(cmSystemTools::FileExists(hname.c_str()))
|
|
||||||
{
|
|
||||||
m_SourceExtension = "m";
|
|
||||||
m_HeaderFileOnly = false;
|
|
||||||
m_FullPath = hname;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hname = pathname;
|
|
||||||
hname += ".M";
|
|
||||||
if(cmSystemTools::FileExists(hname.c_str()))
|
|
||||||
{
|
|
||||||
m_SourceExtension = "M";
|
|
||||||
m_HeaderFileOnly = false;
|
|
||||||
m_FullPath = hname;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hname = pathname;
|
|
||||||
hname += ".h";
|
|
||||||
if(cmSystemTools::FileExists(hname.c_str()))
|
|
||||||
{
|
|
||||||
m_SourceExtension = "h";
|
|
||||||
m_FullPath = hname;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmSystemTools::Error("can not find file ", hname.c_str());
|
|
||||||
cmSystemTools::Error("Tried .cxx .c .txx .cpp .m .M .h for ", hname.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmSourceFile::SetName(const char* name, const char* dir, const char *ext,
|
void cmSourceFile::SetName(const char* name, const char* dir, const char *ext,
|
||||||
bool hfo)
|
bool hfo)
|
||||||
{
|
{
|
||||||
m_HeaderFileOnly = hfo;
|
m_HeaderFileOnly = hfo;
|
||||||
m_SourceName = name;
|
m_SourceName = name;
|
||||||
|
@ -64,15 +64,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of the file, given the directory
|
* Set the name of the file, given the directory the file should be
|
||||||
* the file should be in. Various extensions are tried on
|
* in. The various extensions provided are tried on the name
|
||||||
* the name (e.g., .cxx, .cpp) in the directory to find the actual file.
|
* (e.g., cxx, cpp) in the directory to find the actual file.
|
||||||
*/
|
*/
|
||||||
void SetName(const char* name, const char* dir);
|
void SetName(const char* name, const char* dir,
|
||||||
|
const std::vector<std::string>& sourceExts,
|
||||||
|
const std::vector<std::string>& headerExts);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of the file, given the directory the file should be in. IN
|
* Set the name of the file, given the directory the file should be in. IN
|
||||||
* this version the extesion is provided in the call. This is useful for
|
* this version the extension is provided in the call. This is useful for
|
||||||
* generated files that do not exist prior to the build.
|
* generated files that do not exist prior to the build.
|
||||||
*/
|
*/
|
||||||
void SetName(const char* name, const char* dir, const char *ext,
|
void SetName(const char* name, const char* dir, const char *ext,
|
||||||
|
@ -61,11 +61,15 @@ bool cmSourceFilesCommand::InitialPass(std::vector<std::string>& args)
|
|||||||
(path.size() > 1 && path[1] == ':'))
|
(path.size() > 1 && path[1] == ':'))
|
||||||
{
|
{
|
||||||
file.SetName(cmSystemTools::GetFilenameName(copy.c_str()).c_str(),
|
file.SetName(cmSystemTools::GetFilenameName(copy.c_str()).c_str(),
|
||||||
path.c_str());
|
path.c_str(),
|
||||||
|
m_Makefile->GetSourceExtensions(),
|
||||||
|
m_Makefile->GetHeaderExtensions());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file.SetName(i->c_str(), m_Makefile->GetCurrentDirectory());
|
file.SetName(i->c_str(), m_Makefile->GetCurrentDirectory(),
|
||||||
|
m_Makefile->GetSourceExtensions(),
|
||||||
|
m_Makefile->GetHeaderExtensions());
|
||||||
}
|
}
|
||||||
m_Makefile->AddSource(file, args[0].c_str());
|
m_Makefile->AddSource(file, args[0].c_str());
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,9 @@ bool cmSourceFilesRemoveCommand::InitialPass(std::vector<std::string>& args)
|
|||||||
i != args.end(); ++i)
|
i != args.end(); ++i)
|
||||||
{
|
{
|
||||||
cmSourceFile file;
|
cmSourceFile file;
|
||||||
file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory());
|
file.SetName((*i).c_str(), m_Makefile->GetCurrentDirectory(),
|
||||||
|
m_Makefile->GetSourceExtensions(),
|
||||||
|
m_Makefile->GetHeaderExtensions());
|
||||||
m_Makefile->RemoveSource(file, args[0].c_str());
|
m_Makefile->RemoveSource(file, args[0].c_str());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -71,7 +71,9 @@ void cmTarget::GenerateSourceFilesFromSourceLists(const cmMakefile &mf)
|
|||||||
{
|
{
|
||||||
cmSourceFile file;
|
cmSourceFile file;
|
||||||
file.SetIsAnAbstractClass(false);
|
file.SetIsAnAbstractClass(false);
|
||||||
file.SetName(temps.c_str(), mf.GetCurrentDirectory());
|
file.SetName(temps.c_str(), mf.GetCurrentDirectory(),
|
||||||
|
mf.GetSourceExtensions(),
|
||||||
|
mf.GetHeaderExtensions());
|
||||||
m_SourceFiles.push_back(file);
|
m_SourceFiles.push_back(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user