/*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Insight Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmGlobalCodeWarriorGenerator.h"
#include "cmLocalCodeWarriorGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
#include "cmSourceFile.h"
#include "cmCacheManager.h"
cmLocalCodeWarriorGenerator::cmLocalCodeWarriorGenerator()
{
}
cmLocalCodeWarriorGenerator::~cmLocalCodeWarriorGenerator()
{
}
void cmLocalCodeWarriorGenerator::Generate(bool /* fromTheTop */)
{
}
void cmLocalCodeWarriorGenerator::WriteTargets(std::ostream& fout)
{
cmTargets &tgts = m_Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
{
this->WriteTarget(fout,l->first.c_str(),&(l->second));
}
}
void cmLocalCodeWarriorGenerator::WriteTarget(std::ostream& fout,
const char *tgtName,
cmTarget const *l)
{
fout << "\n";
fout << "" << tgtName << "\n";
this->WriteSettingList(fout, tgtName,l);
this->WriteFileList(fout, tgtName,l);
this->WriteLinkOrder(fout, tgtName, l);
// this->WriteSubTargetList(fout,l);
fout << "\n";
}
void cmLocalCodeWarriorGenerator::AddFileMapping(std::ostream& fout,
const char *ftype,
const char *ext,
const char *comp,
const char *edit,
bool precomp,
bool launch,
bool res,
bool ignored)
{
fout << "\n";
fout << "FileType" << ftype <<
"\n";
fout << "FileExtension" << ext <<
"\n";
fout << "Compiler" << comp <<
"\n";
fout << "EditLanguage" << edit <<
"\n";
fout << "Precompile"
<< (precomp ? "true" : "false") << "\n";
fout << "Launchable"
<< (launch ? "true" : "false") << "\n";
fout << "ResourceFile"
<< (res ? "true" : "false") << "\n";
fout << "IgnoredByMake"
<< (ignored ? "true" : "false") << "\n";
fout << "\n";
}
void cmLocalCodeWarriorGenerator::WriteSettingList(std::ostream& fout,
const char *tgtName,
cmTarget const *l)
{
fout << "\n";
fout << "UserSourceTrees\n";
fout << "AlwaysSearchUserPathsfalse\n";
fout << "InterpretDOSAndUnixPathsfalse\n";
fout << "RequireFrameworkStyleIncludesfalse\n";
// list the include paths
fout << "UserSearchPaths\n";
std::vector& includes = m_Makefile->GetIncludeDirectories();
std::vector::iterator i = includes.begin();
for(;i != includes.end(); ++i)
{
fout << "\n";
fout << "SearchPath\n";
fout << "Path" << i->c_str() << "\n";
fout << "PathFormatGeneric\n";
fout << "PathRootAbsolute\n";
fout << "\n";
fout << "Recursivefalse\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
}
fout << "\n";
fout << "SystemSearchPaths\n";
fout << "\n";
fout << "SearchPath\n";
fout << "Path:MSL:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootCodeWarrior\n";
fout << "\n";
fout << "Recursivetrue\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
fout << "\n";
fout << "SearchPath\n";
fout << "Path:MacOS Support:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootCodeWarrior\n";
fout << "\n";
fout << "Recursivetrue\n";
fout << "FrameworkPathfalse\n";
fout << "HostFlagsAll\n";
fout << "\n";
fout << "\n";
fout << "MWRuntimeSettings_WorkingDirectory\n";
fout << "MWRuntimeSettings_CommandLine\n";
fout << "MWRuntimeSettings_HostApplication\n";
fout << "Path\n";
fout << "PathFormatGeneric\n";
fout << "PathRootAbsolute\n";
fout << "\n";
fout << "MWRuntimeSettings_EnvVars\n";
//
fout << "LinkerMacOS PPC Linker\n";
fout << "PreLinker\n";
fout << "PostLinker\n";
fout << "Targetname" << tgtName
<< "\n";
fout << "OutputDirectory\n";
fout << "Path:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootProject\n";
fout << "\n";
fout << "SaveEntriesUsingRelativePathsfalse\n";
// add the cxx file type
fout << "FileMappings\n";
this->AddFileMapping(fout,"TEXT",".cxx","MW C/C++ PPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cpp","MW C/C++ PPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".c","MW C/C++ PPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cc","MW C/C++ PPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cp","MW C/C++ PPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".cpp","MW C/C++ PPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".h","MW C/C++ PPC","C/C++",
false,false,false,true);
this->AddFileMapping(fout,"TEXT",".hpp","MW C/C++ PPC","C/C++",
false,false,false,true);
this->AddFileMapping(fout,"TEXT",".m","MW C/C++ PPC","C/C++",
false,false,false,false);
this->AddFileMapping(fout,"TEXT",".mm","MW C/C++ PPC","C/C++",
false,false,false,false);
fout << "\n";
//
fout << "MWProject_PPC_type";
switch (l->GetType())
{
case cmTarget::STATIC_LIBRARY:
fout << "Library" << "\n";
fout << "MWProject_PPC_outfile";
fout << tgtName << ".lib";
fout << "\n";
break;
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
// m_Makefile->GetDefinition("CMAKE_MODULE_SUFFIX");
fout << "Shared Library" << "\n";
fout << "MWProject_PPC_outfile";
fout << tgtName << ".dylib";
fout << "\n";
break;
case cmTarget::EXECUTABLE:
case cmTarget::WIN32_EXECUTABLE:
fout << "Application" << "\n";
fout << "MWProject_PPC_outfile";
fout << tgtName << cmSystemTools::GetExecutableExtension();
fout << "\n";
break;
default:;
}
fout << "MWProject_PPC_filecreator????" << "\n";
fout << "MWProject_PPC_filetypeAPPL\n";
fout << "MWProject_PPC_size384\n";
fout << "MWProject_PPC_minsize384\n";
fout << "MWProject_PPC_stacksize64\n";
fout << "MWProject_PPC_flags22720\n";
fout << "MWProject_PPC_symfilename\n";
fout << "MWProject_PPC_rsrcname\n";
fout << "MWProject_PPC_rsrcheaderNative\n";
fout << "MWProject_PPC_rsrctype????" << "\n";
fout << "MWProject_PPC_rsrcid0\n";
fout << "MWProject_PPC_rsrcflags0\n";
fout << "MWProject_PPC_rsrcstore0\n";
fout << "MWProject_PPC_rsrcmerge0\n";
fout << "MWProject_PPC_flatrsrc0\n";
fout << "MWProject_PPC_flatrsrcoutputdir\n";
fout << "Path:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootProject\n";
fout << "\n";
fout << "MWProject_PPC_flatrsrcfilename\n";
/*
fout << "MWMerge_MacOS_outputCreator????\n";
fout << "MWMerge_MacOS_outputTypeAPPL\n";
fout << "MWMerge_MacOS_suppressWarning0\n";
fout << "MWMerge_MacOS_copyFragments1\n";
fout << "MWMerge_MacOS_copyResources1\n";
fout << "MWMerge_MacOS_flattenResource0\n";
fout << "MWMerge_MacOS_flatFileNamea.rsrc\n";
fout << "MWMerge_MacOS_flatFileOutputPath\n";
fout << "Path:\n";
fout << "PathFormatMacOS\n";
fout << "PathRootProject\n";
fout << "\n";
fout << "MWMerge_MacOS_skipResources\n";
*/
fout << "\n";
}
void cmLocalCodeWarriorGenerator::WriteFileList(std::ostream& fout,
const char* /*tgtName*/,
cmTarget const *l)
{
fout << "\n";
// for each file
std::vector const& classes = l->GetSourceFiles();
for(std::vector::const_iterator i = classes.begin();
i != classes.end(); i++)
{
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
fout << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
//fout << "common\n";
fout << "" << source << "\n";
fout << "Generic\n";
fout << "Text\n";
fout << "Debug\n";
fout << "\n";
}
// now add in the libraries we depend on
// now add in the system libs (for an executable)
if (l->GetType() == cmTarget::EXECUTABLE)
{
fout << "\n";
fout << "Name\n";
fout << "MSL RuntimePPC.Lib\n";
fout << "MacOS\n";
fout << "Library\n";
fout << "Debug\n";
fout << "\n";
}
fout << "\n";
}
void cmLocalCodeWarriorGenerator::WriteLinkOrder(std::ostream& fout,
const char* /*tgtName*/,
cmTarget const *l)
{
fout << "\n";
// for each file
std::vector const& classes = l->GetSourceFiles();
for(std::vector::const_iterator i = classes.begin();
i != classes.end(); i++)
{
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
fout << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
//fout << "common\n";
fout << "" << source << "\n";
fout << "Generic\n";
fout << "\n";
}
// now add in the system libs (for an executable)
if (l->GetType() == cmTarget::EXECUTABLE)
{
fout << "\n";
fout << "Name\n";
fout << "MSL RuntimePPC.Lib\n";
fout << "MacOS\n";
fout << "\n";
}
fout << "\n";
}
void cmLocalCodeWarriorGenerator::WriteGroups(std::ostream& fout)
{
cmTargets &tgts = m_Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
{
this->WriteGroup(fout,l->first.c_str(),&(l->second));
}
}
void cmLocalCodeWarriorGenerator::WriteGroup(std::ostream& fout,
const char *tgtName,
cmTarget const *l)
{
fout << "" << tgtName << "\n";
// for each file
std::vector const& classes = l->GetSourceFiles();
for(std::vector::const_iterator i = classes.begin();
i != classes.end(); i++)
{
std::string source = (*i)->GetFullPath();
fout << "\n";
fout << "" << tgtName << "\n";
fout << "Absolute\n";
fout << "Absolute\n";
fout << "" << source << "\n";
fout << "Generic\n";
fout << "\n";
}
// write out the libraries groups
/*
Classic Release
Name
console.stubs.c
MacOS
*/
if (l->GetType() == cmTarget::EXECUTABLE)
{
fout << "\n";
fout << "" << tgtName << "\n";
fout << "Name\n";
fout << "MSL RuntimePPC.Lib\n";
fout << "MacOS\n";
fout << "\n";
}
/*
Classic Release
Name
MSL C++.PPC.Lib
MacOS
Classic Release
Name
MSL C.PPC.Lib
MacOS
Carbon Debug
Name
MSL C.CARBON.Lib
MacOS
*/
fout << "\n";
}