STYLE: Lots of formating to remove style problems

This commit is contained in:
Andy Cedilnik 2006-03-08 16:33:39 -05:00
parent 3d44b9a354
commit e8affe5cc2
15 changed files with 384 additions and 200 deletions

View File

@ -31,7 +31,8 @@ cmCPackGenerators::cmCPackGenerators()
this->RegisterGenerator("TGZ", cmCPackTGZGenerator::CreateGenerator);
this->RegisterGenerator("STGZ", cmCPackSTGZGenerator::CreateGenerator);
this->RegisterGenerator("NSIS", cmCPackNSISGenerator::CreateGenerator);
this->RegisterGenerator("PackageMaker", cmCPackPackageMakerGenerator::CreateGenerator);
this->RegisterGenerator("PackageMaker",
cmCPackPackageMakerGenerator::CreateGenerator);
}
//----------------------------------------------------------------------
@ -58,13 +59,15 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGenerator(const char* name)
}
//----------------------------------------------------------------------
cmCPackGenericGenerator* cmCPackGenerators::NewGeneratorInternal(const char* name)
cmCPackGenericGenerator* cmCPackGenerators::NewGeneratorInternal(
const char* name)
{
if ( !name )
{
return 0;
}
cmCPackGenerators::t_GeneratorCreatorsMap::iterator it = m_GeneratorCreators.find(name);
cmCPackGenerators::t_GeneratorCreatorsMap::iterator it
= m_GeneratorCreators.find(name);
if ( it == m_GeneratorCreators.end() )
{
return 0;
@ -73,11 +76,13 @@ cmCPackGenericGenerator* cmCPackGenerators::NewGeneratorInternal(const char* nam
}
//----------------------------------------------------------------------
void cmCPackGenerators::RegisterGenerator(const char* name, CreateGeneratorCall* createGenerator)
void cmCPackGenerators::RegisterGenerator(const char* name,
CreateGeneratorCall* createGenerator)
{
if ( !name || !createGenerator )
{
cmCPack_Log(m_Logger, cmCPackLog::LOG_ERROR, "Cannot register generator" << std::endl);
cmCPack_Log(m_Logger, cmCPackLog::LOG_ERROR, "Cannot register generator"
<< std::endl);
return;
}
m_GeneratorCreators[name] = createGenerator;

View File

@ -41,7 +41,8 @@ public:
typedef cmCPackGenericGenerator* CreateGeneratorCall();
void RegisterGenerator(const char* name, CreateGeneratorCall* createGenerator);
void RegisterGenerator(const char* name,
CreateGeneratorCall* createGenerator);
void SetLogger(cmCPackLog* logger) { m_Logger = logger; }
@ -55,6 +56,3 @@ private:
};
#endif

View File

@ -72,26 +72,32 @@ int cmCPackGenericGenerator::PrepareNames()
cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()).c_str());
this->SetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY", installPrefix.c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
const char* descFileName = this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: " << descFileName << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl);
const char* descFileName
= this->GetOption("CPACK_PACKAGE_DESCRIPTION_FILE");
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Look for: " << descFileName << std::endl);
if ( descFileName )
{
if ( !cmSystemTools::FileExists(descFileName) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find description file name: " << descFileName << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find description file name: " << descFileName << std::endl);
return 0;
}
std::ifstream ifs(descFileName);
if ( !ifs )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot open description file name: " << descFileName << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot open description file name: " << descFileName << std::endl);
return 0;
}
cmOStringStream ostr;
std::string line;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Read description file: " << descFileName << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Read description file: " << descFileName << std::endl);
while ( ifs && cmSystemTools::GetLineFromStream(ifs, line) )
{
ostr << cmSystemTools::MakeXMLSafe(line.c_str()) << std::endl;
@ -101,7 +107,8 @@ int cmCPackGenericGenerator::PrepareNames()
if ( !this->GetOption("CPACK_PACKAGE_DESCRIPTION") )
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Project description not specified. Please specify CPACK_PACKAGE_DESCRIPTION or CPACK_PACKAGE_DESCRIPTION_FILE."
"Project description not specified. Please specify "
"CPACK_PACKAGE_DESCRIPTION or CPACK_PACKAGE_DESCRIPTION_FILE."
<< std::endl);
return 0;
}
@ -113,11 +120,14 @@ int cmCPackGenericGenerator::PrepareNames()
int cmCPackGenericGenerator::InstallProject()
{
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Install project" << std::endl);
const char* tempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
const char* tempInstallDirectory
= this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY");
int res = 1;
if ( !cmsys::SystemTools::MakeDirectory(tempInstallDirectory))
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating temporary directory: " << tempInstallDirectory << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating temporary directory: " << tempInstallDirectory
<< std::endl);
return 0;
}
bool movable = true;
@ -141,10 +151,12 @@ int cmCPackGenericGenerator::InstallProject()
for ( it = installCommandsVector.begin(); it != installCommandsVector.end();
++it )
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << it->c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << it->c_str()
<< std::endl);
std::string output;
int retVal = 1;
bool resB = cmSystemTools::RunSingleCommand(it->c_str(), &output, &retVal, 0, m_GeneratorVerbose, 0);
bool resB = cmSystemTools::RunSingleCommand(it->c_str(), &output,
&retVal, 0, m_GeneratorVerbose, 0);
if ( !resB || retVal )
{
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@ -153,26 +165,33 @@ int cmCPackGenericGenerator::InstallProject()
ofs << "# Run command: " << it->c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running install command: " << it->c_str() << std::endl
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem running install command: " << it->c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
res = 0;
break;
}
}
}
const char* installDirectories = this->GetOption("CPACK_INSTALLED_DIRECTORIES");
const char* installDirectories
= this->GetOption("CPACK_INSTALLED_DIRECTORIES");
if ( installDirectories )
{
std::vector<std::string> installDirectoriesVector;
cmSystemTools::ExpandListArgument(installDirectories,installDirectoriesVector);
cmSystemTools::ExpandListArgument(installDirectories,
installDirectoriesVector);
if ( installDirectoriesVector.size() % 2 != 0 )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_INSTALLED_DIRECTORIES should contain pairs of <directory> and <subdirectory>. The <subdirectory> can be '.' to be installed in the toplevel directory of installation." << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_INSTALLED_DIRECTORIES should contain pairs of <directory> and "
"<subdirectory>. The <subdirectory> can be '.' to be installed in the "
"toplevel directory of installation." << std::endl);
return 0;
}
std::vector<std::string>::iterator it;
const char* tempDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
for ( it = installDirectoriesVector.begin(); it != installDirectoriesVector.end();
for ( it = installDirectoriesVector.begin();
it != installDirectoriesVector.end();
++it )
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
@ -185,7 +204,8 @@ int cmCPackGenericGenerator::InstallProject()
gl.RecurseOn();
if ( !gl.FindFiles(findExpr) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find any files in the installed directory" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find any files in the installed directory" << std::endl);
return 0;
}
std::vector<std::string>& files = gl.GetFiles();
@ -193,12 +213,16 @@ int cmCPackGenericGenerator::InstallProject()
for ( gfit = files.begin(); gfit != files.end(); ++ gfit )
{
std::string filePath = tempDir;
filePath += "/" + subdir + "/" + cmSystemTools::RelativePath(toplevel.c_str(), gfit->c_str());
filePath += "/" + subdir + "/"
+ cmSystemTools::RelativePath(toplevel.c_str(), gfit->c_str());
std::string &inFile = *gfit;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile.c_str() << " -> " << filePath.c_str() << std::endl);
if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(), filePath.c_str()) )
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
<< inFile.c_str() << " -> " << filePath.c_str() << std::endl);
if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(),
filePath.c_str()) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " << inFile.c_str() << " -> " << filePath.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
<< inFile.c_str() << " -> " << filePath.c_str() << std::endl);
}
}
}
@ -249,7 +273,8 @@ void cmCPackGenericGenerator::SetOption(const char* op, const char* value)
m_MakefileMap->RemoveDefinition(op);
return;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass() << "::SetOption(" << op << ", " << value << ")" << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
<< "::SetOption(" << op << ", " << value << ")" << std::endl);
m_MakefileMap->AddDefinition(op, value);
}
@ -278,33 +303,41 @@ int cmCPackGenericGenerator::ProcessGenerator()
gl.RecurseOn();
if ( !gl.FindFiles(findExpr) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find any files in the packaging tree" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find any files in the packaging tree" << std::endl);
return 0;
}
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Compress package" << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress files to: " << tempPackageFileName << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress files to: "
<< tempPackageFileName << std::endl);
if ( cmSystemTools::FileExists(tempPackageFileName) )
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove old package file" << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Remove old package file"
<< std::endl);
cmSystemTools::RemoveFile(tempPackageFileName);
}
if ( !this->CompressFiles(tempPackageFileName,
tempDirectory, gl.GetFiles()) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory"
<< std::endl);
return 0;
}
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Finalize package" << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copy final package: " << tempPackageFileName << " to " << packageFileName << std::endl);
if ( !cmSystemTools::CopyFileIfDifferent(tempPackageFileName, packageFileName) )
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copy final package: "
<< tempPackageFileName << " to " << packageFileName << std::endl);
if ( !cmSystemTools::CopyFileIfDifferent(tempPackageFileName,
packageFileName) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the package: " << tempPackageFileName << " to " << packageFileName << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the package: "
<< tempPackageFileName << " to " << packageFileName << std::endl);
return 0;
}
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Package " << packageFileName << " generated." << std::endl);
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Package " << packageFileName
<< " generated." << std::endl);
return 1;
}
@ -412,7 +445,8 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
}
// is there no Modules direcory there?
modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< modules.c_str() << std::endl);
}
if (!cmSystemTools::FileExists(modules.c_str()))
@ -420,7 +454,8 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
// try exe/../share/cmake
cMakeRoot += CMAKE_DATA_DIR;
modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< modules.c_str() << std::endl);
}
#ifdef CMAKE_ROOT_DIR
if (!cmSystemTools::FileExists(modules.c_str()))
@ -428,7 +463,8 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
// try compiled in root directory
cMakeRoot = CMAKE_ROOT_DIR;
modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< modules.c_str() << std::endl);
}
#endif
#ifdef CMAKE_PREFIX
@ -437,7 +473,8 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
// try compiled in install prefix
cMakeRoot = CMAKE_PREFIX CMAKE_DATA_DIR;
modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< modules.c_str() << std::endl);
}
#endif
if (!cmSystemTools::FileExists(modules.c_str()))
@ -446,7 +483,8 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
cMakeRoot = cmSystemTools::GetProgramPath(m_CMakeSelf.c_str());
cMakeRoot += CMAKE_DATA_DIR;
modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< modules.c_str() << std::endl);
}
if(!cmSystemTools::FileExists(modules.c_str()))
{
@ -454,7 +492,8 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
cMakeRoot = cmSystemTools::GetProgramPath(m_CMakeSelf.c_str());
// is there no Modules direcory there?
modules = cMakeRoot + "/Modules/CMake.cmake";
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< modules.c_str() << std::endl);
}
if (!cmSystemTools::FileExists(modules.c_str()))
{
@ -466,14 +505,15 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0)
return 0;
}
m_CMakeRoot = cMakeRoot;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << m_CMakeRoot.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: "
<< m_CMakeRoot.c_str() << std::endl);
this->SetOption("CMAKE_ROOT", m_CMakeRoot.c_str());
return 1;
}
//----------------------------------------------------------------------
int cmCPackGenericGenerator::CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files)
int cmCPackGenericGenerator::CompressFiles(const char* outFileName,
const char* toplevel, const std::vector<std::string>& files)
{
(void)outFileName;
(void)toplevel;
@ -517,15 +557,18 @@ const char* cmCPackGenericGenerator::GetInstallPath()
//----------------------------------------------------------------------
std::string cmCPackGenericGenerator::FindTemplate(const char* name)
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: " << name << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
<< name << std::endl);
std::string ffile = m_MakefileMap->GetModulesFile(name);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " << ffile.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
<< ffile.c_str() << std::endl);
return ffile;
}
//----------------------------------------------------------------------
bool cmCPackGenericGenerator::ConfigureFile(const char* inName, const char* outName)
bool cmCPackGenericGenerator::ConfigureFile(const char* inName,
const char* outName)
{
return m_MakefileMap->ConfigureFile(inName, outName, false, true, false) == 1;
return m_MakefileMap->ConfigureFile(inName, outName,
false, true, false) == 1;
}

View File

@ -115,5 +115,3 @@ private:
};
#endif

View File

@ -77,7 +77,8 @@ bool cmCPackLog::SetLogOutputFile(const char* fname)
}
//----------------------------------------------------------------------
void cmCPackLog::Log(int tag, const char* file, int line, const char* msg, size_t length)
void cmCPackLog::Log(int tag, const char* file, int line,
const char* msg, size_t length)
{
// By default no logging
bool display = false;
@ -217,6 +218,6 @@ void cmCPackLog::Log(int tag, const char* file, int line, const char* msg, size_
}
if ( msg[length-1] == '\n' || length > 2 )
{
m_NewLine = true;;
m_NewLine = true;
}
}

View File

@ -60,10 +60,20 @@ public:
};
//! Various signatures for logging.
void Log(const char* file, int line, const char* msg) { this->Log(LOG_OUTPUT, file, line, msg); }
void Log(const char* file, int line, const char* msg, size_t length) { this->Log(LOG_OUTPUT, file, line, msg, length); }
void Log(int tag, const char* file, int line, const char* msg) { this->Log(tag, file, line, msg, strlen(msg)); }
void Log(int tag, const char* file, int line, const char* msg, size_t length);
void Log(const char* file, int line, const char* msg)
{
this->Log(LOG_OUTPUT, file, line, msg);
}
void Log(const char* file, int line, const char* msg, size_t length)
{
this->Log(LOG_OUTPUT, file, line, msg, length);
}
void Log(int tag, const char* file, int line, const char* msg)
{
this->Log(tag, file, line, msg, strlen(msg));
}
void Log(int tag, const char* file, int line, const char* msg,
size_t length);
//! Set Verbose
void VerboseOn() { this->SetVerbose(true); }
@ -133,7 +143,8 @@ private:
class cmCPackLogWrite
{
public:
cmCPackLogWrite(const char* data, size_t length) : Data(data), Length(length) {}
cmCPackLogWrite(const char* data, size_t length)
: Data(data), Length(length) {}
const char* Data;
size_t Length;

View File

@ -40,15 +40,17 @@ cmCPackNSISGenerator::~cmCPackNSISGenerator()
}
//----------------------------------------------------------------------
int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files)
int cmCPackNSISGenerator::CompressFiles(const char* outFileName,
const char* toplevel, const std::vector<std::string>& files)
{
(void)outFileName; // TODO: Fix nsis to force out file name
(void)toplevel;
std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
if ( nsisInFileName.size() == 0 )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack error: Could not find NSIS installer template file." << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPack error: Could not find NSIS installer template file."
<< std::endl);
return false;
}
std::string nsisFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@ -64,7 +66,8 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* top
cmSystemTools::ReplaceString(fileN, "/", "\\");
str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << str.str().c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: "
<< str.str().c_str() << std::endl);
this->SetOption("CPACK_NSIS_DELETE_FILES", str.str().c_str());
std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel, dirs);
@ -81,25 +84,30 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* top
cmSystemTools::ReplaceString(fileN, "/", "\\");
dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str().c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: "
<< dstr.str().c_str() << std::endl);
this->SetOption("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName << " to " << nsisFileName << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName
<< " to " << nsisFileName << std::endl);
this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str());
std::string nsisCmd = "\"";
nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM");
nsisCmd += "\" \"" + nsisFileName + "\"";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd.c_str()
<< std::endl);
std::string output;
int retVal = 1;
bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &retVal, 0, m_GeneratorVerbose, 0);
bool res = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output,
&retVal, 0, m_GeneratorVerbose, 0);
if ( !res || retVal )
{
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << nsisCmd.c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: " << nsisCmd.c_str() << std::endl
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: "
<< nsisCmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return 0;
}
@ -114,27 +122,32 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
{
return res;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()" << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackNSISGenerator::Initialize()"
<< std::endl);
std::vector<std::string> path;
std::string nsisPath;
if ( !cmsys::SystemTools::ReadRegistryValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS",
nsisPath) )
if ( !cmsys::SystemTools::ReadRegistryValue(
"HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find NSIS registry value" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find NSIS registry value"
<< std::endl);
return 0;
}
path.push_back(nsisPath);
nsisPath = cmSystemTools::FindProgram("makensis", path, false);
if ( nsisPath.empty() )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find NSIS compiler" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find NSIS compiler"
<< std::endl);
return 0;
}
std::string nsisCmd = "\"" + nsisPath + "\" /VERSION";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " << nsisCmd.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: "
<< nsisCmd.c_str() << std::endl);
std::string output;
int retVal = 1;
bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &retVal, 0, m_GeneratorVerbose, 0);
bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(),
&output, &retVal, 0, m_GeneratorVerbose, 0);
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
if ( !resS || retVal || !versionRex.find(output))
@ -145,7 +158,9 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
ofs << "# Run command: " << nsisCmd.c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: " << nsisCmd.c_str() << std::endl
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem checking NSIS version with command: "
<< nsisCmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return 0;
}
@ -155,34 +170,45 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
<< nsisVersion << std::endl);
if ( nsisVersion < minNSISVersion )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack requires NSIS Version 2.09 or greater. NSIS found on the system was: "
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPack requires NSIS Version 2.09 or greater. NSIS found on the system "
"was: "
<< nsisVersion << std::endl);
return 0;
}
this->SetOption("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
const char* cpackPackageExecutables
= this->GetOption("CPACK_PACKAGE_EXECUTABLES");
if ( cpackPackageExecutables )
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: " << cpackPackageExecutables << "." << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
<< cpackPackageExecutables << "." << std::endl);
cmOStringStream str;
cmOStringStream deleteStr;
std::vector<std::string> cpackPackageExecutablesVector;
cmSystemTools::ExpandListArgument(cpackPackageExecutables,cpackPackageExecutablesVector);
cmSystemTools::ExpandListArgument(cpackPackageExecutables,
cpackPackageExecutablesVector);
if ( cpackPackageExecutablesVector.size() % 2 != 0 )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and <icon name>." << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
"<icon name>." << std::endl);
return 0;
}
std::vector<std::string>::iterator it;
for ( it = cpackPackageExecutablesVector.begin(); it != cpackPackageExecutablesVector.end();
for ( it = cpackPackageExecutablesVector.begin();
it != cpackPackageExecutablesVector.end();
++it )
{
std::string execName = *it;
++ it;
std::string linkName = *it;
str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\" << linkName << ".lnk\" \"$INSTDIR\\bin\\" << execName << ".exe\"" << std::endl;
deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName << ".lnk\"" << std::endl;
str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
<< linkName << ".lnk\" \"$INSTDIR\\bin\\" << execName << ".exe\""
<< std::endl;
deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
<< ".lnk\"" << std::endl;
}
this->SetOption("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
this->SetOption("CPACK_NSIS_DELETE_ICONS", deleteStr.str().c_str());
@ -192,7 +218,8 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
}
//----------------------------------------------------------------------
bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, std::vector<std::string>& dirs)
bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir,
std::vector<std::string>& dirs)
{
cmsys::Directory dir;
dir.Load(topdir);
@ -218,4 +245,3 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, std::vect
dirs.push_back(topdir);
return true;
}

View File

@ -48,9 +48,8 @@ protected:
virtual const char* GetOutputExtension() { return "exe"; }
virtual const char* GetOutputPostfix() { return "win32"; }
bool GetListOfSubdirectories(const char* dir, std::vector<std::string>& dirs);
bool GetListOfSubdirectories(const char* dir,
std::vector<std::string>& dirs);
};
#endif

View File

@ -39,7 +39,8 @@ cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator()
}
//----------------------------------------------------------------------
int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const char* toplevel,
int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName,
const char* toplevel,
const std::vector<std::string>& files)
{
(void) files; // TODO: Fix api to not need files.
@ -53,7 +54,9 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const c
if ( !cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())
|| !cmsys::SystemTools::MakeDirectory(postflightDirName.c_str()) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating installer directories: " << preflightDirName.c_str() << " and "
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating installer directories: "
<< preflightDirName.c_str() << " and "
<< postflightDirName.c_str() << std::endl);
return 0;
}
@ -64,56 +67,68 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const c
|| !this->CopyResourcePlistFile("Info.plist")
|| !this->CopyResourcePlistFile("Description.plist") )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
<< std::endl);
return 0;
}
std::string packageDirFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
std::string packageDirFileName
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packageDirFileName += ".pkg";
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/PackageMakerOutput.log";
cmOStringStream pkgCmd;
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" -build -p \"" << packageDirFileName << "\" -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY")
<< "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Resources\" -i \""
<< "\" -build -p \"" << packageDirFileName << "\" -f \""
<< this->GetOption("CPACK_TEMPORARY_DIRECTORY")
<< "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Resources\" -i \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Info.plist\" -d \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Description.plist\"";
if ( this->PackageMakerVersion > 2.0 )
{
pkgCmd << " -v";
}
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << pkgCmd.str().c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << pkgCmd.str().c_str()
<< std::endl);
std::string output;
int retVal = 1;
//bool res = cmSystemTools::RunSingleCommand(pkgCmd.str().c_str(), &output, &retVal, 0, m_GeneratorVerbose, 0);
//bool res = cmSystemTools::RunSingleCommand(pkgCmd.str().c_str(), &output,
//&retVal, 0, m_GeneratorVerbose, 0);
bool res = true;
retVal = system(pkgCmd.str().c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker" << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
<< std::endl);
if ( !res || retVal )
{
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << pkgCmd.str().c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running PackageMaker command: " << pkgCmd.str().c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem running PackageMaker command: " << pkgCmd.str().c_str()
<< std::endl << "Please check " << tmpFile.c_str() << " for errors"
<< std::endl);
return 0;
}
tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/hdiutilOutput.log";
cmOStringStream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
<< "\" \"" << outFileName << "\"";
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &retVal, 0, m_GeneratorVerbose, 0);
res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output,
&retVal, 0, m_GeneratorVerbose, 0);
if ( !res || retVal )
{
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: " << dmgCmd.str().c_str() << std::endl
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
<< dmgCmd.str().c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return 0;
}
@ -125,20 +140,25 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, const c
int cmCPackPackageMakerGenerator::Initialize(const char* name, cmMakefile* mf)
{
int res = this->Superclass::Initialize(name, mf);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackPackageMakerGenerator::Initialize()" << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"cmCPackPackageMakerGenerator::Initialize()" << std::endl);
std::vector<std::string> path;
std::string pkgPath = "/Developer/Applications/Utilities/PackageMaker.app/Contents";
std::string pkgPath
= "/Developer/Applications/Utilities/PackageMaker.app/Contents";
std::string versionFile = pkgPath + "/version.plist";
pkgPath += "/MacOS";
if ( !cmSystemTools::FileExists(versionFile.c_str()) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler version file: " << versionFile.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find PackageMaker compiler version file: "
<< versionFile.c_str() << std::endl);
return 0;
}
std::ifstream ifs(versionFile.c_str());
if ( !ifs )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot open PackageMaker compiler version file" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot open PackageMaker compiler version file" << std::endl);
return 0;
}
// Check the PackageMaker version
@ -156,34 +176,42 @@ int cmCPackPackageMakerGenerator::Initialize(const char* name, cmMakefile* mf)
}
if ( !foundKey )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find CFBundleShortVersionString in the PackageMaker compiler version file" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find CFBundleShortVersionString in the PackageMaker compiler "
"version file" << std::endl);
return 0;
}
if ( !cmSystemTools::GetLineFromStream(ifs, line) || !rexVersion.find(line) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem reading the PackageMaker compiler version file: " << versionFile.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem reading the PackageMaker compiler version file: "
<< versionFile.c_str() << std::endl);
return 0;
}
this->PackageMakerVersion = atof(rexVersion.match(1).c_str());
if ( this->PackageMakerVersion < 1 )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher"
<< std::endl);
return 0;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: " << this->PackageMakerVersion << std::endl);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: "
<< this->PackageMakerVersion << std::endl);
path.push_back(pkgPath);
pkgPath = cmSystemTools::FindProgram("PackageMaker", path, false);
if ( pkgPath.empty() )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler"
<< std::endl);
return 0;
}
this->SetOption("CPACK_INSTALLER_PROGRAM", pkgPath.c_str());
pkgPath = cmSystemTools::FindProgram("hdiutil", path, false);
if ( pkgPath.empty() )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
<< std::endl);
return 0;
}
this->SetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE", pkgPath.c_str());
@ -199,18 +227,23 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name)
const char* inFileName = this->GetOption(cpackVar.c_str());
if ( !inFileName )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str() << " not specified. It should point to " << name << ".rtf, " << name << ".html, or " << name << ".txt file" << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str()
<< " not specified. It should point to " << name << ".rtf, " << name
<< ".html, or " << name << ".txt file" << std::endl);
return false;
}
if ( !cmSystemTools::FileExists(inFileName) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find " << name << " resource file: " << inFileName << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find " << name
<< " resource file: " << inFileName << std::endl);
return false;
}
std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
if ( ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt" )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Bad file extension specified: " << ext << ". Currently only .rtfd, .rtf, .html, and .txt files allowed." << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Bad file extension specified: "
<< ext << ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
<< std::endl);
return false;
}
@ -219,7 +252,8 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name)
destFileName += name + ext;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << inFileName << " to " << destFileName.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << inFileName
<< " to " << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName, destFileName.c_str());
return true;
}
@ -232,7 +266,8 @@ bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name)
std::string inFileName = this->FindTemplate(inFName.c_str());
if ( inFileName.empty() )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: " << inFName << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
<< inFName << std::endl);
return false;
}
@ -240,8 +275,8 @@ bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name)
destFileName += "/";
destFileName += name;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << inFileName.c_str() << " to " << destFileName.c_str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
<< inFileName.c_str() << " to " << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str());
return true;
}

View File

@ -24,7 +24,8 @@
/** \class cmCPackPackageMakerGenerator
* \brief A generator for PackageMaker files
*
* http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/packagemaker.1.html
* http://developer.apple.com/documentation/Darwin
* /Reference/ManPages/man1/packagemaker.1.html
*/
class cmCPackPackageMakerGenerator : public cmCPackGenericGenerator
{
@ -56,5 +57,3 @@ protected:
};
#endif

View File

@ -43,21 +43,25 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
<< "#!/bin/sh" << std::endl
<< "echo \"" << this->GetOption("CPACK_PACKAGE_NAME")
<< " - self-extracting archive.\"" << std::endl
<< "echo \"If you want to stop extracting, please press <ctrl-C>.\"" << std::endl
<< "echo \"If you want to stop extracting, please press <ctrl-C>.\""
<< std::endl
<< "read line" << std::endl
<< "echo \"Extracting... Please wait...\"" << std::endl
<< "echo \"\"" << std::endl
<< "" << std::endl
<< "# take the archive portion of this file and pipe it to tar" << std::endl
<< "# the NUMERIC parameter in this command should be one more" << std::endl
<< "# take the archive portion of this file and pipe it to tar"
<< std::endl
<< "# the NUMERIC parameter in this command should be one more"
<< std::endl
<< "# than the number of lines in this header file" << std::endl
<< "tail +18 \"$0\" | gunzip | tar xf -" << std::endl
<< "" << std::endl
<< "exit 0" << std::endl
<< "echo \"\"" << std::endl
<< "#-----------------------------------------------------------" << std::endl
<< "#-----------------------------------------------------------"
<< std::endl
<< "# Start of TAR.GZ file" << std::endl
<< "#-----------------------------------------------------------" << std::endl;
<< "#-----------------------------------------------------------"
<< std::endl;
return this->Superclass::GenerateHeader(os);
}

View File

@ -42,6 +42,3 @@ protected:
};
#endif

View File

@ -59,7 +59,8 @@ class cmCPackTGZ_Data
{
public:
cmCPackTGZ_Data(cmCPackTGZGenerator* gen) :
OutputStream(0), Generator(gen), m_CompressionLevel(Z_DEFAULT_COMPRESSION) {}
OutputStream(0), Generator(gen),
m_CompressionLevel(Z_DEFAULT_COMPRESSION) {}
std::ostream* OutputStream;
cmCPackTGZGenerator* Generator;
char m_CompressedBuffer[cmCPackTGZ_Data_BlockSize];
@ -70,14 +71,16 @@ public:
//----------------------------------------------------------------------
extern "C" {
int cmCPackTGZ_Data_Open(void *client_data, const char* name, int oflags, mode_t mode);
int cmCPackTGZ_Data_Open(void *client_data, const char* name, int oflags,
mode_t mode);
ssize_t cmCPackTGZ_Data_Write(void *client_data, void *buff, size_t n);
int cmCPackTGZ_Data_Close(void *client_data);
}
//----------------------------------------------------------------------
int cmCPackTGZ_Data_Open(void *client_data, const char* pathname, int, mode_t)
int cmCPackTGZ_Data_Open(void *client_data, const char* pathname,
int, mode_t)
{
cmCPackTGZ_Data *mydata = (cmCPackTGZ_Data*)client_data;
@ -120,16 +123,21 @@ ssize_t cmCPackTGZ_Data_Write(void *client_data, void *buff, size_t n)
do {
mydata->m_ZLibStream.avail_out = cmCPackTGZ_Data_BlockSize;
mydata->m_ZLibStream.next_out = reinterpret_cast<Bytef*>(mydata->m_CompressedBuffer);
int ret = deflate(&mydata->m_ZLibStream, (n?Z_NO_FLUSH:Z_FINISH)); // no bad return value
mydata->m_ZLibStream.next_out
= reinterpret_cast<Bytef*>(mydata->m_CompressedBuffer);
// no bad return value
int ret = deflate(&mydata->m_ZLibStream, (n?Z_NO_FLUSH:Z_FINISH));
if(ret == Z_STREAM_ERROR)
{
return 0;
}
size_t compressedSize = cmCPackTGZ_Data_BlockSize - mydata->m_ZLibStream.avail_out;
size_t compressedSize
= cmCPackTGZ_Data_BlockSize - mydata->m_ZLibStream.avail_out;
mydata->OutputStream->write(reinterpret_cast<const char*>(mydata->m_CompressedBuffer), compressedSize);
mydata->OutputStream->write(
reinterpret_cast<const char*>(mydata->m_CompressedBuffer),
compressedSize);
} while ( mydata->m_ZLibStream.avail_out == 0 );
if ( !*mydata->OutputStream )
@ -171,8 +179,8 @@ int cmCPackTGZ_Data_Close(void *client_data)
}
//----------------------------------------------------------------------
int cmCPackTGZGenerator::CompressFiles(const char* outFileName, const char* toplevel,
const std::vector<std::string>& files)
int cmCPackTGZGenerator::CompressFiles(const char* outFileName,
const char* toplevel, const std::vector<std::string>& files)
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
cmCPackTGZ_Data mydata(this);
@ -199,7 +207,8 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, const char* topl
(m_GeneratorVerbose?TAR_VERBOSE:0)
| 0) == -1)
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_open(): " << strerror(errno) << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_open(): "
<< strerror(errno) << std::endl);
return 0;
}
@ -214,7 +223,8 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, const char* topl
if (tar_append_tree(t, pathname, buf) != 0)
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem with tar_append_tree(\"" << buf << "\", \"" << pathname << "\"): "
"Problem with tar_append_tree(\"" << buf << "\", \""
<< pathname << "\"): "
<< strerror(errno) << std::endl);
tar_close(t);
return 0;
@ -222,14 +232,16 @@ int cmCPackTGZGenerator::CompressFiles(const char* outFileName, const char* topl
}
if (tar_append_eof(t) != 0)
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_append_eof(): " << strerror(errno) << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_append_eof(): "
<< strerror(errno) << std::endl);
tar_close(t);
return 0;
}
if (tar_close(t) != 0)
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_close(): " << strerror(errno) << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with tar_close(): "
<< strerror(errno) << std::endl);
return 0;
}
return 1;
@ -245,5 +257,3 @@ int cmCPackTGZGenerator::GenerateHeader(std::ostream* os)
os->write(header, 10);
return 1;
}

View File

@ -47,5 +47,3 @@ protected:
};
#endif

View File

@ -62,10 +62,10 @@ static const cmDocumentationEntry cmDocumentationDescription[] =
static const cmDocumentationEntry cmDocumentationOptions[] =
{
{"-G <generator>", "Use the specified generator to generate package.",
"CPack may support multiple native packaging systems on certain platforms. A "
"generator is responsible for generating input files for particular system "
"and invoking that systems. Possible generator names are specified in the "
"Generators section." },
"CPack may support multiple native packaging systems on certain platforms."
"A generator is responsible for generating input files for particular "
"system and invoking that systems. Possible generator names are "
"specified in the Generators section." },
{"-P <ProjectName>", "Specify the project name.",
"This option specifies the project name that will be used to generate the "
"installer." },
@ -118,13 +118,15 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
size_t pos = value.find_first_of("=");
if ( pos == std::string::npos )
{
cmCPack_Log(def->m_Log, cmCPackLog::LOG_ERROR, "Please specify CPack definitions as: KEY=VALUE" << std::endl);
cmCPack_Log(def->m_Log, cmCPackLog::LOG_ERROR,
"Please specify CPack definitions as: KEY=VALUE" << std::endl);
return 0;
}
std::string key = value.substr(0, pos);
value = value.c_str() + pos + 1;
def->m_Map[key] = value;
cmCPack_Log(def->m_Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl);
cmCPack_Log(def->m_Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
<< key.c_str() << " to \"" << value.c_str() << "\"" << std::endl);
return 1;
}
@ -142,7 +144,8 @@ int main (int argc, char *argv[])
if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Current working directory cannot be established." << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Current working directory cannot be established." << std::endl);
}
std::string generator;
@ -155,7 +158,8 @@ int main (int argc, char *argv[])
std::string helpHTML;
std::string cpackProjectName;
std::string cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
std::string cpackProjectDirectory
= cmsys::SystemTools::GetCurrentWorkingDirectory();
std::string cpackBuildConfig;
std::string cpackProjectVersion;
std::string cpackProjectPatch;
@ -181,15 +185,24 @@ int main (int argc, char *argv[])
arg.AddArgument("-V", argT::NO_ARGUMENT, &verbose, "CPack verbose");
arg.AddArgument("--verbose", argT::NO_ARGUMENT, &verbose, "-V");
arg.AddArgument("--debug", argT::NO_ARGUMENT, &debug, "-V");
arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile, "CPack configuration file");
arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig, "CPack build configuration");
arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator");
arg.AddArgument("-P", argT::SPACE_ARGUMENT, &cpackProjectName, "CPack project name");
arg.AddArgument("-R", argT::SPACE_ARGUMENT, &cpackProjectVersion, "CPack project version");
arg.AddArgument("-B", argT::SPACE_ARGUMENT, &cpackProjectDirectory, "CPack project directory");
arg.AddArgument("--patch", argT::SPACE_ARGUMENT, &cpackProjectPatch, "CPack project patch");
arg.AddArgument("--vendor", argT::SPACE_ARGUMENT, &cpackProjectVendor, "CPack project vendor");
arg.AddCallback("-D", argT::SPACE_ARGUMENT, cpackDefinitionArgument, &definitions, "CPack Definitions");
arg.AddArgument("--config", argT::SPACE_ARGUMENT, &cpackConfigFile,
"CPack configuration file");
arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
"CPack build configuration");
arg.AddArgument("-G", argT::SPACE_ARGUMENT,
&generator, "CPack generator");
arg.AddArgument("-P", argT::SPACE_ARGUMENT,
&cpackProjectName, "CPack project name");
arg.AddArgument("-R", argT::SPACE_ARGUMENT,
&cpackProjectVersion, "CPack project version");
arg.AddArgument("-B", argT::SPACE_ARGUMENT,
&cpackProjectDirectory, "CPack project directory");
arg.AddArgument("--patch", argT::SPACE_ARGUMENT,
&cpackProjectPatch, "CPack project patch");
arg.AddArgument("--vendor", argT::SPACE_ARGUMENT,
&cpackProjectVendor, "CPack project vendor");
arg.AddCallback("-D", argT::SPACE_ARGUMENT,
cpackDefinitionArgument, &definitions, "CPack Definitions");
arg.SetUnknownArgumentCallback(cpackUnknownArgument);
// Parse command line
@ -207,7 +220,8 @@ int main (int argc, char *argv[])
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
}
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
cmake cminst;
cmGlobalGenerator cmgg;
@ -227,7 +241,8 @@ int main (int argc, char *argv[])
generators.SetLogger(&log);
cmCPackGenericGenerator* cpackGenerator = 0;
if ( !helpFull.empty() || !helpMAN.empty() || !helpHTML.empty() || helpVersion )
if ( !helpFull.empty() || !helpMAN.empty() ||
!helpHTML.empty() || helpVersion )
{
help = true;
}
@ -238,24 +253,49 @@ int main (int argc, char *argv[])
{
if ( !mf->ReadListFile(0, cpackConfigFile.c_str()) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Problem reding CPack config file: \"" << cpackConfigFile.c_str() << "\"" << std::endl);
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);
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_PACKAGE_NAME", cpackProjectName.c_str()); }
if ( !cpackProjectVersion.empty() ) { mf->AddDefinition("CPACK_PACKAGE_VERSION", cpackProjectVersion.c_str()); }
if ( !cpackProjectVendor.empty() ) { mf->AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor.c_str()); }
if ( !cpackProjectDirectory.empty() ) { mf->AddDefinition("CPACK_PACKAGE_DIRECTORY", cpackProjectDirectory.c_str()); }
if ( !cpackBuildConfig.empty() ) { mf->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); }
if ( !generator.empty() )
{
mf->AddDefinition("CPACK_GENERATOR", generator.c_str());
}
if ( !cpackProjectName.empty() )
{
mf->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
}
if ( !cpackProjectVersion.empty() )
{
mf->AddDefinition("CPACK_PACKAGE_VERSION", cpackProjectVersion.c_str());
}
if ( !cpackProjectVendor.empty() )
{
mf->AddDefinition("CPACK_PACKAGE_VENDOR", cpackProjectVendor.c_str());
}
if ( !cpackProjectDirectory.empty() )
{
mf->AddDefinition("CPACK_PACKAGE_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 )
for ( cdit = definitions.m_Map.begin();
cdit != definitions.m_Map.end();
++cdit )
{
mf->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
}
@ -263,20 +303,25 @@ int main (int argc, char *argv[])
const char* gen = mf->GetDefinition("CPACK_GENERATOR");
if ( !gen )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified" << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack generator not specified" << std::endl);
parsed = 0;
}
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack project name not specified" << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack project name not specified" << std::endl);
parsed = 0;
}
if ( parsed && !(mf->GetDefinition("CPACK_PACKAGE_VERSION")
|| mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") && mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR")
|| mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR")
&& mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack project version not specified" << std::endl
<< "Specify CPACK_PACKAGE_VERSION, or CPACK_PACKAGE_VERSION_MAJOR, CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack project version not specified" << std::endl
<< "Specify CPACK_PACKAGE_VERSION, or CPACK_PACKAGE_VERSION_MAJOR, "
"CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
<< std::endl);
parsed = 0;
}
@ -285,7 +330,9 @@ int main (int argc, char *argv[])
cpackGenerator = generators.NewGenerator(gen);
if ( !cpackGenerator )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize CPack generator: " << generator.c_str() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize CPack generator: "
<< generator.c_str() << std::endl);
parsed = 0;
}
if ( !cpackGenerator->Initialize(gen, mf) )
@ -294,18 +341,26 @@ int main (int argc, char *argv[])
}
if ( parsed && !cpackGenerator->FindRunningCMake(argv[0]) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize the generator" << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize the generator" << std::endl);
parsed = 0;
}
if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") && !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") )
if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") )
{
cmsys::SystemTools::ConvertToUnixSlashes(cpackProjectDirectory);
std::string makeInstallFile = cpackProjectDirectory + "/cmake_install.cmake";
std::string makeInstallFile
= cpackProjectDirectory + "/cmake_install.cmake";
if ( !cmsys::SystemTools::FileExists(makeInstallFile.c_str()) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot find installation file: " << makeInstallFile.c_str() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Please specify build tree of the project that uses CMake, specify CPACK_INSTALL_COMMANDS, or specify CPACK_INSTALLED_DIRECTORIES." << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot find installation file: " << makeInstallFile.c_str()
<< std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Please specify build tree of the project that uses CMake, specify "
"CPACK_INSTALL_COMMANDS, or specify CPACK_INSTALLED_DIRECTORIES."
<< std::endl);
parsed = 0;
}
}
@ -333,28 +388,33 @@ int main (int argc, char *argv[])
#endif
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: " << cpackGenerator->GetNameOfClass() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " << projName << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
<< cpackGenerator->GetNameOfClass() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
<< projName << std::endl);
const char* projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION");
if ( !projVersion )
{
const char* projVersionMajor = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
const char* projVersionMinor = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
const char* projVersionPatch = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
const char* projVersionMajor
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
const char* projVersionMinor
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
const char* projVersionPatch
= mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
cmOStringStream ostr;
ostr << projVersionMajor << "." << projVersionMinor << "." << projVersionPatch;
ostr << projVersionMajor << "." << projVersionMinor << "."
<< projVersionPatch;
mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
}
int res = cpackGenerator->ProcessGenerator();
if ( !res )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error when generating package: " << projName << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error when generating package: " << projName << std::endl);
return 1;
}
return 0;
}