summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-07-24 16:52:39 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2007-07-24 16:52:39 (GMT)
commit919265516ea3233e6a4e29a17ad4ec24150eefda (patch)
tree1d2beab70b483ab0f2153d6766763094c7b11331 /Source
parent4ae802d9c19d1f021970215d992b6aebc4165ec8 (diff)
downloadCMake-919265516ea3233e6a4e29a17ad4ec24150eefda.zip
CMake-919265516ea3233e6a4e29a17ad4ec24150eefda.tar.gz
CMake-919265516ea3233e6a4e29a17ad4ec24150eefda.tar.bz2
ENH: add ReadListFile() to cmCPackGenericGenerator, so cmMakefile can be
private again -convert the ZIP generator to use a cmake script instead of hardcoding everything (CPackZIP.cmake) Alex
Diffstat (limited to 'Source')
-rw-r--r--Source/CPack/cmCPackGenericGenerator.cxx41
-rw-r--r--Source/CPack/cmCPackGenericGenerator.h7
-rw-r--r--Source/CPack/cmCPackZIPGenerator.cxx138
-rw-r--r--Source/CPack/cmCPackZIPGenerator.h8
4 files changed, 58 insertions, 136 deletions
diff --git a/Source/CPack/cmCPackGenericGenerator.cxx b/Source/CPack/cmCPackGenericGenerator.cxx
index 06f2b00..64b283c 100644
--- a/Source/CPack/cmCPackGenericGenerator.cxx
+++ b/Source/CPack/cmCPackGenericGenerator.cxx
@@ -32,14 +32,14 @@
cmCPackGenericGenerator::cmCPackGenericGenerator()
{
this->GeneratorVerbose = false;
- this->Makefile = 0;
+ this->MakefileMap = 0;
this->Logger = 0;
}
//----------------------------------------------------------------------
cmCPackGenericGenerator::~cmCPackGenericGenerator()
{
- this->Makefile = 0;
+ this->MakefileMap = 0;
}
//----------------------------------------------------------------------
@@ -392,7 +392,7 @@ int cmCPackGenericGenerator::InstallProjectViaInstallScript(
tempInstallDirectory);
this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
tempInstallDirectory);
- int res = this->Makefile->ReadListFile(0, installScript.c_str());
+ int res = this->MakefileMap->ReadListFile(0, installScript.c_str());
if ( cmSystemTools::GetErrorOccuredFlag() || !res )
{
return 0;
@@ -454,7 +454,7 @@ int cmCPackGenericGenerator::InstallProjectViaInstallCMakeProjects(
const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
cmGlobalGenerator* globalGenerator
- = this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
+ = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGenerator);
// set the global flag for unix style paths on cmSystemTools as
// soon as the generator is set. This allows gmake to be used
@@ -464,9 +464,9 @@ int cmCPackGenericGenerator::InstallProjectViaInstallCMakeProjects(
// Does this generator require pre-install?
if ( globalGenerator->GetPreinstallTargetName() )
{
- globalGenerator->FindMakeProgram(this->Makefile);
+ globalGenerator->FindMakeProgram(this->MakefileMap);
const char* cmakeMakeProgram
- = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
+ = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
std::string buildCommand
= globalGenerator->GenerateBuildCommand(cmakeMakeProgram,
installProjectName.c_str(), 0,
@@ -551,10 +551,17 @@ int cmCPackGenericGenerator::InstallProjectViaInstallCMakeProjects(
}
//----------------------------------------------------------------------
+bool cmCPackGenericGenerator::ReadListFile(const char* moduleName)
+{
+ std::string fullPath = this->MakefileMap->GetModulesFile(moduleName);
+ return this->MakefileMap->ReadListFile(0, fullPath.c_str());
+}
+
+//----------------------------------------------------------------------
void cmCPackGenericGenerator::SetOptionIfNotSet(const char* op,
const char* value)
{
- const char* def = this->Makefile->GetDefinition(op);
+ const char* def = this->MakefileMap->GetDefinition(op);
if ( def && *def )
{
return;
@@ -571,12 +578,12 @@ void cmCPackGenericGenerator::SetOption(const char* op, const char* value)
}
if ( !value )
{
- this->Makefile->RemoveDefinition(op);
+ this->MakefileMap->RemoveDefinition(op);
return;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
<< "::SetOption(" << op << ", " << value << ")" << std::endl);
- this->Makefile->AddDefinition(op, value);
+ this->MakefileMap->AddDefinition(op, value);
}
//----------------------------------------------------------------------
@@ -680,7 +687,7 @@ int cmCPackGenericGenerator::ProcessGenerator()
int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf,
const char* argv0)
{
- this->Makefile = mf;
+ this->MakefileMap = mf;
this->Name = name;
if ( !this->FindRunningCMake(argv0) )
{
@@ -698,9 +705,15 @@ int cmCPackGenericGenerator::InitializeInternal()
}
//----------------------------------------------------------------------
+bool cmCPackGenericGenerator::IsSet(const char* name) const
+{
+ return this->MakefileMap->IsSet(name);
+}
+
+//----------------------------------------------------------------------
const char* cmCPackGenericGenerator::GetOption(const char* op)
{
- return this->Makefile->GetDefinition(op);
+ return this->MakefileMap->GetDefinition(op);
}
//----------------------------------------------------------------------
@@ -913,7 +926,7 @@ std::string cmCPackGenericGenerator::FindTemplate(const char* name)
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
<< (name ? name : "(NULL)") << std::endl);
- std::string ffile = this->Makefile->GetModulesFile(name);
+ std::string ffile = this->MakefileMap->GetModulesFile(name);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
<< ffile.c_str() << std::endl);
return ffile;
@@ -923,7 +936,7 @@ std::string cmCPackGenericGenerator::FindTemplate(const char* name)
bool cmCPackGenericGenerator::ConfigureString(const std::string& inString,
std::string& outString)
{
- this->Makefile->ConfigureString(inString,
+ this->MakefileMap->ConfigureString(inString,
outString, true, false);
return true;
}
@@ -932,7 +945,7 @@ bool cmCPackGenericGenerator::ConfigureString(const std::string& inString,
bool cmCPackGenericGenerator::ConfigureFile(const char* inName,
const char* outName, bool copyOnly /* = false */)
{
- return this->Makefile->ConfigureFile(inName, outName,
+ return this->MakefileMap->ConfigureFile(inName, outName,
copyOnly, true, false) == 1;
}
diff --git a/Source/CPack/cmCPackGenericGenerator.h b/Source/CPack/cmCPackGenericGenerator.h
index f5df78e..7e0b10a 100644
--- a/Source/CPack/cmCPackGenericGenerator.h
+++ b/Source/CPack/cmCPackGenericGenerator.h
@@ -80,6 +80,7 @@ public:
void SetOption(const char* op, const char* value);
void SetOptionIfNotSet(const char* op, const char* value);
const char* GetOption(const char* op);
+ bool IsSet(const char* name) const;
//! Set all the variables
int FindRunningCMake(const char* arg0);
@@ -89,6 +90,8 @@ public:
//! Display verbose information via logger
void DisplayVerboseOutput(const char* msg, float progress);
+
+ bool ReadListFile(const char* moduleName);
protected:
int PrepareNames();
@@ -129,8 +132,8 @@ protected:
std::string CMakeRoot;
cmCPackLog* Logger;
-
- cmMakefile* Makefile;
+private:
+ cmMakefile* MakefileMap;
};
#endif
diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx
index 34db2f3..8af17c5 100644
--- a/Source/CPack/cmCPackZIPGenerator.cxx
+++ b/Source/CPack/cmCPackZIPGenerator.cxx
@@ -17,11 +17,7 @@
#include "cmCPackZIPGenerator.h"
-#include "cmake.h"
-#include "cmGlobalGenerator.h"
-#include "cmLocalGenerator.h"
#include "cmSystemTools.h"
-#include "cmMakefile.h"
#include "cmGeneratedFileStream.h"
#include "cmCPackLog.h"
@@ -41,67 +37,14 @@ cmCPackZIPGenerator::~cmCPackZIPGenerator()
int cmCPackZIPGenerator::InitializeInternal()
{
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1");
- std::vector<std::string> path;
- std::string pkgPath = "c:/Program Files/WinZip";
- path.push_back(pkgPath);
- pkgPath = cmSystemTools::FindProgram("wzzip", path, false);
- this->ZipStyle = cmCPackZIPGenerator::StyleUnkown;
- bool found = false;
- if ( pkgPath.empty() )
- {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Cannot find WinZip" << std::endl);
- }
- else
- {
- this->ZipStyle = cmCPackZIPGenerator::StyleWinZip;
- found = true;
- }
-
- if ( !found )
- {
- pkgPath = "c:/Program Files/7-Zip";
- path.push_back(pkgPath);
- pkgPath = cmSystemTools::FindProgram("7z", path, false);
-
- if ( pkgPath.empty() )
- {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Cannot find 7ZIP"
- << std::endl);
- }
- else
- {
- this->ZipStyle = cmCPackZIPGenerator::Style7Zip;
- found = true;
- }
- }
-
- if ( !found )
- {
- path.erase(path.begin(), path.end());
- pkgPath = "c:/cygwin/bin";
- path.push_back(pkgPath);
- pkgPath = cmSystemTools::FindProgram("zip", path, false);
- if ( pkgPath.empty() )
- {
- cmCPackLogger(cmCPackLog::LOG_DEBUG, "Cannot find unix ZIP"
- << std::endl);
- }
- else
- {
- this->ZipStyle = cmCPackZIPGenerator::StyleUnixZip;
- found = true;
- }
- }
- if ( !found )
+ this->ReadListFile("CPackZIP.cmake");
+ if ((!this->IsSet("ZIP_EXECUTABLE"))
+ || (!this->IsSet("CPACK_ZIP_COMMAND")))
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find a suitable ZIP program"
<< std::endl);
return 0;
}
- this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Found ZIP program: "
- << pkgPath.c_str()
- << std::endl);
return this->Superclass::InitializeInternal();
}
@@ -112,75 +55,46 @@ int cmCPackZIPGenerator::CompressFiles(const char* outFileName,
std::string tempFileName;
tempFileName = toplevel;
tempFileName += "/winZip.filelist";
- bool needQuotesInFile = false;
- cmOStringStream dmgCmd;
- switch ( this->ZipStyle )
- {
- case cmCPackZIPGenerator::StyleWinZip:
- dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
- << "\" -P \"" << outFileName
- << "\" @winZip.filelist";
- needQuotesInFile = true;
- break;
- case cmCPackZIPGenerator::Style7Zip:
- // this is the zip generator, so tell 7zip to generate zip files
- dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
- << "\" a -tzip \"" << outFileName
- << "\" @winZip.filelist";
- needQuotesInFile = true;
- break;
- case cmCPackZIPGenerator::StyleUnixZip:
- dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
- << "\" -r \"" << outFileName
- << "\" . -i@winZip.filelist";
- break;
- default:
- cmCPackLogger(cmCPackLog::LOG_ERROR, "Unknown ZIP style"
- << std::endl);
- return 0;
- }
- if(tempFileName.size())
+ bool needQuotesInFile = cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES"));
+
+ std::string cmd = this->GetOption("CPACK_ZIP_COMMAND");
+ cmsys::SystemTools::ReplaceString(cmd, "<ARCHIVE>", outFileName);
+ cmsys::SystemTools::ReplaceString(cmd, "<FILELIST>", "winZip.filelist");
+
+ { // the scope is needed for cmGeneratedFileStream
+ cmGeneratedFileStream out(tempFileName.c_str());
+ std::vector<std::string>::const_iterator fileIt;
+ for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
{
- cmGeneratedFileStream out(tempFileName.c_str());
- std::vector<std::string>::const_iterator fileIt;
- for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
+ if ( needQuotesInFile )
{
- if ( needQuotesInFile )
- {
- out << "\"";
- }
- out << cmSystemTools::RelativePath(toplevel, fileIt->c_str());
- if ( needQuotesInFile )
- {
- out << "\"";
- }
- out << std::endl;
+ out << "\"";
}
- }
- else
- {
- std::vector<std::string>::const_iterator fileIt;
- for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
+ out << cmSystemTools::RelativePath(toplevel, fileIt->c_str());
+ if ( needQuotesInFile )
{
- dmgCmd << " \""
- << cmSystemTools::RelativePath(toplevel, fileIt->c_str())
- << "\"";
+ out << "\"";
}
+ out << std::endl;
}
+ }
+
+
std::string output;
int retVal = -1;
- int res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
+ int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output,
&retVal, toplevel, this->GeneratorVerbose, 0);
+
if ( !res || retVal )
{
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/CompressZip.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
+ ofs << "# Run command: " << cmd.c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: "
- << dmgCmd.str().c_str() << std::endl
+ << cmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return 0;
}
diff --git a/Source/CPack/cmCPackZIPGenerator.h b/Source/CPack/cmCPackZIPGenerator.h
index 06d9b99..ed66336 100644
--- a/Source/CPack/cmCPackZIPGenerator.h
+++ b/Source/CPack/cmCPackZIPGenerator.h
@@ -37,14 +37,6 @@ public:
cmCPackZIPGenerator();
virtual ~cmCPackZIPGenerator();
- enum ZipStyles
- {
- StyleUnkown,
- StyleWinZip,
- StyleUnixZip,
- Style7Zip
- };
-
protected:
virtual int InitializeInternal();
int CompressFiles(const char* outFileName, const char* toplevel,