ENH: Start working on CPack input file and cleanups

This commit is contained in:
Andy Cedilnik 2006-01-02 17:28:20 -05:00
parent f00b344ada
commit ebbe10193f
12 changed files with 66 additions and 133 deletions

View File

@ -52,11 +52,6 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGenerator(const char* name)
{
return 0;
}
if ( !gen->Initialize(name) )
{
delete gen;
return 0;
}
m_Generators.push_back(gen);
gen->SetLogger(m_Logger);
return gen;

View File

@ -17,11 +17,11 @@
#include "cmCPackGenericGenerator.h"
#include "cmMakefile.h"
#include "cmCPackLog.h"
#include "cmake.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmCPackLog.h"
#include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx>
@ -31,31 +31,13 @@
cmCPackGenericGenerator::cmCPackGenericGenerator()
{
m_GeneratorVerbose = false;
m_GlobalGenerator = 0;
m_LocalGenerator = 0;
m_MakefileMap = 0;
m_CMakeInstance = 0;
m_Logger = 0;
}
//----------------------------------------------------------------------
cmCPackGenericGenerator::~cmCPackGenericGenerator()
{
if ( m_GlobalGenerator )
{
delete m_GlobalGenerator;
m_GlobalGenerator = 0;
}
if ( m_LocalGenerator )
{
delete m_LocalGenerator;
m_LocalGenerator = 0;
}
if ( m_CMakeInstance )
{
delete m_CMakeInstance;
m_CMakeInstance = 0;
}
m_MakefileMap = 0;
}
@ -258,14 +240,9 @@ int cmCPackGenericGenerator::ProcessGenerator()
}
//----------------------------------------------------------------------
int cmCPackGenericGenerator::Initialize(const char* name)
int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf)
{
m_CMakeInstance = new cmake;
m_CMakeInstance->AddCMakePaths(m_CMakeRoot.c_str());
m_GlobalGenerator = new cmGlobalGenerator;
m_GlobalGenerator->SetCMakeInstance(m_CMakeInstance);
m_LocalGenerator = m_GlobalGenerator->CreateLocalGenerator();
m_MakefileMap = m_LocalGenerator->GetMakefile();
m_MakefileMap = mf;
m_Name = name;
return 1;
}

View File

@ -43,9 +43,6 @@
#define cout no_cout_use_cmCPack_Log
class cmMakefile;
class cmLocalGenerator;
class cmGlobalGenerator;
class cmake;
class cmCPackLog;
/** \class cmCPackGenericGenerator
@ -70,7 +67,7 @@ public:
/**
* Initialize generator
*/
virtual int Initialize(const char* name);
virtual int Initialize(const char* name, cmMakefile* mf);
/**
* Construct generator
@ -114,10 +111,7 @@ protected:
cmCPackLog* m_Logger;
private:
cmGlobalGenerator* m_GlobalGenerator;
cmLocalGenerator* m_LocalGenerator;
cmMakefile* m_MakefileMap;
cmake* m_CMakeInstance;
};
#endif

View File

@ -38,12 +38,6 @@ cmCPackNSISGenerator::~cmCPackNSISGenerator()
{
}
//----------------------------------------------------------------------
int cmCPackNSISGenerator::ProcessGenerator()
{
return this->Superclass::ProcessGenerator();
}
//----------------------------------------------------------------------
int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files)
@ -84,10 +78,14 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* top
}
//----------------------------------------------------------------------
int cmCPackNSISGenerator::Initialize(const char* name)
int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
{
int res = this->Superclass::Initialize(name, mf);
if ( !res )
{
return res;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()" << std::endl);
int res = this->Superclass::Initialize(name);
std::vector<std::string> path;
std::string nsisPath;
if ( !cmsys::SystemTools::ReadRegistryValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS",

View File

@ -31,16 +31,11 @@ class cmCPackNSISGenerator : public cmCPackGenericGenerator
{
public:
cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenericGenerator);
/**
* Do the actual processing. Subclass has to override it.
* Return < 0 if error.
*/
virtual int ProcessGenerator();
/**
* Initialize generator
*/
virtual int Initialize(const char* name);
virtual int Initialize(const char* name, cmMakefile* mf);
/**
* Construct generator

View File

@ -37,12 +37,6 @@ cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator()
{
}
//----------------------------------------------------------------------
int cmCPackPackageMakerGenerator::ProcessGenerator()
{
return this->Superclass::ProcessGenerator();
}
//----------------------------------------------------------------------
int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files)
@ -126,10 +120,10 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const c
}
//----------------------------------------------------------------------
int cmCPackPackageMakerGenerator::Initialize(const char* name)
int cmCPackPackageMakerGenerator::Initialize(const char* name, cmMakefile* mf)
{
int res = this->Superclass::Initialize(name, mf);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPackageMakerGenerator::Initialize()" << std::endl);
int res = this->Superclass::Initialize(name);
std::vector<std::string> path;
std::string pkgPath = "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS";
path.push_back(pkgPath);

View File

@ -31,16 +31,11 @@ class cmCPackPackageMakerGenerator : public cmCPackGenericGenerator
{
public:
cmCPackTypeMacro(cmCPackPackageMakerGenerator, cmCPackGenericGenerator);
/**
* Do the actual processing. Subclass has to override it.
* Return < 0 if error.
*/
virtual int ProcessGenerator();
/**
* Initialize generator
*/
virtual int Initialize(const char* name);
virtual int Initialize(const char* name, cmMakefile* mf);
/**
* Construct generator

View File

@ -35,18 +35,6 @@ cmCPackSTGZGenerator::~cmCPackSTGZGenerator()
{
}
//----------------------------------------------------------------------
int cmCPackSTGZGenerator::ProcessGenerator()
{
return this->Superclass::ProcessGenerator();
}
//----------------------------------------------------------------------
int cmCPackSTGZGenerator::Initialize(const char* name)
{
return this->Superclass::Initialize(name);
}
//----------------------------------------------------------------------
int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
{

View File

@ -29,16 +29,6 @@ class cmCPackSTGZGenerator : public cmCPackTGZGenerator
{
public:
cmCPackTypeMacro(cmCPackSTGZGenerator, cmCPackTGZGenerator);
/**
* Do the actual processing. Subclass has to override it.
* Return < 0 if error.
*/
virtual int ProcessGenerator();
/**
* Initialize generator
*/
virtual int Initialize(const char* name);
/**
* Construct generator

View File

@ -52,18 +52,6 @@ cmCPackTGZGenerator::~cmCPackTGZGenerator()
{
}
//----------------------------------------------------------------------
int cmCPackTGZGenerator::ProcessGenerator()
{
return this->Superclass::ProcessGenerator();
}
//----------------------------------------------------------------------
int cmCPackTGZGenerator::Initialize(const char* name)
{
return this->Superclass::Initialize(name);
}
//----------------------------------------------------------------------
class cmCPackTGZ_Data
{

View File

@ -33,17 +33,6 @@ public:
friend class cmCPackTGZGeneratorForward;
cmCPackTypeMacro(cmCPackTGZGenerator, cmCPackGenericGenerator);
/**
* Do the actual processing. Subclass has to override it.
* Return < 0 if error.
*/
virtual int ProcessGenerator();
/**
* Initialize generator
*/
virtual int Initialize(const char* name);
/**
* Construct generator
*/

View File

@ -21,6 +21,10 @@
#include "cmDocumentation.h"
#include "cmCPackGenerators.h"
#include "cmCPackGenericGenerator.h"
#include "cmake.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmCPackLog.h"
@ -129,6 +133,7 @@ int main (int argc, char *argv[])
log.SetErrorPrefix("CPack Error: ");
log.SetWarningPrefix("CPack Warning: ");
log.SetOutputPrefix("CPack: ");
log.SetVerbosePrefix("CPack Verbose: ");
int res = 0;
cmSystemTools::EnableMSVCDebugHook();
@ -158,8 +163,7 @@ int main (int argc, char *argv[])
cpackDefinitions definitions;
definitions.m_Log = &log;
cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
cpackConfigFile += "/CPack.cmake";
cpackConfigFile = "";
cmDocumentation doc;
cmsys::CommandLineArguments arg;
@ -203,6 +207,19 @@ int main (int argc, char *argv[])
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
cmake cminst;
cmGlobalGenerator cmgg;
cmgg.SetCMakeInstance(&cminst);
cmLocalGenerator* cmlg = cmgg.CreateLocalGenerator();
cmMakefile* mf = cmlg->GetMakefile();
bool cpackConfigFileSpecified = true;
if ( cpackConfigFile.empty() )
{
cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
cpackConfigFile += "/CPack.cmake";
cpackConfigFileSpecified = false;
}
cmCPackGenerators generators;
generators.SetLogger(&log);
@ -215,29 +232,55 @@ int main (int argc, char *argv[])
if ( parsed && !help )
{
if ( generator.empty() )
if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) && !mf->ReadListFile(0, cpackConfigFile.c_str()) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reding CPack config file: \"" << cpackConfigFile.c_str() << "\"" << std::endl);
return 1;
}
else if ( cpackConfigFileSpecified )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot find CPack config file: \"" << cpackConfigFile.c_str() << "\"" << std::endl);
return 1;
}
if ( !generator.empty() ) { mf->AddDefinition("CPACK_GENERATOR", generator.c_str()); }
if ( !cpackProjectName.empty() ) { mf->AddDefinition("CPACK_PROJECT_NAME", cpackProjectName.c_str()); }
if ( !cpackProjectVersion.empty() ) { mf->AddDefinition("CPACK_PROJECT_VERSION", cpackProjectVersion.c_str()); }
if ( !cpackProjectPatch.empty() ) { mf->AddDefinition("CPACK_PROJECT_VERSION_PATCH", cpackProjectPatch.c_str()); }
if ( !cpackProjectVendor.empty() ) { mf->AddDefinition("CPACK_PROJECT_VENDOR", cpackProjectVendor.c_str()); }
if ( !cpackProjectDirectory.empty() ) { mf->AddDefinition("CPACK_PROJECT_DIRECTORY", cpackProjectDirectory.c_str()); }
if ( !cpackBuildConfig.empty() ) { mf->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); }
cpackDefinitions::MapType::iterator cdit;
for ( cdit = definitions.m_Map.begin(); cdit != definitions.m_Map.end(); ++cdit )
{
cpackGenerator->SetOption(cdit->first.c_str(), cdit->second.c_str());
}
const char* gen = mf->GetDefinition("CPACK_GENERATOR");
if ( !gen )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified" << std::endl);
parsed = 0;
}
if ( parsed && cpackProjectName.empty() )
if ( parsed && !mf->GetDefinition("CPACK_PROJECT_NAME") )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack project name not specified" << std::endl);
parsed = 0;
}
if ( parsed && cpackProjectVersion.empty() )
if ( parsed && !mf->GetDefinition("CPACK_PROJECT_VERSION"))
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack project version not specified" << std::endl);
parsed = 0;
}
if ( parsed )
{
cpackGenerator = generators.NewGenerator(generator.c_str());
cpackGenerator = generators.NewGenerator(gen);
if ( !cpackGenerator )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize CPack generator: " << generator.c_str() << std::endl);
parsed = 0;
}
cpackGenerator->Initialize(gen, mf);
if ( parsed && !cpackGenerator->FindRunningCMake(argv[0]) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize the generator" << std::endl);
@ -274,22 +317,9 @@ int main (int argc, char *argv[])
cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
#endif
const char* projName = mf->GetDefinition("CPACK_PROJECT_NAME");
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: " << cpackGenerator->GetNameOfClass() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " << cpackProjectName.c_str() << std::endl);
cpackGenerator->SetOption("CPACK_PROJECT_NAME", cpackProjectName.c_str());
cpackGenerator->SetOption("CPACK_PROJECT_VERSION", cpackProjectVersion.c_str());
cpackGenerator->SetOption("CPACK_PROJECT_VERSION_PATCH", cpackProjectPatch.c_str());
cpackGenerator->SetOption("CPACK_PROJECT_VENDOR", cpackProjectVendor.c_str());
cpackGenerator->SetOption("CPACK_PROJECT_DIRECTORY", cpackProjectDirectory.c_str());
if ( !cpackBuildConfig.empty() )
{
cpackGenerator->SetOption("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
}
cpackDefinitions::MapType::iterator cdit;
for ( cdit = definitions.m_Map.begin(); cdit != definitions.m_Map.end(); ++cdit )
{
cpackGenerator->SetOption(cdit->first.c_str(), cdit->second.c_str());
}
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " << projName << std::endl);
res = cpackGenerator->ProcessGenerator();
if ( !res )