ENH: Added creation of custom rules for generating CABLE packages.
This commit is contained in:
parent
02fe911803
commit
71153219e1
@ -71,11 +71,4 @@ void cmCableCommand::SetupCableData()
|
|||||||
std::string pathName = m_Makefile->GetStartOutputDirectory();
|
std::string pathName = m_Makefile->GetStartOutputDirectory();
|
||||||
pathName += "/cable_config.xml";
|
pathName += "/cable_config.xml";
|
||||||
m_CableData = new cmCableData(this, pathName);
|
m_CableData = new cmCableData(this, pathName);
|
||||||
|
|
||||||
// std::vector<std::string> depends;
|
|
||||||
// depends.push_back("cable_config.xml");
|
|
||||||
// m_Makefile->AddCustomCommand("source_cable_config.xml",
|
|
||||||
// "result_file",
|
|
||||||
// "cable cable_config.xml",
|
|
||||||
// depends);
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,8 @@ cmCableData::cmCableData(const cmCableCommand* owner,
|
|||||||
m_Owner(owner),
|
m_Owner(owner),
|
||||||
m_Indentation(0),
|
m_Indentation(0),
|
||||||
m_Package(NULL),
|
m_Package(NULL),
|
||||||
m_PackageNamespaceDepth(0)
|
m_PackageNamespaceDepth(0),
|
||||||
|
m_PackageClassIndex(-1)
|
||||||
{
|
{
|
||||||
this->OpenOutputFile(configurationFile);
|
this->OpenOutputFile(configurationFile);
|
||||||
}
|
}
|
||||||
@ -167,6 +168,9 @@ void cmCableData::BeginPackage(cmCablePackageCommand* command)
|
|||||||
// Open this package.
|
// Open this package.
|
||||||
m_Package = command;
|
m_Package = command;
|
||||||
|
|
||||||
|
// Write out the package's header.
|
||||||
|
m_Package->WritePackageHeader();
|
||||||
|
|
||||||
// Save the package's opening namespace depth for later verification
|
// Save the package's opening namespace depth for later verification
|
||||||
// on the end of the package.
|
// on the end of the package.
|
||||||
m_PackageNamespaceDepth = m_NamespaceStack.size();
|
m_PackageNamespaceDepth = m_NamespaceStack.size();
|
||||||
|
@ -71,6 +71,9 @@ public:
|
|||||||
void BeginPackage(cmCablePackageCommand*);
|
void BeginPackage(cmCablePackageCommand*);
|
||||||
void EndPackage();
|
void EndPackage();
|
||||||
|
|
||||||
|
void SetPackageClassIndex(int index) { m_PackageClassIndex = index; }
|
||||||
|
int GetPackageClassIndex() const { return m_PackageClassIndex; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* The cmCableCommand which created this instance of cmCableCommand.
|
* The cmCableCommand which created this instance of cmCableCommand.
|
||||||
@ -102,6 +105,13 @@ private:
|
|||||||
* This must be the level when the package is ended.
|
* This must be the level when the package is ended.
|
||||||
*/
|
*/
|
||||||
unsigned int m_PackageNamespaceDepth;
|
unsigned int m_PackageNamespaceDepth;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* During the final pass, this maintains the index into a cmMakefile's
|
||||||
|
* m_Classes corresponding to the cmClassFile for this package's generated
|
||||||
|
* file.
|
||||||
|
*/
|
||||||
|
int m_PackageClassIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream&, const cmCableData::Indentation&);
|
std::ostream& operator<<(std::ostream&, const cmCableData::Indentation&);
|
||||||
|
@ -32,17 +32,54 @@ bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
|
|||||||
m_PackageName = args[0];
|
m_PackageName = args[0];
|
||||||
|
|
||||||
// Ask the cable data to begin the package. This may call another
|
// Ask the cable data to begin the package. This may call another
|
||||||
// cmCablePackageCommand's WritePackageFooter().
|
// cmCablePackageCommand's WritePackageFooter(). This will call
|
||||||
|
// this cmCablePackageCommand's WritePackageHeader().
|
||||||
m_CableData->BeginPackage(this);
|
m_CableData->BeginPackage(this);
|
||||||
|
|
||||||
// Write the configuration for this command.
|
// Add custom rules to the makefile to generate this package's source
|
||||||
// The cmCableData::EndPackage() later on will call WritePackageFooter().
|
// files.
|
||||||
this->WritePackageHeader();
|
std::vector<std::string> depends;
|
||||||
|
depends.push_back("cable_config.xml");
|
||||||
|
|
||||||
|
std::string command = "${CABLE}";
|
||||||
|
m_Makefile->ExpandVariablesInString(command);
|
||||||
|
depends.push_back(command);
|
||||||
|
command += " cable_config.xml";
|
||||||
|
|
||||||
|
std::string packageFile = "Cxx/"+m_PackageName+"_cxx";
|
||||||
|
std::string packageHeader = packageFile+".h";
|
||||||
|
std::string packageSource = packageFile+".cxx";
|
||||||
|
|
||||||
|
// A rule for the package's header file.
|
||||||
|
m_Makefile->AddCustomCommand("",
|
||||||
|
packageHeader.c_str(),
|
||||||
|
command.c_str(),
|
||||||
|
depends);
|
||||||
|
|
||||||
|
// A rule for the package's source file.
|
||||||
|
m_Makefile->AddCustomCommand("",
|
||||||
|
packageSource.c_str(),
|
||||||
|
command.c_str(),
|
||||||
|
depends);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void cmCablePackageCommand::FinalPass()
|
||||||
|
{
|
||||||
|
// Add a rule to build the generated package.
|
||||||
|
std::string fileName = "Cxx/"+m_PackageName+"_cxx";
|
||||||
|
std::string filePath = m_Makefile->GetStartOutputDirectory();
|
||||||
|
cmClassFile file;
|
||||||
|
file.m_AbstractClass = false;
|
||||||
|
file.SetName(fileName.c_str(), filePath.c_str(), "cxx", false);
|
||||||
|
|
||||||
|
m_CableData->SetPackageClassIndex(m_Makefile->GetClasses().size());
|
||||||
|
m_Makefile->AddClass(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write a CABLE package header.
|
* Write a CABLE package header.
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool Invoke(std::vector<std::string>& args);
|
virtual bool Invoke(std::vector<std::string>& args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called at the end after all the information
|
||||||
|
* specified by the command is accumulated. Most commands do
|
||||||
|
* not implement this method. At this point, reading and
|
||||||
|
* writing to the cache can be done.
|
||||||
|
*/
|
||||||
|
virtual void FinalPass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the command as specified in CMakeList.txt.
|
* The name of the command as specified in CMakeList.txt.
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +16,30 @@
|
|||||||
#include "cmCableSourceFilesCommand.h"
|
#include "cmCableSourceFilesCommand.h"
|
||||||
#include "cmCacheManager.h"
|
#include "cmCacheManager.h"
|
||||||
|
|
||||||
|
void cmCableSourceFilesCommand::FinalPass()
|
||||||
|
{
|
||||||
|
// Get the index of the current package's cmClassFile.
|
||||||
|
// If it doesn't exist, ignore this command.
|
||||||
|
int index = m_CableData->GetPackageClassIndex();
|
||||||
|
if(index < 0)
|
||||||
|
{ return; }
|
||||||
|
|
||||||
|
// The package's file has not yet been generated yet. The dependency
|
||||||
|
// finder will need hints. Add one for each source file.
|
||||||
|
cmClassFile& cFile = m_Makefile->GetClasses()[index];
|
||||||
|
|
||||||
|
std::string curPath = m_Makefile->GetCurrentDirectory();
|
||||||
|
curPath += "/";
|
||||||
|
|
||||||
|
for(Entries::const_iterator f = m_Entries.begin();
|
||||||
|
f != m_Entries.end(); ++f)
|
||||||
|
{
|
||||||
|
std::string header = curPath+*f+".h";
|
||||||
|
cFile.m_Depends.push_back(header);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the CABLE configuration code to indicate header dependencies for
|
* Write the CABLE configuration code to indicate header dependencies for
|
||||||
* a package.
|
* a package.
|
||||||
|
@ -36,6 +36,14 @@ public:
|
|||||||
return new cmCableSourceFilesCommand;
|
return new cmCableSourceFilesCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is called at the end after all the information
|
||||||
|
* specified by the command is accumulated. Most commands do
|
||||||
|
* not implement this method. At this point, reading and
|
||||||
|
* writing to the cache can be done.
|
||||||
|
*/
|
||||||
|
virtual void FinalPass();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the command as specified in CMakeList.txt.
|
* The name of the command as specified in CMakeList.txt.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user