2001-05-17 00:41:30 +04:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: Insight Segmentation & Registration Toolkit
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2001 Insight Consortium
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
* Redistributions of source code must retain the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer.
|
|
|
|
|
|
|
|
* Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
* The name of the Insight Consortium, nor the names of any consortium members,
|
|
|
|
nor of any contributors, may be used to endorse or promote products derived
|
|
|
|
from this software without specific prior written permission.
|
|
|
|
|
|
|
|
* Modified source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
|
|
|
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmCableWrapTclCommand.h"
|
|
|
|
#include "cmCacheManager.h"
|
|
|
|
#include "cmTarget.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
2001-07-17 23:41:49 +04:00
|
|
|
#include "cmMakeDepend.h"
|
2001-05-17 00:41:30 +04:00
|
|
|
|
2001-09-12 23:18:23 +04:00
|
|
|
#include "cmData.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* One instance of this is associated with the makefile to hold a
|
|
|
|
* vector of the GCC-XML flags pre-parsed from the string in the
|
|
|
|
* cache. The first cmCableWrapTclCommand to need it creates the
|
|
|
|
* instance. The others find it and use it.
|
|
|
|
*/
|
|
|
|
class cmCableWrapTclCommand::cmGccXmlFlagsParser: public cmData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmGccXmlFlagsParser(const char* name): cmData(name) {}
|
|
|
|
|
|
|
|
void Parse(const char*);
|
|
|
|
void AddParsedFlags(std::vector<std::string>& resultArgs);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::string> m_Flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
void cmCableWrapTclCommand::cmGccXmlFlagsParser::Parse(const char* in_flags)
|
|
|
|
{
|
|
|
|
// Prepare a work string for searching.
|
|
|
|
std::string flags = in_flags;
|
|
|
|
|
|
|
|
// Look for " -" separating arguments. Currently the find_*_options
|
|
|
|
// scripts always output a single space between arguments, so we don't
|
|
|
|
// need to worry about removing extra whitespace.
|
|
|
|
|
|
|
|
// The first argument starts at the beginning of the string.
|
|
|
|
std::string::size_type leftPos = 0;
|
|
|
|
std::string::size_type rightPos = flags.find(" -", leftPos);
|
|
|
|
while(rightPos != std::string::npos)
|
|
|
|
{
|
|
|
|
// Pull out and store this argument.
|
|
|
|
m_Flags.push_back(flags.substr(leftPos, rightPos-leftPos));
|
|
|
|
|
|
|
|
// The next argument starts at the '-' from the previously found " -".
|
|
|
|
leftPos = rightPos+1;
|
|
|
|
rightPos = flags.find(" -", leftPos);
|
|
|
|
}
|
|
|
|
// Pull out and store the last argument.
|
|
|
|
m_Flags.push_back(flags.substr(leftPos, std::string::npos));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
cmCableWrapTclCommand::cmGccXmlFlagsParser
|
|
|
|
::AddParsedFlags(std::vector<std::string>& resultArgs)
|
|
|
|
{
|
|
|
|
for(std::vector<std::string>::const_iterator flag = m_Flags.begin();
|
|
|
|
flag != m_Flags.end(); ++flag)
|
|
|
|
{
|
|
|
|
resultArgs.push_back(*flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-17 00:41:30 +04:00
|
|
|
cmCableWrapTclCommand::cmCableWrapTclCommand():
|
2001-08-24 00:28:29 +04:00
|
|
|
m_CableClassSet(NULL), m_MakeDepend(new cmMakeDepend)
|
2001-05-17 00:41:30 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCableWrapTclCommand::~cmCableWrapTclCommand()
|
|
|
|
{
|
|
|
|
if(m_CableClassSet)
|
|
|
|
{
|
|
|
|
delete m_CableClassSet;
|
|
|
|
}
|
2001-08-24 00:28:29 +04:00
|
|
|
delete m_MakeDepend;
|
2001-05-17 00:41:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cmCableWrapTclCommand
|
2001-09-20 23:08:30 +04:00
|
|
|
bool cmCableWrapTclCommand::InitialPass(std::vector<std::string> const& argsIn)
|
2001-05-17 00:41:30 +04:00
|
|
|
{
|
2001-09-20 23:08:30 +04:00
|
|
|
if(argsIn.size() < 2)
|
2001-05-17 00:41:30 +04:00
|
|
|
{
|
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
|
|
|
}
|
2001-09-20 23:08:30 +04:00
|
|
|
std::vector<std::string> args = argsIn;
|
2001-07-26 19:07:18 +04:00
|
|
|
|
|
|
|
// First, we want to expand all CMAKE variables in all arguments.
|
|
|
|
for(std::vector<std::string>::iterator a = args.begin();
|
|
|
|
a != args.end(); ++a)
|
|
|
|
{
|
|
|
|
m_Makefile->ExpandVariablesInString(*a);
|
|
|
|
}
|
2001-05-17 00:41:30 +04:00
|
|
|
|
|
|
|
// Prepare to iterate through the arguments.
|
|
|
|
std::vector<std::string>::const_iterator arg = args.begin();
|
|
|
|
|
|
|
|
// The first argument is the name of the target.
|
|
|
|
m_TargetName = *arg++;
|
|
|
|
|
|
|
|
// Create the new class set.
|
|
|
|
m_CableClassSet = new cmCableClassSet(m_TargetName.c_str());
|
|
|
|
|
|
|
|
// Add all the regular entries.
|
|
|
|
for(; (arg != args.end()) && (*arg != "SOURCES_BEGIN"); ++arg)
|
|
|
|
{
|
|
|
|
m_CableClassSet->ParseAndAddElement(arg->c_str(), m_Makefile);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add any sources that are associated with all the members.
|
|
|
|
if(arg != args.end())
|
|
|
|
{
|
|
|
|
for(++arg; arg != args.end(); ++arg)
|
|
|
|
{
|
|
|
|
m_CableClassSet->AddSource(arg->c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this->GenerateCableFiles();
|
|
|
|
|
|
|
|
// Add the source list to the target.
|
|
|
|
m_Makefile->GetTargets()[m_TargetName.c_str()].GetSourceLists().push_back(m_TargetName);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate the files that CABLE will use to generate the wrappers.
|
|
|
|
*/
|
|
|
|
void cmCableWrapTclCommand::GenerateCableFiles() const
|
|
|
|
{
|
2001-08-24 00:28:29 +04:00
|
|
|
// Make sure the dependency generator is ready to go.
|
|
|
|
m_MakeDepend->SetMakefile(m_Makefile);
|
|
|
|
|
2001-08-03 01:27:00 +04:00
|
|
|
// Each wrapped class may have an associated "tag" that represents
|
|
|
|
// an alternative name without funky C++ syntax in it. This makes
|
|
|
|
// it easier to refer to the class in a Tcl script. We will also
|
|
|
|
// use the tags to make easy-to-read, unique file names for each
|
|
|
|
// class's wrapper. Count the number of times each tag is used.
|
|
|
|
// Warn if a tag is used more than once.
|
2001-08-22 19:58:17 +04:00
|
|
|
std::map<cmStdString, unsigned int> tagCounts;
|
2001-08-03 01:27:00 +04:00
|
|
|
for(cmCableClassSet::CableClassMap::const_iterator
|
|
|
|
c = m_CableClassSet->Begin(); c != m_CableClassSet->End(); ++c)
|
|
|
|
{
|
|
|
|
std::string tag = c->second->GetTag();
|
|
|
|
if((++tagCounts[tag] > 1) && (tag != ""))
|
|
|
|
{
|
|
|
|
std::string message =
|
|
|
|
"CABLE_WRAP_TCL has found two classes with the tag "+tag
|
|
|
|
+" for target "+m_TargetName;
|
|
|
|
cmSystemTools::Message(message.c_str(), "Warning");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Each class wrapper will be written into its own CABLE "group"
|
|
|
|
// file. This should hold the names of the groups generated so that
|
|
|
|
// the package configuration file can tell cable how to generate the
|
|
|
|
// package initialization code.
|
|
|
|
std::vector<std::string> groupTags;
|
|
|
|
|
|
|
|
// Setup the output directory name and make sure it exists.
|
2001-05-17 00:41:30 +04:00
|
|
|
std::string outDir = m_Makefile->GetCurrentOutputDirectory();
|
|
|
|
cmSystemTools::MakeDirectory((outDir+"/Tcl").c_str());
|
|
|
|
|
2001-08-03 01:27:00 +04:00
|
|
|
// Write out the cable configuration files with one class per group.
|
|
|
|
// Try to name the groups based on their class's tag, but use an
|
|
|
|
// index to disambiguate tag repeats (mostly used for empty tags).
|
2001-08-22 19:58:17 +04:00
|
|
|
std::map<cmStdString, unsigned int> tagIndexes;
|
2001-08-03 01:27:00 +04:00
|
|
|
for(cmCableClassSet::CableClassMap::const_iterator
|
|
|
|
c = m_CableClassSet->Begin(); c != m_CableClassSet->End(); ++c)
|
|
|
|
{
|
|
|
|
// Construct the group's tag-based name, with index if necessary.
|
|
|
|
std::string tag = c->second->GetTag();
|
|
|
|
std::string groupTag;
|
|
|
|
if(tagCounts[tag] > 1)
|
|
|
|
{
|
|
|
|
unsigned int tagIndex = tagIndexes[tag]++;
|
|
|
|
std::strstream indexStrStream;
|
|
|
|
indexStrStream << tagIndex << std::ends;
|
|
|
|
std::string indexStr = indexStrStream.str();
|
|
|
|
groupTag = "_"+indexStr;
|
|
|
|
}
|
|
|
|
if(tag != "")
|
|
|
|
{
|
|
|
|
groupTag += "_"+tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save this group tag in the list of tags for the main package
|
|
|
|
// configuration file below.
|
|
|
|
groupTags.push_back(groupTag);
|
|
|
|
|
|
|
|
// Actually generate the class's configuration file.
|
|
|
|
this->GenerateCableClassFiles(c->first.c_str(), *(c->second),
|
|
|
|
groupTag.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Construct the output file names.
|
2001-05-17 00:41:30 +04:00
|
|
|
std::string packageConfigName = outDir+"/Tcl/"+m_TargetName+"_config.xml";
|
2001-06-10 04:54:06 +04:00
|
|
|
std::string packageTclFileName = "Tcl/"+m_TargetName+"_tcl";
|
2001-08-03 01:27:00 +04:00
|
|
|
std::string packageTclFullName = outDir+"/"+packageTclFileName;
|
2001-05-17 00:41:30 +04:00
|
|
|
|
2001-08-03 01:27:00 +04:00
|
|
|
// Generate the main package configuration file for CABLE. This
|
|
|
|
// just lists the "group" files generated above.
|
2001-05-17 00:41:30 +04:00
|
|
|
cmGeneratedFileStream packageConfig(packageConfigName.c_str());
|
|
|
|
if(packageConfig)
|
|
|
|
{
|
|
|
|
packageConfig <<
|
2001-05-22 00:21:27 +04:00
|
|
|
"<CableConfiguration package=\"" << m_TargetName.c_str() << "\">\n";
|
2001-08-03 01:27:00 +04:00
|
|
|
for(std::vector<std::string>::const_iterator g = groupTags.begin();
|
|
|
|
g != groupTags.end(); ++g)
|
2001-05-17 00:41:30 +04:00
|
|
|
{
|
|
|
|
packageConfig <<
|
2001-08-03 01:27:00 +04:00
|
|
|
" <Group name=\"" << m_TargetName.c_str() << g->c_str() << "\"/>\n";
|
2001-05-17 00:41:30 +04:00
|
|
|
}
|
|
|
|
packageConfig <<
|
|
|
|
"</CableConfiguration>\n";
|
|
|
|
|
|
|
|
packageConfig.close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("Error opening CABLE configuration file for writing: ",
|
|
|
|
packageConfigName.c_str());
|
|
|
|
}
|
2001-08-03 01:27:00 +04:00
|
|
|
|
|
|
|
// Generate the rule to run CABLE for the package configuration file.
|
2001-05-17 00:41:30 +04:00
|
|
|
std::string command = "${CABLE}";
|
|
|
|
m_Makefile->ExpandVariablesInString(command);
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
depends.push_back(command);
|
2001-09-10 23:11:15 +04:00
|
|
|
std::vector<std::string> commandArgs;
|
|
|
|
commandArgs.push_back(packageConfigName);
|
|
|
|
commandArgs.push_back("-tcl");
|
|
|
|
std::string tmp = packageTclFullName+".cxx";
|
|
|
|
commandArgs.push_back(tmp);
|
2001-05-17 00:41:30 +04:00
|
|
|
|
|
|
|
depends.push_back(packageConfigName);
|
|
|
|
|
|
|
|
std::vector<std::string> outputs;
|
2001-06-10 04:54:06 +04:00
|
|
|
outputs.push_back(packageTclFileName+".cxx");
|
2001-05-17 00:41:30 +04:00
|
|
|
|
|
|
|
m_Makefile->AddCustomCommand(packageConfigName.c_str(),
|
|
|
|
command.c_str(),
|
2001-09-10 23:11:15 +04:00
|
|
|
commandArgs,
|
2001-05-17 00:41:30 +04:00
|
|
|
depends,
|
|
|
|
outputs, m_TargetName.c_str());
|
2001-08-03 01:27:00 +04:00
|
|
|
|
|
|
|
// Add the generated source to the package target's source list.
|
2001-05-17 00:41:30 +04:00
|
|
|
cmSourceFile file;
|
2001-06-10 04:54:06 +04:00
|
|
|
file.SetName(packageTclFileName.c_str(), outDir.c_str(), "cxx", false);
|
2001-05-17 00:41:30 +04:00
|
|
|
// Set dependency hints.
|
2001-08-30 01:10:25 +04:00
|
|
|
file.GetDepends().push_back("WrapTclFacility/wrapCalls.h");
|
2001-05-17 00:41:30 +04:00
|
|
|
m_Makefile->AddSource(file, m_TargetName.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmCableWrapTclCommand::GenerateCableClassFiles(const char* name,
|
|
|
|
const cmCableClass& c,
|
2001-08-03 01:27:00 +04:00
|
|
|
const char* groupTag) const
|
|
|
|
{
|
2001-05-17 00:41:30 +04:00
|
|
|
std::string outDir = m_Makefile->GetCurrentOutputDirectory();
|
|
|
|
|
|
|
|
std::string className = name;
|
2001-08-03 01:27:00 +04:00
|
|
|
std::string groupName = m_TargetName+groupTag;
|
2001-05-17 00:41:30 +04:00
|
|
|
std::string classConfigName = outDir+"/Tcl/"+groupName+"_config_tcl.xml";
|
2001-06-07 18:16:18 +04:00
|
|
|
std::string classCxxName = outDir+"/Tcl/"+groupName+"_cxx.cc";
|
2001-05-17 19:22:11 +04:00
|
|
|
std::string classXmlName = outDir+"/Tcl/"+groupName+"_cxx.xml";
|
2001-06-10 04:54:06 +04:00
|
|
|
std::string classTclFileName = "Tcl/"+groupName+"_tcl";
|
|
|
|
std::string classTclFullName = outDir+"/"+classTclFileName;
|
2001-05-17 00:41:30 +04:00
|
|
|
|
|
|
|
cmGeneratedFileStream classConfig(classConfigName.c_str());
|
|
|
|
if(classConfig)
|
|
|
|
{
|
|
|
|
classConfig <<
|
|
|
|
"<CableConfiguration source=\"" << classXmlName.c_str() << "\" "
|
|
|
|
"group=\"" << groupName.c_str() << "\">\n";
|
|
|
|
for(cmCableClass::Sources::const_iterator source = c.SourcesBegin();
|
|
|
|
source != c.SourcesEnd(); ++source)
|
|
|
|
{
|
|
|
|
classConfig <<
|
|
|
|
" <Header name=\"" << source->c_str() << "\"/>\n";
|
|
|
|
}
|
|
|
|
classConfig <<
|
2001-07-26 19:07:18 +04:00
|
|
|
" <Class name=\"_wrap_::wrapper::Wrapper\">\n";
|
|
|
|
if(c.GetTag() != "")
|
|
|
|
{
|
|
|
|
classConfig <<
|
|
|
|
" <AlternateName name=\"" << c.GetTag().c_str() << "\"/>\n";
|
|
|
|
}
|
|
|
|
classConfig <<
|
|
|
|
" </Class>\n"
|
2001-05-17 00:41:30 +04:00
|
|
|
"</CableConfiguration>\n";
|
|
|
|
|
|
|
|
classConfig.close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("Error opening CABLE configuration file for writing: ",
|
|
|
|
classConfigName.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
cmGeneratedFileStream classCxx(classCxxName.c_str());
|
|
|
|
if(classCxx)
|
|
|
|
{
|
|
|
|
for(cmCableClass::Sources::const_iterator source = c.SourcesBegin();
|
|
|
|
source != c.SourcesEnd(); ++source)
|
|
|
|
{
|
|
|
|
classCxx <<
|
|
|
|
"#include \"" << source->c_str() << "\"\n";
|
|
|
|
}
|
|
|
|
classCxx <<
|
|
|
|
"\n"
|
|
|
|
"namespace _wrap_\n"
|
|
|
|
"{\n"
|
|
|
|
"\n"
|
|
|
|
"struct wrapper\n"
|
|
|
|
"{\n"
|
|
|
|
" typedef ::" << className.c_str() << " Wrapper;\n"
|
|
|
|
"};\n"
|
|
|
|
"\n"
|
|
|
|
"template <typename T> void Eat(T) {}\n"
|
|
|
|
"\n"
|
|
|
|
"void InstantiateMemberDeclarations()\n"
|
|
|
|
"{\n"
|
|
|
|
" Eat(sizeof(wrapper::Wrapper));\n"
|
|
|
|
"}\n"
|
|
|
|
"\n"
|
|
|
|
"}\n";
|
|
|
|
|
|
|
|
classCxx.close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmSystemTools::Error("Error opening file for writing: ",
|
|
|
|
classCxxName.c_str());
|
|
|
|
}
|
2001-06-08 22:40:28 +04:00
|
|
|
|
|
|
|
// Generate the rule to have GCC-XML parse the classes to be wrapped.
|
2001-05-17 00:41:30 +04:00
|
|
|
{
|
2001-06-08 22:40:28 +04:00
|
|
|
std::string command = this->GetGccXmlFromCache();
|
|
|
|
std::vector<std::string> depends;
|
|
|
|
depends.push_back(command);
|
2001-07-17 23:41:49 +04:00
|
|
|
|
|
|
|
// Get the dependencies of the file.
|
|
|
|
const cmDependInformation* dependInfo =
|
2001-08-24 00:28:29 +04:00
|
|
|
m_MakeDepend->FindDependencies(classCxxName.c_str());
|
2001-07-17 23:41:49 +04:00
|
|
|
if(dependInfo)
|
|
|
|
{
|
|
|
|
for(cmDependInformation::DependencySet::const_iterator d =
|
|
|
|
dependInfo->m_DependencySet.begin();
|
|
|
|
d != dependInfo->m_DependencySet.end(); ++d)
|
|
|
|
{
|
|
|
|
// Make sure the full path is given. If not, the dependency was
|
|
|
|
// not found.
|
|
|
|
if((*d)->m_FullPath != "")
|
|
|
|
{
|
|
|
|
depends.push_back((*d)->m_FullPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-08 22:40:28 +04:00
|
|
|
|
2001-09-10 23:11:15 +04:00
|
|
|
std::vector<std::string> commandArgs;
|
2001-09-12 23:18:23 +04:00
|
|
|
this->AddGccXmlFlagsFromCache(commandArgs);
|
|
|
|
//commandArgs.push_back(m_Makefile->GetDefineFlags());
|
|
|
|
|
|
|
|
{
|
|
|
|
std::string tmp = "-I";
|
|
|
|
tmp += m_Makefile->GetStartDirectory();
|
|
|
|
commandArgs.push_back(cmSystemTools::EscapeSpaces(tmp.c_str()));
|
|
|
|
}
|
2001-05-17 00:41:30 +04:00
|
|
|
|
2001-07-30 19:34:03 +04:00
|
|
|
const std::vector<std::string>& includes =
|
2001-06-08 22:40:28 +04:00
|
|
|
m_Makefile->GetIncludeDirectories();
|
2001-07-30 19:34:03 +04:00
|
|
|
for(std::vector<std::string>::const_iterator i = includes.begin();
|
2001-06-08 22:40:28 +04:00
|
|
|
i != includes.end(); ++i)
|
|
|
|
{
|
2001-09-12 23:18:23 +04:00
|
|
|
std::string tmp = "-I";
|
|
|
|
tmp += i->c_str();
|
|
|
|
commandArgs.push_back(cmSystemTools::EscapeSpaces(tmp.c_str()));
|
2001-05-17 00:41:30 +04:00
|
|
|
}
|
2001-09-10 23:11:15 +04:00
|
|
|
std::string tmp = "-fxml=";
|
|
|
|
tmp += classXmlName;
|
|
|
|
commandArgs.push_back(tmp);
|
|
|
|
commandArgs.push_back(classCxxName);
|
2001-06-08 22:40:28 +04:00
|
|
|
|
|
|
|
std::vector<std::string> outputs;
|
|
|
|
outputs.push_back(classXmlName);
|
|
|
|
|
|
|
|
m_Makefile->AddCustomCommand(classCxxName.c_str(),
|
|
|
|
command.c_str(),
|
2001-09-10 23:11:15 +04:00
|
|
|
commandArgs,
|
2001-06-08 22:40:28 +04:00
|
|
|
depends,
|
|
|
|
outputs, m_TargetName.c_str());
|
2001-05-17 00:41:30 +04:00
|
|
|
}
|
|
|
|
|
2001-06-08 22:40:28 +04:00
|
|
|
// Generate the rule to run cable on the GCC-XML output to generate wrappers.
|
2001-05-17 00:41:30 +04:00
|
|
|
{
|
2001-06-08 22:40:28 +04:00
|
|
|
std::string command = this->GetCableFromCache();
|
2001-05-17 00:41:30 +04:00
|
|
|
std::vector<std::string> depends;
|
|
|
|
depends.push_back(command);
|
2001-09-10 23:11:15 +04:00
|
|
|
std::vector<std::string > commandArgs;
|
|
|
|
commandArgs.push_back(classConfigName);
|
|
|
|
commandArgs.push_back("-tcl");
|
|
|
|
std::string tmp = classTclFullName+".cxx";
|
|
|
|
commandArgs.push_back(tmp);
|
2001-05-17 00:41:30 +04:00
|
|
|
|
|
|
|
depends.push_back(classConfigName);
|
|
|
|
depends.push_back(classXmlName);
|
|
|
|
|
|
|
|
std::vector<std::string> outputs;
|
2001-06-10 04:54:06 +04:00
|
|
|
outputs.push_back(classTclFileName+".cxx");
|
2001-05-17 00:41:30 +04:00
|
|
|
|
|
|
|
m_Makefile->AddCustomCommand(classConfigName.c_str(),
|
|
|
|
command.c_str(),
|
2001-09-10 23:11:15 +04:00
|
|
|
commandArgs, depends,
|
2001-05-17 00:41:30 +04:00
|
|
|
outputs, m_TargetName.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the generated source to the package's source list.
|
|
|
|
cmSourceFile file;
|
2001-06-10 04:54:06 +04:00
|
|
|
file.SetName(classTclFileName.c_str(), outDir.c_str(), "cxx", false);
|
2001-05-17 00:41:30 +04:00
|
|
|
// Set dependency hints.
|
|
|
|
for(cmCableClass::Sources::const_iterator source = c.SourcesBegin();
|
|
|
|
source != c.SourcesEnd(); ++source)
|
|
|
|
{
|
|
|
|
file.GetDepends().push_back(*source);
|
|
|
|
}
|
2001-08-30 01:10:25 +04:00
|
|
|
file.GetDepends().push_back("WrapTclFacility/wrapCalls.h");
|
2001-05-17 00:41:30 +04:00
|
|
|
m_Makefile->AddSource(file, m_TargetName.c_str());
|
|
|
|
}
|
2001-06-08 22:40:28 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "GCCXML" cache entry value. If there is no cache entry for GCCXML,
|
|
|
|
* one will be created and initialized to NOTFOUND.
|
|
|
|
*/
|
|
|
|
std::string cmCableWrapTclCommand::GetGccXmlFromCache() const
|
|
|
|
{
|
|
|
|
const char* gccxml =
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->GetDefinition("GCCXML");
|
2001-06-08 22:40:28 +04:00
|
|
|
if(gccxml)
|
|
|
|
{ return gccxml; }
|
|
|
|
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->AddCacheDefinition("GCCXML",
|
|
|
|
"NOTFOUND",
|
|
|
|
"Path to GCC-XML executable.",
|
|
|
|
cmCacheManager::FILEPATH);
|
2001-06-08 22:40:28 +04:00
|
|
|
return "NOTFOUND";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "GCCXML_FLAGS" cache entry value. If there is no cache
|
|
|
|
* entry for GCCXML_FLAGS, one will be created and initialized "".
|
|
|
|
*/
|
|
|
|
std::string cmCableWrapTclCommand::GetGccXmlFlagsFromCache() const
|
|
|
|
{
|
|
|
|
const char* gccxmlFlags =
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->GetDefinition("GCCXML_FLAGS");
|
2001-06-08 22:40:28 +04:00
|
|
|
if(gccxmlFlags)
|
|
|
|
{ return gccxmlFlags; }
|
|
|
|
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->AddCacheDefinition(
|
2001-06-08 22:40:28 +04:00
|
|
|
"GCCXML_FLAGS",
|
|
|
|
"",
|
|
|
|
"Flags to GCC-XML to get it to parse the native compiler's headers.",
|
|
|
|
cmCacheManager::STRING);
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the "CABLE" cache entry value. If there is no cache entry for CABLE,
|
|
|
|
* one will be created and initialized to NOTFOUND.
|
|
|
|
*/
|
|
|
|
std::string cmCableWrapTclCommand::GetCableFromCache() const
|
|
|
|
{
|
|
|
|
const char* cable =
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->GetDefinition("CABLE");
|
2001-06-08 22:40:28 +04:00
|
|
|
if(cable)
|
|
|
|
{ return cable; }
|
|
|
|
|
2001-08-08 19:54:46 +04:00
|
|
|
m_Makefile->AddCacheDefinition("CABLE",
|
|
|
|
"NOTFOUND",
|
|
|
|
"Path to CABLE executable.",
|
|
|
|
cmCacheManager::FILEPATH);
|
2001-06-08 22:40:28 +04:00
|
|
|
return "NOTFOUND";
|
|
|
|
}
|
2001-09-12 23:18:23 +04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse flags from the result of GetGccXmlFlagsFromCache() and push
|
|
|
|
* them onto the back of the given vector, in order. This uses an
|
|
|
|
* instance of cmGccXmlFlagsParser associated with the makefile so
|
|
|
|
* that parsing need only be done once.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cmCableWrapTclCommand
|
|
|
|
::AddGccXmlFlagsFromCache(std::vector<std::string>& resultArgs) const
|
|
|
|
{
|
|
|
|
cmGccXmlFlagsParser* parser = 0;
|
|
|
|
|
|
|
|
// See if the instance already exists with the parsed flags.
|
|
|
|
cmData* data = m_Makefile->LookupData("cmGccXmlFlagsParser");
|
|
|
|
if(data)
|
|
|
|
{
|
|
|
|
// Yes, use it.
|
|
|
|
parser = static_cast<cmGccXmlFlagsParser*>(data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No, create the instance and ask it to parse the flags.
|
|
|
|
parser = new cmGccXmlFlagsParser("cmGccXmlFlagsParser");
|
|
|
|
m_Makefile->RegisterData(parser);
|
|
|
|
parser->Parse(this->GetGccXmlFlagsFromCache().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use the parsed flags in the single instance.
|
|
|
|
parser->AddParsedFlags(resultArgs);
|
|
|
|
}
|