2001-03-02 00:47:05 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: Insight Segmentation & Registration Toolkit
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2000 National Library of Medicine
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
See COPYRIGHT.txt for copyright details.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmCablePackageCommand.h"
|
|
|
|
#include "cmCacheManager.h"
|
|
|
|
|
|
|
|
// cmCablePackageCommand
|
|
|
|
bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
|
|
|
|
{
|
|
|
|
if(args.size() != 1)
|
|
|
|
{
|
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This command needs to access the Cable data.
|
|
|
|
this->SetupCableData();
|
|
|
|
|
|
|
|
// The argument is the package name.
|
|
|
|
m_PackageName = args[0];
|
|
|
|
|
|
|
|
// Ask the cable data to begin the package. This may call another
|
2001-03-09 00:13:27 +03:00
|
|
|
// cmCablePackageCommand's WritePackageFooter(). This will call
|
|
|
|
// this cmCablePackageCommand's WritePackageHeader().
|
2001-03-02 00:47:05 +03:00
|
|
|
m_CableData->BeginPackage(this);
|
|
|
|
|
2001-03-09 00:13:27 +03:00
|
|
|
// Add custom rules to the makefile to generate this package's source
|
|
|
|
// files.
|
|
|
|
std::string command = "${CABLE}";
|
|
|
|
m_Makefile->ExpandVariablesInString(command);
|
2001-03-09 01:30:53 +03:00
|
|
|
std::vector<std::string> depends;
|
2001-03-09 00:13:27 +03:00
|
|
|
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.
|
2001-03-09 01:30:53 +03:00
|
|
|
m_Makefile->AddCustomCommand("cable_config.xml",
|
2001-03-09 00:13:27 +03:00
|
|
|
packageHeader.c_str(),
|
|
|
|
command.c_str(),
|
|
|
|
depends);
|
|
|
|
|
|
|
|
// A rule for the package's source file.
|
2001-03-09 01:30:53 +03:00
|
|
|
m_Makefile->AddCustomCommand("cable_config.xml",
|
2001-03-09 00:13:27 +03:00
|
|
|
packageSource.c_str(),
|
|
|
|
command.c_str(),
|
|
|
|
depends);
|
2001-03-02 00:47:05 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-09 00:13:27 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-02 00:47:05 +03:00
|
|
|
/**
|
|
|
|
* Write a CABLE package header.
|
|
|
|
*/
|
|
|
|
void cmCablePackageCommand::WritePackageHeader() const
|
|
|
|
{
|
|
|
|
std::ostream& os = m_CableData->GetOutputStream();
|
|
|
|
cmCableData::Indentation indent = m_CableData->GetIndentation();
|
|
|
|
os << indent << "<Package name=\"" << m_PackageName.c_str() << "\">"
|
|
|
|
<< std::endl;
|
|
|
|
m_CableData->Indent();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a CABLE package footer.
|
|
|
|
*/
|
|
|
|
void cmCablePackageCommand::WritePackageFooter() const
|
|
|
|
{
|
|
|
|
m_CableData->Unindent();
|
|
|
|
std::ostream& os = m_CableData->GetOutputStream();
|
|
|
|
cmCableData::Indentation indent = m_CableData->GetIndentation();
|
|
|
|
os << indent << "</Package> <!-- \"" << m_PackageName.c_str() << "\" -->"
|
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
|