ENH: added new generator

This commit is contained in:
Ken Martin 2005-05-12 10:49:56 -04:00
parent e1c9730a01
commit caf17c123b
11 changed files with 91 additions and 38 deletions

View File

@ -52,12 +52,15 @@ SET(SRCS
cmGlobalGenerator.h
cmGlobalUnixMakefileGenerator.cxx
cmGlobalUnixMakefileGenerator.h
cmGlobalUnixMakefileGenerator3.cxx
cmGlobalUnixMakefileGenerator3.h
cmListFileCache.cxx
cmListFileCache.h
cmListFileLexer.c
cmLocalGenerator.cxx
cmLocalGenerator.h
cmLocalUnixMakefileGenerator2.cxx
cmLocalUnixMakefileGenerator3.cxx
cmMakeDepend.cxx
cmMakeDepend.h
cmMakefile.cxx

View File

@ -15,7 +15,7 @@
=========================================================================*/
#include "cmGlobalBorlandMakefileGenerator.h"
#include "cmLocalUnixMakefileGenerator2.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmake.h"
@ -33,14 +33,13 @@ void cmGlobalBorlandMakefileGenerator::EnableLanguage(std::vector<std::string>co
mf->AddDefinition("BORLAND", "1");
mf->AddDefinition("CMAKE_GENERATOR_CC", "bcc32");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "bcc32");
this->cmGlobalUnixMakefileGenerator::EnableLanguage(l, mf);
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf);
}
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator()
{
cmLocalUnixMakefileGenerator2* lg = new cmLocalUnixMakefileGenerator2;
lg->SetEmptyCommand("@REM Borland Make needs a command here.");
cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
lg->SetEchoNeedsQuote(false);
lg->SetIncludeDirective("!include");
lg->SetWindowsShell(true);

View File

@ -15,7 +15,7 @@
=========================================================================*/
#include "cmGlobalNMakeMakefileGenerator.h"
#include "cmLocalUnixMakefileGenerator2.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
cmGlobalNMakeMakefileGenerator::cmGlobalNMakeMakefileGenerator()
@ -30,13 +30,13 @@ void cmGlobalNMakeMakefileGenerator::EnableLanguage(std::vector<std::string>cons
// pick a default
mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
this->cmGlobalUnixMakefileGenerator::EnableLanguage(l, mf);
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf);
}
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalNMakeMakefileGenerator::CreateLocalGenerator()
{
cmLocalUnixMakefileGenerator2* lg = new cmLocalUnixMakefileGenerator2;
cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
lg->SetEchoNeedsQuote(false);
lg->SetWindowsShell(true);
lg->SetMakeSilentFlag("/nologo");

View File

@ -17,14 +17,14 @@
#ifndef cmGlobalNMakeMakefileGenerator_h
#define cmGlobalNMakeMakefileGenerator_h
#include "cmGlobalUNIXMakefileGenerator.h"
#include "cmGlobalUNIXMakefileGenerator3.h"
/** \class cmGlobalNMakeMakefileGenerator
* \brief Write a NMake makefiles.
*
* cmGlobalNMakeMakefileGenerator manages nmake build process for a tree
*/
class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator
class cmGlobalNMakeMakefileGenerator : public cmGlobalUnixMakefileGenerator3
{
public:
cmGlobalNMakeMakefileGenerator();

View File

@ -187,6 +187,11 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
// Write the do not edit header.
lg->WriteDisclaimer(cmakefileStream);
// Save the generator name
cmakefileStream
<< "# The generator used is:\n"
<< "SET(CMAKE_DEPENDS_GENERATOR \"" << this->GetName() << "\")\n\n";
// for each cmMakefile get its list of dependencies
unsigned int i;
std::vector<std::string> lfiles;

View File

@ -134,6 +134,12 @@ public:
///! for existing files convert to output path and short path if spaces
std::string ConvertToOutputForExisting(const char* p);
/** Called from command-line hook to check dependencies. */
virtual void CheckDependencies(cmMakefile* /* mf */, bool /* verbose */) {};
/** Called from command-line hook to scan dependencies. */
virtual bool ScanDependencies(std::vector<std::string> const& /* args */) {return true;};
protected:
/** Construct a script from the given list of command lines. */
std::string ConstructScript(const cmCustomCommandLines& commandLines,

View File

@ -535,7 +535,9 @@ cmLocalUnixMakefileGenerator2
cmOStringStream depCmd;
// TODO: Account for source file properties and directory-level
// definitions when scanning for dependencies.
depCmd << "$(CMAKE_COMMAND) -E cmake_depends " << lang << " "
depCmd << "$(CMAKE_COMMAND) -E cmake_depends \""
<< m_GlobalGenerator->GetName() << "\" "
<< lang << " "
<< this->ConvertToRelativeOutputPath(obj.c_str()) << " "
<< this->ConvertToRelativeOutputPath(source.GetFullPath().c_str());
commands.push_back(depCmd.str());
@ -3131,17 +3133,17 @@ cmLocalUnixMakefileGenerator2
::ScanDependencies(std::vector<std::string> const& args)
{
// Format of arguments is:
// $(CMAKE_COMMAND), cmake_depends, <lang>, <obj>, <src>
// $(CMAKE_COMMAND), cmake_depends, GeneratorName, <lang>, <obj>, <src>
// The caller has ensured that all required arguments exist.
// The language for which we are scanning dependencies.
std::string const& lang = args[2];
std::string const& lang = args[3];
// The file to which to write dependencies.
const char* objFile = args[3].c_str();
const char* objFile = args[4].c_str();
// The source file at which to start the scan.
const char* srcFile = args[4].c_str();
const char* srcFile = args[5].c_str();
// Read the directory information file.
cmake cm;

View File

@ -94,10 +94,10 @@ public:
virtual void Generate();
/** Called from command-line hook to scan dependencies. */
static bool ScanDependencies(std::vector<std::string> const& args);
virtual bool ScanDependencies(std::vector<std::string> const& args);
/** Called from command-line hook to check dependencies. */
static void CheckDependencies(cmMakefile* mf, bool verbose);
virtual void CheckDependencies(cmMakefile* mf, bool verbose);
protected:

View File

@ -489,7 +489,9 @@ cmLocalUnixMakefileGenerator3
cmOStringStream depCmd;
// TODO: Account for source file properties and directory-level
// definitions when scanning for dependencies.
depCmd << "$(CMAKE_COMMAND) -E cmake_depends " << lang << " "
depCmd << "$(CMAKE_COMMAND) -E cmake_depends \""
<< m_GlobalGenerator->GetName() << "\" "
<< lang << " "
<< relativeObj.c_str() << " "
<< m_GlobalGenerator->ConvertToHomeRelativeOutputPath
(source.GetFullPath().c_str());
@ -576,8 +578,12 @@ cmLocalUnixMakefileGenerator3
this->AppendFlags(flags, this->GetIncludeFlags(lang));
// Get the output paths for source and object files.
std::string sourceFile =
this->ConvertToOptionallyRelativeOutputPath(source.GetFullPath().c_str());
std::string sourceFile = source.GetFullPath();
if(m_UseRelativePaths)
{
sourceFile = m_GlobalGenerator->ConvertToHomeRelativePath(sourceFile.c_str());
}
sourceFile = cmSystemTools::ConvertToOutputPath(sourceFile.c_str());
std::string objectFile =
this->ConvertToRelativeOutputPath(obj.c_str());
@ -2844,21 +2850,27 @@ cmLocalUnixMakefileGenerator3::GetDependsChecker(const std::string& lang,
const char* objFile,
bool verbose)
{
cmDepends *ret = 0;
if(lang == "C" || lang == "CXX" || lang == "RC")
{
return new cmDependsC(dir, objFile, verbose);
ret = new cmDependsC();
}
#ifdef CMAKE_BUILD_WITH_CMAKE
else if(lang == "Fortran")
{
return new cmDependsFortran(dir, objFile, verbose);
ret = new cmDependsFortran();
}
else if(lang == "Java")
{
return new cmDependsJava(dir, objFile, verbose);
ret = new cmDependsJava();
}
#endif
return 0;
if (ret)
{
ret->SetTargetFile(dir, objFile, ".depend",".build.depend.make");
ret->SetVerbose(verbose);
}
return ret;
}
//----------------------------------------------------------------------------
@ -2867,17 +2879,17 @@ cmLocalUnixMakefileGenerator3
::ScanDependencies(std::vector<std::string> const& args)
{
// Format of arguments is:
// $(CMAKE_COMMAND), cmake_depends, <lang>, <obj>, <src>
// $(CMAKE_COMMAND), cmake_depends, GeneratorName, <lang>, <obj>, <src>
// The caller has ensured that all required arguments exist.
// The language for which we are scanning dependencies.
std::string const& lang = args[2];
std::string const& lang = args[3];
// The file to which to write dependencies.
const char* objFile = args[3].c_str();
const char* objFile = args[4].c_str();
// The source file at which to start the scan.
const char* srcFile = args[4].c_str();
const char* srcFile = args[5].c_str();
// Read the directory information file.
cmake cm;
@ -2943,19 +2955,22 @@ cmLocalUnixMakefileGenerator3
if(lang == "C" || lang == "CXX" || lang == "RC")
{
// TODO: Handle RC (resource files) dependencies correctly.
cmDependsC scanner(".", objFile, srcFile, includes,
cmDependsC scanner(srcFile, includes,
includeRegexScan.c_str(), includeRegexComplain.c_str());
scanner.SetTargetFile(".",objFile,".depend",".build.depend.make");
return scanner.Write();
}
#ifdef CMAKE_BUILD_WITH_CMAKE
else if(lang == "Fortran")
{
cmDependsFortran scanner(".", objFile, srcFile, includes);
cmDependsFortran scanner(srcFile, includes);
scanner.SetTargetFile(".",objFile,".depend",".build.depend.make");
return scanner.Write();
}
else if(lang == "Java")
{
cmDependsJava scanner(".", objFile, srcFile);
cmDependsJava scanner(srcFile);
scanner.SetTargetFile(".",objFile,".depend",".build.depend.make");
return scanner.Write();
}
#endif

View File

@ -119,10 +119,10 @@ public:
/** Called from command-line hook to scan dependencies. */
static bool ScanDependencies(std::vector<std::string> const& args);
virtual bool ScanDependencies(std::vector<std::string> const& args);
/** Called from command-line hook to check dependencies. */
static void CheckDependencies(cmMakefile* mf, bool verbose);
virtual void CheckDependencies(cmMakefile* mf, bool verbose);
/** write some extra rules suahc as make test etc */
void WriteSpecialTargetsTop(std::ostream& makefileStream);

View File

@ -28,8 +28,6 @@
# include "cmVersion.h"
#endif
#include "cmLocalUnixMakefileGenerator2.h" // For -E cmake_depends callback.
// only build kdevelop generator on non-windows platforms
// when not bootstrapping cmake
#if !defined(_WIN32)
@ -52,6 +50,7 @@
#else
#endif
#include "cmGlobalUnixMakefileGenerator.h"
#include "cmGlobalUnixMakefileGenerator3.h"
#ifdef CMAKE_USE_KDEVELOP
# include "cmGlobalKdevelopGenerator.h"
@ -827,9 +826,18 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
}
// Internal CMake dependency scanning support.
else if (args[1] == "cmake_depends" && args.size() >= 5)
else if (args[1] == "cmake_depends" && args.size() >= 6)
{
return cmLocalUnixMakefileGenerator2::ScanDependencies(args)? 0 : 1;
cmake cm;
cmGlobalGenerator *ggd = cm.CreateGlobalGenerator(args[2].c_str());
ggd->SetCMakeInstance(&cm);
if (ggd)
{
std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
lgd->SetGlobalGenerator(ggd);
return lgd->ScanDependencies(args)? 0 : 1;
}
return 1;
}
#if defined(CMAKE_BUILD_WITH_CMAKE)
@ -1103,7 +1111,7 @@ int cmake::Configure()
}
this->SetGlobalGenerator(gen);
#else
this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator);
this->SetGlobalGenerator(new cmGlobalUnixMakefileGenerator2);
#endif
}
if(!m_GlobalGenerator)
@ -1419,6 +1427,8 @@ void cmake::AddDefaultGenerators()
#endif
m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] =
&cmGlobalUnixMakefileGenerator::New;
m_Generators[cmGlobalUnixMakefileGenerator3::GetActualName()] =
&cmGlobalUnixMakefileGenerator3::New;
#ifdef CMAKE_USE_XCODE
m_Generators[cmGlobalXCodeGenerator::GetActualName()] =
&cmGlobalXCodeGenerator::New;
@ -1618,7 +1628,20 @@ int cmake::CheckBuildSystem()
// the make system's VERBOSE environment variable to enable verbose
// output.
bool verbose = cmSystemTools::GetEnv("VERBOSE") != 0;
cmLocalUnixMakefileGenerator2::CheckDependencies(mf, verbose);
// compute depends based on the generator specified
const char* genName = mf->GetDefinition("CMAKE_DEPENDS_GENERATOR");
if (!genName || genName[0] == '\0')
{
genName = "Unix Makefiles";
}
cmGlobalGenerator *ggd = this->CreateGlobalGenerator(genName);
if (ggd)
{
std::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
lgd->SetGlobalGenerator(ggd);
lgd->CheckDependencies(mf, verbose);
}
// No need to rerun.
return 0;