Revise C++ coding style using clang-format

Run the `Utilities/Scripts/clang-format.bash` script to update
all our C++ code to a new style defined by `.clang-format`.
Use `clang-format` version 3.8.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
This commit is contained in:
Kitware Robot 2016-05-16 10:34:04 -04:00 committed by Brad King
parent 82df6deaaf
commit d9fd2f5402
1450 changed files with 62404 additions and 83728 deletions

View File

@ -6,12 +6,11 @@
#define const #define const
#endif #endif
#include "CMakeCompilerABI.h" #include "CMakeCompilerABI.h"
#ifdef __CLASSIC_C__ #ifdef __CLASSIC_C__
int main(argc, argv) int argc; char *argv[]; int main(argc, argv) int argc;
char* argv[];
#else #else
int main(int argc, char* argv[]) int main(int argc, char* argv[])
#endif #endif

View File

@ -2,10 +2,8 @@
#error "A C compiler has been selected for C++." #error "A C compiler has been selected for C++."
#endif #endif
#include "CMakeCompilerABI.h" #include "CMakeCompilerABI.h"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int require = 0; int require = 0;

View File

@ -2,14 +2,12 @@
/* Size of a pointer-to-data in bytes. */ /* Size of a pointer-to-data in bytes. */
#define SIZEOF_DPTR (sizeof(void*)) #define SIZEOF_DPTR (sizeof(void*))
const char info_sizeof_dptr[] = { const char info_sizeof_dptr[] = {
'I', 'N', 'F', 'O', ':', 's', 'i', 'z', 'e', 'o', 'f', '_', 'd', 'p', 't', 'r', '[', 'I', 'N', 'F', 'O', ':', 's', 'i', 'z', 'e', 'o', 'f', '_', 'd', 'p', 't',
('0' + ((SIZEOF_DPTR / 10)%10)), 'r', '[', ('0' + ((SIZEOF_DPTR / 10) % 10)), ('0' + (SIZEOF_DPTR % 10)), ']',
('0' + (SIZEOF_DPTR % 10)), '\0'
']','\0'
/* clang-format needs this comment to break after the opening brace */ /* clang-format needs this comment to break after the opening brace */
}; };
/* Application Binary Interface. */ /* Application Binary Interface. */
#if defined(__sgi) && defined(_ABIO32) #if defined(__sgi) && defined(_ABIO32)
#define ABI_ID "ELF O32" #define ABI_ID "ELF O32"

View File

@ -6,11 +6,13 @@ void* runner(void*);
int res = 0; int res = 0;
#ifdef __CLASSIC_C__ #ifdef __CLASSIC_C__
int main(){ int main()
{
int ac; int ac;
char* av[]; char* av[];
#else #else
int main(int ac, char*av[]){ int main(int ac, char* av[])
{
#endif #endif
pthread_t tid[2]; pthread_t tid[2];
pthread_create(&tid[0], 0, runner, (void*)1); pthread_create(&tid[0], 0, runner, (void*)1);
@ -22,15 +24,16 @@ int main(int ac, char*av[]){
pthread_join(tid[0], 0); pthread_join(tid[0], 0);
pthread_join(tid[1], 0); pthread_join(tid[1], 0);
if(ac > 1000){return *av[0];} if (ac > 1000) {
return *av[0];
}
return res; return res;
} }
void* runner(void* args) void* runner(void* args)
{ {
int cc; int cc;
for ( cc = 0; cc < 10; cc ++ ) for (cc = 0; cc < 10; cc++) {
{
printf("%p CC: %d\n", args, cc); printf("%p CC: %d\n", args, cc);
} }
res++; res++;

View File

@ -3,17 +3,19 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
char CHECK_FUNCTION_EXISTS(); char
CHECK_FUNCTION_EXISTS();
#ifdef __CLASSIC_C__ #ifdef __CLASSIC_C__
int main(){ int main()
{
int ac; int ac;
char* av[]; char* av[];
#else #else
int main(int ac, char*av[]){ int main(int ac, char* av[])
{
#endif #endif
CHECK_FUNCTION_EXISTS(); CHECK_FUNCTION_EXISTS();
if(ac > 1000) if (ac > 1000) {
{
return *av[0]; return *av[0];
} }
return 0; return 0;

View File

@ -3,13 +3,17 @@
extern int CHECK_VARIABLE_EXISTS; extern int CHECK_VARIABLE_EXISTS;
#ifdef __CLASSIC_C__ #ifdef __CLASSIC_C__
int main(){ int main()
{
int ac; int ac;
char* av[]; char* av[];
#else #else
int main(int ac, char*av[]){ int main(int ac, char* av[])
{
#endif #endif
if(ac > 1000){return *av[0];} if (ac > 1000) {
return *av[0];
}
return CHECK_VARIABLE_EXISTS; return CHECK_VARIABLE_EXISTS;
} }

View File

@ -1 +1,3 @@
void my_module_(void) {} void my_module_(void)
{
}

View File

@ -1 +1,3 @@
void mymodule_(void) {} void mymodule_(void)
{
}

View File

@ -1,7 +1,8 @@
int main(int, char* []) int main(int, char* [])
{ {
int i; int i;
for(int i=0; i < 1; ++i); for (int i = 0; i < 1; ++i)
;
(void)i; (void)i;
return 0; return 0;
} }

View File

@ -3,8 +3,7 @@ int main(int, char*[])
{ {
std::ostringstream os; std::ostringstream os;
os << "12345"; os << "12345";
if(os.str().size() == 5) if (os.str().size() == 5) {
{
return 0; return 0;
} }
return -1; return -1;

View File

@ -72,51 +72,41 @@ int cmCPackIFWGenerator::PackageFiles()
ifwTmpFile += "/IFWOutput.log"; ifwTmpFile += "/IFWOutput.log";
// Run repogen // Run repogen
if (!Installer.Repositories.empty()) if (!Installer.Repositories.empty()) {
{
std::string ifwCmd = RepoGen; std::string ifwCmd = RepoGen;
if(IsVersionLess("2.0.0")) if (IsVersionLess("2.0.0")) {
{
ifwCmd += " -c " + this->toplevel + "/config/config.xml"; ifwCmd += " -c " + this->toplevel + "/config/config.xml";
} }
ifwCmd += " -p " + this->toplevel + "/packages"; ifwCmd += " -p " + this->toplevel + "/packages";
if(!PkgsDirsVector.empty()) if (!PkgsDirsVector.empty()) {
{
for (std::vector<std::string>::iterator it = PkgsDirsVector.begin(); for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
it != PkgsDirsVector.end(); ++it) it != PkgsDirsVector.end(); ++it) {
{
ifwCmd += " -p " + *it; ifwCmd += " -p " + *it;
} }
} }
if (!OnlineOnly && !DownloadedPackages.empty()) if (!OnlineOnly && !DownloadedPackages.empty()) {
{
ifwCmd += " -i "; ifwCmd += " -i ";
std::set<cmCPackIFWPackage*>::iterator it std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
= DownloadedPackages.begin();
ifwCmd += (*it)->Name; ifwCmd += (*it)->Name;
++it; ++it;
while(it != DownloadedPackages.end()) while (it != DownloadedPackages.end()) {
{
ifwCmd += "," + (*it)->Name; ifwCmd += "," + (*it)->Name;
++it; ++it;
} }
} }
ifwCmd += " " + this->toplevel + "/repository"; ifwCmd += " " + this->toplevel + "/repository";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
<< std::endl);
std::string output; std::string output;
int retVal = 1; int retVal = 1;
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate repository"
"- Generate repository" << std::endl); << std::endl);
bool res = cmSystemTools::RunSingleCommand( bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output, ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
&retVal, 0, this->GeneratorVerbose, 0); if (!res || retVal) {
if ( !res || retVal )
{
cmGeneratedFileStream ofs(ifwTmpFile.c_str()); cmGeneratedFileStream ofs(ifwTmpFile.c_str());
ofs << "# Run command: " << ifwCmd << std::endl ofs << "# Run command: " << ifwCmd << std::endl
<< "# Output:" << std::endl << "# Output:" << std::endl
@ -127,8 +117,8 @@ int cmCPackIFWGenerator::PackageFiles()
<< std::endl); << std::endl);
return 0; return 0;
} }
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: " << this->toplevel cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: "
<< "/repository generated" << std::endl); << this->toplevel << "/repository generated" << std::endl);
} }
// Run binary creator // Run binary creator
@ -137,39 +127,30 @@ int cmCPackIFWGenerator::PackageFiles()
ifwCmd += " -c " + this->toplevel + "/config/config.xml"; ifwCmd += " -c " + this->toplevel + "/config/config.xml";
ifwCmd += " -p " + this->toplevel + "/packages"; ifwCmd += " -p " + this->toplevel + "/packages";
if(!PkgsDirsVector.empty()) if (!PkgsDirsVector.empty()) {
{
for (std::vector<std::string>::iterator it = PkgsDirsVector.begin(); for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
it != PkgsDirsVector.end(); ++it) it != PkgsDirsVector.end(); ++it) {
{
ifwCmd += " -p " + *it; ifwCmd += " -p " + *it;
} }
} }
if (OnlineOnly) if (OnlineOnly) {
{
ifwCmd += " --online-only"; ifwCmd += " --online-only";
} } else if (!DownloadedPackages.empty() &&
else if (!DownloadedPackages.empty() && !Installer.Repositories.empty()) !Installer.Repositories.empty()) {
{
ifwCmd += " -e "; ifwCmd += " -e ";
std::set<cmCPackIFWPackage*>::iterator it std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
= DownloadedPackages.begin();
ifwCmd += (*it)->Name; ifwCmd += (*it)->Name;
++it; ++it;
while(it != DownloadedPackages.end()) while (it != DownloadedPackages.end()) {
{
ifwCmd += "," + (*it)->Name; ifwCmd += "," + (*it)->Name;
++it; ++it;
} }
} } else if (!DependentPackages.empty()) {
else if (!DependentPackages.empty())
{
ifwCmd += " -i "; ifwCmd += " -i ";
// Binary // Binary
std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin(); std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin();
while(bit != BinaryPackages.end()) while (bit != BinaryPackages.end()) {
{
ifwCmd += (*bit)->Name + ","; ifwCmd += (*bit)->Name + ",";
++bit; ++bit;
} }
@ -177,31 +158,24 @@ int cmCPackIFWGenerator::PackageFiles()
DependenceMap::iterator it = DependentPackages.begin(); DependenceMap::iterator it = DependentPackages.begin();
ifwCmd += it->second.Name; ifwCmd += it->second.Name;
++it; ++it;
while(it != DependentPackages.end()) while (it != DependentPackages.end()) {
{
ifwCmd += "," + it->second.Name; ifwCmd += "," + it->second.Name;
++it; ++it;
} }
} }
// TODO: set correct name for multipackages // TODO: set correct name for multipackages
if (!this->packageFileNames.empty()) if (!this->packageFileNames.empty()) {
{
ifwCmd += " " + packageFileNames[0]; ifwCmd += " " + packageFileNames[0];
} } else {
else
{
ifwCmd += " installer"; ifwCmd += " installer";
} }
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
<< std::endl);
std::string output; std::string output;
int retVal = 1; int retVal = 1;
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl); cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
bool res = cmSystemTools::RunSingleCommand( bool res = cmSystemTools::RunSingleCommand(
ifwCmd.c_str(), &output, &output, ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
&retVal, 0, this->GeneratorVerbose, 0); if (!res || retVal) {
if ( !res || retVal )
{
cmGeneratedFileStream ofs(ifwTmpFile.c_str()); cmGeneratedFileStream ofs(ifwTmpFile.c_str());
ofs << "# Run command: " << ifwCmd << std::endl ofs << "# Run command: " << ifwCmd << std::endl
<< "# Output:" << std::endl << "# Output:" << std::endl
@ -223,8 +197,7 @@ const char *cmCPackIFWGenerator::GetPackagingInstallPrefix()
std::string tmpPref = defPrefix ? defPrefix : ""; std::string tmpPref = defPrefix ? defPrefix : "";
if(this->Components.empty()) if (this->Components.empty()) {
{
tmpPref += "packages/" + GetRootPackageName() + "/data"; tmpPref += "packages/" + GetRootPackageName() + "/data";
} }
@ -246,27 +219,21 @@ int cmCPackIFWGenerator::InitializeInternal()
const std::string RepoGenOpt = "CPACK_IFW_REPOGEN_EXECUTABLE"; const std::string RepoGenOpt = "CPACK_IFW_REPOGEN_EXECUTABLE";
const std::string FrameworkVersionOpt = "CPACK_IFW_FRAMEWORK_VERSION"; const std::string FrameworkVersionOpt = "CPACK_IFW_FRAMEWORK_VERSION";
if(!this->IsSet(BinCreatorOpt) || if (!this->IsSet(BinCreatorOpt) || !this->IsSet(RepoGenOpt) ||
!this->IsSet(RepoGenOpt) || !this->IsSet(FrameworkVersionOpt)) {
!this->IsSet(FrameworkVersionOpt))
{
this->ReadListFile("CPackIFW.cmake"); this->ReadListFile("CPackIFW.cmake");
} }
// Look 'binarycreator' executable (needs) // Look 'binarycreator' executable (needs)
const char* BinCreatorStr = this->GetOption(BinCreatorOpt); const char* BinCreatorStr = this->GetOption(BinCreatorOpt);
if(!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) {
{
BinCreator = ""; BinCreator = "";
} } else {
else
{
BinCreator = BinCreatorStr; BinCreator = BinCreatorStr;
} }
if (BinCreator.empty()) if (BinCreator.empty()) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find QtIFW compiler \"binarycreator\": " "Cannot find QtIFW compiler \"binarycreator\": "
"likely it is not installed, or not in your PATH" "likely it is not installed, or not in your PATH"
@ -277,23 +244,16 @@ int cmCPackIFWGenerator::InitializeInternal()
// Look 'repogen' executable (optional) // Look 'repogen' executable (optional)
const char* RepoGenStr = this->GetOption(RepoGenOpt); const char* RepoGenStr = this->GetOption(RepoGenOpt);
if(!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) {
{
RepoGen = ""; RepoGen = "";
} } else {
else
{
RepoGen = RepoGenStr; RepoGen = RepoGenStr;
} }
// Framework version // Framework version
if(const char* FrameworkVersionSrt = if (const char* FrameworkVersionSrt = this->GetOption(FrameworkVersionOpt)) {
this->GetOption(FrameworkVersionOpt))
{
FrameworkVersion = FrameworkVersionSrt; FrameworkVersion = FrameworkVersionSrt;
} } else {
else
{
FrameworkVersion = "1.9.9"; FrameworkVersion = "1.9.9";
} }
@ -304,28 +264,20 @@ int cmCPackIFWGenerator::InitializeInternal()
// Additional packages dirs // Additional packages dirs
PkgsDirsVector.clear(); PkgsDirsVector.clear();
if(const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
{ cmSystemTools::ExpandListArgument(dirs, PkgsDirsVector);
cmSystemTools::ExpandListArgument(dirs,
PkgsDirsVector);
} }
// Installer // Installer
Installer.Generator = this; Installer.Generator = this;
Installer.ConfigureFromOptions(); Installer.ConfigureFromOptions();
if (const char* ifwDownloadAll = if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
this->GetOption("CPACK_IFW_DOWNLOAD_ALL"))
{
OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll); OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll);
} } else if (const char* cpackDownloadAll =
else if (const char* cpackDownloadAll = this->GetOption("CPACK_DOWNLOAD_ALL")) {
this->GetOption("CPACK_DOWNLOAD_ALL"))
{
OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll); OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll);
} } else {
else
{
OnlineOnly = false; OnlineOnly = false;
} }
@ -338,28 +290,22 @@ int cmCPackIFWGenerator::InitializeInternal()
} }
// Executable suffix // Executable suffix
if(const char *optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) if (const char* optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) {
{
ExecutableSuffix = optExeSuffix; ExecutableSuffix = optExeSuffix;
if(ExecutableSuffix.empty()) if (ExecutableSuffix.empty()) {
{
std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME")); std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME"));
if(sysName == "Linux") if (sysName == "Linux") {
{
ExecutableSuffix = ".run"; ExecutableSuffix = ".run";
} }
} }
} } else {
else
{
ExecutableSuffix = cmCPackGenerator::GetOutputExtension(); ExecutableSuffix = cmCPackGenerator::GetOutputExtension();
} }
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }
std::string std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
const std::string& componentName) const std::string& componentName)
{ {
const std::string prefix = "packages/"; const std::string prefix = "packages/";
@ -369,92 +315,78 @@ cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
return std::string(prefix + GetRootPackageName() + suffix); return std::string(prefix + GetRootPackageName() + suffix);
} }
return prefix return prefix + GetComponentPackageName(&Components[componentName]) + suffix;
+ GetComponentPackageName(&Components[componentName])
+ suffix;
} }
cmCPackComponent* cmCPackComponent* cmCPackIFWGenerator::GetComponent(
cmCPackIFWGenerator::GetComponent(const std::string &projectName, const std::string& projectName, const std::string& componentName)
const std::string &componentName)
{ {
ComponentsMap::iterator cit = Components.find(componentName); ComponentsMap::iterator cit = Components.find(componentName);
if ( cit != Components.end() ) return &(cit->second); if (cit != Components.end())
return &(cit->second);
cmCPackComponent* component cmCPackComponent* component =
= cmCPackGenerator::GetComponent(projectName, componentName); cmCPackGenerator::GetComponent(projectName, componentName);
if(!component) return component; if (!component)
return component;
std::string name = GetComponentPackageName(component); std::string name = GetComponentPackageName(component);
PackagesMap::iterator pit = Packages.find(name); PackagesMap::iterator pit = Packages.find(name);
if(pit != Packages.end()) return component; if (pit != Packages.end())
return component;
cmCPackIFWPackage* package = &Packages[name]; cmCPackIFWPackage* package = &Packages[name];
package->Name = name; package->Name = name;
package->Generator = this; package->Generator = this;
if(package->ConfigureFromComponent(component)) if (package->ConfigureFromComponent(component)) {
{
package->Installer = &Installer; package->Installer = &Installer;
Installer.Packages.insert( Installer.Packages.insert(
std::pair<std::string, cmCPackIFWPackage*>( std::pair<std::string, cmCPackIFWPackage*>(name, package));
name, package));
ComponentPackages.insert( ComponentPackages.insert(
std::pair<cmCPackComponent*, cmCPackIFWPackage*>( std::pair<cmCPackComponent*, cmCPackIFWPackage*>(component, package));
component, package)); if (component->IsDownloaded) {
if(component->IsDownloaded)
{
DownloadedPackages.insert(package); DownloadedPackages.insert(package);
} } else {
else
{
BinaryPackages.insert(package); BinaryPackages.insert(package);
} }
} } else {
else
{
Packages.erase(name); Packages.erase(name);
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \""
"Cannot configure package \"" << name << << name << "\" for component \"" << component->Name << "\""
"\" for component \"" << component->Name << "\""
<< std::endl); << std::endl);
} }
return component; return component;
} }
cmCPackComponentGroup* cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup(
cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName, const std::string& projectName, const std::string& groupName)
const std::string &groupName)
{ {
cmCPackComponentGroup* group cmCPackComponentGroup* group =
= cmCPackGenerator::GetComponentGroup(projectName, groupName); cmCPackGenerator::GetComponentGroup(projectName, groupName);
if(!group) return group; if (!group)
return group;
std::string name = GetGroupPackageName(group); std::string name = GetGroupPackageName(group);
PackagesMap::iterator pit = Packages.find(name); PackagesMap::iterator pit = Packages.find(name);
if(pit != Packages.end()) return group; if (pit != Packages.end())
return group;
cmCPackIFWPackage* package = &Packages[name]; cmCPackIFWPackage* package = &Packages[name];
package->Name = name; package->Name = name;
package->Generator = this; package->Generator = this;
if(package->ConfigureFromGroup(group)) if (package->ConfigureFromGroup(group)) {
{
package->Installer = &Installer; package->Installer = &Installer;
Installer.Packages.insert( Installer.Packages.insert(
std::pair<std::string, cmCPackIFWPackage*>( std::pair<std::string, cmCPackIFWPackage*>(name, package));
name, package));
GroupPackages.insert( GroupPackages.insert(
std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>( std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>(group, package));
group, package));
BinaryPackages.insert(package); BinaryPackages.insert(package);
} } else {
else
{
Packages.erase(name); Packages.erase(name);
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \""
"Cannot configure package \"" << name << << name << "\" for component group \"" << group->Name
"\" for component group \"" << group->Name << "\"" << "\"" << std::endl);
<< std::endl);
} }
return group; return group;
} }
@ -485,53 +417,44 @@ std::string cmCPackIFWGenerator::GetRootPackageName()
// Default value // Default value
std::string name = "root"; std::string name = "root";
if (const char* optIFW_PACKAGE_GROUP = if (const char* optIFW_PACKAGE_GROUP =
this->GetOption("CPACK_IFW_PACKAGE_GROUP")) this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
{
// Configure from root group // Configure from root group
cmCPackIFWPackage package; cmCPackIFWPackage package;
package.Generator = this; package.Generator = this;
package.ConfigureFromGroup(optIFW_PACKAGE_GROUP); package.ConfigureFromGroup(optIFW_PACKAGE_GROUP);
name = package.Name; name = package.Name;
} } else if (const char* optIFW_PACKAGE_NAME =
else if (const char* optIFW_PACKAGE_NAME = this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
this->GetOption("CPACK_IFW_PACKAGE_NAME"))
{
// Configure from root package name // Configure from root package name
name = optIFW_PACKAGE_NAME; name = optIFW_PACKAGE_NAME;
} } else if (const char* optPACKAGE_NAME =
else if (const char* optPACKAGE_NAME = this->GetOption("CPACK_PACKAGE_NAME")) {
this->GetOption("CPACK_PACKAGE_NAME"))
{
// Configure from package name // Configure from package name
name = optPACKAGE_NAME; name = optPACKAGE_NAME;
} }
return name; return name;
} }
std::string std::string cmCPackIFWGenerator::GetGroupPackageName(
cmCPackIFWGenerator::GetGroupPackageName(cmCPackComponentGroup *group) const cmCPackComponentGroup* group) const
{ {
std::string name; std::string name;
if (!group) return name; if (!group)
if (cmCPackIFWPackage* package = GetGroupPackage(group)) return name;
{ if (cmCPackIFWPackage* package = GetGroupPackage(group)) {
return package->Name; return package->Name;
} }
const char* option = GetOption( const char* option =
"CPACK_IFW_COMPONENT_GROUP_" GetOption("CPACK_IFW_COMPONENT_GROUP_" +
+ cmsys::SystemTools::UpperCase(group->Name) cmsys::SystemTools::UpperCase(group->Name) + "_NAME");
+ "_NAME");
name = option ? option : group->Name; name = option ? option : group->Name;
if(group->ParentGroup) if (group->ParentGroup) {
{
cmCPackIFWPackage* package = GetGroupPackage(group->ParentGroup); cmCPackIFWPackage* package = GetGroupPackage(group->ParentGroup);
bool dot = !ResolveDuplicateNames; bool dot = !ResolveDuplicateNames;
if(dot && name.substr(0, package->Name.size()) == package->Name) if (dot && name.substr(0, package->Name.size()) == package->Name) {
{
dot = false; dot = false;
} }
if(dot) if (dot) {
{
name = package->Name + "." + name; name = package->Name + "." + name;
} }
} }
@ -542,31 +465,26 @@ std::string cmCPackIFWGenerator::GetComponentPackageName(
cmCPackComponent* component) const cmCPackComponent* component) const
{ {
std::string name; std::string name;
if (!component) return name; if (!component)
if (cmCPackIFWPackage* package = GetComponentPackage(component)) return name;
{ if (cmCPackIFWPackage* package = GetComponentPackage(component)) {
return package->Name; return package->Name;
} }
std::string prefix = "CPACK_IFW_COMPONENT_" std::string prefix = "CPACK_IFW_COMPONENT_" +
+ cmsys::SystemTools::UpperCase(component->Name) cmsys::SystemTools::UpperCase(component->Name) + "_";
+ "_";
const char* option = GetOption(prefix + "NAME"); const char* option = GetOption(prefix + "NAME");
name = option ? option : component->Name; name = option ? option : component->Name;
if(component->Group) if (component->Group) {
{
cmCPackIFWPackage* package = GetGroupPackage(component->Group); cmCPackIFWPackage* package = GetGroupPackage(component->Group);
if((componentPackageMethod == ONE_PACKAGE_PER_GROUP) if ((componentPackageMethod == ONE_PACKAGE_PER_GROUP) ||
|| IsOn(prefix + "COMMON")) IsOn(prefix + "COMMON")) {
{
return package->Name; return package->Name;
} }
bool dot = !ResolveDuplicateNames; bool dot = !ResolveDuplicateNames;
if(dot && name.substr(0, package->Name.size()) == package->Name) if (dot && name.substr(0, package->Name.size()) == package->Name) {
{
dot = false; dot = false;
} }
if(dot) if (dot) {
{
name = package->Name + "." + name; name = package->Name + "." + name;
} }
} }
@ -576,16 +494,16 @@ std::string cmCPackIFWGenerator::GetComponentPackageName(
cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage( cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage(
cmCPackComponentGroup* group) const cmCPackComponentGroup* group) const
{ {
std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit =
= GroupPackages.find(group); GroupPackages.find(group);
return pit != GroupPackages.end() ? pit->second : 0; return pit != GroupPackages.end() ? pit->second : 0;
} }
cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage( cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage(
cmCPackComponent* component) const cmCPackComponent* component) const
{ {
std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit =
= ComponentPackages.find(component); ComponentPackages.find(component);
return pit != ComponentPackages.end() ? pit->second : 0; return pit != ComponentPackages.end() ? pit->second : 0;
} }
@ -594,12 +512,9 @@ void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter &xout)
std::stringstream comment; std::stringstream comment;
comment << "Generated by CPack " << CMake_VERSION << " IFW generator " comment << "Generated by CPack " << CMake_VERSION << " IFW generator "
<< "for QtIFW "; << "for QtIFW ";
if(IsVersionLess("2.0")) if (IsVersionLess("2.0")) {
{
comment << "less 2.0"; comment << "less 2.0";
} } else {
else
{
comment << FrameworkVersion; comment << FrameworkVersion;
} }
comment << " tools at " << cmTimestamp().CurrentTime("", true); comment << " tools at " << cmTimestamp().CurrentTime("", true);

View File

@ -90,8 +90,7 @@ protected:
* *
* @return Pointer to component * @return Pointer to component
*/ */
virtual cmCPackComponent* GetComponent( virtual cmCPackComponent* GetComponent(const std::string& projectName,
const std::string& projectName,
const std::string& componentName); const std::string& componentName);
/** /**
@ -104,8 +103,7 @@ protected:
* @return Pointer to component group * @return Pointer to component group
*/ */
virtual cmCPackComponentGroup* GetComponentGroup( virtual cmCPackComponentGroup* GetComponentGroup(
const std::string& projectName, const std::string& projectName, const std::string& groupName);
const std::string& groupName);
enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const; enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const;
virtual bool SupportsAbsoluteDestination() const; virtual bool SupportsAbsoluteDestination() const;

View File

@ -32,8 +32,8 @@
} \ } \
} while (0) } while (0)
cmCPackIFWInstaller::cmCPackIFWInstaller() : cmCPackIFWInstaller::cmCPackIFWInstaller()
Generator(0) : Generator(0)
{ {
} }
@ -62,208 +62,149 @@ bool cmCPackIFWInstaller::IsVersionEqual(const char *version)
return Generator ? Generator->IsVersionEqual(version) : false; return Generator ? Generator->IsVersionEqual(version) : false;
} }
void cmCPackIFWInstaller::ConfigureFromOptions() void cmCPackIFWInstaller::ConfigureFromOptions()
{ {
// Name; // Name;
if (const char* optIFW_PACKAGE_NAME = if (const char* optIFW_PACKAGE_NAME =
this->GetOption("CPACK_IFW_PACKAGE_NAME")) this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
{
Name = optIFW_PACKAGE_NAME; Name = optIFW_PACKAGE_NAME;
} } else if (const char* optPACKAGE_NAME =
else if (const char* optPACKAGE_NAME = this->GetOption("CPACK_PACKAGE_NAME")) {
this->GetOption("CPACK_PACKAGE_NAME"))
{
Name = optPACKAGE_NAME; Name = optPACKAGE_NAME;
} } else {
else
{
Name = "Your package"; Name = "Your package";
} }
// Title; // Title;
if (const char* optIFW_PACKAGE_TITLE = if (const char* optIFW_PACKAGE_TITLE =
GetOption("CPACK_IFW_PACKAGE_TITLE")) GetOption("CPACK_IFW_PACKAGE_TITLE")) {
{
Title = optIFW_PACKAGE_TITLE; Title = optIFW_PACKAGE_TITLE;
} } else if (const char* optPACKAGE_DESCRIPTION_SUMMARY =
else if (const char* optPACKAGE_DESCRIPTION_SUMMARY = GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY"))
{
Title = optPACKAGE_DESCRIPTION_SUMMARY; Title = optPACKAGE_DESCRIPTION_SUMMARY;
} } else {
else
{
Title = "Your package description"; Title = "Your package description";
} }
// Version; // Version;
if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) {
{
Version = option; Version = option;
} } else {
else
{
Version = "1.0.0"; Version = "1.0.0";
} }
// Publisher // Publisher
if (const char* optIFW_PACKAGE_PUBLISHER = if (const char* optIFW_PACKAGE_PUBLISHER =
GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) {
{
Publisher = optIFW_PACKAGE_PUBLISHER; Publisher = optIFW_PACKAGE_PUBLISHER;
} } else if (const char* optPACKAGE_VENDOR =
else if(const char* optPACKAGE_VENDOR = GetOption("CPACK_PACKAGE_VENDOR")) GetOption("CPACK_PACKAGE_VENDOR")) {
{
Publisher = optPACKAGE_VENDOR; Publisher = optPACKAGE_VENDOR;
} }
// ProductUrl // ProductUrl
if(const char* option = GetOption("CPACK_IFW_PRODUCT_URL")) if (const char* option = GetOption("CPACK_IFW_PRODUCT_URL")) {
{
ProductUrl = option; ProductUrl = option;
} }
// ApplicationIcon // ApplicationIcon
if(const char* option = GetOption("CPACK_IFW_PACKAGE_ICON")) if (const char* option = GetOption("CPACK_IFW_PACKAGE_ICON")) {
{ if (cmSystemTools::FileExists(option)) {
if(cmSystemTools::FileExists(option))
{
InstallerApplicationIcon = option; InstallerApplicationIcon = option;
} } else {
else
{
// TODO: implement warning // TODO: implement warning
} }
} }
// WindowIcon // WindowIcon
if(const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) if (const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) {
{ if (cmSystemTools::FileExists(option)) {
if(cmSystemTools::FileExists(option))
{
InstallerWindowIcon = option; InstallerWindowIcon = option;
} } else {
else
{
// TODO: implement warning // TODO: implement warning
} }
} }
// Logo // Logo
if(const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO")) if (const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO")) {
{ if (cmSystemTools::FileExists(option)) {
if(cmSystemTools::FileExists(option))
{
Logo = option; Logo = option;
} } else {
else
{
// TODO: implement warning // TODO: implement warning
} }
} }
// Start menu // Start menu
if (const char* optIFW_START_MENU_DIR = if (const char* optIFW_START_MENU_DIR =
this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) {
{
StartMenuDir = optIFW_START_MENU_DIR; StartMenuDir = optIFW_START_MENU_DIR;
} } else {
else
{
StartMenuDir = Name; StartMenuDir = Name;
} }
// Default target directory for installation // Default target directory for installation
if (const char* optIFW_TARGET_DIRECTORY = if (const char* optIFW_TARGET_DIRECTORY =
GetOption("CPACK_IFW_TARGET_DIRECTORY")) GetOption("CPACK_IFW_TARGET_DIRECTORY")) {
{
TargetDir = optIFW_TARGET_DIRECTORY; TargetDir = optIFW_TARGET_DIRECTORY;
} } else if (const char* optPACKAGE_INSTALL_DIRECTORY =
else if (const char *optPACKAGE_INSTALL_DIRECTORY = GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) {
GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY"))
{
TargetDir = "@ApplicationsDir@/"; TargetDir = "@ApplicationsDir@/";
TargetDir += optPACKAGE_INSTALL_DIRECTORY; TargetDir += optPACKAGE_INSTALL_DIRECTORY;
} } else {
else
{
TargetDir = "@RootDir@/usr/local"; TargetDir = "@RootDir@/usr/local";
} }
// Default target directory for installation with administrator rights // Default target directory for installation with administrator rights
if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) {
{
AdminTargetDir = option; AdminTargetDir = option;
} }
// Repositories // Repositories
Repositories.clear(); Repositories.clear();
RepositoryStruct Repo; RepositoryStruct Repo;
if(const char *site = this->GetOption("CPACK_DOWNLOAD_SITE")) if (const char* site = this->GetOption("CPACK_DOWNLOAD_SITE")) {
{
Repo.Url = site; Repo.Url = site;
Repositories.push_back(Repo); Repositories.push_back(Repo);
} }
if(const char *RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) {
{
std::vector<std::string> RepoAllVector; std::vector<std::string> RepoAllVector;
cmSystemTools::ExpandListArgument(RepoAllStr, cmSystemTools::ExpandListArgument(RepoAllStr, RepoAllVector);
RepoAllVector); for (std::vector<std::string>::iterator rit = RepoAllVector.begin();
for(std::vector<std::string>::iterator rit != RepoAllVector.end(); ++rit) {
rit = RepoAllVector.begin(); rit != RepoAllVector.end(); ++rit) std::string prefix =
{ "CPACK_IFW_REPOSITORY_" + cmsys::SystemTools::UpperCase(*rit) + "_";
std::string prefix = "CPACK_IFW_REPOSITORY_"
+ cmsys::SystemTools::UpperCase(*rit)
+ "_";
// Url // Url
if (const char* url = GetOption(prefix + "URL")) if (const char* url = GetOption(prefix + "URL")) {
{
Repo.Url = url; Repo.Url = url;
} } else {
else
{
Repo.Url = ""; Repo.Url = "";
} }
// Enabled // Enabled
if (IsOn(prefix + "DISABLED")) if (IsOn(prefix + "DISABLED")) {
{
Repo.Enabled = "0"; Repo.Enabled = "0";
} } else {
else
{
Repo.Enabled = ""; Repo.Enabled = "";
} }
// Username // Username
if (const char* username = GetOption(prefix + "USERNAME")) if (const char* username = GetOption(prefix + "USERNAME")) {
{
Repo.Username = username; Repo.Username = username;
} } else {
else
{
Repo.Username = ""; Repo.Username = "";
} }
// Password // Password
if (const char* password = GetOption(prefix + "PASSWORD")) if (const char* password = GetOption(prefix + "PASSWORD")) {
{
Repo.Password = password; Repo.Password = password;
} } else {
else
{
Repo.Password = ""; Repo.Password = "";
} }
// DisplayName // DisplayName
if (const char* displayName = GetOption(prefix + "DISPLAY_NAME")) if (const char* displayName = GetOption(prefix + "DISPLAY_NAME")) {
{
Repo.DisplayName = displayName; Repo.DisplayName = displayName;
} } else {
else
{
Repo.DisplayName = ""; Repo.DisplayName = "";
} }
if(!Repo.Url.empty()) if (!Repo.Url.empty()) {
{
Repositories.push_back(Repo); Repositories.push_back(Repo);
} }
} }
@ -271,48 +212,37 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
// Maintenance tool // Maintenance tool
if (const char* optIFW_MAINTENANCE_TOOL = if (const char* optIFW_MAINTENANCE_TOOL =
this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) {
{
MaintenanceToolName = optIFW_MAINTENANCE_TOOL; MaintenanceToolName = optIFW_MAINTENANCE_TOOL;
} }
// Maintenance tool ini file // Maintenance tool ini file
if (const char* optIFW_MAINTENANCE_TOOL_INI = if (const char* optIFW_MAINTENANCE_TOOL_INI =
this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) {
{
MaintenanceToolIniFile = optIFW_MAINTENANCE_TOOL_INI; MaintenanceToolIniFile = optIFW_MAINTENANCE_TOOL_INI;
} }
// Allow non-ASCII characters // Allow non-ASCII characters
if(this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
{ if (IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) {
if(IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS"))
{
AllowNonAsciiCharacters = "true"; AllowNonAsciiCharacters = "true";
} } else {
else
{
AllowNonAsciiCharacters = "false"; AllowNonAsciiCharacters = "false";
} }
} }
// Space in path // Space in path
if(this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
{ if (IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) {
if(IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH"))
{
AllowSpaceInPath = "true"; AllowSpaceInPath = "true";
} } else {
else
{
AllowSpaceInPath = "false"; AllowSpaceInPath = "false";
} }
} }
// Control script // Control script
if (const char* optIFW_CONTROL_SCRIPT = if (const char* optIFW_CONTROL_SCRIPT =
this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) {
{
ControlScript = optIFW_CONTROL_SCRIPT; ControlScript = optIFW_CONTROL_SCRIPT;
} }
} }
@ -320,8 +250,7 @@ void cmCPackIFWInstaller::ConfigureFromOptions()
void cmCPackIFWInstaller::GenerateInstallerFile() void cmCPackIFWInstaller::GenerateInstallerFile()
{ {
// Lazy directory initialization // Lazy directory initialization
if(Directory.empty() && Generator) if (Directory.empty() && Generator) {
{
Directory = Generator->toplevel; Directory = Generator->toplevel;
} }
@ -339,41 +268,36 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
xout.Element("Version", Version); xout.Element("Version", Version);
xout.Element("Title", Title); xout.Element("Title", Title);
if(!Publisher.empty()) if (!Publisher.empty()) {
{
xout.Element("Publisher", Publisher); xout.Element("Publisher", Publisher);
} }
if(!ProductUrl.empty()) if (!ProductUrl.empty()) {
{
xout.Element("ProductUrl", ProductUrl); xout.Element("ProductUrl", ProductUrl);
} }
// ApplicationIcon // ApplicationIcon
if(!InstallerApplicationIcon.empty()) if (!InstallerApplicationIcon.empty()) {
{
std::string name = std::string name =
cmSystemTools::GetFilenameName(InstallerApplicationIcon); cmSystemTools::GetFilenameName(InstallerApplicationIcon);
std::string path = Directory + "/config/" + name; std::string path = Directory + "/config/" + name;
name = cmSystemTools::GetFilenameWithoutExtension(name); name = cmSystemTools::GetFilenameWithoutExtension(name);
cmsys::SystemTools::CopyFileIfDifferent( cmsys::SystemTools::CopyFileIfDifferent(InstallerApplicationIcon.data(),
InstallerApplicationIcon.data(), path.data()); path.data());
xout.Element("InstallerApplicationIcon", name); xout.Element("InstallerApplicationIcon", name);
} }
// WindowIcon // WindowIcon
if(!InstallerWindowIcon.empty()) if (!InstallerWindowIcon.empty()) {
{
std::string name = cmSystemTools::GetFilenameName(InstallerWindowIcon); std::string name = cmSystemTools::GetFilenameName(InstallerWindowIcon);
std::string path = Directory + "/config/" + name; std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent( cmsys::SystemTools::CopyFileIfDifferent(InstallerWindowIcon.data(),
InstallerWindowIcon.data(), path.data()); path.data());
xout.Element("InstallerWindowIcon", name); xout.Element("InstallerWindowIcon", name);
} }
// Logo // Logo
if(!Logo.empty()) if (!Logo.empty()) {
{
std::string name = cmSystemTools::GetFilenameName(Logo); std::string name = cmSystemTools::GetFilenameName(Logo);
std::string path = Directory + "/config/" + name; std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data()); cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data());
@ -381,51 +305,42 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
} }
// Start menu // Start menu
if(!IsVersionLess("2.0")) if (!IsVersionLess("2.0")) {
{
xout.Element("StartMenuDir", StartMenuDir); xout.Element("StartMenuDir", StartMenuDir);
} }
// Target dir // Target dir
if(!TargetDir.empty()) if (!TargetDir.empty()) {
{
xout.Element("TargetDir", TargetDir); xout.Element("TargetDir", TargetDir);
} }
// Admin target dir // Admin target dir
if(!AdminTargetDir.empty()) if (!AdminTargetDir.empty()) {
{
xout.Element("AdminTargetDir", AdminTargetDir); xout.Element("AdminTargetDir", AdminTargetDir);
} }
// Remote repositories // Remote repositories
if (!Repositories.empty()) if (!Repositories.empty()) {
{
xout.StartElement("RemoteRepositories"); xout.StartElement("RemoteRepositories");
for(std::vector<RepositoryStruct>::iterator for (std::vector<RepositoryStruct>::iterator rit = Repositories.begin();
rit = Repositories.begin(); rit != Repositories.end(); ++rit) rit != Repositories.end(); ++rit) {
{
xout.StartElement("Repository"); xout.StartElement("Repository");
// Url // Url
xout.Element("Url", rit->Url); xout.Element("Url", rit->Url);
// Enabled // Enabled
if(!rit->Enabled.empty()) if (!rit->Enabled.empty()) {
{
xout.Element("Enabled", rit->Enabled); xout.Element("Enabled", rit->Enabled);
} }
// Username // Username
if(!rit->Username.empty()) if (!rit->Username.empty()) {
{
xout.Element("Username", rit->Username); xout.Element("Username", rit->Username);
} }
// Password // Password
if(!rit->Password.empty()) if (!rit->Password.empty()) {
{
xout.Element("Password", rit->Password); xout.Element("Password", rit->Password);
} }
// DisplayName // DisplayName
if(!rit->DisplayName.empty()) if (!rit->DisplayName.empty()) {
{
xout.Element("DisplayName", rit->DisplayName); xout.Element("DisplayName", rit->DisplayName);
} }
xout.EndElement(); xout.EndElement();
@ -434,40 +349,32 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
} }
// Maintenance tool // Maintenance tool
if(!IsVersionLess("2.0") && !MaintenanceToolName.empty()) if (!IsVersionLess("2.0") && !MaintenanceToolName.empty()) {
{
xout.Element("MaintenanceToolName", MaintenanceToolName); xout.Element("MaintenanceToolName", MaintenanceToolName);
} }
// Maintenance tool ini file // Maintenance tool ini file
if(!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty()) if (!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty()) {
{
xout.Element("MaintenanceToolIniFile", MaintenanceToolIniFile); xout.Element("MaintenanceToolIniFile", MaintenanceToolIniFile);
} }
// Different allows // Different allows
if(IsVersionLess("2.0")) if (IsVersionLess("2.0")) {
{
// CPack IFW default policy // CPack IFW default policy
xout.Comment("CPack IFW default policy for QtIFW less 2.0"); xout.Comment("CPack IFW default policy for QtIFW less 2.0");
xout.Element("AllowNonAsciiCharacters", "true"); xout.Element("AllowNonAsciiCharacters", "true");
xout.Element("AllowSpaceInPath", "true"); xout.Element("AllowSpaceInPath", "true");
} } else {
else if (!AllowNonAsciiCharacters.empty()) {
{
if(!AllowNonAsciiCharacters.empty())
{
xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters); xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters);
} }
if(!AllowSpaceInPath.empty()) if (!AllowSpaceInPath.empty()) {
{
xout.Element("AllowSpaceInPath", AllowSpaceInPath); xout.Element("AllowSpaceInPath", AllowSpaceInPath);
} }
} }
// Control script (copy to config dir) // Control script (copy to config dir)
if(!IsVersionLess("2.0") && !ControlScript.empty()) if (!IsVersionLess("2.0") && !ControlScript.empty()) {
{
std::string name = cmSystemTools::GetFilenameName(ControlScript); std::string name = cmSystemTools::GetFilenameName(ControlScript);
std::string path = Directory + "/config/" + name; std::string path = Directory + "/config/" + name;
cmsys::SystemTools::CopyFileIfDifferent(ControlScript.data(), path.data()); cmsys::SystemTools::CopyFileIfDifferent(ControlScript.data(), path.data());
@ -480,20 +387,16 @@ void cmCPackIFWInstaller::GenerateInstallerFile()
void cmCPackIFWInstaller::GeneratePackageFiles() void cmCPackIFWInstaller::GeneratePackageFiles()
{ {
if (Packages.empty() || Generator->IsOnePackage()) if (Packages.empty() || Generator->IsOnePackage()) {
{
// Generate default package // Generate default package
cmCPackIFWPackage package; cmCPackIFWPackage package;
package.Generator = Generator; package.Generator = Generator;
package.Installer = this; package.Installer = this;
// Check package group // Check package group
if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) {
{
package.ConfigureFromGroup(option); package.ConfigureFromGroup(option);
package.ForcedInstallation = "true"; package.ForcedInstallation = "true";
} } else {
else
{
package.ConfigureFromOptions(); package.ConfigureFromOptions();
} }
package.GeneratePackageFile(); package.GeneratePackageFile();
@ -501,9 +404,8 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
} }
// Generate packages meta information // Generate packages meta information
for(PackagesMap::iterator pit = Packages.begin(); for (PackagesMap::iterator pit = Packages.begin(); pit != Packages.end();
pit != Packages.end(); ++pit) ++pit) {
{
cmCPackIFWPackage* package = pit->second; cmCPackIFWPackage* package = pit->second;
package->GeneratePackageFile(); package->GeneratePackageFile();
} }
@ -511,5 +413,6 @@ void cmCPackIFWInstaller::GeneratePackageFiles()
void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout) void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout)
{ {
if(Generator) Generator->WriteGeneratedByToStrim(xout); if (Generator)
Generator->WriteGeneratedByToStrim(xout);
} }

View File

@ -35,8 +35,8 @@
} while (0) } while (0)
//---------------------------------------------------------- CompareStruct --- //---------------------------------------------------------- CompareStruct ---
cmCPackIFWPackage::CompareStruct::CompareStruct() : cmCPackIFWPackage::CompareStruct::CompareStruct()
Type(CompareNone) : Type(CompareNone)
{ {
} }
@ -50,28 +50,19 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct(
{ {
// Search compare section // Search compare section
size_t pos = std::string::npos; size_t pos = std::string::npos;
if((pos = dependence.find("<=")) != std::string::npos) if ((pos = dependence.find("<=")) != std::string::npos) {
{
Compare.Type = CompareLessOrEqual; Compare.Type = CompareLessOrEqual;
Compare.Value = dependence.substr(pos + 2); Compare.Value = dependence.substr(pos + 2);
} } else if ((pos = dependence.find(">=")) != std::string::npos) {
else if((pos = dependence.find(">=")) != std::string::npos)
{
Compare.Type = CompareGreaterOrEqual; Compare.Type = CompareGreaterOrEqual;
Compare.Value = dependence.substr(pos + 2); Compare.Value = dependence.substr(pos + 2);
} } else if ((pos = dependence.find("<")) != std::string::npos) {
else if((pos = dependence.find("<")) != std::string::npos)
{
Compare.Type = CompareLess; Compare.Type = CompareLess;
Compare.Value = dependence.substr(pos + 1); Compare.Value = dependence.substr(pos + 1);
} } else if ((pos = dependence.find("=")) != std::string::npos) {
else if((pos = dependence.find("=")) != std::string::npos)
{
Compare.Type = CompareEqual; Compare.Type = CompareEqual;
Compare.Value = dependence.substr(pos + 1); Compare.Value = dependence.substr(pos + 1);
} } else if ((pos = dependence.find(">")) != std::string::npos) {
else if((pos = dependence.find(">")) != std::string::npos)
{
Compare.Type = CompareGreater; Compare.Type = CompareGreater;
Compare.Value = dependence.substr(pos + 1); Compare.Value = dependence.substr(pos + 1);
} }
@ -80,28 +71,20 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct(
std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
{ {
if (Compare.Type == CompareNone) return Name; if (Compare.Type == CompareNone)
return Name;
std::string result = Name; std::string result = Name;
if (Compare.Type == CompareLessOrEqual) if (Compare.Type == CompareLessOrEqual) {
{
result += "<="; result += "<=";
} } else if (Compare.Type == CompareGreaterOrEqual) {
else if (Compare.Type == CompareGreaterOrEqual)
{
result += ">="; result += ">=";
} } else if (Compare.Type == CompareLess) {
else if (Compare.Type == CompareLess)
{
result += "<"; result += "<";
} } else if (Compare.Type == CompareEqual) {
else if (Compare.Type == CompareEqual)
{
result += "="; result += "=";
} } else if (Compare.Type == CompareGreater) {
else if (Compare.Type == CompareGreater)
{
result += ">"; result += ">";
} }
@ -111,9 +94,9 @@ std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
} }
//------------------------------------------------------ cmCPackIFWPackage --- //------------------------------------------------------ cmCPackIFWPackage ---
cmCPackIFWPackage::cmCPackIFWPackage() : cmCPackIFWPackage::cmCPackIFWPackage()
Generator(0), : Generator(0)
Installer(0) , Installer(0)
{ {
} }
@ -145,11 +128,11 @@ bool cmCPackIFWPackage::IsVersionEqual(const char *version)
std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component) std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component)
{ {
if (!component) return ""; if (!component)
const char* option = GetOption( return "";
"CPACK_IFW_COMPONENT_" const char* option =
+ cmsys::SystemTools::UpperCase(component->Name) GetOption("CPACK_IFW_COMPONENT_" +
+ "_NAME"); cmsys::SystemTools::UpperCase(component->Name) + "_NAME");
return option ? option : component->Name; return option ? option : component->Name;
} }
@ -177,33 +160,24 @@ int cmCPackIFWPackage::ConfigureFromOptions()
Name = Generator->GetRootPackageName(); Name = Generator->GetRootPackageName();
// Display name // Display name
if (const char *option = this->GetOption("CPACK_PACKAGE_NAME")) if (const char* option = this->GetOption("CPACK_PACKAGE_NAME")) {
{
DisplayName = option; DisplayName = option;
} } else {
else
{
DisplayName = "Your package"; DisplayName = "Your package";
} }
// Description // Description
if (const char* option = if (const char* option =
this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
{
Description = option; Description = option;
} } else {
else
{
Description = "Your package description"; Description = "Your package description";
} }
// Version // Version
if(const char* option = GetOption("CPACK_PACKAGE_VERSION")) if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) {
{
Version = option; Version = option;
} } else {
else
{
Version = "1.0.0"; Version = "1.0.0";
} }
@ -214,14 +188,14 @@ int cmCPackIFWPackage::ConfigureFromOptions()
int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
{ {
if(!component) return 0; if (!component)
return 0;
// Restore defaul configuration // Restore defaul configuration
DefaultConfiguration(); DefaultConfiguration();
std::string prefix = "CPACK_IFW_COMPONENT_" std::string prefix = "CPACK_IFW_COMPONENT_" +
+ cmsys::SystemTools::UpperCase(component->Name) cmsys::SystemTools::UpperCase(component->Name) + "_";
+ "_";
// Display name // Display name
DisplayName = component->DisplayName; DisplayName = component->DisplayName;
@ -230,55 +204,40 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
Description = component->Description; Description = component->Description;
// Version // Version
if(const char* optVERSION = GetOption(prefix + "VERSION")) if (const char* optVERSION = GetOption(prefix + "VERSION")) {
{
Version = optVERSION; Version = optVERSION;
} } else if (const char* optPACKAGE_VERSION =
else if(const char* optPACKAGE_VERSION = GetOption("CPACK_PACKAGE_VERSION")) {
GetOption("CPACK_PACKAGE_VERSION"))
{
Version = optPACKAGE_VERSION; Version = optPACKAGE_VERSION;
} } else {
else
{
Version = "1.0.0"; Version = "1.0.0";
} }
// Script // Script
if (const char* option = GetOption(prefix + "SCRIPT")) if (const char* option = GetOption(prefix + "SCRIPT")) {
{
Script = option; Script = option;
} }
// CMake dependencies // CMake dependencies
if (!component->Dependencies.empty()) if (!component->Dependencies.empty()) {
{
std::vector<cmCPackComponent*>::iterator dit; std::vector<cmCPackComponent*>::iterator dit;
for (dit = component->Dependencies.begin(); for (dit = component->Dependencies.begin();
dit != component->Dependencies.end(); dit != component->Dependencies.end(); ++dit) {
++dit)
{
Dependencies.insert(Generator->ComponentPackages[*dit]); Dependencies.insert(Generator->ComponentPackages[*dit]);
} }
} }
// QtIFW dependencies // QtIFW dependencies
if(const char* option = this->GetOption(prefix + "DEPENDS")) if (const char* option = this->GetOption(prefix + "DEPENDS")) {
{
std::vector<std::string> deps; std::vector<std::string> deps;
cmSystemTools::ExpandListArgument(option, cmSystemTools::ExpandListArgument(option, deps);
deps); for (std::vector<std::string>::iterator dit = deps.begin();
for(std::vector<std::string>::iterator dit != deps.end(); ++dit) {
dit = deps.begin(); dit != deps.end(); ++dit)
{
DependenceStruct dep(*dit); DependenceStruct dep(*dit);
if (!Generator->Packages.count(dep.Name)) if (!Generator->Packages.count(dep.Name)) {
{
bool hasDep = Generator->DependentPackages.count(dep.Name) > 0; bool hasDep = Generator->DependentPackages.count(dep.Name) > 0;
DependenceStruct &depRef = DependenceStruct& depRef = Generator->DependentPackages[dep.Name];
Generator->DependentPackages[dep.Name]; if (!hasDep) {
if(!hasDep)
{
depRef = dep; depRef = dep;
} }
AlienDependencies.insert(&depRef); AlienDependencies.insert(&depRef);
@ -287,13 +246,13 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
} }
// Licenses // Licenses
if (const char* option = this->GetOption(prefix + "LICENSES")) if (const char* option = this->GetOption(prefix + "LICENSES")) {
{
Licenses.clear(); Licenses.clear();
cmSystemTools::ExpandListArgument(option, Licenses); cmSystemTools::ExpandListArgument(option, Licenses);
if ( Licenses.size() % 2 != 0 ) if (Licenses.size() % 2 != 0) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_WARNING, prefix << "LICENSES" cmCPackLog::LOG_WARNING, prefix
<< "LICENSES"
<< " should contain pairs of <display_name> and <file_path>." << " should contain pairs of <display_name> and <file_path>."
<< std::endl); << std::endl);
Licenses.clear(); Licenses.clear();
@ -301,8 +260,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
} }
// Priority // Priority
if(const char* option = this->GetOption(prefix + "PRIORITY")) if (const char* option = this->GetOption(prefix + "PRIORITY")) {
{
SortingPriority = option; SortingPriority = option;
} }
@ -318,50 +276,43 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component)
return 1; return 1;
} }
int int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup *group)
{ {
if(!group) return 0; if (!group)
return 0;
// Restore defaul configuration // Restore defaul configuration
DefaultConfiguration(); DefaultConfiguration();
std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" +
+ cmsys::SystemTools::UpperCase(group->Name) cmsys::SystemTools::UpperCase(group->Name) + "_";
+ "_";
DisplayName = group->DisplayName; DisplayName = group->DisplayName;
Description = group->Description; Description = group->Description;
// Version // Version
if(const char* optVERSION = GetOption(prefix + "VERSION")) if (const char* optVERSION = GetOption(prefix + "VERSION")) {
{
Version = optVERSION; Version = optVERSION;
} } else if (const char* optPACKAGE_VERSION =
else if(const char* optPACKAGE_VERSION = GetOption("CPACK_PACKAGE_VERSION")) {
GetOption("CPACK_PACKAGE_VERSION"))
{
Version = optPACKAGE_VERSION; Version = optPACKAGE_VERSION;
} } else {
else
{
Version = "1.0.0"; Version = "1.0.0";
} }
// Script // Script
if (const char* option = GetOption(prefix + "SCRIPT")) if (const char* option = GetOption(prefix + "SCRIPT")) {
{
Script = option; Script = option;
} }
// Licenses // Licenses
if (const char* option = this->GetOption(prefix + "LICENSES")) if (const char* option = this->GetOption(prefix + "LICENSES")) {
{
Licenses.clear(); Licenses.clear();
cmSystemTools::ExpandListArgument(option, Licenses); cmSystemTools::ExpandListArgument(option, Licenses);
if ( Licenses.size() % 2 != 0 ) if (Licenses.size() % 2 != 0) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_WARNING, prefix << "LICENSES" cmCPackLog::LOG_WARNING, prefix
<< "LICENSES"
<< " should contain pairs of <display_name> and <file_path>." << " should contain pairs of <display_name> and <file_path>."
<< std::endl); << std::endl);
Licenses.clear(); Licenses.clear();
@ -369,8 +320,7 @@ cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup *group)
} }
// Priority // Priority
if(const char* option = this->GetOption(prefix + "PRIORITY")) if (const char* option = this->GetOption(prefix + "PRIORITY")) {
{
SortingPriority = option; SortingPriority = option;
} }
@ -382,21 +332,16 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
// Group configuration // Group configuration
cmCPackComponentGroup group; cmCPackComponentGroup group;
std::string prefix = "CPACK_COMPONENT_GROUP_" std::string prefix =
+ cmsys::SystemTools::UpperCase(groupName) "CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(groupName) + "_";
+ "_";
if (const char *option = GetOption(prefix + "DISPLAY_NAME")) if (const char* option = GetOption(prefix + "DISPLAY_NAME")) {
{
group.DisplayName = option; group.DisplayName = option;
} } else {
else
{
group.DisplayName = group.Name; group.DisplayName = group.Name;
} }
if (const char* option = GetOption(prefix + "DESCRIPTION")) if (const char* option = GetOption(prefix + "DESCRIPTION")) {
{
group.Description = option; group.Description = option;
} }
group.IsBold = IsOn(prefix + "BOLD_TITLE"); group.IsBold = IsOn(prefix + "BOLD_TITLE");
@ -406,12 +351,9 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
group.Name = groupName; group.Name = groupName;
if(Generator) if (Generator) {
{
Name = Generator->GetGroupPackageName(&group); Name = Generator->GetGroupPackageName(&group);
} } else {
else
{
Name = group.Name; Name = group.Name;
} }
@ -421,14 +363,10 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName)
void cmCPackIFWPackage::GeneratePackageFile() void cmCPackIFWPackage::GeneratePackageFile()
{ {
// Lazy directory initialization // Lazy directory initialization
if (Directory.empty()) if (Directory.empty()) {
{ if (Installer) {
if(Installer)
{
Directory = Installer->Directory + "/packages/" + Name; Directory = Installer->Directory + "/packages/" + Name;
} } else if (Generator) {
else if (Generator)
{
Directory = Generator->toplevel + "/packages/" + Name; Directory = Generator->toplevel + "/packages/" + Name;
} }
} }
@ -448,18 +386,14 @@ void cmCPackIFWPackage::GeneratePackageFile()
xout.Element("Name", Name); xout.Element("Name", Name);
xout.Element("Version", Version); xout.Element("Version", Version);
if (!ReleaseDate.empty()) if (!ReleaseDate.empty()) {
{
xout.Element("ReleaseDate", ReleaseDate); xout.Element("ReleaseDate", ReleaseDate);
} } else {
else
{
xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true)); xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true));
} }
// Script (copy to meta dir) // Script (copy to meta dir)
if(!Script.empty()) if (!Script.empty()) {
{
std::string name = cmSystemTools::GetFilenameName(Script); std::string name = cmSystemTools::GetFilenameName(Script);
std::string path = Directory + "/meta/" + name; std::string path = Directory + "/meta/" + name;
cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data()); cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data());
@ -469,24 +403,20 @@ void cmCPackIFWPackage::GeneratePackageFile()
// Dependencies // Dependencies
std::set<DependenceStruct> compDepSet; std::set<DependenceStruct> compDepSet;
for (std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin(); for (std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin();
ait != AlienDependencies.end(); ++ait) ait != AlienDependencies.end(); ++ait) {
{
compDepSet.insert(*(*ait)); compDepSet.insert(*(*ait));
} }
for (std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin(); for (std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin();
it != Dependencies.end(); ++it) it != Dependencies.end(); ++it) {
{
compDepSet.insert(DependenceStruct((*it)->Name)); compDepSet.insert(DependenceStruct((*it)->Name));
} }
// Write dependencies // Write dependencies
if (!compDepSet.empty()) if (!compDepSet.empty()) {
{
std::stringstream dependencies; std::stringstream dependencies;
std::set<DependenceStruct>::iterator it = compDepSet.begin(); std::set<DependenceStruct>::iterator it = compDepSet.begin();
dependencies << it->NameWithCompare(); dependencies << it->NameWithCompare();
++it; ++it;
while(it != compDepSet.end()) while (it != compDepSet.end()) {
{
dependencies << "," << it->NameWithCompare(); dependencies << "," << it->NameWithCompare();
++it; ++it;
} }
@ -495,18 +425,15 @@ void cmCPackIFWPackage::GeneratePackageFile()
// Licenses (copy to meta dir) // Licenses (copy to meta dir)
std::vector<std::string> licenses = Licenses; std::vector<std::string> licenses = Licenses;
for(size_t i = 1; i < licenses.size(); i += 2) for (size_t i = 1; i < licenses.size(); i += 2) {
{
std::string name = cmSystemTools::GetFilenameName(licenses[i]); std::string name = cmSystemTools::GetFilenameName(licenses[i]);
std::string path = Directory + "/meta/" + name; std::string path = Directory + "/meta/" + name;
cmsys::SystemTools::CopyFileIfDifferent(licenses[i].data(), path.data()); cmsys::SystemTools::CopyFileIfDifferent(licenses[i].data(), path.data());
licenses[i] = name; licenses[i] = name;
} }
if(!licenses.empty()) if (!licenses.empty()) {
{
xout.StartElement("Licenses"); xout.StartElement("Licenses");
for(size_t i = 0; i < licenses.size(); i += 2) for (size_t i = 0; i < licenses.size(); i += 2) {
{
xout.StartElement("License"); xout.StartElement("License");
xout.Attribute("name", licenses[i]); xout.Attribute("name", licenses[i]);
xout.Attribute("file", licenses[i + 1]); xout.Attribute("file", licenses[i + 1]);
@ -515,23 +442,18 @@ void cmCPackIFWPackage::GeneratePackageFile()
xout.EndElement(); xout.EndElement();
} }
if (!ForcedInstallation.empty()) if (!ForcedInstallation.empty()) {
{
xout.Element("ForcedInstallation", ForcedInstallation); xout.Element("ForcedInstallation", ForcedInstallation);
} }
if (!Virtual.empty()) if (!Virtual.empty()) {
{
xout.Element("Virtual", Virtual); xout.Element("Virtual", Virtual);
} } else if (!Default.empty()) {
else if (!Default.empty())
{
xout.Element("Default", Default); xout.Element("Default", Default);
} }
// Priority // Priority
if(!SortingPriority.empty()) if (!SortingPriority.empty()) {
{
xout.Element("SortingPriority", SortingPriority); xout.Element("SortingPriority", SortingPriority);
} }
@ -541,5 +463,6 @@ void cmCPackIFWPackage::GeneratePackageFile()
void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout) void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout)
{ {
if(Generator) Generator->WriteGeneratedByToStrim(xout); if (Generator)
Generator->WriteGeneratedByToStrim(xout);
} }

View File

@ -36,30 +36,26 @@ int main(int argc, char* argv[])
UInt8* path; UInt8* path;
// get CF URL for script // get CF URL for script
if (! (appBundle = CFBundleGetMainBundle())) if (!(appBundle = CFBundleGetMainBundle())) {
{
DebugError("Cannot get main bundle"); DebugError("Cannot get main bundle");
return 1; return 1;
} }
fileName = CFSTR("RuntimeScript"); fileName = CFSTR("RuntimeScript");
if (! (scriptFileURL = CFBundleCopyResourceURL(appBundle, fileName, NULL, if (!(scriptFileURL =
NULL))) CFBundleCopyResourceURL(appBundle, fileName, NULL, NULL))) {
{
DebugError("CFBundleCopyResourceURL failed"); DebugError("CFBundleCopyResourceURL failed");
return 1; return 1;
} }
// create path string // create path string
if (! (path = new UInt8[PATH_MAX])) if (!(path = new UInt8[PATH_MAX])) {
{
return 1; return 1;
} }
// get the file system path of the url as a cstring // get the file system path of the url as a cstring
// in an encoding suitable for posix apis // in an encoding suitable for posix apis
if ( CFURLGetFileSystemRepresentation(scriptFileURL, true, path, if (CFURLGetFileSystemRepresentation(scriptFileURL, true, path, PATH_MAX) ==
PATH_MAX) == false) false) {
{
DebugError("CFURLGetFileSystemRepresentation failed"); DebugError("CFURLGetFileSystemRepresentation failed");
return 1; return 1;
} }
@ -70,20 +66,17 @@ int main(int argc, char* argv[])
std::string fullScriptPath = reinterpret_cast<char*>(path); std::string fullScriptPath = reinterpret_cast<char*>(path);
delete[] path; delete[] path;
if (!cmsys::SystemTools::FileExists(fullScriptPath.c_str())) {
if (! cmsys::SystemTools::FileExists(fullScriptPath.c_str()))
{
return 1; return 1;
} }
std::string scriptDirectory = cmsys::SystemTools::GetFilenamePath( std::string scriptDirectory =
fullScriptPath); cmsys::SystemTools::GetFilenamePath(fullScriptPath);
ofs << fullScriptPath.c_str() << std::endl; ofs << fullScriptPath.c_str() << std::endl;
std::vector<const char*> args; std::vector<const char*> args;
args.push_back(fullScriptPath.c_str()); args.push_back(fullScriptPath.c_str());
int cc; int cc;
for ( cc = 1; cc < argc; ++ cc ) for (cc = 1; cc < argc; ++cc) {
{
args.push_back(argv[cc]); args.push_back(argv[cc]);
} }
args.push_back(0); args.push_back(0);
@ -98,15 +91,12 @@ int main(int argc, char* argv[])
std::vector<char> tempOutput; std::vector<char> tempOutput;
char* data; char* data;
int length; int length;
while(cmsysProcess_WaitForData(cp, &data, &length, 0)) while (cmsysProcess_WaitForData(cp, &data, &length, 0)) {
{
// Translate NULL characters in the output into valid text. // Translate NULL characters in the output into valid text.
// Visual Studio 7 puts these characters in the output of its // Visual Studio 7 puts these characters in the output of its
// build process. // build process.
for(int i=0; i < length; ++i) for (int i = 0; i < length; ++i) {
{ if (data[i] == '\0') {
if(data[i] == '\0')
{
data[i] = ' '; data[i] = ' ';
} }
} }
@ -116,27 +106,19 @@ int main(int argc, char* argv[])
cmsysProcess_WaitForExit(cp, 0); cmsysProcess_WaitForExit(cp, 0);
bool result = true; bool result = true;
if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) {
{ if (cmsysProcess_GetExitValue(cp) != 0) {
if ( cmsysProcess_GetExitValue(cp) != 0 )
{
result = false; result = false;
} }
} } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Exception) {
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception)
{
const char* exception_str = cmsysProcess_GetExceptionString(cp); const char* exception_str = cmsysProcess_GetExceptionString(cp);
std::cerr << exception_str << std::endl; std::cerr << exception_str << std::endl;
result = false; result = false;
} } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Error) {
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error)
{
const char* error_str = cmsysProcess_GetErrorString(cp); const char* error_str = cmsysProcess_GetErrorString(cp);
std::cerr << error_str << std::endl; std::cerr << error_str << std::endl;
result = false; result = false;
} } else if (cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) {
else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired)
{
const char* error_str = "Process terminated due to timeout\n"; const char* error_str = "Process terminated due to timeout\n";
std::cerr << error_str << std::endl; std::cerr << error_str << std::endl;
result = false; result = false;

File diff suppressed because it is too large Load Diff

View File

@ -42,25 +42,16 @@ protected:
virtual int PackageFiles(); virtual int PackageFiles();
virtual const char* GetOutputExtension() virtual const char* GetOutputExtension() { return ".msi"; }
{
return ".msi";
}
virtual enum CPackSetDestdirSupport SupportsSetDestdir() const virtual enum CPackSetDestdirSupport SupportsSetDestdir() const
{ {
return SETDESTDIR_UNSUPPORTED; return SETDESTDIR_UNSUPPORTED;
} }
virtual bool SupportsAbsoluteDestination() const virtual bool SupportsAbsoluteDestination() const { return false; }
{
return false;
}
virtual bool SupportsComponentInstallation() const virtual bool SupportsComponentInstallation() const { return true; }
{
return true;
}
private: private:
typedef std::map<std::string, std::string> id_map_t; typedef std::map<std::string, std::string> id_map_t;
@ -77,11 +68,10 @@ private:
void CreateWiXProductFragmentIncludeFile(); void CreateWiXProductFragmentIncludeFile();
void CopyDefinition( void CopyDefinition(cmWIXSourceWriter& source, std::string const& name);
cmWIXSourceWriter &source, std::string const& name);
void AddDefinition(cmWIXSourceWriter& source, void AddDefinition(cmWIXSourceWriter& source, std::string const& name,
std::string const& name, std::string const& value); std::string const& value);
bool CreateWiXSourceFiles(); bool CreateWiXSourceFiles();
@ -89,19 +79,15 @@ private:
bool GenerateMainSourceFileFromTemplate(); bool GenerateMainSourceFileFromTemplate();
bool CreateFeatureHierarchy( bool CreateFeatureHierarchy(cmWIXFeaturesSourceWriter& featureDefinitions);
cmWIXFeaturesSourceWriter& featureDefinitions);
bool AddComponentsToFeature( bool AddComponentsToFeature(
std::string const& rootPath, std::string const& rootPath, std::string const& featureId,
std::string const& featureId,
cmWIXDirectoriesSourceWriter& directoryDefinitions, cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions, cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions, cmWIXFeaturesSourceWriter& featureDefinitions, cmWIXShortcuts& shortcuts);
cmWIXShortcuts& shortcuts);
bool CreateShortcuts( bool CreateShortcuts(std::string const& cpackComponentName,
std::string const& cpackComponentName,
std::string const& featureId, std::string const& featureId,
cmWIXShortcuts const& shortcuts, cmWIXShortcuts const& shortcuts,
bool emitUninstallShortcut, bool emitUninstallShortcut,
@ -109,12 +95,9 @@ private:
cmWIXFeaturesSourceWriter& featureDefinitions); cmWIXFeaturesSourceWriter& featureDefinitions);
bool CreateShortcutsOfSpecificType( bool CreateShortcutsOfSpecificType(
cmWIXShortcuts::Type type, cmWIXShortcuts::Type type, std::string const& cpackComponentName,
std::string const& cpackComponentName, std::string const& featureId, std::string const& idPrefix,
std::string const& featureId, cmWIXShortcuts const& shortcuts, bool emitUninstallShortcut,
std::string const& idPrefix,
cmWIXShortcuts const& shortcuts,
bool emitUninstallShortcut,
cmWIXFilesSourceWriter& fileDefinitions, cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions); cmWIXFeaturesSourceWriter& featureDefinitions);
@ -126,13 +109,13 @@ private:
bool RunWiXCommand(std::string const& command); bool RunWiXCommand(std::string const& command);
bool RunCandleCommand( bool RunCandleCommand(std::string const& sourceFile,
std::string const& sourceFile, std::string const& objectFile); std::string const& objectFile);
bool RunLightCommand(std::string const& objectFiles); bool RunLightCommand(std::string const& objectFiles);
void AddDirectoryAndFileDefinitons(std::string const& topdir, void AddDirectoryAndFileDefinitons(
std::string const& directoryId, std::string const& topdir, std::string const& directoryId,
cmWIXDirectoriesSourceWriter& directoryDefinitions, cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions, cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions, cmWIXFeaturesSourceWriter& featureDefinitions,
@ -154,22 +137,20 @@ private:
std::string CreateNewIdForPath(std::string const& path); std::string CreateNewIdForPath(std::string const& path);
static std::string CreateHashedId( static std::string CreateHashedId(std::string const& path,
std::string const& path, std::string const& normalizedFilename); std::string const& normalizedFilename);
std::string NormalizeComponentForId( std::string NormalizeComponentForId(std::string const& component,
std::string const& component, size_t& replacementCount); size_t& replacementCount);
static bool IsLegalIdCharacter(char c); static bool IsLegalIdCharacter(char c);
void CollectExtensions( void CollectExtensions(std::string const& variableName,
std::string const& variableName, extension_set_t& extensions); extension_set_t& extensions);
void AddCustomFlags( void AddCustomFlags(std::string const& variableName, std::ostream& stream);
std::string const& variableName, std::ostream& stream);
std::string RelativePathWithoutComponentPrefix( std::string RelativePathWithoutComponentPrefix(std::string const& path);
std::string const& path);
std::vector<std::string> WixSources; std::vector<std::string> WixSources;
id_map_t PathToIdMap; id_map_t PathToIdMap;

View File

@ -17,14 +17,12 @@
#include <cmSystemTools.h> #include <cmSystemTools.h>
cmWIXAccessControlList::cmWIXAccessControlList( cmWIXAccessControlList::cmWIXAccessControlList(
cmCPackLog *logger, cmCPackLog* logger, cmInstalledFile const& installedFile,
cmInstalledFile const& installedFile, cmWIXSourceWriter& sourceWriter)
cmWIXSourceWriter &sourceWriter): : Logger(logger)
Logger(logger), , InstalledFile(installedFile)
InstalledFile(installedFile), , SourceWriter(sourceWriter)
SourceWriter(sourceWriter)
{ {
} }
bool cmWIXAccessControlList::Apply() bool cmWIXAccessControlList::Apply()
@ -32,20 +30,17 @@ bool cmWIXAccessControlList::Apply()
std::vector<std::string> entries; std::vector<std::string> entries;
this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries); this->InstalledFile.GetPropertyAsList("CPACK_WIX_ACL", entries);
for(size_t i = 0; i < entries.size(); ++i) for (size_t i = 0; i < entries.size(); ++i) {
{
this->CreatePermissionElement(entries[i]); this->CreatePermissionElement(entries[i]);
} }
return true; return true;
} }
void cmWIXAccessControlList::CreatePermissionElement( void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry)
std::string const& entry)
{ {
std::string::size_type pos = entry.find('='); std::string::size_type pos = entry.find('=');
if(pos == std::string::npos) if (pos == std::string::npos) {
{
this->ReportError(entry, "Did not find mandatory '='"); this->ReportError(entry, "Did not find mandatory '='");
return; return;
} }
@ -56,13 +51,10 @@ void cmWIXAccessControlList::CreatePermissionElement(
pos = user_and_domain.find('@'); pos = user_and_domain.find('@');
std::string user; std::string user;
std::string domain; std::string domain;
if(pos != std::string::npos) if (pos != std::string::npos) {
{
user = user_and_domain.substr(0, pos); user = user_and_domain.substr(0, pos);
domain = user_and_domain.substr(pos + 1); domain = user_and_domain.substr(pos + 1);
} } else {
else
{
user = user_and_domain; user = user_and_domain;
} }
@ -71,31 +63,26 @@ void cmWIXAccessControlList::CreatePermissionElement(
this->SourceWriter.BeginElement("Permission"); this->SourceWriter.BeginElement("Permission");
this->SourceWriter.AddAttribute("User", user); this->SourceWriter.AddAttribute("User", user);
if(!domain.empty()) if (!domain.empty()) {
{
this->SourceWriter.AddAttribute("Domain", domain); this->SourceWriter.AddAttribute("Domain", domain);
} }
for(size_t i = 0; i < permissions.size(); ++i) for (size_t i = 0; i < permissions.size(); ++i) {
{
this->EmitBooleanAttribute(entry, this->EmitBooleanAttribute(entry,
cmSystemTools::TrimWhitespace(permissions[i])); cmSystemTools::TrimWhitespace(permissions[i]));
} }
this->SourceWriter.EndElement("Permission"); this->SourceWriter.EndElement("Permission");
} }
void cmWIXAccessControlList::ReportError( void cmWIXAccessControlList::ReportError(std::string const& entry,
std::string const& entry,
std::string const& message) std::string const& message)
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed processing ACL entry '"
"Failed processing ACL entry '" << entry << << entry << "': " << message << std::endl);
"': " << message << std::endl);
} }
bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name) bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
{ {
static const char* validAttributes[] = static const char* validAttributes[] = {
{
/* clang-format needs this comment to break after the opening brace */ /* clang-format needs this comment to break after the opening brace */
"Append", "Append",
"ChangePermission", "ChangePermission",
@ -128,19 +115,18 @@ bool cmWIXAccessControlList::IsBooleanAttribute(std::string const& name)
}; };
size_t i = 0; size_t i = 0;
while(validAttributes[i]) while (validAttributes[i]) {
{ if (name == validAttributes[i++])
if(name == validAttributes[i++]) return true; return true;
} }
return false; return false;
} }
void cmWIXAccessControlList::EmitBooleanAttribute( void cmWIXAccessControlList::EmitBooleanAttribute(std::string const& entry,
std::string const& entry, std::string const& name) std::string const& name)
{
if(!this->IsBooleanAttribute(name))
{ {
if (!this->IsBooleanAttribute(name)) {
std::stringstream message; std::stringstream message;
message << "Unknown boolean attribute '" << name << "'"; message << "Unknown boolean attribute '" << name << "'";
this->ReportError(entry, message.str()); this->ReportError(entry, message.str());

View File

@ -21,8 +21,7 @@
class cmWIXAccessControlList class cmWIXAccessControlList
{ {
public: public:
cmWIXAccessControlList( cmWIXAccessControlList(cmCPackLog* logger,
cmCPackLog *logger,
cmInstalledFile const& installedFile, cmInstalledFile const& installedFile,
cmWIXSourceWriter& sourceWriter); cmWIXSourceWriter& sourceWriter);
@ -35,8 +34,7 @@ private:
bool IsBooleanAttribute(std::string const& name); bool IsBooleanAttribute(std::string const& name);
void EmitBooleanAttribute( void EmitBooleanAttribute(std::string const& entry, std::string const& name);
std::string const& entry, std::string const& name);
cmCPackLog* Logger; cmCPackLog* Logger;
cmInstalledFile const& InstalledFile; cmInstalledFile const& InstalledFile;

View File

@ -12,11 +12,10 @@
#include "cmWIXDirectoriesSourceWriter.h" #include "cmWIXDirectoriesSourceWriter.h"
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger, cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
std::string const& filename): cmCPackLog* logger, std::string const& filename)
cmWIXSourceWriter(logger, filename) : cmWIXSourceWriter(logger, filename)
{ {
} }
void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder( void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
@ -60,21 +59,16 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
cmSystemTools::SplitPath(installRootString.c_str(), installRoot); cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
if(!installRoot.empty() && installRoot.back().empty()) if (!installRoot.empty() && installRoot.back().empty()) {
{
installRoot.pop_back(); installRoot.pop_back();
} }
for(size_t i = 1; i < installRoot.size(); ++i) for (size_t i = 1; i < installRoot.size(); ++i) {
{
BeginElement("Directory"); BeginElement("Directory");
if(i == installRoot.size() - 1) if (i == installRoot.size() - 1) {
{
AddAttribute("Id", "INSTALL_ROOT"); AddAttribute("Id", "INSTALL_ROOT");
} } else {
else
{
std::stringstream tmp; std::stringstream tmp;
tmp << "INSTALL_PREFIX_" << i; tmp << "INSTALL_PREFIX_" << i;
AddAttribute("Id", tmp.str()); AddAttribute("Id", tmp.str());
@ -88,8 +82,7 @@ size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size) void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
{ {
for(size_t i = 0; i < size; ++i) for (size_t i = 0; i < size; ++i) {
{
EndElement("Directory"); EndElement("Directory");
} }
} }

View File

@ -12,16 +12,14 @@
#include "cmWIXFeaturesSourceWriter.h" #include "cmWIXFeaturesSourceWriter.h"
cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger, cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(
std::string const& filename): cmCPackLog* logger, std::string const& filename)
cmWIXSourceWriter(logger, filename) : cmWIXSourceWriter(logger, filename)
{ {
} }
void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry( void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
std::string const& package, std::string const& package, std::string const& upgradeGuid)
std::string const& upgradeGuid)
{ {
BeginElement("Component"); BeginElement("Component");
AddAttribute("Id", "CM_PACKAGE_REGISTRY"); AddAttribute("Id", "CM_PACKAGE_REGISTRY");
@ -49,23 +47,22 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
BeginElement("Feature"); BeginElement("Feature");
AddAttribute("Id", "CM_G_" + group.Name); AddAttribute("Id", "CM_G_" + group.Name);
if(group.IsExpandedByDefault) if (group.IsExpandedByDefault) {
{
AddAttribute("Display", "expand"); AddAttribute("Display", "expand");
} }
AddAttributeUnlessEmpty("Title", group.DisplayName); AddAttributeUnlessEmpty("Title", group.DisplayName);
AddAttributeUnlessEmpty("Description", group.Description); AddAttributeUnlessEmpty("Description", group.Description);
for(std::vector<cmCPackComponentGroup*>::const_iterator for (std::vector<cmCPackComponentGroup*>::const_iterator i =
i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i) group.Subgroups.begin();
{ i != group.Subgroups.end(); ++i) {
EmitFeatureForComponentGroup(**i); EmitFeatureForComponentGroup(**i);
} }
for(std::vector<cmCPackComponent*>::const_iterator for (std::vector<cmCPackComponent*>::const_iterator i =
i = group.Components.begin(); i != group.Components.end(); ++i) group.Components.begin();
{ i != group.Components.end(); ++i) {
EmitFeatureForComponent(**i); EmitFeatureForComponent(**i);
} }
@ -81,13 +78,11 @@ void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
AddAttributeUnlessEmpty("Title", component.DisplayName); AddAttributeUnlessEmpty("Title", component.DisplayName);
AddAttributeUnlessEmpty("Description", component.Description); AddAttributeUnlessEmpty("Description", component.Description);
if(component.IsRequired) if (component.IsRequired) {
{
AddAttribute("Absent", "disallow"); AddAttribute("Absent", "disallow");
} }
if(component.IsHidden) if (component.IsHidden) {
{
AddAttribute("Display", "hidden"); AddAttribute("Display", "hidden");
} }

View File

@ -23,11 +23,9 @@
class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter
{ {
public: public:
cmWIXFeaturesSourceWriter(cmCPackLog* logger, cmWIXFeaturesSourceWriter(cmCPackLog* logger, std::string const& filename);
std::string const& filename);
void CreateCMakePackageRegistryEntry( void CreateCMakePackageRegistryEntry(std::string const& package,
std::string const& package,
std::string const& upgradeGuid); std::string const& upgradeGuid);
void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group); void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group);

View File

@ -21,14 +21,12 @@
#include <sys/stat.h> #include <sys/stat.h>
cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger, cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
std::string const& filename): std::string const& filename)
cmWIXSourceWriter(logger, filename) : cmWIXSourceWriter(logger, filename)
{ {
} }
void cmWIXFilesSourceWriter::EmitShortcut( void cmWIXFilesSourceWriter::EmitShortcut(std::string const& id,
std::string const& id,
cmWIXShortcut const& shortcut, cmWIXShortcut const& shortcut,
std::string const& shortcutPrefix, std::string const& shortcutPrefix,
size_t shortcutIndex) size_t shortcutIndex)
@ -36,8 +34,7 @@ void cmWIXFilesSourceWriter::EmitShortcut(
std::stringstream shortcutId; std::stringstream shortcutId;
shortcutId << shortcutPrefix << id; shortcutId << shortcutPrefix << id;
if(shortcutIndex > 0) if (shortcutIndex > 0) {
{
shortcutId << "_" << shortcutIndex; shortcutId << "_" << shortcutIndex;
} }
@ -61,13 +58,11 @@ void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id)
} }
void cmWIXFilesSourceWriter::EmitInstallRegistryValue( void cmWIXFilesSourceWriter::EmitInstallRegistryValue(
std::string const& registryKey, std::string const& registryKey, std::string const& cpackComponentName,
std::string const& cpackComponentName,
std::string const& suffix) std::string const& suffix)
{ {
std::string valueName; std::string valueName;
if(!cpackComponentName.empty()) if (!cpackComponentName.empty()) {
{
valueName = cpackComponentName + "_"; valueName = cpackComponentName + "_";
} }
@ -97,12 +92,10 @@ void cmWIXFilesSourceWriter::EmitUninstallShortcut(
} }
std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder( std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
std::string const& directoryId, std::string const& directoryId, std::string const& guid,
std::string const& guid,
cmInstalledFile const* installedFile) cmInstalledFile const* installedFile)
{ {
std::string componentId = std::string componentId = std::string("CM_C_EMPTY_") + directoryId;
std::string("CM_C_EMPTY_") + directoryId;
BeginElement("DirectoryRef"); BeginElement("DirectoryRef");
AddAttribute("Id", directoryId); AddAttribute("Id", directoryId);
@ -113,8 +106,7 @@ std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
BeginElement("CreateFolder"); BeginElement("CreateFolder");
if(installedFile) if (installedFile) {
{
cmWIXAccessControlList acl(Logger, *installedFile, *this); cmWIXAccessControlList acl(Logger, *installedFile, *this);
acl.Apply(); acl.Apply();
} }
@ -127,10 +119,8 @@ std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
} }
std::string cmWIXFilesSourceWriter::EmitComponentFile( std::string cmWIXFilesSourceWriter::EmitComponentFile(
std::string const& directoryId, std::string const& directoryId, std::string const& id,
std::string const& id, std::string const& filePath, cmWIXPatch& patch,
std::string const& filePath,
cmWIXPatch &patch,
cmInstalledFile const* installedFile) cmInstalledFile const* installedFile)
{ {
std::string componentId = std::string("CM_C") + id; std::string componentId = std::string("CM_C") + id;
@ -143,14 +133,11 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
AddAttribute("Id", componentId); AddAttribute("Id", componentId);
AddAttribute("Guid", "*"); AddAttribute("Guid", "*");
if(installedFile) if (installedFile) {
{ if (installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE")) {
if(installedFile->GetPropertyAsBool("CPACK_NEVER_OVERWRITE"))
{
AddAttribute("NeverOverwrite", "yes"); AddAttribute("NeverOverwrite", "yes");
} }
if(installedFile->GetPropertyAsBool("CPACK_PERMANENT")) if (installedFile->GetPropertyAsBool("CPACK_PERMANENT")) {
{
AddAttribute("Permanent", "yes"); AddAttribute("Permanent", "yes");
} }
} }
@ -163,13 +150,11 @@ std::string cmWIXFilesSourceWriter::EmitComponentFile(
mode_t fileMode = 0; mode_t fileMode = 0;
cmSystemTools::GetPermissions(filePath.c_str(), fileMode); cmSystemTools::GetPermissions(filePath.c_str(), fileMode);
if(!(fileMode & S_IWRITE)) if (!(fileMode & S_IWRITE)) {
{
AddAttribute("ReadOnly", "yes"); AddAttribute("ReadOnly", "yes");
} }
if(installedFile) if (installedFile) {
{
cmWIXAccessControlList acl(Logger, *installedFile, *this); cmWIXAccessControlList acl(Logger, *installedFile, *this);
acl.Apply(); acl.Apply();
} }

View File

@ -26,36 +26,27 @@
class cmWIXFilesSourceWriter : public cmWIXSourceWriter class cmWIXFilesSourceWriter : public cmWIXSourceWriter
{ {
public: public:
cmWIXFilesSourceWriter(cmCPackLog* logger, cmWIXFilesSourceWriter(cmCPackLog* logger, std::string const& filename);
std::string const& filename);
void EmitShortcut( void EmitShortcut(std::string const& id, cmWIXShortcut const& shortcut,
std::string const& id, std::string const& shortcutPrefix, size_t shortcutIndex);
cmWIXShortcut const& shortcut,
std::string const& shortcutPrefix,
size_t shortcutIndex);
void EmitRemoveFolder(std::string const& id); void EmitRemoveFolder(std::string const& id);
void EmitInstallRegistryValue( void EmitInstallRegistryValue(std::string const& registryKey,
std::string const& registryKey,
std::string const& cpackComponentName, std::string const& cpackComponentName,
std::string const& suffix); std::string const& suffix);
void EmitUninstallShortcut(std::string const& packageName); void EmitUninstallShortcut(std::string const& packageName);
std::string EmitComponentCreateFolder( std::string EmitComponentCreateFolder(std::string const& directoryId,
std::string const& directoryId,
std::string const& guid, std::string const& guid,
cmInstalledFile const* installedFile); cmInstalledFile const* installedFile);
std::string EmitComponentFile( std::string EmitComponentFile(std::string const& directoryId,
std::string const& directoryId,
std::string const& id, std::string const& id,
std::string const& filePath, std::string const& filePath, cmWIXPatch& patch,
cmWIXPatch &patch,
cmInstalledFile const* installedFile); cmInstalledFile const* installedFile);
}; };
#endif #endif

View File

@ -14,31 +14,29 @@
#include <CPack/cmCPackGenerator.h> #include <CPack/cmCPackGenerator.h>
cmWIXPatch::cmWIXPatch(cmCPackLog* logger): cmWIXPatch::cmWIXPatch(cmCPackLog* logger)
Logger(logger) : Logger(logger)
{ {
} }
bool cmWIXPatch::LoadFragments(std::string const& patchFilePath) bool cmWIXPatch::LoadFragments(std::string const& patchFilePath)
{ {
cmWIXPatchParser parser(Fragments, Logger); cmWIXPatchParser parser(Fragments, Logger);
if(!parser.ParseFile(patchFilePath.c_str())) if (!parser.ParseFile(patchFilePath.c_str())) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Failed parsing XML patch file: '"
cmCPackLogger(cmCPackLog::LOG_ERROR, << patchFilePath << "'" << std::endl);
"Failed parsing XML patch file: '" <<
patchFilePath << "'" << std::endl);
return false; return false;
} }
return true; return true;
} }
void cmWIXPatch::ApplyFragment( void cmWIXPatch::ApplyFragment(std::string const& id,
std::string const& id, cmWIXSourceWriter& writer) cmWIXSourceWriter& writer)
{ {
cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id); cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
if(i == Fragments.end()) return; if (i == Fragments.end())
return;
const cmWIXPatchElement& fragment = i->second; const cmWIXPatchElement& fragment = i->second;
@ -47,16 +45,15 @@ void cmWIXPatch::ApplyFragment(
Fragments.erase(i); Fragments.erase(i);
} }
void cmWIXPatch::ApplyElementChildren( void cmWIXPatch::ApplyElementChildren(const cmWIXPatchElement& element,
const cmWIXPatchElement& element, cmWIXSourceWriter& writer) cmWIXSourceWriter& writer)
{
for(cmWIXPatchElement::child_list_t::const_iterator
j = element.children.begin(); j != element.children.end(); ++j)
{ {
for (cmWIXPatchElement::child_list_t::const_iterator j =
element.children.begin();
j != element.children.end(); ++j) {
cmWIXPatchNode* node = *j; cmWIXPatchNode* node = *j;
switch(node->type()) switch (node->type()) {
{
case cmWIXPatchNode::ELEMENT: case cmWIXPatchNode::ELEMENT:
ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer); ApplyElement(dynamic_cast<const cmWIXPatchElement&>(*node), writer);
break; break;
@ -67,14 +64,14 @@ void cmWIXPatch::ApplyElementChildren(
} }
} }
void cmWIXPatch::ApplyElement( void cmWIXPatch::ApplyElement(const cmWIXPatchElement& element,
const cmWIXPatchElement& element, cmWIXSourceWriter& writer) cmWIXSourceWriter& writer)
{ {
writer.BeginElement(element.name); writer.BeginElement(element.name);
for(cmWIXPatchElement::attributes_t::const_iterator for (cmWIXPatchElement::attributes_t::const_iterator i =
i = element.attributes.begin(); i != element.attributes.end(); ++i) element.attributes.begin();
{ i != element.attributes.end(); ++i) {
writer.AddAttribute(i->first, i->second); writer.AddAttribute(i->first, i->second);
} }
@ -86,11 +83,9 @@ void cmWIXPatch::ApplyElement(
bool cmWIXPatch::CheckForUnappliedFragments() bool cmWIXPatch::CheckForUnappliedFragments()
{ {
std::string fragmentList; std::string fragmentList;
for(cmWIXPatchParser::fragment_map_t::const_iterator for (cmWIXPatchParser::fragment_map_t::const_iterator i = Fragments.begin();
i = Fragments.begin(); i != Fragments.end(); ++i) i != Fragments.end(); ++i) {
{ if (!fragmentList.empty()) {
if(!fragmentList.empty())
{
fragmentList += ", "; fragmentList += ", ";
} }
@ -99,11 +94,10 @@ bool cmWIXPatch::CheckForUnappliedFragments()
fragmentList += "'"; fragmentList += "'";
} }
if(!fragmentList.empty()) if (!fragmentList.empty()) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Some XML patch fragments did not have matching IDs: " << "Some XML patch fragments did not have matching IDs: "
fragmentList << std::endl); << fragmentList << std::endl);
return false; return false;
} }

View File

@ -44,5 +44,4 @@ private:
cmWIXPatchParser::fragment_map_t Fragments; cmWIXPatchParser::fragment_map_t Fragments;
}; };
#endif #endif

View File

@ -28,54 +28,40 @@ cmWIXPatchNode::Type cmWIXPatchElement::type()
cmWIXPatchNode::~cmWIXPatchNode() cmWIXPatchNode::~cmWIXPatchNode()
{ {
} }
cmWIXPatchElement::~cmWIXPatchElement() cmWIXPatchElement::~cmWIXPatchElement()
{ {
for(child_list_t::iterator i = children.begin(); i != children.end(); ++i) for (child_list_t::iterator i = children.begin(); i != children.end(); ++i) {
{
delete *i; delete *i;
} }
} }
cmWIXPatchParser::cmWIXPatchParser( cmWIXPatchParser::cmWIXPatchParser(fragment_map_t& fragments,
fragment_map_t& fragments, cmCPackLog* logger): cmCPackLog* logger)
Logger(logger), : Logger(logger)
State(BEGIN_DOCUMENT), , State(BEGIN_DOCUMENT)
Valid(true), , Valid(true)
Fragments(fragments) , Fragments(fragments)
{ {
} }
void cmWIXPatchParser::StartElement(const std::string& name, const char** atts) void cmWIXPatchParser::StartElement(const std::string& name, const char** atts)
{ {
if(State == BEGIN_DOCUMENT) if (State == BEGIN_DOCUMENT) {
{ if (name == "CPackWiXPatch") {
if(name == "CPackWiXPatch")
{
State = BEGIN_FRAGMENTS; State = BEGIN_FRAGMENTS;
} } else {
else
{
ReportValidationError("Expected root element 'CPackWiXPatch'"); ReportValidationError("Expected root element 'CPackWiXPatch'");
} }
} } else if (State == BEGIN_FRAGMENTS) {
else if(State == BEGIN_FRAGMENTS) if (name == "CPackWiXFragment") {
{
if(name == "CPackWiXFragment")
{
State = INSIDE_FRAGMENT; State = INSIDE_FRAGMENT;
StartFragment(atts); StartFragment(atts);
} } else {
else
{
ReportValidationError("Expected 'CPackWixFragment' element"); ReportValidationError("Expected 'CPackWixFragment' element");
} }
} } else if (State == INSIDE_FRAGMENT) {
else if(State == INSIDE_FRAGMENT)
{
cmWIXPatchElement& parent = *ElementStack.back(); cmWIXPatchElement& parent = *ElementStack.back();
cmWIXPatchElement* element = new cmWIXPatchElement; cmWIXPatchElement* element = new cmWIXPatchElement;
@ -83,8 +69,7 @@ void cmWIXPatchParser::StartElement(const std::string& name, const char **atts)
element->name = name; element->name = name;
for(size_t i = 0; atts[i]; i += 2) for (size_t i = 0; atts[i]; i += 2) {
{
std::string key = atts[i]; std::string key = atts[i];
std::string value = atts[i + 1]; std::string value = atts[i + 1];
@ -97,24 +82,19 @@ void cmWIXPatchParser::StartElement(const std::string& name, const char **atts)
void cmWIXPatchParser::StartFragment(const char** attributes) void cmWIXPatchParser::StartFragment(const char** attributes)
{ {
for(size_t i = 0; attributes[i]; i += 2) for (size_t i = 0; attributes[i]; i += 2) {
{
std::string key = attributes[i]; std::string key = attributes[i];
std::string value = attributes[i + 1]; std::string value = attributes[i + 1];
if(key == "Id") if (key == "Id") {
{ if (Fragments.find(value) != Fragments.end()) {
if(Fragments.find(value) != Fragments.end())
{
std::stringstream tmp; std::stringstream tmp;
tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value; tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
ReportValidationError(tmp.str()); ReportValidationError(tmp.str());
} }
ElementStack.push_back(&Fragments[value]); ElementStack.push_back(&Fragments[value]);
} } else {
else
{
ReportValidationError( ReportValidationError(
"The only allowed 'CPackWixFragment' attribute is 'Id'"); "The only allowed 'CPackWixFragment' attribute is 'Id'");
} }
@ -123,15 +103,11 @@ void cmWIXPatchParser::StartFragment(const char **attributes)
void cmWIXPatchParser::EndElement(const std::string& name) void cmWIXPatchParser::EndElement(const std::string& name)
{ {
if(State == INSIDE_FRAGMENT) if (State == INSIDE_FRAGMENT) {
{ if (name == "CPackWiXFragment") {
if(name == "CPackWiXFragment")
{
State = BEGIN_FRAGMENTS; State = BEGIN_FRAGMENTS;
ElementStack.clear(); ElementStack.clear();
} } else {
else
{
ElementStack.pop_back(); ElementStack.pop_back();
} }
} }
@ -141,8 +117,7 @@ void cmWIXPatchParser::CharacterDataHandler(const char* data, int length)
{ {
const char* whitespace = "\x20\x09\x0d\x0a"; const char* whitespace = "\x20\x09\x0d\x0a";
if(State == INSIDE_FRAGMENT) if (State == INSIDE_FRAGMENT) {
{
cmWIXPatchElement& parent = *ElementStack.back(); cmWIXPatchElement& parent = *ElementStack.back();
std::string text(data, length); std::string text(data, length);
@ -150,8 +125,7 @@ void cmWIXPatchParser::CharacterDataHandler(const char* data, int length)
std::string::size_type first = text.find_first_not_of(whitespace); std::string::size_type first = text.find_first_not_of(whitespace);
std::string::size_type last = text.find_last_not_of(whitespace); std::string::size_type last = text.find_last_not_of(whitespace);
if(first != std::string::npos && last != std::string::npos) if (first != std::string::npos && last != std::string::npos) {
{
cmWIXPatchText* text_node = new cmWIXPatchText; cmWIXPatchText* text_node = new cmWIXPatchText;
text_node->text = text.substr(first, last - first + 1); text_node->text = text.substr(first, last - first + 1);
@ -163,14 +137,15 @@ void cmWIXPatchParser::CharacterDataHandler(const char* data, int length)
void cmWIXPatchParser::ReportError(int line, int column, const char* msg) void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while processing XML patch file at " << line << ":" << column << "Error while processing XML patch file at "
": "<< msg << std::endl); << line << ":" << column << ": " << msg << std::endl);
Valid = false; Valid = false;
} }
void cmWIXPatchParser::ReportValidationError(std::string const& message) void cmWIXPatchParser::ReportValidationError(std::string const& message)
{ {
ReportError(XML_GetCurrentLineNumber(static_cast<XML_Parser>(this->Parser)), ReportError(
XML_GetCurrentLineNumber(static_cast<XML_Parser>(this->Parser)),
XML_GetCurrentColumnNumber(static_cast<XML_Parser>(this->Parser)), XML_GetCurrentColumnNumber(static_cast<XML_Parser>(this->Parser)),
message.c_str()); message.c_str());
} }

View File

@ -15,8 +15,8 @@
#include <cmVersion.h> #include <cmVersion.h>
cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter( cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
std::string const& filename): std::string const& filename)
File(filename.c_str(), std::ios::binary) : File(filename.c_str(), std::ios::binary)
{ {
StartGroup(); StartGroup();
WriteHeader(); WriteHeader();
@ -37,12 +37,10 @@ void cmWIXRichTextFormatWriter::AddText(std::string const& text)
{ {
typedef unsigned char rtf_byte_t; typedef unsigned char rtf_byte_t;
for(size_t i = 0; i < text.size(); ++i) for (size_t i = 0; i < text.size(); ++i) {
{
rtf_byte_t c = rtf_byte_t(text[i]); rtf_byte_t c = rtf_byte_t(text[i]);
switch(c) switch (c) {
{
case '\\': case '\\':
File << "\\\\"; File << "\\\\";
break; break;
@ -57,52 +55,30 @@ void cmWIXRichTextFormatWriter::AddText(std::string const& text)
break; break;
case '\r': case '\r':
continue; continue;
default: default: {
{ if (c <= 0x7F) {
if(c <= 0x7F)
{
File << c; File << c;
} } else {
else if (c <= 0xC0) {
{
if(c <= 0xC0)
{
EmitInvalidCodepoint(c); EmitInvalidCodepoint(c);
} } else if (c < 0xE0 && i + 1 < text.size()) {
else if(c < 0xE0 && i+1 < text.size()) EmitUnicodeCodepoint((text[i + 1] & 0x3F) | ((c & 0x1F) << 6));
{
EmitUnicodeCodepoint(
(text[i+1] & 0x3F) |
((c & 0x1F) << 6)
);
i += 1; i += 1;
} } else if (c < 0xF0 && i + 2 < text.size()) {
else if(c < 0xF0 && i+2 < text.size()) EmitUnicodeCodepoint((text[i + 2] & 0x3F) |
{
EmitUnicodeCodepoint(
(text[i+2] & 0x3F) |
((text[i + 1] & 0x3F) << 6) | ((text[i + 1] & 0x3F) << 6) |
((c & 0xF) << 12) ((c & 0xF) << 12));
);
i += 2; i += 2;
} } else if (c < 0xF8 && i + 3 < text.size()) {
else if(c < 0xF8 && i+3 < text.size())
{
EmitUnicodeCodepoint( EmitUnicodeCodepoint(
(text[i+3] & 0x3F) | (text[i + 3] & 0x3F) | ((text[i + 2] & 0x3F) << 6) |
((text[i+2] & 0x3F) << 6) | ((text[i + 1] & 0x3F) << 12) | ((c & 0x7) << 18));
((text[i+1] & 0x3F) << 12) |
((c & 0x7) << 18)
);
i += 3; i += 3;
} } else {
else
{
EmitInvalidCodepoint(c); EmitInvalidCodepoint(c);
} }
} }
} } break;
break;
} }
} }
} }
@ -190,16 +166,11 @@ void cmWIXRichTextFormatWriter::EndGroup()
void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c) void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c)
{ {
// Do not emit byte order mark (BOM) // Do not emit byte order mark (BOM)
if(c == 0xFEFF) if (c == 0xFEFF) {
{
return; return;
} } else if (c <= 0xFFFF) {
else if(c <= 0xFFFF)
{
EmitUnicodeSurrogate(c); EmitUnicodeSurrogate(c);
} } else {
else
{
c -= 0x10000; c -= 0x10000;
EmitUnicodeSurrogate(((c >> 10) & 0x3FF) + 0xD800); EmitUnicodeSurrogate(((c >> 10) & 0x3FF) + 0xD800);
EmitUnicodeSurrogate((c & 0x3FF) + 0xDC00); EmitUnicodeSurrogate((c & 0x3FF) + 0xDC00);
@ -209,12 +180,9 @@ void cmWIXRichTextFormatWriter::EmitUnicodeCodepoint(int c)
void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c) void cmWIXRichTextFormatWriter::EmitUnicodeSurrogate(int c)
{ {
ControlWord("u"); ControlWord("u");
if(c <= 32767) if (c <= 32767) {
{
File << c; File << c;
} } else {
else
{
File << (c - 65536); File << (c - 65536);
} }
File << "?"; File << "?";

View File

@ -14,8 +14,8 @@
#include "cmWIXFilesSourceWriter.h" #include "cmWIXFilesSourceWriter.h"
void cmWIXShortcuts::insert( void cmWIXShortcuts::insert(Type type, std::string const& id,
Type type, std::string const& id, cmWIXShortcut const& shortcut) cmWIXShortcut const& shortcut)
{ {
this->Shortcuts[type][id].push_back(shortcut); this->Shortcuts[type][id].push_back(shortcut);
} }
@ -26,15 +26,13 @@ bool cmWIXShortcuts::empty(Type type) const
} }
bool cmWIXShortcuts::EmitShortcuts( bool cmWIXShortcuts::EmitShortcuts(
Type type, Type type, std::string const& registryKey,
std::string const& registryKey,
std::string const& cpackComponentName, std::string const& cpackComponentName,
cmWIXFilesSourceWriter& fileDefinitions) const cmWIXFilesSourceWriter& fileDefinitions) const
{ {
shortcut_type_map_t::const_iterator i = this->Shortcuts.find(type); shortcut_type_map_t::const_iterator i = this->Shortcuts.find(type);
if(i == this->Shortcuts.end()) if (i == this->Shortcuts.end()) {
{
return false; return false;
} }
@ -43,8 +41,7 @@ bool cmWIXShortcuts::EmitShortcuts(
std::string shortcutPrefix; std::string shortcutPrefix;
std::string registrySuffix; std::string registrySuffix;
switch(type) switch (type) {
{
case START_MENU: case START_MENU:
shortcutPrefix = "CM_S"; shortcutPrefix = "CM_S";
break; break;
@ -60,23 +57,21 @@ bool cmWIXShortcuts::EmitShortcuts(
return false; return false;
} }
for(shortcut_id_map_t::const_iterator j = id_map.begin(); for (shortcut_id_map_t::const_iterator j = id_map.begin(); j != id_map.end();
j != id_map.end(); ++j) ++j) {
{
std::string const& id = j->first; std::string const& id = j->first;
shortcut_list_t const& shortcutList = j->second; shortcut_list_t const& shortcutList = j->second;
for(size_t shortcutListIndex = 0; for (size_t shortcutListIndex = 0; shortcutListIndex < shortcutList.size();
shortcutListIndex < shortcutList.size(); ++shortcutListIndex) ++shortcutListIndex) {
{
cmWIXShortcut const& shortcut = shortcutList[shortcutListIndex]; cmWIXShortcut const& shortcut = shortcutList[shortcutListIndex];
fileDefinitions.EmitShortcut(id, shortcut, fileDefinitions.EmitShortcut(id, shortcut, shortcutPrefix,
shortcutPrefix, shortcutListIndex); shortcutListIndex);
} }
} }
fileDefinitions.EmitInstallRegistryValue( fileDefinitions.EmitInstallRegistryValue(registryKey, cpackComponentName,
registryKey, cpackComponentName, registrySuffix); registrySuffix);
return true; return true;
} }
@ -84,39 +79,34 @@ bool cmWIXShortcuts::EmitShortcuts(
void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types) void cmWIXShortcuts::AddShortcutTypes(std::set<Type>& types)
{ {
for (shortcut_type_map_t::const_iterator i = this->Shortcuts.begin(); for (shortcut_type_map_t::const_iterator i = this->Shortcuts.begin();
i != this->Shortcuts.end(); ++i) i != this->Shortcuts.end(); ++i) {
{
types.insert(i->first); types.insert(i->first);
} }
} }
void cmWIXShortcuts::CreateFromProperties( void cmWIXShortcuts::CreateFromProperties(std::string const& id,
std::string const& id,
std::string const& directoryId, std::string const& directoryId,
cmInstalledFile const& installedFile) cmInstalledFile const& installedFile)
{ {
CreateFromProperty("CPACK_START_MENU_SHORTCUTS", CreateFromProperty("CPACK_START_MENU_SHORTCUTS", START_MENU, id, directoryId,
START_MENU, id, directoryId, installedFile); installedFile);
CreateFromProperty("CPACK_DESKTOP_SHORTCUTS", CreateFromProperty("CPACK_DESKTOP_SHORTCUTS", DESKTOP, id, directoryId,
DESKTOP, id, directoryId, installedFile); installedFile);
CreateFromProperty("CPACK_STARTUP_SHORTCUTS", CreateFromProperty("CPACK_STARTUP_SHORTCUTS", STARTUP, id, directoryId,
STARTUP, id, directoryId, installedFile); installedFile);
} }
void cmWIXShortcuts::CreateFromProperty( void cmWIXShortcuts::CreateFromProperty(std::string const& propertyName,
std::string const& propertyName, Type type, std::string const& id,
Type type,
std::string const& id,
std::string const& directoryId, std::string const& directoryId,
cmInstalledFile const& installedFile) cmInstalledFile const& installedFile)
{ {
std::vector<std::string> list; std::vector<std::string> list;
installedFile.GetPropertyAsList(propertyName, list); installedFile.GetPropertyAsList(propertyName, list);
for(size_t i = 0; i < list.size(); ++i) for (size_t i = 0; i < list.size(); ++i) {
{
cmWIXShortcut shortcut; cmWIXShortcut shortcut;
shortcut.label = list[i]; shortcut.label = list[i];
shortcut.workingDirectoryId = directoryId; shortcut.workingDirectoryId = directoryId;

View File

@ -45,23 +45,20 @@ public:
bool empty(Type type) const; bool empty(Type type) const;
bool EmitShortcuts( bool EmitShortcuts(Type type, std::string const& registryKey,
Type type,
std::string const& registryKey,
std::string const& cpackComponentName, std::string const& cpackComponentName,
cmWIXFilesSourceWriter& fileDefinitions) const; cmWIXFilesSourceWriter& fileDefinitions) const;
void AddShortcutTypes(std::set<Type>& types); void AddShortcutTypes(std::set<Type>& types);
void CreateFromProperties(std::string const& id, void CreateFromProperties(std::string const& id,
std::string const& directoryId, cmInstalledFile const& installedFile); std::string const& directoryId,
cmInstalledFile const& installedFile);
private: private:
typedef std::map<Type, shortcut_id_map_t> shortcut_type_map_t; typedef std::map<Type, shortcut_id_map_t> shortcut_type_map_t;
void CreateFromProperty( void CreateFromProperty(std::string const& propertyName, Type type,
std::string const& propertyName,
Type type,
std::string const& id, std::string const& id,
std::string const& directoryId, std::string const& directoryId,
cmInstalledFile const& installedFile); cmInstalledFile const& installedFile);

View File

@ -18,20 +18,17 @@
cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger, cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
std::string const& filename, std::string const& filename,
bool isIncludeFile): bool isIncludeFile)
Logger(logger), : Logger(logger)
File(filename.c_str()), , File(filename.c_str())
State(DEFAULT), , State(DEFAULT)
SourceFilename(filename) , SourceFilename(filename)
{ {
WriteXMLDeclaration(); WriteXMLDeclaration();
if(isIncludeFile) if (isIncludeFile) {
{
BeginElement("Include"); BeginElement("Include");
} } else {
else
{
BeginElement("Wix"); BeginElement("Wix");
} }
@ -40,11 +37,10 @@ cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
cmWIXSourceWriter::~cmWIXSourceWriter() cmWIXSourceWriter::~cmWIXSourceWriter()
{ {
if(Elements.size() > 1) if (Elements.size() > 1) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, Elements.size() - 1
cmCPackLogger(cmCPackLog::LOG_ERROR, << " WiX elements were still open when closing '"
Elements.size() - 1 << " WiX elements were still open when closing '" << << SourceFilename << "'" << std::endl);
SourceFilename << "'" << std::endl);
return; return;
} }
@ -53,8 +49,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter()
void cmWIXSourceWriter::BeginElement(std::string const& name) void cmWIXSourceWriter::BeginElement(std::string const& name)
{ {
if(State == BEGIN) if (State == BEGIN) {
{
File << ">"; File << ">";
} }
@ -68,31 +63,25 @@ void cmWIXSourceWriter::BeginElement(std::string const& name)
void cmWIXSourceWriter::EndElement(std::string const& name) void cmWIXSourceWriter::EndElement(std::string const& name)
{ {
if(Elements.empty()) if (Elements.empty()) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"can not end WiX element with no open elements in '" << "can not end WiX element with no open elements in '"
SourceFilename << "'" << std::endl); << SourceFilename << "'" << std::endl);
return; return;
} }
if(Elements.back() != name) if (Elements.back() != name) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "WiX element <"
cmCPackLogger(cmCPackLog::LOG_ERROR, << Elements.back() << "> can not be closed by </" << name
"WiX element <" << Elements.back() << << "> in '" << SourceFilename << "'" << std::endl);
"> can not be closed by </" << name << "> in '" <<
SourceFilename << "'" << std::endl);
return; return;
} }
if(State == DEFAULT) if (State == DEFAULT) {
{
File << "\n"; File << "\n";
Indent(Elements.size() - 1); Indent(Elements.size() - 1);
File << "</" << Elements.back() << ">"; File << "</" << Elements.back() << ">";
} } else {
else
{
File << "/>"; File << "/>";
} }
@ -102,16 +91,14 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
void cmWIXSourceWriter::AddTextNode(std::string const& text) void cmWIXSourceWriter::AddTextNode(std::string const& text)
{ {
if(State == BEGIN) if (State == BEGIN) {
{
File << ">"; File << ">";
} }
if(Elements.empty()) if (Elements.empty()) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"can not add text without open WiX element in '" << "can not add text without open WiX element in '"
SourceFilename << "'" << std::endl); << SourceFilename << "'" << std::endl);
return; return;
} }
@ -119,11 +106,10 @@ void cmWIXSourceWriter::AddTextNode(std::string const& text)
State = DEFAULT; State = DEFAULT;
} }
void cmWIXSourceWriter::AddProcessingInstruction( void cmWIXSourceWriter::AddProcessingInstruction(std::string const& target,
std::string const& target, std::string const& content) std::string const& content)
{
if(State == BEGIN)
{ {
if (State == BEGIN) {
File << ">"; File << ">";
} }
@ -134,19 +120,18 @@ void cmWIXSourceWriter::AddProcessingInstruction(
State = DEFAULT; State = DEFAULT;
} }
void cmWIXSourceWriter::AddAttribute( void cmWIXSourceWriter::AddAttribute(std::string const& key,
std::string const& key, std::string const& value) std::string const& value)
{ {
std::string utf8 = CMakeEncodingToUtf8(value); std::string utf8 = CMakeEncodingToUtf8(value);
File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"'; File << " " << key << "=\"" << EscapeAttributeValue(utf8) << '"';
} }
void cmWIXSourceWriter::AddAttributeUnlessEmpty( void cmWIXSourceWriter::AddAttributeUnlessEmpty(std::string const& key,
std::string const& key, std::string const& value) std::string const& value)
{
if(!value.empty())
{ {
if (!value.empty()) {
AddAttribute(key, value); AddAttribute(key, value);
} }
} }
@ -156,30 +141,26 @@ std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value)
#ifdef CMAKE_ENCODING_UTF8 #ifdef CMAKE_ENCODING_UTF8
return value; return value;
#else #else
if(value.empty()) if (value.empty()) {
{
return std::string(); return std::string();
} }
int characterCount = MultiByteToWideChar( int characterCount = MultiByteToWideChar(
CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), 0, 0); CP_ACP, 0, value.c_str(), static_cast<int>(value.size()), 0, 0);
if(characterCount == 0) if (characterCount == 0) {
{
return std::string(); return std::string();
} }
std::vector<wchar_t> utf16(characterCount); std::vector<wchar_t> utf16(characterCount);
MultiByteToWideChar( MultiByteToWideChar(CP_ACP, 0, value.c_str(), static_cast<int>(value.size()),
CP_ACP, 0, value.c_str(), static_cast<int>(value.size()),
&utf16[0], static_cast<int>(utf16.size())); &utf16[0], static_cast<int>(utf16.size()));
int utf8ByteCount = WideCharToMultiByte( int utf8ByteCount = WideCharToMultiByte(
CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), 0, 0, 0, 0); CP_UTF8, 0, &utf16[0], static_cast<int>(utf16.size()), 0, 0, 0, 0);
if(utf8ByteCount == 0) if (utf8ByteCount == 0) {
{
return std::string(); return std::string();
} }
@ -192,7 +173,6 @@ std::string cmWIXSourceWriter::CMakeEncodingToUtf8(std::string const& value)
#endif #endif
} }
void cmWIXSourceWriter::WriteXMLDeclaration() void cmWIXSourceWriter::WriteXMLDeclaration()
{ {
File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl; File << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
@ -200,24 +180,20 @@ void cmWIXSourceWriter::WriteXMLDeclaration()
void cmWIXSourceWriter::Indent(size_t count) void cmWIXSourceWriter::Indent(size_t count)
{ {
for(size_t i = 0; i < count; ++i) for (size_t i = 0; i < count; ++i) {
{
File << " "; File << " ";
} }
} }
std::string cmWIXSourceWriter::EscapeAttributeValue( std::string cmWIXSourceWriter::EscapeAttributeValue(std::string const& value)
std::string const& value)
{ {
std::string result; std::string result;
result.reserve(value.size()); result.reserve(value.size());
char c = 0; char c = 0;
for(size_t i = 0 ; i < value.size(); ++i) for (size_t i = 0; i < value.size(); ++i) {
{
c = value[i]; c = value[i];
switch(c) switch (c) {
{
case '<': case '<':
result += "&lt;"; result += "&lt;";
break; break;

View File

@ -26,8 +26,8 @@
class cmWIXSourceWriter class cmWIXSourceWriter
{ {
public: public:
cmWIXSourceWriter(cmCPackLog* logger, cmWIXSourceWriter(cmCPackLog* logger, std::string const& filename,
std::string const& filename, bool isIncludeFile = false); bool isIncludeFile = false);
~cmWIXSourceWriter(); ~cmWIXSourceWriter();
@ -37,14 +37,13 @@ public:
void AddTextNode(std::string const& text); void AddTextNode(std::string const& text);
void AddProcessingInstruction( void AddProcessingInstruction(std::string const& target,
std::string const& target, std::string const& content); std::string const& content);
void AddAttribute( void AddAttribute(std::string const& key, std::string const& value);
std::string const& key, std::string const& value);
void AddAttributeUnlessEmpty( void AddAttributeUnlessEmpty(std::string const& key,
std::string const& key, std::string const& value); std::string const& value);
static std::string CMakeEncodingToUtf8(std::string const& value); static std::string CMakeEncodingToUtf8(std::string const& value);

View File

@ -13,8 +13,7 @@
#include "cmCPack7zGenerator.h" #include "cmCPack7zGenerator.h"
cmCPack7zGenerator::cmCPack7zGenerator() cmCPack7zGenerator::cmCPack7zGenerator()
:cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "7zip")
"7zip")
{ {
} }

View File

@ -40,12 +40,11 @@ int cmCPackArchiveGenerator::InitializeInternal()
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1");
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }
int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive, int cmCPackArchiveGenerator::addOneComponentToArchive(
cmCPackComponent* component) cmArchiveWrite& archive, cmCPackComponent* component)
{ {
cmCPackLogger(cmCPackLog::LOG_VERBOSE, " - packaging component: " cmCPackLogger(cmCPackLog::LOG_VERBOSE,
<< component->Name " - packaging component: " << component->Name << std::endl);
<< std::endl);
// Add the files of this component to the archive // Add the files of this component to the archive
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
localToplevel += "/" + component->Name; localToplevel += "/" + component->Name;
@ -53,32 +52,26 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
// Change to local toplevel // Change to local toplevel
cmSystemTools::ChangeDirectory(localToplevel); cmSystemTools::ChangeDirectory(localToplevel);
std::string filePrefix; std::string filePrefix;
if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY")) {
{
filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME"); filePrefix = this->GetOption("CPACK_PACKAGE_FILE_NAME");
filePrefix += "/"; filePrefix += "/";
} }
const char* installPrefix = const char* installPrefix =
this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
if(installPrefix && installPrefix[0] == '/' && installPrefix[1] != 0) if (installPrefix && installPrefix[0] == '/' && installPrefix[1] != 0) {
{
// add to file prefix and remove the leading '/' // add to file prefix and remove the leading '/'
filePrefix += installPrefix + 1; filePrefix += installPrefix + 1;
filePrefix += "/"; filePrefix += "/";
} }
std::vector<std::string>::const_iterator fileIt; std::vector<std::string>::const_iterator fileIt;
for (fileIt = component->Files.begin(); fileIt != component->Files.end(); for (fileIt = component->Files.begin(); fileIt != component->Files.end();
++fileIt ) ++fileIt) {
{
std::string rp = filePrefix + *fileIt; std::string rp = filePrefix + *fileIt;
cmCPackLogger(cmCPackLog::LOG_DEBUG,"Adding file: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file: " << rp << std::endl);
<< rp << std::endl);
archive.Add(rp, 0, 0, false); archive.Add(rp, 0, 0, false);
if (!archive) if (!archive) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: " cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: "
<< archive.GetError() << archive.GetError() << std::endl);
<< std::endl);
return 0; return 0;
} }
} }
@ -95,21 +88,16 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
#define DECLARE_AND_OPEN_ARCHIVE(filename, archive) \ #define DECLARE_AND_OPEN_ARCHIVE(filename, archive) \
cmGeneratedFileStream gf; \ cmGeneratedFileStream gf; \
gf.Open(filename.c_str(), false, true); \ gf.Open(filename.c_str(), false, true); \
if (!GenerateHeader(&gf)) \ if (!GenerateHeader(&gf)) { \
{ \
cmCPackLogger(cmCPackLog::LOG_ERROR, \ cmCPackLogger(cmCPackLog::LOG_ERROR, \
"Problem to generate Header for archive < " \ "Problem to generate Header for archive < " \
<< filename \ << filename << ">." << std::endl); \
<< ">." << std::endl); \
return 0; \ return 0; \
} \ } \
cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \ cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \
if (!archive) \ if (!archive) { \
{ \
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \
<< filename \ << filename << ">. ERROR =" << archive.GetError() \
<< ">. ERROR =" \
<< archive.GetError() \
<< std::endl); \ << std::endl); \
return 0; \ return 0; \
} }
@ -119,22 +107,18 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
packageFileNames.clear(); packageFileNames.clear();
// The default behavior is to have one package by component group // The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified. // unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) if (!ignoreGroup) {
{
std::map<std::string, cmCPackComponentGroup>::iterator compGIt; std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt = this->ComponentGroups.begin(); for (compGIt = this->ComponentGroups.begin();
compGIt!=this->ComponentGroups.end(); ++compGIt) compGIt != this->ComponentGroups.end(); ++compGIt) {
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
<< compGIt->first << compGIt->first << std::endl);
<< std::endl);
// Begin the archive for this group // Begin the archive for this group
std::string packageFileName = std::string(toplevel); std::string packageFileName = std::string(toplevel);
packageFileName += "/" + packageFileName += "/" +
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
compGIt->first, compGIt->first, true) +
true) this->GetOutputExtension();
+ this->GetOutputExtension();
// open a block in order to automatically close archive // open a block in order to automatically close archive
// at the end of the block // at the end of the block
{ {
@ -142,9 +126,7 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
// now iterate over the component of this group // now iterate over the component of this group
std::vector<cmCPackComponent*>::iterator compIt; std::vector<cmCPackComponent*>::iterator compIt;
for (compIt = (compGIt->second).Components.begin(); for (compIt = (compGIt->second).Components.begin();
compIt!=(compGIt->second).Components.end(); compIt != (compGIt->second).Components.end(); ++compIt) {
++compIt)
{
// Add the files of this component to the archive // Add the files of this component to the archive
addOneComponentToArchive(archive, *compIt); addOneComponentToArchive(archive, *compIt);
} }
@ -154,28 +136,24 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
} }
// Handle Orphan components (components not belonging to any groups) // Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt=this->Components.begin(); for (compIt = this->Components.begin(); compIt != this->Components.end();
compIt!=this->Components.end(); ++compIt ) ++compIt) {
{
// Does the component belong to a group? // Does the component belong to a group?
if (compIt->second.Group==NULL) if (compIt->second.Group == NULL) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLog::LOG_VERBOSE, "Component <"
"Component <"
<< compIt->second.Name << compIt->second.Name
<< "> does not belong to any group, package it separately." << "> does not belong to any group, package it separately."
<< std::endl); << std::endl);
std::string localToplevel( std::string localToplevel(
this->GetOption("CPACK_TEMPORARY_DIRECTORY") this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
);
std::string packageFileName = std::string(toplevel); std::string packageFileName = std::string(toplevel);
localToplevel += "/" + compIt->first; localToplevel += "/" + compIt->first;
packageFileName += "/"+ packageFileName += "/" + GetComponentPackageFileName(
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), this->GetOption("CPACK_PACKAGE_FILE_NAME"),
compIt->first, compIt->first, false) +
false) this->GetOutputExtension();
+ this->GetOutputExtension();
{ {
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// Add the files of this component to the archive // Add the files of this component to the archive
@ -188,21 +166,18 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup)
} }
// CPACK_COMPONENTS_IGNORE_GROUPS is set // CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component // We build 1 package per component
else else {
{
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt=this->Components.begin(); for (compIt = this->Components.begin(); compIt != this->Components.end();
compIt!=this->Components.end(); ++compIt ) ++compIt) {
{
std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY"));
std::string packageFileName = std::string(toplevel); std::string packageFileName = std::string(toplevel);
localToplevel += "/" + compIt->first; localToplevel += "/" + compIt->first;
packageFileName += "/" + packageFileName += "/" +
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
compIt->first, compIt->first, false) +
false) this->GetOutputExtension();
+ this->GetOutputExtension();
{ {
DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive); DECLARE_AND_OPEN_ARCHIVE(packageFileName, archive);
// Add the files of this component to the archive // Add the files of this component to the archive
@ -220,9 +195,9 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
// reset the package file names // reset the package file names
packageFileNames.clear(); packageFileNames.clear();
packageFileNames.push_back(std::string(toplevel)); packageFileNames.push_back(std::string(toplevel));
packageFileNames[0] += "/" packageFileNames[0] += "/" +
+std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+ this->GetOutputExtension(); this->GetOutputExtension();
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Packaging all groups in one package..." "Packaging all groups in one package..."
"(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)" "(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)"
@ -232,8 +207,7 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
// The ALL COMPONENTS in ONE package case // The ALL COMPONENTS in ONE package case
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end(); for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt ) ++compIt) {
{
// Add the files of this component to the archive // Add the files of this component to the archive
addOneComponentToArchive(archive, &(compIt->second)); addOneComponentToArchive(archive, &(compIt->second));
} }
@ -244,23 +218,20 @@ int cmCPackArchiveGenerator::PackageComponentsAllInOne()
int cmCPackArchiveGenerator::PackageFiles() int cmCPackArchiveGenerator::PackageFiles()
{ {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
<< toplevel << std::endl);
if (WantsComponentInstallation()) { if (WantsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package // CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL COMPONENTS in ONE package has been requested // If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here. // then the package file is unique and should be open here.
if (componentPackageMethod == ONE_PACKAGE) if (componentPackageMethod == ONE_PACKAGE) {
{
return PackageComponentsAllInOne(); return PackageComponentsAllInOne();
} }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else else {
{
return PackageComponents(componentPackageMethod == return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT); ONE_PACKAGE_PER_COMPONENT);
} }
@ -271,20 +242,15 @@ int cmCPackArchiveGenerator::PackageFiles()
std::vector<std::string>::const_iterator fileIt; std::vector<std::string>::const_iterator fileIt;
std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(toplevel); cmSystemTools::ChangeDirectory(toplevel);
for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) for (fileIt = files.begin(); fileIt != files.end(); ++fileIt) {
{
// Get the relative path to the file // Get the relative path to the file
std::string rp = cmSystemTools::RelativePath(toplevel.c_str(), std::string rp =
fileIt->c_str()); cmSystemTools::RelativePath(toplevel.c_str(), fileIt->c_str());
archive.Add(rp, 0, 0, false); archive.Add(rp, 0, 0, false);
if(!archive) if (!archive) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< " cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< "
<< *fileIt << *fileIt << "> to archive <" << packageFileNames[0]
<< "> to archive <" << "> .ERROR =" << archive.GetError() << std::endl);
<< packageFileNames[0] << "> .ERROR ="
<< archive.GetError()
<< std::endl);
return 0; return 0;
} }
} }
@ -298,16 +264,14 @@ int cmCPackArchiveGenerator::GenerateHeader(std::ostream*)
return 1; return 1;
} }
bool cmCPackArchiveGenerator::SupportsComponentInstallation() const { bool cmCPackArchiveGenerator::SupportsComponentInstallation() const
{
// The Component installation support should only // The Component installation support should only
// be activated if explicitly requested by the user // be activated if explicitly requested by the user
// (for backward compatibility reason) // (for backward compatibility reason)
if (IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL")) if (IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL")) {
{
return true; return true;
} } else {
else
{
return false; return false;
} }
} }

View File

@ -17,7 +17,6 @@
#include "cmArchiveWrite.h" #include "cmArchiveWrite.h"
/** \class cmCPackArchiveGenerator /** \class cmCPackArchiveGenerator
* \brief A generator base for libarchive generation. * \brief A generator base for libarchive generation.
* The generator itself uses the libarchive wrapper * The generator itself uses the libarchive wrapper
@ -38,6 +37,7 @@ public:
virtual int GenerateHeader(std::ostream* os); virtual int GenerateHeader(std::ostream* os);
// component support // component support
virtual bool SupportsComponentInstallation() const; virtual bool SupportsComponentInstallation() const;
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
/** /**

View File

@ -28,8 +28,7 @@ cmCPackBundleGenerator::~cmCPackBundleGenerator()
int cmCPackBundleGenerator::InitializeInternal() int cmCPackBundleGenerator::InitializeInternal()
{ {
const char* name = this->GetOption("CPACK_BUNDLE_NAME"); const char* name = this->GetOption("CPACK_BUNDLE_NAME");
if(0 == name) if (0 == name) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_BUNDLE_NAME must be set to use the Bundle generator." "CPACK_BUNDLE_NAME must be set to use the Bundle generator."
<< std::endl); << std::endl);
@ -37,15 +36,12 @@ int cmCPackBundleGenerator::InitializeInternal()
return 0; return 0;
} }
if(this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) if (this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")) {
{ const std::string codesign_path = cmSystemTools::FindProgram(
const std::string codesign_path = cmSystemTools::FindProgram("codesign", "codesign", std::vector<std::string>(), false);
std::vector<std::string>(), false);
if(codesign_path.empty()) if (codesign_path.empty()) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate codesign command"
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot locate codesign command"
<< std::endl); << std::endl);
return 0; return 0;
} }
@ -69,33 +65,30 @@ int cmCPackBundleGenerator::ConstructBundle()
// Get required arguments ... // Get required arguments ...
const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME") const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME")
? this->GetOption("CPACK_BUNDLE_NAME") : ""; ? this->GetOption("CPACK_BUNDLE_NAME")
if(cpack_bundle_name.empty()) : "";
{ if (cpack_bundle_name.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_NAME must be set."
"CPACK_BUNDLE_NAME must be set."
<< std::endl); << std::endl);
return 0; return 0;
} }
const std::string cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST") const std::string cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST")
? this->GetOption("CPACK_BUNDLE_PLIST") : ""; ? this->GetOption("CPACK_BUNDLE_PLIST")
if(cpack_bundle_plist.empty()) : "";
{ if (cpack_bundle_plist.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_PLIST must be set."
"CPACK_BUNDLE_PLIST must be set."
<< std::endl); << std::endl);
return 0; return 0;
} }
const std::string cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON") const std::string cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON")
? this->GetOption("CPACK_BUNDLE_ICON") : ""; ? this->GetOption("CPACK_BUNDLE_ICON")
if(cpack_bundle_icon.empty()) : "";
{ if (cpack_bundle_icon.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_BUNDLE_ICON must be set."
"CPACK_BUNDLE_ICON must be set."
<< std::endl); << std::endl);
return 0; return 0;
@ -104,7 +97,8 @@ int cmCPackBundleGenerator::ConstructBundle()
// Get optional arguments ... // Get optional arguments ...
const std::string cpack_bundle_startup_command = const std::string cpack_bundle_startup_command =
this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND")
? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") : ""; ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND")
: "";
// The staging directory contains everything that will end-up inside the // The staging directory contains everything that will end-up inside the
// final disk image ... // final disk image ...
@ -112,25 +106,28 @@ int cmCPackBundleGenerator::ConstructBundle()
staging << toplevel; staging << toplevel;
std::ostringstream contents; std::ostringstream contents;
contents << staging.str() << "/" << cpack_bundle_name contents << staging.str() << "/" << cpack_bundle_name << ".app/"
<< ".app/" << "Contents"; << "Contents";
std::ostringstream application; std::ostringstream application;
application << contents.str() << "/" << "MacOS"; application << contents.str() << "/"
<< "MacOS";
std::ostringstream resources; std::ostringstream resources;
resources << contents.str() << "/" << "Resources"; resources << contents.str() << "/"
<< "Resources";
// Install a required, user-provided bundle metadata file ... // Install a required, user-provided bundle metadata file ...
std::ostringstream plist_source; std::ostringstream plist_source;
plist_source << cpack_bundle_plist; plist_source << cpack_bundle_plist;
std::ostringstream plist_target; std::ostringstream plist_target;
plist_target << contents.str() << "/" << "Info.plist"; plist_target << contents.str() << "/"
<< "Info.plist";
if(!this->CopyFile(plist_source, plist_target)) if (!this->CopyFile(plist_source, plist_target)) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLog::LOG_ERROR,
"Error copying plist. Check the value of CPACK_BUNDLE_PLIST." "Error copying plist. Check the value of CPACK_BUNDLE_PLIST."
<< std::endl); << std::endl);
@ -144,9 +141,9 @@ int cmCPackBundleGenerator::ConstructBundle()
std::ostringstream icon_target; std::ostringstream icon_target;
icon_target << resources.str() << "/" << cpack_bundle_name << ".icns"; icon_target << resources.str() << "/" << cpack_bundle_name << ".icns";
if(!this->CopyFile(icon_source, icon_target)) if (!this->CopyFile(icon_source, icon_target)) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLog::LOG_ERROR,
"Error copying bundle icon. Check the value of CPACK_BUNDLE_ICON." "Error copying bundle icon. Check the value of CPACK_BUNDLE_ICON."
<< std::endl); << std::endl);
@ -155,16 +152,14 @@ int cmCPackBundleGenerator::ConstructBundle()
// Optionally a user-provided startup command (could be an // Optionally a user-provided startup command (could be an
// executable or a script) ... // executable or a script) ...
if(!cpack_bundle_startup_command.empty()) if (!cpack_bundle_startup_command.empty()) {
{
std::ostringstream command_source; std::ostringstream command_source;
command_source << cpack_bundle_startup_command; command_source << cpack_bundle_startup_command;
std::ostringstream command_target; std::ostringstream command_target;
command_target << application.str() << "/" << cpack_bundle_name; command_target << application.str() << "/" << cpack_bundle_name;
if(!this->CopyFile(command_source, command_target)) if (!this->CopyFile(command_source, command_target)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error copying startup command. " "Error copying startup command. "
" Check the value of CPACK_BUNDLE_STARTUP_COMMAND." " Check the value of CPACK_BUNDLE_STARTUP_COMMAND."
@ -181,13 +176,11 @@ int cmCPackBundleGenerator::ConstructBundle()
int cmCPackBundleGenerator::PackageFiles() int cmCPackBundleGenerator::PackageFiles()
{ {
if(!this->ConstructBundle()) if (!this->ConstructBundle()) {
{
return 0; return 0;
} }
if(!this->SignBundle(toplevel)) if (!this->SignBundle(toplevel)) {
{
return 0; return 0;
} }
@ -199,16 +192,15 @@ bool cmCPackBundleGenerator::SupportsComponentInstallation() const
return false; return false;
} }
int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
{ {
const std::string cpack_apple_cert_app = const std::string cpack_apple_cert_app =
this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") : ""; ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
: "";
// codesign the application. // codesign the application.
if(!cpack_apple_cert_app.empty()) if (!cpack_apple_cert_app.empty()) {
{
std::string output; std::string output;
std::string bundle_path; std::string bundle_path;
bundle_path = src_dir + "/"; bundle_path = src_dir + "/";
@ -223,15 +215,15 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
const std::string sign_files = const std::string sign_files =
this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") : ""; ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
: "";
std::vector<std::string> relFiles; std::vector<std::string> relFiles;
cmSystemTools::ExpandListArgument(sign_files, relFiles); cmSystemTools::ExpandListArgument(sign_files, relFiles);
// sign the files supplied by the user, ie. frameworks. // sign the files supplied by the user, ie. frameworks.
for (std::vector<std::string>::iterator it = relFiles.begin(); for (std::vector<std::string>::iterator it = relFiles.begin();
it != relFiles.end(); ++it) it != relFiles.end(); ++it) {
{
std::ostringstream temp_sign_file_cmd; std::ostringstream temp_sign_file_cmd;
temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
temp_sign_file_cmd << " " << sign_parameter << " -s \"" temp_sign_file_cmd << " " << sign_parameter << " -s \""
@ -242,11 +234,10 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
temp_sign_file_cmd << bundle_path; temp_sign_file_cmd << bundle_path;
temp_sign_file_cmd << it->c_str() << "\""; temp_sign_file_cmd << it->c_str() << "\"";
if(!this->RunCommand(temp_sign_file_cmd, &output)) if (!this->RunCommand(temp_sign_file_cmd, &output)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error signing file:"
cmCPackLogger(cmCPackLog::LOG_ERROR, << bundle_path << it->c_str() << std::endl
"Error signing file:" << output << std::endl);
<< bundle_path << it->c_str() << std::endl << output << std::endl);
return 0; return 0;
} }
@ -259,11 +250,11 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
<< cpack_apple_cert_app; << cpack_apple_cert_app;
temp_sign_binary_cmd << "\" \"" << bundle_path << "\""; temp_sign_binary_cmd << "\" \"" << bundle_path << "\"";
if(!this->RunCommand(temp_sign_binary_cmd, &output)) if (!this->RunCommand(temp_sign_binary_cmd, &output)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error signing the application binary." "Error signing the application binary." << std::endl
<< std::endl << output << std::endl); << output
<< std::endl);
return 0; return 0;
} }
@ -273,28 +264,27 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN"); temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
temp_codesign_cmd << " " << sign_parameter << " -s \"" temp_codesign_cmd << " " << sign_parameter << " -s \""
<< cpack_apple_cert_app << "\""; << cpack_apple_cert_app << "\"";
if(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) if (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")) {
{
temp_codesign_cmd << " --entitlements "; temp_codesign_cmd << " --entitlements ";
temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"); temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS");
} }
temp_codesign_cmd << " \"" << bundle_path << "\""; temp_codesign_cmd << " \"" << bundle_path << "\"";
if(!this->RunCommand(temp_codesign_cmd, &output)) if (!this->RunCommand(temp_codesign_cmd, &output)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error signing the application package." "Error signing the application package." << std::endl
<< std::endl << output << std::endl); << output
<< std::endl);
return 0; return 0;
} }
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Application has been codesigned"
"- Application has been codesigned"
<< std::endl); << std::endl);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE,
(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS") (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")
? "with entitlement sandboxing" : "without entitlement sandboxing") ? "with entitlement sandboxing"
: "without entitlement sandboxing")
<< std::endl); << std::endl);
} }

View File

@ -20,14 +20,12 @@
unsigned long cmCPackComponent::GetInstalledSize( unsigned long cmCPackComponent::GetInstalledSize(
const std::string& installDir) const const std::string& installDir) const
{ {
if (this->TotalSize != 0) if (this->TotalSize != 0) {
{
return this->TotalSize; return this->TotalSize;
} }
std::vector<std::string>::const_iterator fileIt; std::vector<std::string>::const_iterator fileIt;
for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) {
{
std::string path = installDir; std::string path = installDir;
path += '/'; path += '/';
path += *fileIt; path += *fileIt;
@ -37,8 +35,8 @@ unsigned long cmCPackComponent::GetInstalledSize(
return this->TotalSize; return this->TotalSize;
} }
unsigned long unsigned long cmCPackComponent::GetInstalledSizeInKbytes(
cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const const std::string& installDir) const
{ {
unsigned long result = (GetInstalledSize(installDir) + 512) / 1024; unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
return result ? result : 1; return result ? result : 1;

View File

@ -42,9 +42,15 @@ public:
class cmCPackComponent class cmCPackComponent
{ {
public: public:
cmCPackComponent() : Group(0), IsRequired(true), IsHidden(false), cmCPackComponent()
IsDisabledByDefault(false), IsDownloaded(false), : Group(0)
TotalSize(0) { } , IsRequired(true)
, IsHidden(false)
, IsDisabledByDefault(false)
, IsDownloaded(false)
, TotalSize(0)
{
}
/// The name of the component (used to reference the component). /// The name of the component (used to reference the component).
std::string Name; std::string Name;
@ -110,7 +116,10 @@ public:
class cmCPackComponentGroup class cmCPackComponentGroup
{ {
public: public:
cmCPackComponentGroup() : ParentGroup(0) { } cmCPackComponentGroup()
: ParentGroup(0)
{
}
/// The name of the group (used to reference the group). /// The name of the group (used to reference the group).
std::string Name; std::string Name;

View File

@ -45,8 +45,7 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
std::string manifest = "/usr/share/doc/"; std::string manifest = "/usr/share/doc/";
manifest += packageName; manifest += packageName;
manifest += "/MANIFEST"; manifest += "/MANIFEST";
std::string manifestFile std::string manifestFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
// Create a MANIFEST file that contains all of the files in // Create a MANIFEST file that contains all of the files in
// the tar file // the tar file
std::string tempdir = manifestFile; std::string tempdir = manifestFile;
@ -56,8 +55,7 @@ int cmCPackCygwinBinaryGenerator::PackageFiles()
{ {
cmGeneratedFileStream ofs(manifestFile.c_str()); cmGeneratedFileStream ofs(manifestFile.c_str());
for (std::vector<std::string>::const_iterator i = files.begin(); for (std::vector<std::string>::const_iterator i = files.begin();
i != files.end(); ++i) i != files.end(); ++i) {
{
// remove the temp dir and replace with /usr // remove the temp dir and replace with /usr
ofs << (*i).substr(tempdir.size()) << "\n"; ofs << (*i).substr(tempdir.size()) << "\n";
} }
@ -74,8 +72,7 @@ const char* cmCPackCygwinBinaryGenerator::GetOutputExtension()
{ {
this->OutputExtension = "-"; this->OutputExtension = "-";
const char* patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER"); const char* patchNumber = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
if(!patchNumber) if (!patchNumber) {
{
patchNumber = "1"; patchNumber = "1";
cmCPackLogger(cmCPackLog::LOG_WARNING, cmCPackLogger(cmCPackLog::LOG_WARNING,
"CPACK_CYGWIN_PATCH_NUMBER not specified using 1" "CPACK_CYGWIN_PATCH_NUMBER not specified using 1"

View File

@ -28,6 +28,7 @@ public:
*/ */
cmCPackCygwinBinaryGenerator(); cmCPackCygwinBinaryGenerator();
virtual ~cmCPackCygwinBinaryGenerator(); virtual ~cmCPackCygwinBinaryGenerator();
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
int PackageFiles(); int PackageFiles();

View File

@ -46,8 +46,8 @@ int cmCPackCygwinSourceGenerator::InitializeInternal()
int cmCPackCygwinSourceGenerator::PackageFiles() int cmCPackCygwinSourceGenerator::PackageFiles()
{ {
// Create a tar file of the sources // Create a tar file of the sources
std::string packageDirFileName std::string packageDirFileName =
= this->GetOption("CPACK_TEMPORARY_DIRECTORY"); this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packageDirFileName += ".tar.bz2"; packageDirFileName += ".tar.bz2";
packageFileNames[0] = packageDirFileName; packageFileNames[0] = packageDirFileName;
std::string output; std::string output;
@ -55,8 +55,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
// to create tar.bz2 file with the list of source // to create tar.bz2 file with the list of source
// files // files
this->Compress = cmArchiveWrite::CompressBZip2; this->Compress = cmArchiveWrite::CompressBZip2;
if ( !this->cmCPackTarBZip2Generator::PackageFiles() ) if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
{
return 0; return 0;
} }
// Now create a tar file that contains the above .tar.bz2 file // Now create a tar file that contains the above .tar.bz2 file
@ -76,23 +75,20 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
// to the toplevel cpack temp dir // to the toplevel cpack temp dir
// copy the patch file into place // copy the patch file into place
if(!this->GetOption("CPACK_CYGWIN_PATCH_FILE")) if (!this->GetOption("CPACK_CYGWIN_PATCH_FILE")) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"No patch file specified for cygwin sources."); "No patch file specified for cygwin sources.");
return 0; return 0;
} }
if (!cmSystemTools::CopyFileAlways( if (!cmSystemTools::CopyFileAlways(
this->GetOption("CPACK_CYGWIN_PATCH_FILE"), this->GetOption("CPACK_CYGWIN_PATCH_FILE"),
this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: [" cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: ["
<< this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n[" << this->GetOption("CPACK_CYGWIN_PATCH_FILE") << "]\nto\n["
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n"); << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
return 0; return 0;
} }
if(!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT")) if (!this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT")) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"No build script specified for cygwin sources."); "No build script specified for cygwin sources.");
return 0; return 0;
@ -100,19 +96,16 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
// copy the build script into place // copy the build script into place
if (!cmSystemTools::CopyFileAlways( if (!cmSystemTools::CopyFileAlways(
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"), this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"),
this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) this->GetOption("CPACK_TOPLEVEL_DIRECTORY"))) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: " cmCPackLogger(cmCPackLog::LOG_ERROR, "problem copying: "
<< this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n" << this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT") << "\nto\n"
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n"); << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "]\n");
return 0; return 0;
} }
std::string outerTarFile std::string outerTarFile = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
= this->GetOption("CPACK_TEMPORARY_DIRECTORY");
outerTarFile += "-"; outerTarFile += "-";
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER"); const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
if(!patch) if (!patch) {
{
cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER" cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
<< " not specified, defaulting to 1\n"); << " not specified, defaulting to 1\n");
patch = "1"; patch = "1";
@ -126,8 +119,8 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT")); this->GetOption("CPACK_CYGWIN_BUILD_SCRIPT"));
std::string patchFile = tmpDir; std::string patchFile = tmpDir;
patchFile += "/"; patchFile += "/";
patchFile += cmSystemTools::GetFilenameName( patchFile +=
this->GetOption("CPACK_CYGWIN_PATCH_FILE")); cmSystemTools::GetFilenameName(this->GetOption("CPACK_CYGWIN_PATCH_FILE"));
std::string file = cmSystemTools::GetFilenameName(compressOutFile); std::string file = cmSystemTools::GetFilenameName(compressOutFile);
std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile); std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile);
@ -146,8 +139,7 @@ int cmCPackCygwinSourceGenerator::PackageFiles()
packageFileNames[0] = outerTarFile; packageFileNames[0] = outerTarFile;
/* update the toplevel dir */ /* update the toplevel dir */
toplevel = tmpDir; toplevel = tmpDir;
if ( !this->cmCPackTarBZip2Generator::PackageFiles() ) if (!this->cmCPackTarBZip2Generator::PackageFiles()) {
{
return 0; return 0;
} }
return 1; return 1;
@ -164,8 +156,7 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
{ {
this->OutputExtension = "-"; this->OutputExtension = "-";
const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER"); const char* patch = this->GetOption("CPACK_CYGWIN_PATCH_NUMBER");
if(!patch) if (!patch) {
{
cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER" cmCPackLogger(cmCPackLog::LOG_WARNING, "CPACK_CYGWIN_PATCH_NUMBER"
<< " not specified, defaulting to 1\n"); << " not specified, defaulting to 1\n");
patch = "1"; patch = "1";
@ -174,4 +165,3 @@ const char* cmCPackCygwinSourceGenerator::GetOutputExtension()
this->OutputExtension += "-src.tar.bz2"; this->OutputExtension += "-src.tar.bz2";
return this->OutputExtension.c_str(); return this->OutputExtension.c_str();
} }

View File

@ -28,6 +28,7 @@ public:
*/ */
cmCPackCygwinSourceGenerator(); cmCPackCygwinSourceGenerator();
virtual ~cmCPackCygwinSourceGenerator(); virtual ~cmCPackCygwinSourceGenerator();
protected: protected:
const char* GetPackagingInstallPrefix(); const char* GetPackagingInstallPrefix();
virtual int InitializeInternal(); virtual int InitializeInternal();

View File

@ -30,7 +30,8 @@
// a GNU ar. // a GNU ar.
// See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info // See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=161593 for more info
// Therefore we provide our own implementation of a BSD-ar: // Therefore we provide our own implementation of a BSD-ar:
static int ar_append(const char*archive,const std::vector<std::string>& files); static int ar_append(const char* archive,
const std::vector<std::string>& files);
cmCPackDebGenerator::cmCPackDebGenerator() cmCPackDebGenerator::cmCPackDebGenerator()
{ {
@ -43,8 +44,7 @@ cmCPackDebGenerator::~cmCPackDebGenerator()
int cmCPackDebGenerator::InitializeInternal() int cmCPackDebGenerator::InitializeInternal()
{ {
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr"); this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
{
this->SetOption("CPACK_SET_DESTDIR", "I_ON"); this->SetOption("CPACK_SET_DESTDIR", "I_ON");
} }
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
@ -56,14 +56,10 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
int retval = 1; int retval = 1;
// Begin the archive for this pack // Begin the archive for this pack
std::string localToplevel(initialTopLevel); std::string localToplevel(initialTopLevel);
std::string packageFileName( std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
cmSystemTools::GetParentDirectory(toplevel) std::string outputFileName(cmsys::SystemTools::LowerCase(std::string(
); this->GetOption("CPACK_PACKAGE_FILE_NAME"))) +
std::string outputFileName( "-" + packageName + this->GetOutputExtension());
cmsys::SystemTools::LowerCase(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")))
+"-"+packageName + this->GetOutputExtension()
);
localToplevel += "/" + packageName; localToplevel += "/" + packageName;
/* replace the TEMP DIRECTORY with the component one */ /* replace the TEMP DIRECTORY with the component one */
@ -81,10 +77,9 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
component_path += packageName; component_path += packageName;
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str()); component_path.c_str());
if (!this->ReadListFile("CPackDeb.cmake")) if (!this->ReadListFile("CPackDeb.cmake")) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
cmCPackLogger(cmCPackLog::LOG_ERROR, << std::endl);
"Error while execution CPackDeb.cmake" << std::endl);
retval = 0; retval = 0;
return retval; return retval;
} }
@ -94,17 +89,16 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
findExpr += "/*"; findExpr += "/*";
gl.RecurseOn(); gl.RecurseOn();
gl.SetRecurseListDirs(true); gl.SetRecurseListDirs(true);
if ( !gl.FindFiles(findExpr) ) if (!gl.FindFiles(findExpr)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find any files in the installed directory" << std::endl); "Cannot find any files in the installed directory"
<< std::endl);
return 0; return 0;
} }
packageFiles = gl.GetFiles(); packageFiles = gl.GetFiles();
int res = createDeb(); int res = createDeb();
if (res != 1) if (res != 1) {
{
retval = 0; retval = 0;
} }
// add the generated package to package file names list // add the generated package to package file names list
@ -125,28 +119,23 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group // The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified. // unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) if (!ignoreGroup) {
{
std::map<std::string, cmCPackComponentGroup>::iterator compGIt; std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt = this->ComponentGroups.begin(); for (compGIt = this->ComponentGroups.begin();
compGIt!=this->ComponentGroups.end(); ++compGIt) compGIt != this->ComponentGroups.end(); ++compGIt) {
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
<< compGIt->first << compGIt->first << std::endl);
<< std::endl);
// Begin the archive for this group // Begin the archive for this group
retval &= PackageOnePack(initialTopLevel, compGIt->first); retval &= PackageOnePack(initialTopLevel, compGIt->first);
} }
// Handle Orphan components (components not belonging to any groups) // Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt=this->Components.begin(); for (compIt = this->Components.begin(); compIt != this->Components.end();
compIt!=this->Components.end(); ++compIt ) ++compIt) {
{
// Does the component belong to a group? // Does the component belong to a group?
if (compIt->second.Group==NULL) if (compIt->second.Group == NULL) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLog::LOG_VERBOSE, "Component <"
"Component <"
<< compIt->second.Name << compIt->second.Name
<< "> does not belong to any group, package it separately." << "> does not belong to any group, package it separately."
<< std::endl); << std::endl);
@ -157,12 +146,10 @@ int cmCPackDebGenerator::PackageComponents(bool ignoreGroup)
} }
// CPACK_COMPONENTS_IGNORE_GROUPS is set // CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component // We build 1 package per component
else else {
{
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt=this->Components.begin(); for (compIt = this->Components.begin(); compIt != this->Components.end();
compIt!=this->Components.end(); ++compIt ) ++compIt) {
{
retval &= PackageOnePack(initialTopLevel, compIt->first); retval &= PackageOnePack(initialTopLevel, compIt->first);
} }
} }
@ -186,14 +173,10 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
// The ALL GROUPS in ONE package case // The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel); std::string localToplevel(initialTopLevel);
std::string packageFileName( std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
cmSystemTools::GetParentDirectory(toplevel) std::string outputFileName(cmsys::SystemTools::LowerCase(std::string(
); this->GetOption("CPACK_PACKAGE_FILE_NAME"))) +
std::string outputFileName( this->GetOutputExtension());
cmsys::SystemTools::LowerCase(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")))
+ this->GetOutputExtension()
);
// all GROUP in one vs all COMPONENT in one // all GROUP in one vs all COMPONENT in one
localToplevel += "/" + compInstDirName; localToplevel += "/" + compInstDirName;
@ -206,18 +189,16 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
packageFileName.c_str()); packageFileName.c_str());
if(!compInstDirName.empty()) if (!compInstDirName.empty()) {
{
// Tell CPackDeb.cmake the path where the component is. // Tell CPackDeb.cmake the path where the component is.
std::string component_path = "/"; std::string component_path = "/";
component_path += compInstDirName; component_path += compInstDirName;
this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH", this->SetOption("CPACK_DEB_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str()); component_path.c_str());
} }
if (!this->ReadListFile("CPackDeb.cmake")) if (!this->ReadListFile("CPackDeb.cmake")) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackDeb.cmake"
cmCPackLogger(cmCPackLog::LOG_ERROR, << std::endl);
"Error while execution CPackDeb.cmake" << std::endl);
retval = 0; retval = 0;
return retval; return retval;
} }
@ -227,18 +208,16 @@ int cmCPackDebGenerator::PackageComponentsAllInOne(
findExpr += "/*"; findExpr += "/*";
gl.RecurseOn(); gl.RecurseOn();
gl.SetRecurseListDirs(true); gl.SetRecurseListDirs(true);
if ( !gl.FindFiles(findExpr) ) if (!gl.FindFiles(findExpr)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find any files in the installed directory" << std::endl); "Cannot find any files in the installed directory"
<< std::endl);
return 0; return 0;
} }
packageFiles = gl.GetFiles(); packageFiles = gl.GetFiles();
int res = createDeb(); int res = createDeb();
if (res != 1) if (res != 1) {
{
retval = 0; retval = 0;
} }
// add the generated package to package file names list // add the generated package to package file names list
@ -256,23 +235,20 @@ int cmCPackDebGenerator::PackageFiles()
// CASE 1 : COMPONENT ALL-IN-ONE package // CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL GROUPS or ALL COMPONENTS in ONE package has been requested // If ALL GROUPS or ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here. // then the package file is unique and should be open here.
if (componentPackageMethod == ONE_PACKAGE) if (componentPackageMethod == ONE_PACKAGE) {
{
return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE"); return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
} }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else else {
{
return PackageComponents(componentPackageMethod == return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT); ONE_PACKAGE_PER_COMPONENT);
} }
} }
// CASE 3 : NON COMPONENT package. // CASE 3 : NON COMPONENT package.
else else {
{
return PackageComponentsAllInOne(""); return PackageComponentsAllInOne("");
} }
} }
@ -305,8 +281,7 @@ int cmCPackDebGenerator::createDeb()
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE"); this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_ARCHITECTURE");
const char* maintainer = const char* maintainer =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER"); this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MAINTAINER");
const char* desc = const char* desc = this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_DESCRIPTION");
// optional entries // optional entries
const char* debian_pkg_dep = const char* debian_pkg_dep =
@ -332,7 +307,6 @@ int cmCPackDebGenerator::createDeb()
const char* debian_pkg_source = const char* debian_pkg_source =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE"); this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SOURCE");
{ // the scope is needed for cmGeneratedFileStream { // the scope is needed for cmGeneratedFileStream
cmGeneratedFileStream out(ctlfilename.c_str()); cmGeneratedFileStream out(ctlfilename.c_str());
out << "Package: " << debian_pkg_name << "\n"; out << "Package: " << debian_pkg_name << "\n";
@ -340,48 +314,37 @@ int cmCPackDebGenerator::createDeb()
out << "Section: " << debian_pkg_section << "\n"; out << "Section: " << debian_pkg_section << "\n";
out << "Priority: " << debian_pkg_priority << "\n"; out << "Priority: " << debian_pkg_priority << "\n";
out << "Architecture: " << debian_pkg_arch << "\n"; out << "Architecture: " << debian_pkg_arch << "\n";
if(debian_pkg_source && *debian_pkg_source) if (debian_pkg_source && *debian_pkg_source) {
{
out << "Source: " << debian_pkg_source << "\n"; out << "Source: " << debian_pkg_source << "\n";
} }
if(debian_pkg_dep && *debian_pkg_dep) if (debian_pkg_dep && *debian_pkg_dep) {
{
out << "Depends: " << debian_pkg_dep << "\n"; out << "Depends: " << debian_pkg_dep << "\n";
} }
if(debian_pkg_rec && *debian_pkg_rec) if (debian_pkg_rec && *debian_pkg_rec) {
{
out << "Recommends: " << debian_pkg_rec << "\n"; out << "Recommends: " << debian_pkg_rec << "\n";
} }
if(debian_pkg_sug && *debian_pkg_sug) if (debian_pkg_sug && *debian_pkg_sug) {
{
out << "Suggests: " << debian_pkg_sug << "\n"; out << "Suggests: " << debian_pkg_sug << "\n";
} }
if(debian_pkg_url && *debian_pkg_url) if (debian_pkg_url && *debian_pkg_url) {
{
out << "Homepage: " << debian_pkg_url << "\n"; out << "Homepage: " << debian_pkg_url << "\n";
} }
if (debian_pkg_predep && *debian_pkg_predep) if (debian_pkg_predep && *debian_pkg_predep) {
{
out << "Pre-Depends: " << debian_pkg_predep << "\n"; out << "Pre-Depends: " << debian_pkg_predep << "\n";
} }
if (debian_pkg_enhances && *debian_pkg_enhances) if (debian_pkg_enhances && *debian_pkg_enhances) {
{
out << "Enhances: " << debian_pkg_enhances << "\n"; out << "Enhances: " << debian_pkg_enhances << "\n";
} }
if (debian_pkg_breaks && *debian_pkg_breaks) if (debian_pkg_breaks && *debian_pkg_breaks) {
{
out << "Breaks: " << debian_pkg_breaks << "\n"; out << "Breaks: " << debian_pkg_breaks << "\n";
} }
if (debian_pkg_conflicts && *debian_pkg_conflicts) if (debian_pkg_conflicts && *debian_pkg_conflicts) {
{
out << "Conflicts: " << debian_pkg_conflicts << "\n"; out << "Conflicts: " << debian_pkg_conflicts << "\n";
} }
if (debian_pkg_provides && *debian_pkg_provides) if (debian_pkg_provides && *debian_pkg_provides) {
{
out << "Provides: " << debian_pkg_provides << "\n"; out << "Provides: " << debian_pkg_provides << "\n";
} }
if (debian_pkg_replaces && *debian_pkg_replaces) if (debian_pkg_replaces && *debian_pkg_replaces) {
{
out << "Replaces: " << debian_pkg_replaces << "\n"; out << "Replaces: " << debian_pkg_replaces << "\n";
} }
unsigned long totalSize = 0; unsigned long totalSize = 0;
@ -390,8 +353,7 @@ int cmCPackDebGenerator::createDeb()
dirName += '/'; dirName += '/';
for (std::vector<std::string>::const_iterator fileIt = for (std::vector<std::string>::const_iterator fileIt =
packageFiles.begin(); packageFiles.begin();
fileIt != packageFiles.end(); ++ fileIt ) fileIt != packageFiles.end(); ++fileIt) {
{
totalSize += cmSystemTools::FileLength(*fileIt); totalSize += cmSystemTools::FileLength(*fileIt);
} }
} }
@ -403,12 +365,11 @@ int cmCPackDebGenerator::createDeb()
const std::string shlibsfilename = strGenWDIR + "/shlibs"; const std::string shlibsfilename = strGenWDIR + "/shlibs";
const char* debian_pkg_shlibs = this->GetOption( const char* debian_pkg_shlibs =
"GEN_CPACK_DEBIAN_PACKAGE_SHLIBS"); this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_SHLIBS");
const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") &&
&& debian_pkg_shlibs && *debian_pkg_shlibs; debian_pkg_shlibs && *debian_pkg_shlibs;
if( gen_shibs ) if (gen_shibs) {
{
cmGeneratedFileStream out(shlibsfilename.c_str()); cmGeneratedFileStream out(shlibsfilename.c_str());
out << debian_pkg_shlibs; out << debian_pkg_shlibs;
out << std::endl; out << std::endl;
@ -416,21 +377,17 @@ int cmCPackDebGenerator::createDeb()
const std::string postinst = strGenWDIR + "/postinst"; const std::string postinst = strGenWDIR + "/postinst";
const std::string postrm = strGenWDIR + "/postrm"; const std::string postrm = strGenWDIR + "/postrm";
if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
{
cmGeneratedFileStream out(postinst.c_str()); cmGeneratedFileStream out(postinst.c_str());
out << out << "#!/bin/sh\n\n"
"#!/bin/sh\n\n"
"set -e\n\n" "set -e\n\n"
"if [ \"$1\" = \"configure\" ]; then\n" "if [ \"$1\" = \"configure\" ]; then\n"
"\tldconfig\n" "\tldconfig\n"
"fi\n"; "fi\n";
} }
if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
{
cmGeneratedFileStream out(postrm.c_str()); cmGeneratedFileStream out(postrm.c_str());
out << out << "#!/bin/sh\n\n"
"#!/bin/sh\n\n"
"set -e\n\n" "set -e\n\n"
"if [ \"$1\" = \"remove\" ]; then\n" "if [ \"$1\" = \"remove\" ]; then\n"
"\tldconfig\n" "\tldconfig\n"
@ -440,8 +397,7 @@ int cmCPackDebGenerator::createDeb()
cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip; cmArchiveWrite::Compress tar_compression_type = cmArchiveWrite::CompressGZip;
const char* debian_compression_type = const char* debian_compression_type =
this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE"); this->GetOption("GEN_CPACK_DEBIAN_COMPRESSION_TYPE");
if(!debian_compression_type) if (!debian_compression_type) {
{
debian_compression_type = "gzip"; debian_compression_type = "gzip";
} }
@ -467,19 +423,16 @@ int cmCPackDebGenerator::createDeb()
<< debian_compression_type << std::endl); << debian_compression_type << std::endl);
} }
std::string filename_data_tar =
std::string filename_data_tar = strGenWDIR strGenWDIR + "/data.tar" + compression_suffix;
+ "/data.tar" + compression_suffix;
// atomic file generation for data.tar // atomic file generation for data.tar
{ {
cmGeneratedFileStream fileStream_data_tar; cmGeneratedFileStream fileStream_data_tar;
fileStream_data_tar.Open(filename_data_tar.c_str(), false, true); fileStream_data_tar.Open(filename_data_tar.c_str(), false, true);
if(!fileStream_data_tar) if (!fileStream_data_tar) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
cmCPackLogger(cmCPackLog::LOG_ERROR, << filename_data_tar << "\" for writing" << std::endl);
"Error opening the file \"" << filename_data_tar << "\" for writing"
<< std::endl);
return 0; return 0;
} }
cmArchiveWrite data_tar(fileStream_data_tar, tar_compression_type, "paxr"); cmArchiveWrite data_tar(fileStream_data_tar, tar_compression_type, "paxr");
@ -495,8 +448,7 @@ int cmCPackDebGenerator::createDeb()
// give /usr and /opt // give /usr and /opt
size_t topLevelLength = strGenWDIR.length(); size_t topLevelLength = strGenWDIR.length();
cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \"" cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \""
<< strGenWDIR << strGenWDIR << "\", length = " << topLevelLength
<< "\", length = " << topLevelLength
<< std::endl); << std::endl);
std::set<std::string> orderedFiles; std::set<std::string> orderedFiles;
@ -504,11 +456,9 @@ int cmCPackDebGenerator::createDeb()
for (std::vector<std::string>::const_iterator fileIt = for (std::vector<std::string>::const_iterator fileIt =
packageFiles.begin(); packageFiles.begin();
fileIt != packageFiles.end(); ++ fileIt ) fileIt != packageFiles.end(); ++fileIt) {
{
std::string currentPath = *fileIt; std::string currentPath = *fileIt;
while(currentPath != strGenWDIR) while (currentPath != strGenWDIR) {
{
// the last one IS strGenWDIR, but we do not want this one: // the last one IS strGenWDIR, but we do not want this one:
// XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application // XXX/application/usr/bin/myprogram with GEN_WDIR=XXX/application
// should not add XXX/application // should not add XXX/application
@ -517,26 +467,21 @@ int cmCPackDebGenerator::createDeb()
} }
} }
for (std::set<std::string>::const_iterator fileIt = orderedFiles.begin();
for (std::set<std::string>::const_iterator fileIt = fileIt != orderedFiles.end(); ++fileIt) {
orderedFiles.begin();
fileIt != orderedFiles.end(); ++ fileIt )
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\"" cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\""
<< std::endl); << std::endl);
std::string::size_type slashPos = fileIt->find('/', topLevelLength + 1); std::string::size_type slashPos = fileIt->find('/', topLevelLength + 1);
std::string relativeDir = fileIt->substr(topLevelLength, std::string relativeDir =
slashPos - topLevelLength); fileIt->substr(topLevelLength, slashPos - topLevelLength);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \"" << relativeDir cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \""
<< "\"" << std::endl); << relativeDir << "\"" << std::endl);
// do not recurse because the loop will do it // do not recurse because the loop will do it
if(!data_tar.Add(*fileIt, topLevelLength, ".", false)) if (!data_tar.Add(*fileIt, topLevelLength, ".", false)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem adding file to tar:"
cmCPackLogger(cmCPackLog::LOG_ERROR, << std::endl
"Problem adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl
<< "#top level directory: "
<< strGenWDIR << std::endl
<< "#file: " << *fileIt << std::endl << "#file: " << *fileIt << std::endl
<< "#error:" << data_tar.GetError() << std::endl); << "#error:" << data_tar.GetError() << std::endl);
return 0; return 0;
@ -544,7 +489,6 @@ int cmCPackDebGenerator::createDeb()
} }
} // scope for file generation } // scope for file generation
std::string md5filename = strGenWDIR + "/md5sums"; std::string md5filename = strGenWDIR + "/md5sums";
{ {
// the scope is needed for cmGeneratedFileStream // the scope is needed for cmGeneratedFileStream
@ -555,18 +499,15 @@ int cmCPackDebGenerator::createDeb()
topLevelWithTrailingSlash += '/'; topLevelWithTrailingSlash += '/';
for (std::vector<std::string>::const_iterator fileIt = for (std::vector<std::string>::const_iterator fileIt =
packageFiles.begin(); packageFiles.begin();
fileIt != packageFiles.end(); ++ fileIt ) fileIt != packageFiles.end(); ++fileIt) {
{
// hash only regular files // hash only regular files
if( cmSystemTools::FileIsDirectory(*fileIt) if (cmSystemTools::FileIsDirectory(*fileIt) ||
|| cmSystemTools::FileIsSymlink(*fileIt)) cmSystemTools::FileIsSymlink(*fileIt)) {
{
continue; continue;
} }
char md5sum[33]; char md5sum[33];
if(!cmSystemTools::ComputeFileMD5(*fileIt, md5sum)) if (!cmSystemTools::ComputeFileMD5(*fileIt, md5sum)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of " cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem computing the md5 of "
<< *fileIt << std::endl); << *fileIt << std::endl);
} }
@ -578,31 +519,27 @@ int cmCPackDebGenerator::createDeb()
// debian md5sums entries are like this: // debian md5sums entries are like this:
// 014f3604694729f3bf19263bac599765 usr/bin/ccmake // 014f3604694729f3bf19263bac599765 usr/bin/ccmake
// thus strip the full path (with the trailing slash) // thus strip the full path (with the trailing slash)
cmSystemTools::ReplaceString(output, cmSystemTools::ReplaceString(output, topLevelWithTrailingSlash.c_str(),
topLevelWithTrailingSlash.c_str(), ""); "");
out << output; out << output;
} }
// each line contains a eol. // each line contains a eol.
// Do not end the md5sum file with yet another (invalid) // Do not end the md5sum file with yet another (invalid)
} }
std::string filename_control_tar = strGenWDIR + "/control.tar.gz"; std::string filename_control_tar = strGenWDIR + "/control.tar.gz";
// atomic file generation for control.tar // atomic file generation for control.tar
{ {
cmGeneratedFileStream fileStream_control_tar; cmGeneratedFileStream fileStream_control_tar;
fileStream_control_tar.Open(filename_control_tar.c_str(), false, true); fileStream_control_tar.Open(filename_control_tar.c_str(), false, true);
if(!fileStream_control_tar) if (!fileStream_control_tar) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error opening the file \""
cmCPackLogger(cmCPackLog::LOG_ERROR, << filename_control_tar << "\" for writing"
"Error opening the file \"" << filename_control_tar << std::endl);
<< "\" for writing" << std::endl);
return 0; return 0;
} }
cmArchiveWrite control_tar(fileStream_control_tar, cmArchiveWrite control_tar(fileStream_control_tar,
cmArchiveWrite::CompressGZip, cmArchiveWrite::CompressGZip, "paxr");
"paxr");
// sets permissions and uid/gid for the files // sets permissions and uid/gid for the files
control_tar.SetUIDAndGID(0u, 0u); control_tar.SetUIDAndGID(0u, 0u);
@ -623,27 +560,22 @@ int cmCPackDebGenerator::createDeb()
control_tar.SetPermissions(permission644); control_tar.SetPermissions(permission644);
// adds control and md5sums // adds control and md5sums
if( !control_tar.Add(md5filename, strGenWDIR.length(), ".") if (!control_tar.Add(md5filename, strGenWDIR.length(), ".") ||
|| !control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), ".")) !control_tar.Add(strGenWDIR + "/control", strGenWDIR.length(), ".")) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
cmCPackLogger(cmCPackLog::LOG_ERROR, << std::endl
"Error adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl
<< "#top level directory: "
<< strGenWDIR << std::endl
<< "#file: \"control\" or \"md5sums\"" << std::endl << "#file: \"control\" or \"md5sums\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl); << "#error:" << control_tar.GetError() << std::endl);
return 0; return 0;
} }
// adds generated shlibs file // adds generated shlibs file
if( gen_shibs ) if (gen_shibs) {
{ if (!control_tar.Add(shlibsfilename, strGenWDIR.length(), ".")) {
if( !control_tar.Add(shlibsfilename, strGenWDIR.length(), ".") ) cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
{ << std::endl
cmCPackLogger(cmCPackLog::LOG_ERROR, << "#top level directory: " << strGenWDIR << std::endl
"Error adding file to tar:" << std::endl
<< "#top level directory: "
<< strGenWDIR << std::endl
<< "#file: \"shlibs\"" << std::endl << "#file: \"shlibs\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl); << "#error:" << control_tar.GetError() << std::endl);
return 0; return 0;
@ -651,15 +583,12 @@ int cmCPackDebGenerator::createDeb()
} }
// adds LDCONFIG related files // adds LDCONFIG related files
if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) {
{
control_tar.SetPermissions(permission755); control_tar.SetPermissions(permission755);
if(!control_tar.Add(postinst, strGenWDIR.length(), ".")) if (!control_tar.Add(postinst, strGenWDIR.length(), ".")) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
cmCPackLogger(cmCPackLog::LOG_ERROR, << std::endl
"Error adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl
<< "#top level directory: "
<< strGenWDIR << std::endl
<< "#file: \"postinst\"" << std::endl << "#file: \"postinst\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl); << "#error:" << control_tar.GetError() << std::endl);
return 0; return 0;
@ -667,15 +596,12 @@ int cmCPackDebGenerator::createDeb()
control_tar.SetPermissions(permission644); control_tar.SetPermissions(permission644);
} }
if(this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) {
{
control_tar.SetPermissions(permission755); control_tar.SetPermissions(permission755);
if(!control_tar.Add(postrm, strGenWDIR.length(), ".")) if (!control_tar.Add(postrm, strGenWDIR.length(), ".")) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding file to tar:"
cmCPackLogger(cmCPackLog::LOG_ERROR, << std::endl
"Error adding file to tar:" << std::endl << "#top level directory: " << strGenWDIR << std::endl
<< "#top level directory: "
<< strGenWDIR << std::endl
<< "#file: \"postinst\"" << std::endl << "#file: \"postinst\"" << std::endl
<< "#error:" << control_tar.GetError() << std::endl); << "#error:" << control_tar.GetError() << std::endl);
return 0; return 0;
@ -688,16 +614,14 @@ int cmCPackDebGenerator::createDeb()
// -either a permission strictly defined by the Debian policies // -either a permission strictly defined by the Debian policies
const char* controlExtra = const char* controlExtra =
this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
if( controlExtra ) if (controlExtra) {
{
// permissions are now controlled by the original file permissions // permissions are now controlled by the original file permissions
const bool permissionStrictPolicy = const bool permissionStrictPolicy =
this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION"); this->IsSet("GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION");
static const char* strictFiles[] = { static const char* strictFiles[] = { "config", "postinst", "postrm",
"config", "postinst", "postrm", "preinst", "prerm" "preinst", "prerm" };
};
std::set<std::string> setStrictFiles( std::set<std::string> setStrictFiles(
strictFiles, strictFiles,
strictFiles + sizeof(strictFiles) / sizeof(strictFiles[0])); strictFiles + sizeof(strictFiles) / sizeof(strictFiles[0]));
@ -708,28 +632,24 @@ int cmCPackDebGenerator::createDeb()
std::vector<std::string> controlExtraList; std::vector<std::string> controlExtraList;
cmSystemTools::ExpandListArgument(controlExtra, controlExtraList); cmSystemTools::ExpandListArgument(controlExtra, controlExtraList);
for (std::vector<std::string>::iterator i = controlExtraList.begin(); for (std::vector<std::string>::iterator i = controlExtraList.begin();
i != controlExtraList.end(); ++i) i != controlExtraList.end(); ++i) {
{ std::string filenamename = cmsys::SystemTools::GetFilenameName(*i);
std::string filenamename =
cmsys::SystemTools::GetFilenameName(*i);
std::string localcopy = strGenWDIR + "/" + filenamename; std::string localcopy = strGenWDIR + "/" + filenamename;
if(permissionStrictPolicy) if (permissionStrictPolicy) {
{ control_tar.SetPermissions(setStrictFiles.count(filenamename)
control_tar.SetPermissions(setStrictFiles.count(filenamename) ? ? permission755
permission755 : permission644); : permission644);
} }
// if we can copy the file, it means it does exist, let's add it: // if we can copy the file, it means it does exist, let's add it:
if( cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy) ) if (cmsys::SystemTools::CopyFileIfDifferent(*i, localcopy)) {
{
control_tar.Add(localcopy, strGenWDIR.length(), "."); control_tar.Add(localcopy, strGenWDIR.length(), ".");
} }
} }
} }
} }
// ar -r your-package-name.deb debian-binary control.tar.* data.tar.* // ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
// since debian packages require BSD ar (most Linux distros and even // since debian packages require BSD ar (most Linux distros and even
// FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here. // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here.
@ -742,10 +662,9 @@ int cmCPackDebGenerator::createDeb()
outputFileName += "/"; outputFileName += "/";
outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME"); outputFileName += this->GetOption("GEN_CPACK_OUTPUT_FILE_NAME");
int res = ar_append(outputFileName.c_str(), arFiles); int res = ar_append(outputFileName.c_str(), arFiles);
if ( res!=0 ) if (res != 0) {
{ std::string tmpFile =
std::string tmpFile = this->GetOption( this->GetOption("GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME");
"GEN_CPACK_TEMPORARY_PACKAGE_FILE_NAME");
tmpFile += "/Deb.log"; tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str()); cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Problem creating archive using: " << res << std::endl; ofs << "# Problem creating archive using: " << res << std::endl;
@ -756,12 +675,9 @@ int cmCPackDebGenerator::createDeb()
bool cmCPackDebGenerator::SupportsComponentInstallation() const bool cmCPackDebGenerator::SupportsComponentInstallation() const
{ {
if (IsOn("CPACK_DEB_COMPONENT_INSTALL")) if (IsOn("CPACK_DEB_COMPONENT_INSTALL")) {
{
return true; return true;
} } else {
else
{
return false; return false;
} }
} }
@ -778,19 +694,15 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
} }
// We have to find the name of the COMPONENT GROUP // We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to. // the current COMPONENT belongs to.
std::string groupVar = "CPACK_COMPONENT_" + std::string groupVar =
cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (NULL != GetOption(groupVar)) if (NULL != GetOption(groupVar)) {
{
return std::string(GetOption(groupVar)); return std::string(GetOption(groupVar));
} } else {
else
{
return componentName; return componentName;
} }
} }
// The following code is taken from OpenBSD ar: // The following code is taken from OpenBSD ar:
// http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/ // http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/
// It has been slightly modified: // It has been slightly modified:
@ -850,7 +762,8 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
#define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s" #define HDR1 "%s%-13d%-12ld%-6u%-6u%-8o%-10lld%2s"
#define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s" #define HDR2 "%-16.16s%-12ld%-6u%-6u%-8o%-10lld%2s"
struct ar_hdr { struct ar_hdr
{
char ar_name[16]; /* name */ char ar_name[16]; /* name */
char ar_date[12]; /* modification time */ char ar_date[12]; /* modification time */
char ar_uid[6]; /* user id */ char ar_uid[6]; /* user id */
@ -861,7 +774,8 @@ struct ar_hdr {
}; };
/* Set up file copy. */ /* Set up file copy. */
#define SETCF(from, fromname, to, toname, pad) { \ #define SETCF(from, fromname, to, toname, pad) \
{ \
cf.rFile = from; \ cf.rFile = from; \
cf.rname = fromname; \ cf.rname = fromname; \
cf.wFile = to; \ cf.wFile = to; \
@ -870,7 +784,8 @@ struct ar_hdr {
} }
/* File copy structure. */ /* File copy structure. */
typedef struct { typedef struct
{
FILE* rFile; /* read file descriptor */ FILE* rFile; /* read file descriptor */
const char* rname; /* read name */ const char* rname; /* read name */
FILE* wFile; /* write file descriptor */ FILE* wFile; /* write file descriptor */
@ -922,8 +837,9 @@ static int copy_ar(CF *cfp, off_t size)
FILE* to = cfp->wFile; FILE* to = cfp->wFile;
while (sz && while (sz &&
(nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf)) (nr = fread(buf, 1, sz < static_cast<off_t>(sizeof(buf))
? static_cast<size_t>(sz) : sizeof(buf), from )) ? static_cast<size_t>(sz)
> 0) { : sizeof(buf),
from)) > 0) {
sz -= nr; sz -= nr;
for (size_t off = 0; off < nr; nr -= off, off += nw) for (size_t off = 0; off < nr; nr -= off, off += nw)
if ((nw = fwrite(buf + off, 1, nr, to)) < nr) if ((nw = fwrite(buf + off, 1, nr, to)) < nr)
@ -932,8 +848,8 @@ static int copy_ar(CF *cfp, off_t size)
if (sz) if (sz)
return -2; return -2;
if (cfp->flags & WPAD && (size + ar_already_written) & 1 if (cfp->flags & WPAD && (size + ar_already_written) & 1 &&
&& fwrite(&pad, 1, 1, to) != 1) fwrite(&pad, 1, 1, to) != 1)
return -4; return -4;
return 0; return 0;
@ -963,15 +879,13 @@ static int put_arobj(CF *cfp, struct stat *sb)
gid = USHRT_MAX; gid = USHRT_MAX;
} }
if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) if (lname > sizeof(hdr->ar_name) || strchr(name, ' '))
(void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime,
(long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, (unsigned)uid, (unsigned)gid, (unsigned)sb->st_mode,
(unsigned)sb->st_mode, (long long)sb->st_size + lname, (long long)sb->st_size + lname, ARFMAG);
ARFMAG);
else { else {
lname = 0; lname = 0;
(void)sprintf(ar_hb, HDR2, name, (void)sprintf(ar_hb, HDR2, name, (long int)sb->st_mtime, (unsigned)uid,
(long int)sb->st_mtime, (unsigned)uid, (unsigned)gid, (unsigned)gid, (unsigned)sb->st_mode, (long long)sb->st_size,
(unsigned)sb->st_mode, (long long)sb->st_size,
ARFMAG); ARFMAG);
} }
off_t size = sb->st_size; off_t size = sb->st_size;
@ -995,7 +909,8 @@ static int put_arobj(CF *cfp, struct stat *sb)
* Append files to the archive - modifies original archive or creates * Append files to the archive - modifies original archive or creates
* a new archive if named archive does not exist. * a new archive if named archive does not exist.
*/ */
static int ar_append(const char* archive,const std::vector<std::string>& files) static int ar_append(const char* archive,
const std::vector<std::string>& files)
{ {
int eval = 0; int eval = 0;
FILE* aFile = cmSystemTools::Fopen(archive, "wb+"); FILE* aFile = cmSystemTools::Fopen(archive, "wb+");
@ -1023,13 +938,11 @@ static int ar_append(const char* archive,const std::vector<std::string>& files)
break; break;
} }
} }
} } else {
else {
eval = -3; eval = -3;
} }
fclose(aFile); fclose(aFile);
} } else {
else {
eval = -4; eval = -4;
} }
return eval; return eval;

View File

@ -70,7 +70,6 @@ protected:
private: private:
int createDeb(); int createDeb();
std::vector<std::string> packageFiles; std::vector<std::string> packageFiles;
}; };
#endif #endif

View File

@ -80,68 +80,57 @@ int cmCPackDragNDropGenerator::InitializeInternal()
paths.push_back("/Applications/Xcode.app/Contents/Developer/Tools"); paths.push_back("/Applications/Xcode.app/Contents/Developer/Tools");
paths.push_back("/Developer/Tools"); paths.push_back("/Developer/Tools");
const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil", const std::string hdiutil_path =
std::vector<std::string>(), false); cmSystemTools::FindProgram("hdiutil", std::vector<std::string>(), false);
if(hdiutil_path.empty()) if (hdiutil_path.empty()) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate hdiutil command"
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot locate hdiutil command"
<< std::endl); << std::endl);
return 0; return 0;
} }
this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str()); this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str());
const std::string setfile_path = cmSystemTools::FindProgram("SetFile", const std::string setfile_path =
paths, false); cmSystemTools::FindProgram("SetFile", paths, false);
if(setfile_path.empty()) if (setfile_path.empty()) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate SetFile command"
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot locate SetFile command"
<< std::endl); << std::endl);
return 0; return 0;
} }
this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str()); this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str());
const std::string rez_path = cmSystemTools::FindProgram("Rez", const std::string rez_path = cmSystemTools::FindProgram("Rez", paths, false);
paths, false); if (rez_path.empty()) {
if(rez_path.empty()) cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot locate Rez command"
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot locate Rez command"
<< std::endl); << std::endl);
return 0; return 0;
} }
this->SetOptionIfNotSet("CPACK_COMMAND_REZ", rez_path.c_str()); this->SetOptionIfNotSet("CPACK_COMMAND_REZ", rez_path.c_str());
if(this->IsSet("CPACK_DMG_SLA_DIR")) if (this->IsSet("CPACK_DMG_SLA_DIR")) {
{
slaDirectory = this->GetOption("CPACK_DMG_SLA_DIR"); slaDirectory = this->GetOption("CPACK_DMG_SLA_DIR");
if(!slaDirectory.empty() && this->IsSet("CPACK_RESOURCE_FILE_LICENSE")) if (!slaDirectory.empty() && this->IsSet("CPACK_RESOURCE_FILE_LICENSE")) {
{
std::string license_file = std::string license_file =
this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); this->GetOption("CPACK_RESOURCE_FILE_LICENSE");
if (!license_file.empty() && if (!license_file.empty() &&
(license_file.find("CPack.GenericLicense.txt") == std::string::npos)) (license_file.find("CPack.GenericLicense.txt") ==
{ std::string::npos)) {
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(
cmCPackLog::LOG_OUTPUT,
"Both CPACK_DMG_SLA_DIR and CPACK_RESOURCE_FILE_LICENSE specified, " "Both CPACK_DMG_SLA_DIR and CPACK_RESOURCE_FILE_LICENSE specified, "
"using CPACK_RESOURCE_FILE_LICENSE as a license for all languages." "using CPACK_RESOURCE_FILE_LICENSE as a license for all languages."
<< std::endl); << std::endl);
singleLicense = true; singleLicense = true;
} }
} }
if(!this->IsSet("CPACK_DMG_SLA_LANGUAGES")) if (!this->IsSet("CPACK_DMG_SLA_LANGUAGES")) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_DMG_SLA_DIR set but no languages defined " "CPACK_DMG_SLA_DIR set but no languages defined "
"(set CPACK_DMG_SLA_LANGUAGES)" "(set CPACK_DMG_SLA_LANGUAGES)"
<< std::endl); << std::endl);
return 0; return 0;
} }
if(!cmSystemTools::FileExists(slaDirectory, false)) if (!cmSystemTools::FileExists(slaDirectory, false)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_DMG_SLA_DIR does not exist"
cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_DMG_SLA_DIR does not exist"
<< std::endl); << std::endl);
return 0; return 0;
} }
@ -149,29 +138,22 @@ int cmCPackDragNDropGenerator::InitializeInternal()
std::vector<std::string> languages; std::vector<std::string> languages;
cmSystemTools::ExpandListArgument( cmSystemTools::ExpandListArgument(
this->GetOption("CPACK_DMG_SLA_LANGUAGES"), languages); this->GetOption("CPACK_DMG_SLA_LANGUAGES"), languages);
if(languages.empty()) if (languages.empty()) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"CPACK_DMG_SLA_LANGUAGES set but empty" "CPACK_DMG_SLA_LANGUAGES set but empty" << std::endl);
<< std::endl);
return 0; return 0;
} }
for(size_t i = 0; i < languages.size(); ++i) for (size_t i = 0; i < languages.size(); ++i) {
{
std::string license = slaDirectory + "/" + languages[i] + ".license.txt"; std::string license = slaDirectory + "/" + languages[i] + ".license.txt";
if (!singleLicense && !cmSystemTools::FileExists(license)) if (!singleLicense && !cmSystemTools::FileExists(license)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing license file "
cmCPackLogger(cmCPackLog::LOG_ERROR, << languages[i] << ".license.txt" << std::endl);
"Missing license file " << languages[i] << ".license.txt"
<< std::endl);
return 0; return 0;
} }
std::string menu = slaDirectory + "/" + languages[i] + ".menu.txt"; std::string menu = slaDirectory + "/" + languages[i] + ".menu.txt";
if (!cmSystemTools::FileExists(menu)) if (!cmSystemTools::FileExists(menu)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Missing menu file "
cmCPackLogger(cmCPackLog::LOG_ERROR, << languages[i] << ".menu.txt" << std::endl);
"Missing menu file " << languages[i] << ".menu.txt"
<< std::endl);
return 0; return 0;
} }
} }
@ -191,8 +173,7 @@ int cmCPackDragNDropGenerator::PackageFiles()
// multiple directories occur if packaging components or groups separately // multiple directories occur if packaging components or groups separately
// monolith // monolith
if(this->Components.empty()) if (this->Components.empty()) {
{
return this->CreateDMG(toplevel, packageFileNames[0]); return this->CreateDMG(toplevel, packageFileNames[0]);
} }
@ -200,29 +181,22 @@ int cmCPackDragNDropGenerator::PackageFiles()
std::vector<std::string> package_files; std::vector<std::string> package_files;
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt=this->Components.begin(); for (compIt = this->Components.begin(); compIt != this->Components.end();
compIt!=this->Components.end(); ++compIt ) ++compIt) {
{
std::string name = GetComponentInstallDirNameSuffix(compIt->first); std::string name = GetComponentInstallDirNameSuffix(compIt->first);
package_files.push_back(name); package_files.push_back(name);
} }
std::sort(package_files.begin(), package_files.end()); std::sort(package_files.begin(), package_files.end());
package_files.erase(std::unique(package_files.begin(), package_files.erase(std::unique(package_files.begin(), package_files.end()),
package_files.end()),
package_files.end()); package_files.end());
// loop to create dmg files // loop to create dmg files
packageFileNames.clear(); packageFileNames.clear();
for(size_t i=0; i<package_files.size(); i++) for (size_t i = 0; i < package_files.size(); i++) {
{
std::string full_package_name = std::string(toplevel) + std::string("/"); std::string full_package_name = std::string(toplevel) + std::string("/");
if(package_files[i] == "ALL_IN_ONE") if (package_files[i] == "ALL_IN_ONE") {
{
full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME"); full_package_name += this->GetOption("CPACK_PACKAGE_FILE_NAME");
} } else {
else
{
full_package_name += package_files[i]; full_package_name += package_files[i];
} }
full_package_name += std::string(GetOutputExtension()); full_package_name += std::string(GetOutputExtension());
@ -232,8 +206,7 @@ int cmCPackDragNDropGenerator::PackageFiles()
src_dir += "/"; src_dir += "/";
src_dir += package_files[i]; src_dir += package_files[i];
if(0 == this->CreateDMG(src_dir, full_package_name)) if (0 == this->CreateDMG(src_dir, full_package_name)) {
{
return 0; return 0;
} }
} }
@ -243,16 +216,10 @@ int cmCPackDragNDropGenerator::PackageFiles()
bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source, bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
std::ostringstream& target) std::ostringstream& target)
{ {
if(!cmSystemTools::CopyFileIfDifferent( if (!cmSystemTools::CopyFileIfDifferent(source.str().c_str(),
source.str().c_str(), target.str().c_str())) {
target.str().c_str())) cmCPackLogger(cmCPackLog::LOG_ERROR, "Error copying "
{ << source.str() << " to " << target.str() << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error copying "
<< source.str()
<< " to "
<< target.str()
<< std::endl);
return false; return false;
} }
@ -263,14 +230,10 @@ bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target, bool cmCPackDragNDropGenerator::CreateEmptyFile(std::ostringstream& target,
size_t size) size_t size)
{ {
cmsys::ofstream fout(target.str().c_str(), cmsys::ofstream fout(target.str().c_str(), std::ios::out | std::ios::binary);
std::ios::out | std::ios::binary); if (!fout) {
if(!fout)
{
return false; return false;
} } else {
else
{
// Seek to desired size - 1 byte // Seek to desired size - 1 byte
fout.seekp(size - 1, std::ios_base::beg); fout.seekp(size - 1, std::ios_base::beg);
char byte = 0; char byte = 0;
@ -286,19 +249,12 @@ bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
{ {
int exit_code = 1; int exit_code = 1;
bool result = cmSystemTools::RunSingleCommand( bool result =
command.str().c_str(), cmSystemTools::RunSingleCommand(command.str().c_str(), output, output,
output, output, &exit_code, 0, this->GeneratorVerbose, 0);
&exit_code,
0,
this->GeneratorVerbose,
0);
if(!result || exit_code) if (!result || exit_code) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error executing: " << command.str()
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error executing: "
<< command.str()
<< std::endl); << std::endl);
return false; return false;
@ -312,49 +268,52 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
{ {
// Get optional arguments ... // Get optional arguments ...
const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON")
? this->GetOption("CPACK_PACKAGE_ICON") : ""; ? this->GetOption("CPACK_PACKAGE_ICON")
: "";
const std::string cpack_dmg_volume_name = const std::string cpack_dmg_volume_name =
this->GetOption("CPACK_DMG_VOLUME_NAME") this->GetOption("CPACK_DMG_VOLUME_NAME")
? this->GetOption("CPACK_DMG_VOLUME_NAME") ? this->GetOption("CPACK_DMG_VOLUME_NAME")
: this->GetOption("CPACK_PACKAGE_FILE_NAME"); : this->GetOption("CPACK_PACKAGE_FILE_NAME");
const std::string cpack_dmg_format = const std::string cpack_dmg_format = this->GetOption("CPACK_DMG_FORMAT")
this->GetOption("CPACK_DMG_FORMAT") ? this->GetOption("CPACK_DMG_FORMAT")
? this->GetOption("CPACK_DMG_FORMAT") : "UDZO"; : "UDZO";
// Get optional arguments ... // Get optional arguments ...
std::string cpack_license_file = std::string cpack_license_file =
this->GetOption("CPACK_RESOURCE_FILE_LICENSE") ? this->GetOption("CPACK_RESOURCE_FILE_LICENSE")
this->GetOption("CPACK_RESOURCE_FILE_LICENSE") : ""; ? this->GetOption("CPACK_RESOURCE_FILE_LICENSE")
: "";
const std::string cpack_dmg_background_image = const std::string cpack_dmg_background_image =
this->GetOption("CPACK_DMG_BACKGROUND_IMAGE") this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
? this->GetOption("CPACK_DMG_BACKGROUND_IMAGE") : ""; ? this->GetOption("CPACK_DMG_BACKGROUND_IMAGE")
: "";
const std::string cpack_dmg_ds_store = const std::string cpack_dmg_ds_store = this->GetOption("CPACK_DMG_DS_STORE")
this->GetOption("CPACK_DMG_DS_STORE") ? this->GetOption("CPACK_DMG_DS_STORE")
? this->GetOption("CPACK_DMG_DS_STORE") : ""; : "";
const std::string cpack_dmg_languages = const std::string cpack_dmg_languages =
this->GetOption("CPACK_DMG_SLA_LANGUAGES") this->GetOption("CPACK_DMG_SLA_LANGUAGES")
? this->GetOption("CPACK_DMG_SLA_LANGUAGES") : ""; ? this->GetOption("CPACK_DMG_SLA_LANGUAGES")
: "";
const std::string cpack_dmg_ds_store_setup_script = const std::string cpack_dmg_ds_store_setup_script =
this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT") this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
? this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT") : ""; ? this->GetOption("CPACK_DMG_DS_STORE_SETUP_SCRIPT")
: "";
// only put license on dmg if is user provided // only put license on dmg if is user provided
if (!cpack_license_file.empty() && if (!cpack_license_file.empty() &&
cpack_license_file.find("CPack.GenericLicense.txt") != std::string::npos) cpack_license_file.find("CPack.GenericLicense.txt") !=
{ std::string::npos) {
cpack_license_file = ""; cpack_license_file = "";
} }
// use sla_dir if both sla_dir and license_file are set // use sla_dir if both sla_dir and license_file are set
if(!cpack_license_file.empty() && if (!cpack_license_file.empty() && !slaDirectory.empty() && !singleLicense) {
!slaDirectory.empty() && !singleLicense)
{
cpack_license_file = ""; cpack_license_file = "";
} }
@ -371,16 +330,14 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
application_link.str().c_str()); application_link.str().c_str());
// Optionally add a custom volume icon ... // Optionally add a custom volume icon ...
if(!cpack_package_icon.empty()) if (!cpack_package_icon.empty()) {
{
std::ostringstream package_icon_source; std::ostringstream package_icon_source;
package_icon_source << cpack_package_icon; package_icon_source << cpack_package_icon;
std::ostringstream package_icon_destination; std::ostringstream package_icon_destination;
package_icon_destination << staging.str() << "/.VolumeIcon.icns"; package_icon_destination << staging.str() << "/.VolumeIcon.icns";
if(!this->CopyFile(package_icon_source, package_icon_destination)) if (!this->CopyFile(package_icon_source, package_icon_destination)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error copying disk volume icon. " "Error copying disk volume icon. "
"Check the value of CPACK_PACKAGE_ICON." "Check the value of CPACK_PACKAGE_ICON."
@ -392,16 +349,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Optionally add a custom .DS_Store file // Optionally add a custom .DS_Store file
// (e.g. for setting background/layout) ... // (e.g. for setting background/layout) ...
if(!cpack_dmg_ds_store.empty()) if (!cpack_dmg_ds_store.empty()) {
{
std::ostringstream package_settings_source; std::ostringstream package_settings_source;
package_settings_source << cpack_dmg_ds_store; package_settings_source << cpack_dmg_ds_store;
std::ostringstream package_settings_destination; std::ostringstream package_settings_destination;
package_settings_destination << staging.str() << "/.DS_Store"; package_settings_destination << staging.str() << "/.DS_Store";
if(!this->CopyFile(package_settings_source, package_settings_destination)) if (!this->CopyFile(package_settings_source,
{ package_settings_destination)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error copying disk volume settings file. " "Error copying disk volume settings file. "
"Check the value of CPACK_DMG_DS_STORE." "Check the value of CPACK_DMG_DS_STORE."
@ -414,8 +370,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Optionally add a custom background image ... // Optionally add a custom background image ...
// Make sure the background file type is the same as the custom image // Make sure the background file type is the same as the custom image
// and that the file is hidden so it doesn't show up. // and that the file is hidden so it doesn't show up.
if(!cpack_dmg_background_image.empty()) if (!cpack_dmg_background_image.empty()) {
{
const std::string extension = const std::string extension =
cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image); cmSystemTools::GetFilenameLastExtension(cpack_dmg_background_image);
std::ostringstream package_background_source; std::ostringstream package_background_source;
@ -426,8 +381,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
<< "/.background/background" << extension; << "/.background/background" << extension;
if (!this->CopyFile(package_background_source, if (!this->CopyFile(package_background_source,
package_background_destination)) package_background_destination)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error copying disk volume background image. " "Error copying disk volume background image. "
"Check the value of CPACK_DMG_BACKGROUND_IMAGE." "Check the value of CPACK_DMG_BACKGROUND_IMAGE."
@ -437,19 +391,16 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
} }
} }
bool remount_image = !cpack_package_icon.empty() || bool remount_image =
!cpack_dmg_ds_store_setup_script.empty(); !cpack_package_icon.empty() || !cpack_dmg_ds_store_setup_script.empty();
// Create 1 MB dummy padding file in staging area when we need to remount // Create 1 MB dummy padding file in staging area when we need to remount
// image, so we have enough space for storing changes ... // image, so we have enough space for storing changes ...
if(remount_image) if (remount_image) {
{
std::ostringstream dummy_padding; std::ostringstream dummy_padding;
dummy_padding << staging.str() << "/.dummy-padding-file"; dummy_padding << staging.str() << "/.dummy-padding-file";
if(!this->CreateEmptyFile(dummy_padding, 1048576)) if (!this->CreateEmptyFile(dummy_padding, 1048576)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error creating dummy padding file."
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error creating dummy padding file."
<< std::endl); << std::endl);
return 0; return 0;
@ -465,22 +416,18 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
temp_image_command << " create"; temp_image_command << " create";
temp_image_command << " -ov"; temp_image_command << " -ov";
temp_image_command << " -srcfolder \"" << staging.str() << "\""; temp_image_command << " -srcfolder \"" << staging.str() << "\"";
temp_image_command << " -volname \"" temp_image_command << " -volname \"" << cpack_dmg_volume_name << "\"";
<< cpack_dmg_volume_name << "\"";
temp_image_command << " -format UDRW"; temp_image_command << " -format UDRW";
temp_image_command << " \"" << temp_image << "\""; temp_image_command << " \"" << temp_image << "\"";
if(!this->RunCommand(temp_image_command)) if (!this->RunCommand(temp_image_command)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error generating temporary disk image." "Error generating temporary disk image." << std::endl);
<< std::endl);
return 0; return 0;
} }
if(remount_image) if (remount_image) {
{
// Store that we have a failure so that we always unmount the image // Store that we have a failure so that we always unmount the image
// before we exit. // before we exit.
bool had_error = false; bool had_error = false;
@ -491,11 +438,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
attach_command << " \"" << temp_image << "\""; attach_command << " \"" << temp_image << "\"";
std::string attach_output; std::string attach_output;
if(!this->RunCommand(attach_command, &attach_output)) if (!this->RunCommand(attach_command, &attach_output)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error attaching temporary disk image." "Error attaching temporary disk image." << std::endl);
<< std::endl);
return 0; return 0;
} }
@ -508,25 +453,21 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Remove dummy padding file so we have enough space on RW image ... // Remove dummy padding file so we have enough space on RW image ...
std::ostringstream dummy_padding; std::ostringstream dummy_padding;
dummy_padding << temp_mount.str() << "/.dummy-padding-file"; dummy_padding << temp_mount.str() << "/.dummy-padding-file";
if(!cmSystemTools::RemoveFile(dummy_padding.str())) if (!cmSystemTools::RemoveFile(dummy_padding.str())) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error removing dummy padding file."
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error removing dummy padding file."
<< std::endl); << std::endl);
had_error = true; had_error = true;
} }
// Optionally set the custom icon flag for the image ... // Optionally set the custom icon flag for the image ...
if(!had_error && !cpack_package_icon.empty()) if (!had_error && !cpack_package_icon.empty()) {
{
std::ostringstream setfile_command; std::ostringstream setfile_command;
setfile_command << this->GetOption("CPACK_COMMAND_SETFILE"); setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
setfile_command << " -a C"; setfile_command << " -a C";
setfile_command << " \"" << temp_mount.str() << "\""; setfile_command << " \"" << temp_mount.str() << "\"";
if(!this->RunCommand(setfile_command)) if (!this->RunCommand(setfile_command)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error assigning custom icon to temporary disk image." "Error assigning custom icon to temporary disk image."
<< std::endl); << std::endl);
@ -537,19 +478,17 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Optionally we can execute a custom apple script to generate // Optionally we can execute a custom apple script to generate
// the .DS_Store for the volume folder ... // the .DS_Store for the volume folder ...
if(!had_error && !cpack_dmg_ds_store_setup_script.empty()) if (!had_error && !cpack_dmg_ds_store_setup_script.empty()) {
{
std::ostringstream setup_script_command; std::ostringstream setup_script_command;
setup_script_command << "osascript" setup_script_command << "osascript"
<< " \"" << cpack_dmg_ds_store_setup_script << "\"" << " \"" << cpack_dmg_ds_store_setup_script << "\""
<< " \"" << cpack_dmg_volume_name << "\""; << " \"" << cpack_dmg_volume_name << "\"";
std::string error; std::string error;
if(!this->RunCommand(setup_script_command, &error)) if (!this->RunCommand(setup_script_command, &error)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error executing custom script on disk image." << std::endl "Error executing custom script on disk image."
<< error << std::endl
<< std::endl); << error << std::endl);
had_error = true; had_error = true;
} }
@ -560,43 +499,35 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
detach_command << " detach"; detach_command << " detach";
detach_command << " \"" << temp_mount.str() << "\""; detach_command << " \"" << temp_mount.str() << "\"";
if(!this->RunCommand(detach_command)) if (!this->RunCommand(detach_command)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error detaching temporary disk image." "Error detaching temporary disk image." << std::endl);
<< std::endl);
return 0; return 0;
} }
if(had_error) if (had_error) {
{
return 0; return 0;
} }
} }
if(!cpack_license_file.empty() || !slaDirectory.empty()) if (!cpack_license_file.empty() || !slaDirectory.empty()) {
{
// Use old hardcoded style if sla_dir is not set // Use old hardcoded style if sla_dir is not set
bool oldStyle = slaDirectory.empty(); bool oldStyle = slaDirectory.empty();
std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string sla_r = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
sla_r += "/sla.r"; sla_r += "/sla.r";
std::vector<std::string> languages; std::vector<std::string> languages;
if(!oldStyle) if (!oldStyle) {
{
cmSystemTools::ExpandListArgument(cpack_dmg_languages, languages); cmSystemTools::ExpandListArgument(cpack_dmg_languages, languages);
} }
cmGeneratedFileStream ofs(sla_r.c_str()); cmGeneratedFileStream ofs(sla_r.c_str());
ofs << "#include <CoreServices/CoreServices.r>\n\n"; ofs << "#include <CoreServices/CoreServices.r>\n\n";
if(oldStyle) if (oldStyle) {
{
ofs << SLAHeader; ofs << SLAHeader;
ofs << "\n"; ofs << "\n";
} } else {
else
{
/* /*
* LPic Layout * LPic Layout
* (https://github.com/pypt/dmg-add-license/blob/master/main.c) * (https://github.com/pypt/dmg-add-license/blob/master/main.c)
@ -619,18 +550,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::vector<uint16_t> header_data; std::vector<uint16_t> header_data;
header_data.push_back(0); header_data.push_back(0);
header_data.push_back(languages.size()); header_data.push_back(languages.size());
for(size_t i = 0; i < languages.size(); ++i) for (size_t i = 0; i < languages.size(); ++i) {
{
CFStringRef language_cfstring = CFStringCreateWithCString( CFStringRef language_cfstring = CFStringCreateWithCString(
NULL, languages[i].c_str(), kCFStringEncodingUTF8); NULL, languages[i].c_str(), kCFStringEncodingUTF8);
CFStringRef iso_language = CFStringRef iso_language =
CFLocaleCreateCanonicalLanguageIdentifierFromString( CFLocaleCreateCanonicalLanguageIdentifierFromString(
NULL, language_cfstring); NULL, language_cfstring);
if (!iso_language) if (!iso_language) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, languages[i]
cmCPackLogger(cmCPackLog::LOG_ERROR, << " is not a recognized language" << std::endl);
languages[i] << " is not a recognized language"
<< std::endl);
} }
char* iso_language_cstr = (char*)malloc(65); char* iso_language_cstr = (char*)malloc(65);
CFStringGetCString(iso_language, iso_language_cstr, 64, CFStringGetCString(iso_language, iso_language_cstr, 64,
@ -638,14 +566,14 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
LangCode lang = 0; LangCode lang = 0;
RegionCode region = 0; RegionCode region = 0;
#ifdef HAVE_CoreServices #ifdef HAVE_CoreServices
OSStatus err = LocaleStringToLangAndRegionCodes(iso_language_cstr, OSStatus err =
&lang, &region); LocaleStringToLangAndRegionCodes(iso_language_cstr, &lang, &region);
if (err != noErr) if (err != noErr)
#endif #endif
{ {
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"No language/region code available for " << iso_language_cstr "No language/region code available for "
<< std::endl); << iso_language_cstr << std::endl);
free(iso_language_cstr); free(iso_language_cstr);
return 0; return 0;
} }
@ -659,21 +587,16 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
ofs << "data 'LPic' (5000) {\n"; ofs << "data 'LPic' (5000) {\n";
ofs << std::hex << std::uppercase << std::setfill('0'); ofs << std::hex << std::uppercase << std::setfill('0');
for(size_t i = 0; i < header_data.size(); ++i) for (size_t i = 0; i < header_data.size(); ++i) {
{ if (i % 8 == 0) {
if(i % 8 == 0)
{
ofs << " $\""; ofs << " $\"";
} }
ofs << std::setw(4) << header_data[i]; ofs << std::setw(4) << header_data[i];
if(i % 8 == 7 || i == header_data.size() - 1) if (i % 8 == 7 || i == header_data.size() - 1) {
{
ofs << "\"\n"; ofs << "\"\n";
} } else {
else
{
ofs << " "; ofs << " ";
} }
} }
@ -685,29 +608,20 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
bool have_write_license_error = false; bool have_write_license_error = false;
std::string error; std::string error;
if(oldStyle) if (oldStyle) {
{ if (!this->WriteLicense(ofs, 0, "", cpack_license_file, &error)) {
if(!this->WriteLicense(ofs, 0, "", cpack_license_file, &error))
{
have_write_license_error = true; have_write_license_error = true;
} }
} } else {
else for (size_t i = 0; i < languages.size() && !have_write_license_error;
{ ++i) {
for(size_t i = 0; i < languages.size() && !have_write_license_error; ++i) if (singleLicense) {
{
if(singleLicense)
{
if (!this->WriteLicense(ofs, i + 5000, languages[i], if (!this->WriteLicense(ofs, i + 5000, languages[i],
cpack_license_file, &error)) cpack_license_file, &error)) {
{
have_write_license_error = true; have_write_license_error = true;
} }
} } else {
else if (!this->WriteLicense(ofs, i + 5000, languages[i], "", &error)) {
{
if(!this->WriteLicense(ofs, i + 5000, languages[i], "", &error))
{
have_write_license_error = true; have_write_license_error = true;
} }
} }
@ -716,12 +630,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
ofs.Close(); ofs.Close();
if(have_write_license_error) if (have_write_license_error) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error writing license file to SLA."
cmCPackLogger(cmCPackLog::LOG_ERROR, << std::endl
"Error writing license file to SLA." << std::endl << error << std::endl);
<< error
<< std::endl);
return 0; return 0;
} }
@ -735,12 +647,11 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
udco_image_command << " -format UDCO"; udco_image_command << " -format UDCO";
udco_image_command << " -ov -o \"" << temp_udco << "\""; udco_image_command << " -ov -o \"" << temp_udco << "\"";
if(!this->RunCommand(udco_image_command, &error)) if (!this->RunCommand(udco_image_command, &error)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error converting to UDCO dmg for adding SLA." << std::endl "Error converting to UDCO dmg for adding SLA."
<< error << std::endl
<< std::endl); << error << std::endl);
return 0; return 0;
} }
@ -750,8 +661,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
unflatten_command << " unflatten "; unflatten_command << " unflatten ";
unflatten_command << "\"" << temp_udco << "\""; unflatten_command << "\"" << temp_udco << "\"";
if(!this->RunCommand(unflatten_command, &error)) if (!this->RunCommand(unflatten_command, &error)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error unflattening dmg for adding SLA." << std::endl "Error unflattening dmg for adding SLA." << std::endl
<< error << error
@ -763,18 +673,15 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::ostringstream embed_sla_command; std::ostringstream embed_sla_command;
embed_sla_command << this->GetOption("CPACK_COMMAND_REZ"); embed_sla_command << this->GetOption("CPACK_COMMAND_REZ");
const char* sysroot = this->GetOption("CPACK_OSX_SYSROOT"); const char* sysroot = this->GetOption("CPACK_OSX_SYSROOT");
if(sysroot && sysroot[0] != '\0') if (sysroot && sysroot[0] != '\0') {
{
embed_sla_command << " -isysroot \"" << sysroot << "\""; embed_sla_command << " -isysroot \"" << sysroot << "\"";
} }
embed_sla_command << " \"" << sla_r << "\""; embed_sla_command << " \"" << sla_r << "\"";
embed_sla_command << " -a -o "; embed_sla_command << " -a -o ";
embed_sla_command << "\"" << temp_udco << "\""; embed_sla_command << "\"" << temp_udco << "\"";
if(!this->RunCommand(embed_sla_command, &error)) if (!this->RunCommand(embed_sla_command, &error)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error adding SLA." << std::endl
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error adding SLA." << std::endl
<< error << error
<< std::endl); << std::endl);
return 0; return 0;
@ -786,8 +693,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
flatten_command << " flatten "; flatten_command << " flatten ";
flatten_command << "\"" << temp_udco << "\""; flatten_command << "\"" << temp_udco << "\"";
if(!this->RunCommand(flatten_command, &error)) if (!this->RunCommand(flatten_command, &error)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error flattening dmg for adding SLA." << std::endl "Error flattening dmg for adding SLA." << std::endl
<< error << error
@ -798,7 +704,6 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
temp_image = temp_udco; temp_image = temp_udco;
} }
// Create the final compressed read-only disk image ... // Create the final compressed read-only disk image ...
std::ostringstream final_image_command; std::ostringstream final_image_command;
final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
@ -809,10 +714,8 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
final_image_command << " zlib-level=9"; final_image_command << " zlib-level=9";
final_image_command << " -o \"" << output_file << "\""; final_image_command << " -o \"" << output_file << "\"";
if(!this->RunCommand(final_image_command)) if (!this->RunCommand(final_image_command)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error compressing disk image."
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error compressing disk image."
<< std::endl); << std::endl);
return 0; return 0;
@ -826,8 +729,7 @@ bool cmCPackDragNDropGenerator::SupportsComponentInstallation() const
return true; return true;
} }
std::string std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
const std::string& componentName) const std::string& componentName)
{ {
// we want to group components together that go in the same dmg package // we want to group components together that go in the same dmg package
@ -840,24 +742,21 @@ cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
// 3. ignore groups - if grouping is defined, it is ignored // 3. ignore groups - if grouping is defined, it is ignored
// and each component goes in its own package // and each component goes in its own package
if(this->componentPackageMethod == ONE_PACKAGE) if (this->componentPackageMethod == ONE_PACKAGE) {
{
return "ALL_IN_ONE"; return "ALL_IN_ONE";
} }
if(this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) if (this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) {
{
// We have to find the name of the COMPONENT GROUP // We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to. // the current COMPONENT belongs to.
std::string groupVar = "CPACK_COMPONENT_" + std::string groupVar =
cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
const char* _groupName = GetOption(groupVar.c_str()); const char* _groupName = GetOption(groupVar.c_str());
if (_groupName) if (_groupName) {
{
std::string groupName = _groupName; std::string groupName = _groupName;
groupName = GetComponentPackageFileName(package_file_name, groupName =
groupName, true); GetComponentPackageFileName(package_file_name, groupName, true);
return groupName; return groupName;
} }
} }
@ -865,41 +764,35 @@ cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
return GetComponentPackageFileName(package_file_name, componentName, false); return GetComponentPackageFileName(package_file_name, componentName, false);
} }
bool bool cmCPackDragNDropGenerator::WriteLicense(
cmCPackDragNDropGenerator::WriteLicense(cmGeneratedFileStream& outputStream, cmGeneratedFileStream& outputStream, int licenseNumber,
int licenseNumber, std::string licenseLanguage, std::string licenseFile, std::string licenseLanguage, std::string licenseFile, std::string* error)
std::string *error)
{
if(!licenseFile.empty() && !singleLicense)
{ {
if (!licenseFile.empty() && !singleLicense) {
licenseNumber = 5002; licenseNumber = 5002;
licenseLanguage = "English"; licenseLanguage = "English";
} }
// License header // License header
outputStream << "data 'TEXT' (" << licenseNumber << ", \"" outputStream << "data 'TEXT' (" << licenseNumber << ", \"" << licenseLanguage
<< licenseLanguage << "\") {\n"; << "\") {\n";
// License body // License body
std::string actual_license = !licenseFile.empty() ? licenseFile : std::string actual_license = !licenseFile.empty()
(slaDirectory + "/" + licenseLanguage + ".license.txt"); ? licenseFile
: (slaDirectory + "/" + licenseLanguage + ".license.txt");
cmsys::ifstream license_ifs; cmsys::ifstream license_ifs;
license_ifs.open(actual_license.c_str()); license_ifs.open(actual_license.c_str());
if(license_ifs.is_open()) if (license_ifs.is_open()) {
{ while (license_ifs.good()) {
while(license_ifs.good())
{
std::string line; std::string line;
std::getline(license_ifs, line); std::getline(license_ifs, line);
if(!line.empty()) if (!line.empty()) {
{
EscapeQuotesAndBackslashes(line); EscapeQuotesAndBackslashes(line);
std::vector<std::string> lines; std::vector<std::string> lines;
if(!this->BreakLongLine(line, lines, error)) if (!this->BreakLongLine(line, lines, error)) {
{
return false; return false;
} }
for(size_t i = 0; i < lines.size(); ++i) for (size_t i = 0; i < lines.size(); ++i) {
{
outputStream << " \"" << lines[i] << "\"\n"; outputStream << " \"" << lines[i] << "\"\n";
} }
} }
@ -910,12 +803,9 @@ cmCPackDragNDropGenerator::WriteLicense(cmGeneratedFileStream& outputStream,
// End of License // End of License
outputStream << "};\n\n"; outputStream << "};\n\n";
if(!licenseFile.empty() && !singleLicense) if (!licenseFile.empty() && !singleLicense) {
{
outputStream << SLASTREnglish; outputStream << SLASTREnglish;
} } else {
else
{
// Menu header // Menu header
outputStream << "resource 'STR#' (" << licenseNumber << ", \"" outputStream << "resource 'STR#' (" << licenseNumber << ", \""
<< licenseLanguage << "\") {\n"; << licenseLanguage << "\") {\n";
@ -923,34 +813,27 @@ cmCPackDragNDropGenerator::WriteLicense(cmGeneratedFileStream& outputStream,
// Menu body // Menu body
cmsys::ifstream menu_ifs; cmsys::ifstream menu_ifs;
menu_ifs.open((slaDirectory+"/"+licenseLanguage+".menu.txt").c_str()); menu_ifs.open(
if(menu_ifs.is_open()) (slaDirectory + "/" + licenseLanguage + ".menu.txt").c_str());
{ if (menu_ifs.is_open()) {
size_t lines_written = 0; size_t lines_written = 0;
while(menu_ifs.good()) while (menu_ifs.good()) {
{
// Lines written from original file, not from broken up lines // Lines written from original file, not from broken up lines
std::string line; std::string line;
std::getline(menu_ifs, line); std::getline(menu_ifs, line);
if(!line.empty()) if (!line.empty()) {
{
EscapeQuotesAndBackslashes(line); EscapeQuotesAndBackslashes(line);
std::vector<std::string> lines; std::vector<std::string> lines;
if(!this->BreakLongLine(line, lines, error)) if (!this->BreakLongLine(line, lines, error)) {
{
return false; return false;
} }
for(size_t i = 0; i < lines.size(); ++i) for (size_t i = 0; i < lines.size(); ++i) {
{
std::string comma; std::string comma;
// We need a comma after every complete string, // We need a comma after every complete string,
// but not on the very last line // but not on the very last line
if(lines_written != 8 && i == lines.size() - 1) if (lines_written != 8 && i == lines.size() - 1) {
{
comma = ","; comma = ",";
} } else {
else
{
comma = ""; comma = "";
} }
outputStream << " \"" << lines[i] << "\"" << comma << "\n"; outputStream << " \"" << lines[i] << "\"" << comma << "\n";
@ -970,25 +853,21 @@ cmCPackDragNDropGenerator::WriteLicense(cmGeneratedFileStream& outputStream,
return true; return true;
} }
bool bool cmCPackDragNDropGenerator::BreakLongLine(const std::string& line,
cmCPackDragNDropGenerator::BreakLongLine(const std::string& line, std::vector<std::string>& lines,
std::vector<std::string>& lines, std::string *error) std::string* error)
{ {
const size_t max_line_length = 512; const size_t max_line_length = 512;
for(size_t i = 0; i < line.size(); i += max_line_length) for (size_t i = 0; i < line.size(); i += max_line_length) {
{
size_t line_length = max_line_length; size_t line_length = max_line_length;
if(i + line_length > line.size()) if (i + line_length > line.size()) {
{
line_length = line.size() - i; line_length = line.size() - i;
} } else
else while(line_length > 0 && line[i + line_length - 1] != ' ') while (line_length > 0 && line[i + line_length - 1] != ' ') {
{
line_length = line_length - 1; line_length = line_length - 1;
} }
if(line_length == 0) if (line_length == 0) {
{
*error = "Please make sure there are no words " *error = "Please make sure there are no words "
"(or character sequences not broken up by spaces or newlines) " "(or character sequences not broken up by spaces or newlines) "
"in your license file which are more than 512 characters long."; "in your license file which are more than 512 characters long.";
@ -999,19 +878,16 @@ cmCPackDragNDropGenerator::BreakLongLine(const std::string& line,
return true; return true;
} }
void void cmCPackDragNDropGenerator::EscapeQuotesAndBackslashes(std::string& line)
cmCPackDragNDropGenerator::EscapeQuotesAndBackslashes(std::string& line)
{ {
std::string::size_type backslash_pos = line.find('\\'); std::string::size_type backslash_pos = line.find('\\');
while(backslash_pos != std::string::npos) while (backslash_pos != std::string::npos) {
{
line.replace(backslash_pos, 1, "\\\\"); line.replace(backslash_pos, 1, "\\\\");
backslash_pos = line.find('\\', backslash_pos + 2); backslash_pos = line.find('\\', backslash_pos + 2);
} }
std::string::size_type quote_pos = line.find('\"'); std::string::size_type quote_pos = line.find('\"');
while(quote_pos != std::string::npos) while (quote_pos != std::string::npos) {
{
line.replace(quote_pos, 1, "\\\""); line.replace(quote_pos, 1, "\\\"");
quote_pos = line.find('\"', quote_pos + 2); quote_pos = line.find('\"', quote_pos + 2);
} }

View File

@ -34,13 +34,12 @@ protected:
int PackageFiles(); int PackageFiles();
bool SupportsComponentInstallation() const; bool SupportsComponentInstallation() const;
bool CopyFile(std::ostringstream& source, std::ostringstream& target); bool CopyFile(std::ostringstream& source, std::ostringstream& target);
bool CreateEmptyFile(std::ostringstream& target, size_t size); bool CreateEmptyFile(std::ostringstream& target, size_t size);
bool RunCommand(std::ostringstream& command, std::string* output = 0); bool RunCommand(std::ostringstream& command, std::string* output = 0);
std::string std::string GetComponentInstallDirNameSuffix(
GetComponentInstallDirNameSuffix(const std::string& componentName); const std::string& componentName);
int CreateDMG(const std::string& src_dir, const std::string& output_file); int CreateDMG(const std::string& src_dir, const std::string& output_file);
@ -53,8 +52,7 @@ private:
bool WriteLicense(cmGeneratedFileStream& outputStream, int licenseNumber, bool WriteLicense(cmGeneratedFileStream& outputStream, int licenseNumber,
std::string licenseLanguage, std::string licenseFile, std::string licenseLanguage, std::string licenseFile,
std::string* error); std::string* error);
bool BreakLongLine(const std::string& line, bool BreakLongLine(const std::string& line, std::vector<std::string>& lines,
std::vector<std::string>& lines,
std::string* error); std::string* error);
void EscapeQuotesAndBackslashes(std::string& line); void EscapeQuotesAndBackslashes(std::string& line);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -62,8 +62,10 @@ public:
* If verbose then more information is printed out * If verbose then more information is printed out
*/ */
void SetVerbose(bool val) void SetVerbose(bool val)
{ this->GeneratorVerbose = val ? {
cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; } this->GeneratorVerbose =
val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
}
/** /**
* Returns true if the generator may work on this system. * Returns true if the generator may work on this system.
@ -170,8 +172,7 @@ protected:
*/ */
virtual std::string GetComponentPackageFileName( virtual std::string GetComponentPackageFileName(
const std::string& initialPackageFileName, const std::string& initialPackageFileName,
const std::string& groupOrComponentName, const std::string& groupOrComponentName, bool isGroupName);
bool isGroupName);
/** /**
* Package the list of files and/or components which * Package the list of files and/or components which
@ -192,7 +193,6 @@ protected:
virtual bool ConfigureString(const std::string& input, std::string& output); virtual bool ConfigureString(const std::string& input, std::string& output);
virtual int InitializeInternal(); virtual int InitializeInternal();
//! Run install commands if specified //! Run install commands if specified
virtual int InstallProjectViaInstallCommands( virtual int InstallProjectViaInstallCommands(
bool setDestDir, const std::string& tempInstallDirectory); bool setDestDir, const std::string& tempInstallDirectory);
@ -207,7 +207,8 @@ protected:
* The various level of support of * The various level of support of
* CPACK_SET_DESTDIR used by the generator. * CPACK_SET_DESTDIR used by the generator.
*/ */
enum CPackSetDestdirSupport { enum CPackSetDestdirSupport
{
/* the generator works with or without it */ /* the generator works with or without it */
SETDESTDIR_SUPPORTED, SETDESTDIR_SUPPORTED,
/* the generator works best if automatically handled */ /* the generator works best if automatically handled */
@ -251,13 +252,11 @@ protected:
*/ */
virtual bool WantsComponentInstallation() const; virtual bool WantsComponentInstallation() const;
virtual cmCPackInstallationType* GetInstallationType( virtual cmCPackInstallationType* GetInstallationType(
const std::string& projectName, const std::string& projectName, const std::string& name);
const std::string& name);
virtual cmCPackComponent* GetComponent(const std::string& projectName, virtual cmCPackComponent* GetComponent(const std::string& projectName,
const std::string& name); const std::string& name);
virtual cmCPackComponentGroup* GetComponentGroup( virtual cmCPackComponentGroup* GetComponentGroup(
const std::string& projectName, const std::string& projectName, const std::string& name);
const std::string& name);
cmSystemTools::OutputOption GeneratorVerbose; cmSystemTools::OutputOption GeneratorVerbose;
std::string Name; std::string Name;
@ -324,6 +323,7 @@ protected:
ComponentPackageMethod componentPackageMethod; ComponentPackageMethod componentPackageMethod;
cmCPackLog* Logger; cmCPackLog* Logger;
private: private:
cmMakefile* MakefileMap; cmMakefile* MakefileMap;
}; };

View File

@ -35,8 +35,8 @@
#include "cmCPackCygwinSourceGenerator.h" #include "cmCPackCygwinSourceGenerator.h"
#endif #endif
#if !defined(_WIN32) \ #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \
&& !defined(__QNXNTO__) && !defined(__BEOS__) && !defined(__HAIKU__) !defined(__HAIKU__)
#include "cmCPackDebGenerator.h" #include "cmCPackDebGenerator.h"
#include "cmCPackRPMGenerator.h" #include "cmCPackRPMGenerator.h"
#endif #endif
@ -48,107 +48,88 @@
#include "cmAlgorithms.h" #include "cmAlgorithms.h"
#include "cmCPackLog.h" #include "cmCPackLog.h"
cmCPackGeneratorFactory::cmCPackGeneratorFactory() cmCPackGeneratorFactory::cmCPackGeneratorFactory()
{ {
if (cmCPackTGZGenerator::CanGenerate()) if (cmCPackTGZGenerator::CanGenerate()) {
{
this->RegisterGenerator("TGZ", "Tar GZip compression", this->RegisterGenerator("TGZ", "Tar GZip compression",
cmCPackTGZGenerator::CreateGenerator); cmCPackTGZGenerator::CreateGenerator);
} }
if (cmCPackTXZGenerator::CanGenerate()) if (cmCPackTXZGenerator::CanGenerate()) {
{
this->RegisterGenerator("TXZ", "Tar XZ compression", this->RegisterGenerator("TXZ", "Tar XZ compression",
cmCPackTXZGenerator::CreateGenerator); cmCPackTXZGenerator::CreateGenerator);
} }
if (cmCPackSTGZGenerator::CanGenerate()) if (cmCPackSTGZGenerator::CanGenerate()) {
{
this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression", this->RegisterGenerator("STGZ", "Self extracting Tar GZip compression",
cmCPackSTGZGenerator::CreateGenerator); cmCPackSTGZGenerator::CreateGenerator);
} }
if (cmCPackNSISGenerator::CanGenerate()) if (cmCPackNSISGenerator::CanGenerate()) {
{
this->RegisterGenerator("NSIS", "Null Soft Installer", this->RegisterGenerator("NSIS", "Null Soft Installer",
cmCPackNSISGenerator::CreateGenerator); cmCPackNSISGenerator::CreateGenerator);
this->RegisterGenerator("NSIS64", "Null Soft Installer (64-bit)", this->RegisterGenerator("NSIS64", "Null Soft Installer (64-bit)",
cmCPackNSISGenerator::CreateGenerator64); cmCPackNSISGenerator::CreateGenerator64);
} }
if (cmCPackIFWGenerator::CanGenerate()) if (cmCPackIFWGenerator::CanGenerate()) {
{
this->RegisterGenerator("IFW", "Qt Installer Framework", this->RegisterGenerator("IFW", "Qt Installer Framework",
cmCPackIFWGenerator::CreateGenerator); cmCPackIFWGenerator::CreateGenerator);
} }
#ifdef __CYGWIN__ #ifdef __CYGWIN__
if (cmCPackCygwinBinaryGenerator::CanGenerate()) if (cmCPackCygwinBinaryGenerator::CanGenerate()) {
{
this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer", this->RegisterGenerator("CygwinBinary", "Cygwin Binary Installer",
cmCPackCygwinBinaryGenerator::CreateGenerator); cmCPackCygwinBinaryGenerator::CreateGenerator);
} }
if (cmCPackCygwinSourceGenerator::CanGenerate()) if (cmCPackCygwinSourceGenerator::CanGenerate()) {
{
this->RegisterGenerator("CygwinSource", "Cygwin Source Installer", this->RegisterGenerator("CygwinSource", "Cygwin Source Installer",
cmCPackCygwinSourceGenerator::CreateGenerator); cmCPackCygwinSourceGenerator::CreateGenerator);
} }
#endif #endif
if (cmCPackZIPGenerator::CanGenerate()) if (cmCPackZIPGenerator::CanGenerate()) {
{
this->RegisterGenerator("ZIP", "ZIP file format", this->RegisterGenerator("ZIP", "ZIP file format",
cmCPackZIPGenerator::CreateGenerator); cmCPackZIPGenerator::CreateGenerator);
} }
if (cmCPack7zGenerator::CanGenerate()) if (cmCPack7zGenerator::CanGenerate()) {
{
this->RegisterGenerator("7Z", "7-Zip file format", this->RegisterGenerator("7Z", "7-Zip file format",
cmCPack7zGenerator::CreateGenerator); cmCPack7zGenerator::CreateGenerator);
} }
#ifdef _WIN32 #ifdef _WIN32
if (cmCPackWIXGenerator::CanGenerate()) if (cmCPackWIXGenerator::CanGenerate()) {
{
this->RegisterGenerator("WIX", "MSI file format via WiX tools", this->RegisterGenerator("WIX", "MSI file format via WiX tools",
cmCPackWIXGenerator::CreateGenerator); cmCPackWIXGenerator::CreateGenerator);
} }
#endif #endif
if (cmCPackTarBZip2Generator::CanGenerate()) if (cmCPackTarBZip2Generator::CanGenerate()) {
{
this->RegisterGenerator("TBZ2", "Tar BZip2 compression", this->RegisterGenerator("TBZ2", "Tar BZip2 compression",
cmCPackTarBZip2Generator::CreateGenerator); cmCPackTarBZip2Generator::CreateGenerator);
} }
if (cmCPackTarCompressGenerator::CanGenerate()) if (cmCPackTarCompressGenerator::CanGenerate()) {
{
this->RegisterGenerator("TZ", "Tar Compress compression", this->RegisterGenerator("TZ", "Tar Compress compression",
cmCPackTarCompressGenerator::CreateGenerator); cmCPackTarCompressGenerator::CreateGenerator);
} }
#ifdef __APPLE__ #ifdef __APPLE__
if (cmCPackDragNDropGenerator::CanGenerate()) if (cmCPackDragNDropGenerator::CanGenerate()) {
{
this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop", this->RegisterGenerator("DragNDrop", "Mac OSX Drag And Drop",
cmCPackDragNDropGenerator::CreateGenerator); cmCPackDragNDropGenerator::CreateGenerator);
} }
if (cmCPackBundleGenerator::CanGenerate()) if (cmCPackBundleGenerator::CanGenerate()) {
{
this->RegisterGenerator("Bundle", "Mac OSX bundle", this->RegisterGenerator("Bundle", "Mac OSX bundle",
cmCPackBundleGenerator::CreateGenerator); cmCPackBundleGenerator::CreateGenerator);
} }
if (cmCPackPackageMakerGenerator::CanGenerate()) if (cmCPackPackageMakerGenerator::CanGenerate()) {
{
this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer", this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer",
cmCPackPackageMakerGenerator::CreateGenerator); cmCPackPackageMakerGenerator::CreateGenerator);
} }
if (cmCPackOSXX11Generator::CanGenerate()) if (cmCPackOSXX11Generator::CanGenerate()) {
{
this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle", this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle",
cmCPackOSXX11Generator::CreateGenerator); cmCPackOSXX11Generator::CreateGenerator);
} }
#endif #endif
#if !defined(_WIN32) \ #if !defined(_WIN32) && !defined(__QNXNTO__) && !defined(__BEOS__) && \
&& !defined(__QNXNTO__) && !defined(__BEOS__) && !defined(__HAIKU__) !defined(__HAIKU__)
if (cmCPackDebGenerator::CanGenerate()) if (cmCPackDebGenerator::CanGenerate()) {
{
this->RegisterGenerator("DEB", "Debian packages", this->RegisterGenerator("DEB", "Debian packages",
cmCPackDebGenerator::CreateGenerator); cmCPackDebGenerator::CreateGenerator);
} }
if (cmCPackRPMGenerator::CanGenerate()) if (cmCPackRPMGenerator::CanGenerate()) {
{
this->RegisterGenerator("RPM", "RPM packages", this->RegisterGenerator("RPM", "RPM packages",
cmCPackRPMGenerator::CreateGenerator); cmCPackRPMGenerator::CreateGenerator);
} }
@ -164,8 +145,7 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
const std::string& name) const std::string& name)
{ {
cmCPackGenerator* gen = this->NewGeneratorInternal(name); cmCPackGenerator* gen = this->NewGeneratorInternal(name);
if ( !gen ) if (!gen) {
{
return 0; return 0;
} }
this->Generators.push_back(gen); this->Generators.push_back(gen);
@ -176,21 +156,19 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal( cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
const std::string& name) const std::string& name)
{ {
cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it =
= this->GeneratorCreators.find(name); this->GeneratorCreators.find(name);
if ( it == this->GeneratorCreators.end() ) if (it == this->GeneratorCreators.end()) {
{
return 0; return 0;
} }
return (it->second)(); return (it->second)();
} }
void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name, void cmCPackGeneratorFactory::RegisterGenerator(
const char* generatorDescription, const std::string& name, const char* generatorDescription,
CreateGeneratorCall* createGenerator) CreateGeneratorCall* createGenerator)
{ {
if ( !createGenerator ) if (!createGenerator) {
{
cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR, cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR,
"Cannot register generator" << std::endl); "Cannot register generator" << std::endl);
return; return;

View File

@ -44,7 +44,9 @@ public:
typedef std::map<std::string, std::string> DescriptionsMap; typedef std::map<std::string, std::string> DescriptionsMap;
const DescriptionsMap& GetGeneratorsList() const const DescriptionsMap& GetGeneratorsList() const
{ return this->GeneratorDescriptions; } {
return this->GeneratorDescriptions;
}
private: private:
cmCPackGenerator* NewGeneratorInternal(const std::string& name); cmCPackGenerator* NewGeneratorInternal(const std::string& name);

View File

@ -39,8 +39,7 @@ cmCPackLog::~cmCPackLog()
void cmCPackLog::SetLogOutputStream(std::ostream* os) void cmCPackLog::SetLogOutputStream(std::ostream* os)
{ {
if ( this->LogOutputCleanup && this->LogOutput ) if (this->LogOutputCleanup && this->LogOutput) {
{
delete this->LogOutput; delete this->LogOutput;
} }
this->LogOutputCleanup = false; this->LogOutputCleanup = false;
@ -50,26 +49,23 @@ void cmCPackLog::SetLogOutputStream(std::ostream* os)
bool cmCPackLog::SetLogOutputFile(const char* fname) bool cmCPackLog::SetLogOutputFile(const char* fname)
{ {
cmGeneratedFileStream* cg = 0; cmGeneratedFileStream* cg = 0;
if ( fname ) if (fname) {
{
cg = new cmGeneratedFileStream(fname); cg = new cmGeneratedFileStream(fname);
} }
if ( cg && !*cg ) if (cg && !*cg) {
{
delete cg; delete cg;
cg = 0; cg = 0;
} }
this->SetLogOutputStream(cg); this->SetLogOutputStream(cg);
if ( !cg ) if (!cg) {
{
return false; return false;
} }
this->LogOutputCleanup = true; this->LogOutputCleanup = true;
return true; return true;
} }
void cmCPackLog::Log(int tag, const char* file, int line, void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,
const char* msg, size_t length) size_t length)
{ {
// By default no logging // By default no logging
bool display = false; bool display = false;
@ -86,135 +82,109 @@ void cmCPackLog::Log(int tag, const char* file, int line,
// When writing in file, add list of tags whenever tag changes. // When writing in file, add list of tags whenever tag changes.
std::string tagString; std::string tagString;
bool needTagString = false; bool needTagString = false;
if ( this->LogOutput && this->LastTag != tag ) if (this->LogOutput && this->LastTag != tag) {
{
needTagString = true; needTagString = true;
} }
if ( tag & LOG_OUTPUT ) if (tag & LOG_OUTPUT) {
{
output = true; output = true;
display = true; display = true;
if ( needTagString ) if (needTagString) {
{ if (!tagString.empty()) {
if (!tagString.empty()) { tagString += ","; } tagString += ",";
}
tagString = "VERBOSE"; tagString = "VERBOSE";
} }
} }
if ( tag & LOG_WARNING ) if (tag & LOG_WARNING) {
{
warning = true; warning = true;
display = true; display = true;
if ( needTagString ) if (needTagString) {
{ if (!tagString.empty()) {
if (!tagString.empty()) { tagString += ","; } tagString += ",";
}
tagString = "WARNING"; tagString = "WARNING";
} }
} }
if ( tag & LOG_ERROR ) if (tag & LOG_ERROR) {
{
error = true; error = true;
display = true; display = true;
if ( needTagString ) if (needTagString) {
{ if (!tagString.empty()) {
if (!tagString.empty()) { tagString += ","; } tagString += ",";
}
tagString = "ERROR"; tagString = "ERROR";
} }
} }
if ( tag & LOG_DEBUG && this->Debug ) if (tag & LOG_DEBUG && this->Debug) {
{
debug = true; debug = true;
display = true; display = true;
if ( needTagString ) if (needTagString) {
{ if (!tagString.empty()) {
if (!tagString.empty()) { tagString += ","; } tagString += ",";
}
tagString = "DEBUG"; tagString = "DEBUG";
} }
useFileAndLine = true; useFileAndLine = true;
} }
if ( tag & LOG_VERBOSE && this->Verbose ) if (tag & LOG_VERBOSE && this->Verbose) {
{
verbose = true; verbose = true;
display = true; display = true;
if ( needTagString ) if (needTagString) {
{ if (!tagString.empty()) {
if (!tagString.empty()) { tagString += ","; } tagString += ",";
}
tagString = "VERBOSE"; tagString = "VERBOSE";
} }
} }
if ( this->Quiet ) if (this->Quiet) {
{
display = false; display = false;
} }
if ( this->LogOutput ) if (this->LogOutput) {
{ if (needTagString) {
if ( needTagString ) *this->LogOutput << "[" << file << ":" << line << " " << tagString
{ << "] ";
*this->LogOutput << "[" << file << ":" << line << " "
<< tagString << "] ";
} }
this->LogOutput->write(msg, length); this->LogOutput->write(msg, length);
} }
this->LastTag = tag; this->LastTag = tag;
if ( !display ) if (!display) {
{
return; return;
} }
if ( this->NewLine ) if (this->NewLine) {
{ if (error && !this->ErrorPrefix.empty()) {
if ( error && !this->ErrorPrefix.empty() )
{
*this->DefaultError << this->ErrorPrefix; *this->DefaultError << this->ErrorPrefix;
} } else if (warning && !this->WarningPrefix.empty()) {
else if ( warning && !this->WarningPrefix.empty() )
{
*this->DefaultError << this->WarningPrefix; *this->DefaultError << this->WarningPrefix;
} } else if (output && !this->OutputPrefix.empty()) {
else if ( output && !this->OutputPrefix.empty() )
{
*this->DefaultOutput << this->OutputPrefix; *this->DefaultOutput << this->OutputPrefix;
} } else if (verbose && !this->VerbosePrefix.empty()) {
else if ( verbose && !this->VerbosePrefix.empty() )
{
*this->DefaultOutput << this->VerbosePrefix; *this->DefaultOutput << this->VerbosePrefix;
} } else if (debug && !this->DebugPrefix.empty()) {
else if ( debug && !this->DebugPrefix.empty() )
{
*this->DefaultOutput << this->DebugPrefix; *this->DefaultOutput << this->DebugPrefix;
} } else if (!this->Prefix.empty()) {
else if ( !this->Prefix.empty() )
{
*this->DefaultOutput << this->Prefix; *this->DefaultOutput << this->Prefix;
} }
if ( useFileAndLine ) if (useFileAndLine) {
{ if (error || warning) {
if ( error || warning )
{
*this->DefaultError << file << ":" << line << " "; *this->DefaultError << file << ":" << line << " ";
} } else {
else
{
*this->DefaultOutput << file << ":" << line << " "; *this->DefaultOutput << file << ":" << line << " ";
} }
} }
} }
if ( error || warning ) if (error || warning) {
{
this->DefaultError->write(msg, length); this->DefaultError->write(msg, length);
this->DefaultError->flush(); this->DefaultError->flush();
} } else {
else
{
this->DefaultOutput->write(msg, length); this->DefaultOutput->write(msg, length);
this->DefaultOutput->flush(); this->DefaultOutput->flush();
} }
if ( msg[length-1] == '\n' || length > 2 ) if (msg[length - 1] == '\n' || length > 2) {
{
this->NewLine = true; this->NewLine = true;
} }
if ( error ) if (error) {
{
cmSystemTools::SetErrorOccured(); cmSystemTools::SetErrorOccured();
} }
} }

View File

@ -32,7 +32,6 @@
#endif #endif
#define cout no_cout_use_cmCPack_Log #define cout no_cout_use_cmCPack_Log
/** \class cmCPackLog /** \class cmCPackLog
* \brief A container for CPack generators * \brief A container for CPack generators
* *
@ -45,7 +44,8 @@ public:
cmCPackLog(); cmCPackLog();
~cmCPackLog(); ~cmCPackLog();
enum __log_tags { enum __log_tags
{
NOTAG = 0, NOTAG = 0,
LOG_OUTPUT = 0x1, LOG_OUTPUT = 0x1,
LOG_VERBOSE = 0x2, LOG_VERBOSE = 0x2,
@ -139,7 +139,10 @@ class cmCPackLogWrite
{ {
public: public:
cmCPackLogWrite(const char* data, size_t length) cmCPackLogWrite(const char* data, size_t length)
: Data(data), Length(length) {} : Data(data)
, Length(length)
{
}
const char* Data; const char* Data;
size_t Length; size_t Length;

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,9 @@ public:
cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenerator); cmCPackTypeMacro(cmCPackNSISGenerator, cmCPackGenerator);
static cmCPackGenerator* CreateGenerator64() static cmCPackGenerator* CreateGenerator64()
{ return new cmCPackNSISGenerator(true); } {
return new cmCPackNSISGenerator(true);
}
/** /**
* Construct generator * Construct generator
@ -38,8 +40,7 @@ public:
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
void CreateMenuLinks( std::ostringstream& str, void CreateMenuLinks(std::ostringstream& str, std::ostringstream& deleteStr);
std::ostringstream& deleteStr);
int PackageFiles(); int PackageFiles();
virtual const char* GetOutputExtension() { return ".exe"; } virtual const char* GetOutputExtension() { return ".exe"; }
virtual const char* GetOutputPostfix() { return "win32"; } virtual const char* GetOutputPostfix() { return "win32"; }
@ -54,27 +55,23 @@ protected:
/// Produce a string that contains the NSIS code to describe a /// Produce a string that contains the NSIS code to describe a
/// particular component. Any added macros will be emitted via /// particular component. Any added macros will be emitted via
/// macrosOut. /// macrosOut.
std::string std::string CreateComponentDescription(cmCPackComponent* component,
CreateComponentDescription(cmCPackComponent *component,
std::ostringstream& macrosOut); std::ostringstream& macrosOut);
/// Produce NSIS code that selects all of the components that this component /// Produce NSIS code that selects all of the components that this component
/// depends on, recursively. /// depends on, recursively.
std::string CreateSelectionDependenciesDescription std::string CreateSelectionDependenciesDescription(
(cmCPackComponent *component, cmCPackComponent* component, std::set<cmCPackComponent*>& visited);
std::set<cmCPackComponent *>& visited);
/// Produce NSIS code that de-selects all of the components that are /// Produce NSIS code that de-selects all of the components that are
/// dependent on this component, recursively. /// dependent on this component, recursively.
std::string CreateDeselectionDependenciesDescription std::string CreateDeselectionDependenciesDescription(
(cmCPackComponent *component, cmCPackComponent* component, std::set<cmCPackComponent*>& visited);
std::set<cmCPackComponent *>& visited);
/// Produce a string that contains the NSIS code to describe a /// Produce a string that contains the NSIS code to describe a
/// particular component group, including its components. Any /// particular component group, including its components. Any
/// added macros will be emitted via macrosOut. /// added macros will be emitted via macrosOut.
std::string std::string CreateComponentGroupDescription(cmCPackComponentGroup* group,
CreateComponentGroupDescription(cmCPackComponentGroup *group,
std::ostringstream& macrosOut); std::ostringstream& macrosOut);
/// Translations any newlines found in the string into \\r\\n, so that the /// Translations any newlines found in the string into \\r\\n, so that the

View File

@ -36,10 +36,9 @@ int cmCPackOSXX11Generator::PackageFiles()
// TODO: Use toplevel ? // TODO: Use toplevel ?
// It is used! Is this an obsolete comment? // It is used! Is this an obsolete comment?
const char* cpackPackageExecutables const char* cpackPackageExecutables =
= this->GetOption("CPACK_PACKAGE_EXECUTABLES"); this->GetOption("CPACK_PACKAGE_EXECUTABLES");
if ( cpackPackageExecutables ) if (cpackPackageExecutables) {
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
<< cpackPackageExecutables << "." << std::endl); << cpackPackageExecutables << "." << std::endl);
std::ostringstream str; std::ostringstream str;
@ -47,18 +46,17 @@ int cmCPackOSXX11Generator::PackageFiles()
std::vector<std::string> cpackPackageExecutablesVector; std::vector<std::string> cpackPackageExecutablesVector;
cmSystemTools::ExpandListArgument(cpackPackageExecutables, cmSystemTools::ExpandListArgument(cpackPackageExecutables,
cpackPackageExecutablesVector); cpackPackageExecutablesVector);
if ( cpackPackageExecutablesVector.size() % 2 != 0 ) if (cpackPackageExecutablesVector.size() % 2 != 0) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLog::LOG_ERROR,
"CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and " "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
"<icon name>." << std::endl); "<icon name>."
<< std::endl);
return 0; return 0;
} }
std::vector<std::string>::iterator it; std::vector<std::string>::iterator it;
for (it = cpackPackageExecutablesVector.begin(); for (it = cpackPackageExecutablesVector.begin();
it != cpackPackageExecutablesVector.end(); it != cpackPackageExecutablesVector.end(); ++it) {
++it )
{
std::string cpackExecutableName = *it; std::string cpackExecutableName = *it;
++it; ++it;
this->SetOptionIfNotSet("CPACK_EXECUTABLE_NAME", this->SetOptionIfNotSet("CPACK_EXECUTABLE_NAME",
@ -68,9 +66,8 @@ int cmCPackOSXX11Generator::PackageFiles()
// Disk image directories // Disk image directories
std::string diskImageDirectory = toplevel; std::string diskImageDirectory = toplevel;
std::string diskImageBackgroundImageDir std::string diskImageBackgroundImageDir =
= diskImageDirectory + "/.background"; diskImageDirectory + "/.background";
// App bundle directories // App bundle directories
std::string packageDirFileName = toplevel; std::string packageDirFileName = toplevel;
@ -90,14 +87,12 @@ int cmCPackOSXX11Generator::PackageFiles()
const char* contDir = contentsDirectory.c_str(); const char* contDir = contentsDirectory.c_str();
const char* rsrcFile = resourceFileName.c_str(); const char* rsrcFile = resourceFileName.c_str();
const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON"); const char* iconFile = this->GetOption("CPACK_PACKAGE_ICON");
if ( iconFile ) if (iconFile) {
{ std::string iconFileName = cmsys::SystemTools::GetFilenameName(iconFile);
std::string iconFileName = cmsys::SystemTools::GetFilenameName( if (!cmSystemTools::FileExists(iconFile)) {
iconFile);
if ( !cmSystemTools::FileExists(iconFile) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: " cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find icon file: "
<< iconFile << ". Please check CPACK_PACKAGE_ICON setting." << iconFile
<< ". Please check CPACK_PACKAGE_ICON setting."
<< std::endl); << std::endl);
return 0; return 0;
} }
@ -109,25 +104,24 @@ int cmCPackOSXX11Generator::PackageFiles()
std::string applicationsLinkName = diskImageDirectory + "/Applications"; std::string applicationsLinkName = diskImageDirectory + "/Applications";
cmSystemTools::CreateSymlink("/Applications", applicationsLinkName.c_str()); cmSystemTools::CreateSymlink("/Applications", applicationsLinkName.c_str());
if ( if (!this->CopyResourcePlistFile("VolumeIcon.icns",
!this->CopyResourcePlistFile("VolumeIcon.icns",
diskImageDirectory.c_str(), diskImageDirectory.c_str(),
".VolumeIcon.icns", true) || ".VolumeIcon.icns", true) ||
!this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(), !this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
".DS_Store", true) || ".DS_Store", true) ||
!this->CopyResourcePlistFile("background.png", !this->CopyResourcePlistFile("background.png",
diskImageBackgroundImageDir.c_str(), "background.png", true ) || diskImageBackgroundImageDir.c_str(),
"background.png", true) ||
!this->CopyResourcePlistFile("RuntimeScript", dir) || !this->CopyResourcePlistFile("RuntimeScript", dir) ||
!this->CopyResourcePlistFile("OSXX11.Info.plist", contDir, !this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,
"Info.plist") || "Info.plist") ||
!this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir, !this->CopyResourcePlistFile("OSXX11.main.scpt", scrDir, "main.scpt",
"main.scpt", true ) || true) ||
!this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir, !this->CopyResourcePlistFile("OSXScriptLauncher.rsrc", dir, rsrcFile,
rsrcFile, true) || true) ||
!this->CopyResourcePlistFile("OSXScriptLauncher", appdir, !this->CopyResourcePlistFile("OSXScriptLauncher", appdir,
this->GetOption("CPACK_PACKAGE_FILE_NAME"), true) this->GetOption("CPACK_PACKAGE_FILE_NAME"),
) true)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
<< std::endl); << std::endl);
return 0; return 0;
@ -143,20 +137,20 @@ int cmCPackOSXX11Generator::PackageFiles()
appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME"); appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME");
mode_t mode; mode_t mode;
if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) {
{
mode |= (S_IXUSR | S_IXGRP | S_IXOTH); mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
cmsys::SystemTools::SetPermissions(runTimeScript.c_str(), mode); cmsys::SystemTools::SetPermissions(runTimeScript.c_str(), mode);
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << runTimeScript cmCPackLogger(cmCPackLog::LOG_OUTPUT,
<< " to permission: " << mode << std::endl); "Setting: " << runTimeScript << " to permission: " << mode
<< std::endl);
} }
if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode)) if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode)) {
{
mode |= (S_IXUSR | S_IXGRP | S_IXOTH); mode |= (S_IXUSR | S_IXGRP | S_IXOTH);
cmsys::SystemTools::SetPermissions(appScriptName.c_str(), mode); cmsys::SystemTools::SetPermissions(appScriptName.c_str(), mode);
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << appScriptName cmCPackLogger(cmCPackLog::LOG_OUTPUT,
<< " to permission: " << mode << std::endl); "Setting: " << appScriptName << " to permission: " << mode
<< std::endl);
} }
std::string output; std::string output;
@ -165,38 +159,35 @@ int cmCPackOSXX11Generator::PackageFiles()
std::ostringstream dmgCmd; std::ostringstream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \"" << "\" create -ov -format UDZO -srcfolder \""
<< diskImageDirectory.c_str() << diskImageDirectory.c_str() << "\" \"" << packageFileNames[0]
<< "\" \"" << packageFileNames[0] << "\""; << "\"";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: "
"Compress disk image using command: "
<< dmgCmd.str().c_str() << std::endl); << dmgCmd.str().c_str() << std::endl);
// since we get random dashboard failures with this one // since we get random dashboard failures with this one
// try running it more than once // try running it more than once
int retVal = 1; int retVal = 1;
int numTries = 10; int numTries = 10;
bool res = false; bool res = false;
while(numTries > 0) while (numTries > 0) {
{ res =
res = cmSystemTools::RunSingleCommand( cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
dmgCmd.str().c_str(), &output, &output,
&retVal, 0, this->GeneratorVerbose, 0); &retVal, 0, this->GeneratorVerbose, 0);
if ( res && !retVal ) if (res && !retVal) {
{
numTries = -1; numTries = -1;
break; break;
} }
cmSystemTools::Delay(500); cmSystemTools::Delay(500);
numTries--; numTries--;
} }
if ( !res || retVal ) if (!res || retVal) {
{
cmGeneratedFileStream ofs(tmpFile.c_str()); cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
<< "# Output:" << std::endl << "# Output:" << std::endl
<< output.c_str() << std::endl; << output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: " cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
<< dmgCmd.str().c_str() << std::endl << dmgCmd.str().c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl); << "Please check " << tmpFile.c_str() << " for errors"
<< std::endl);
return 0; return 0;
} }
@ -205,12 +196,11 @@ int cmCPackOSXX11Generator::PackageFiles()
int cmCPackOSXX11Generator::InitializeInternal() int cmCPackOSXX11Generator::InitializeInternal()
{ {
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG, "cmCPackOSXX11Generator::Initialize()"
"cmCPackOSXX11Generator::Initialize()" << std::endl); << std::endl);
std::vector<std::string> path; std::vector<std::string> path;
std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false); std::string pkgPath = cmSystemTools::FindProgram("hdiutil", path, false);
if ( pkgPath.empty() ) if (pkgPath.empty()) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler" cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
<< std::endl); << std::endl);
return 0; return 0;
@ -265,23 +255,21 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
} }
*/ */
bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name, bool cmCPackOSXX11Generator::CopyResourcePlistFile(
const std::string& dir, const char* outputFileName /* = 0 */, const std::string& name, const std::string& dir,
bool copyOnly /* = false */) const char* outputFileName /* = 0 */, bool copyOnly /* = false */)
{ {
std::string inFName = "CPack."; std::string inFName = "CPack.";
inFName += name; inFName += name;
inFName += ".in"; inFName += ".in";
std::string inFileName = this->FindTemplate(inFName.c_str()); std::string inFileName = this->FindTemplate(inFName.c_str());
if ( inFileName.empty() ) if (inFileName.empty()) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR,
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: " "Cannot find input file: " << inFName << std::endl);
<< inFName << std::endl);
return false; return false;
} }
if ( !outputFileName ) if (!outputFileName) {
{
outputFileName = name.c_str(); outputFileName = name.c_str();
} }
@ -289,8 +277,9 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name,
destFileName += "/"; destFileName += "/";
destFileName += outputFileName; destFileName += outputFileName;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " cmCPackLogger(cmCPackLog::LOG_VERBOSE,
<< inFileName.c_str() << " to " << destFileName.c_str() << std::endl); "Configure file: " << inFileName.c_str() << " to "
<< destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly); this->ConfigureFile(inFileName.c_str(), destFileName.c_str(), copyOnly);
return true; return true;
} }

View File

@ -40,7 +40,8 @@ protected:
// bool CopyCreateResourceFile(const std::string& name, // bool CopyCreateResourceFile(const std::string& name,
// const std::string& dir); // const std::string& dir);
bool CopyResourcePlistFile(const std::string& name, const std::string& dir, bool CopyResourcePlistFile(const std::string& name, const std::string& dir,
const char* outputFileName = 0, bool copyOnly = false); const char* outputFileName = 0,
bool copyOnly = false);
std::string InstallPrefix; std::string InstallPrefix;
}; };

View File

@ -25,8 +25,7 @@
#include <assert.h> #include <assert.h>
static inline static inline unsigned int getVersion(unsigned int major, unsigned int minor)
unsigned int getVersion(unsigned int major, unsigned int minor)
{ {
assert(major < 256 && minor < 256); assert(major < 256 && minor < 256);
return ((major & 0xFF) << 16 | minor); return ((major & 0xFF) << 16 | minor);
@ -56,9 +55,8 @@ int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir,
dst += name; dst += name;
cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str()); cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str());
cmSystemTools::SetPermissions(dst.c_str(), 0777); cmSystemTools::SetPermissions(dst.c_str(), 0777);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLogger(cmCPackLog::LOG_VERBOSE, "copy script : "
"copy script : " << script << "\ninto " << dst.c_str() << << script << "\ninto " << dst.c_str() << std::endl);
std::endl);
return 1; return 1;
} }
@ -69,29 +67,24 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// It is used! Is this an obsolete comment? // It is used! Is this an obsolete comment?
std::string resDir; // Where this package's resources will go. std::string resDir; // Where this package's resources will go.
std::string packageDirFileName std::string packageDirFileName =
= this->GetOption("CPACK_TEMPORARY_DIRECTORY"); this->GetOption("CPACK_TEMPORARY_DIRECTORY");
if (this->Components.empty()) if (this->Components.empty()) {
{
packageDirFileName += ".pkg"; packageDirFileName += ".pkg";
resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
resDir += "/Resources"; resDir += "/Resources";
} } else {
else
{
packageDirFileName += ".mpkg"; packageDirFileName += ".mpkg";
if ( !cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str())) if (!cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package directory " "unable to create package directory " << packageDirFileName
<< packageDirFileName << std::endl); << std::endl);
return 0; return 0;
} }
resDir = packageDirFileName; resDir = packageDirFileName;
resDir += "/Contents"; resDir += "/Contents";
if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str())) if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package subdirectory " << resDir "unable to create package subdirectory " << resDir
<< std::endl); << std::endl);
@ -99,8 +92,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
} }
resDir += "/Resources"; resDir += "/Resources";
if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str())) if (!cmsys::SystemTools::MakeDirectory(resDir.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"unable to create package subdirectory " << resDir "unable to create package subdirectory " << resDir
<< std::endl); << std::endl);
@ -114,27 +106,22 @@ int cmCPackPackageMakerGenerator::PackageFiles()
const char* postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT"); const char* postflight = this->GetOption("CPACK_POSTFLIGHT_SCRIPT");
const char* postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT"); const char* postupgrade = this->GetOption("CPACK_POSTUPGRADE_SCRIPT");
if(this->Components.empty()) if (this->Components.empty()) {
{
// Create directory structure // Create directory structure
std::string preflightDirName = resDir + "/PreFlight"; std::string preflightDirName = resDir + "/PreFlight";
std::string postflightDirName = resDir + "/PostFlight"; std::string postflightDirName = resDir + "/PostFlight";
// if preflight or postflight scripts not there create directories // if preflight or postflight scripts not there create directories
// of the same name, I think this makes it work // of the same name, I think this makes it work
if(!preflight) if (!preflight) {
{ if (!cmsys::SystemTools::MakeDirectory(preflightDirName.c_str())) {
if ( !cmsys::SystemTools::MakeDirectory(preflightDirName.c_str()))
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating installer directory: " "Problem creating installer directory: "
<< preflightDirName.c_str() << std::endl); << preflightDirName.c_str() << std::endl);
return 0; return 0;
} }
} }
if(!postflight) if (!postflight) {
{ if (!cmsys::SystemTools::MakeDirectory(postflightDirName.c_str())) {
if ( !cmsys::SystemTools::MakeDirectory(postflightDirName.c_str()))
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating installer directory: " "Problem creating installer directory: "
<< postflightDirName.c_str() << std::endl); << postflightDirName.c_str() << std::endl);
@ -144,27 +131,16 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// if preflight, postflight, or postupgrade are set // if preflight, postflight, or postupgrade are set
// then copy them into the resource directory and make // then copy them into the resource directory and make
// them executable // them executable
if(preflight) if (preflight) {
{ this->CopyInstallScript(resDir.c_str(), preflight, "preflight");
this->CopyInstallScript(resDir.c_str(),
preflight,
"preflight");
} }
if(postflight) if (postflight) {
{ this->CopyInstallScript(resDir.c_str(), postflight, "postflight");
this->CopyInstallScript(resDir.c_str(),
postflight,
"postflight");
} }
if(postupgrade) if (postupgrade) {
{ this->CopyInstallScript(resDir.c_str(), postupgrade, "postupgrade");
this->CopyInstallScript(resDir.c_str(),
postupgrade,
"postupgrade");
} }
} } else if (postflight) {
else if(postflight)
{
// create a postflight component to house the script // create a postflight component to house the script
this->PostFlightComponent.Name = "PostFlight"; this->PostFlightComponent.Name = "PostFlight";
this->PostFlightComponent.DisplayName = "PostFlight"; this->PostFlightComponent.DisplayName = "PostFlight";
@ -173,8 +149,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// empty directory for pkg contents // empty directory for pkg contents
std::string packageDir = toplevel + "/" + PostFlightComponent.Name; std::string packageDir = toplevel + "/" + PostFlightComponent.Name;
if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str())) if (!cmsys::SystemTools::MakeDirectory(packageDir.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating component packages directory: " "Problem creating component packages directory: "
<< packageDir.c_str() << std::endl); << packageDir.c_str() << std::endl);
@ -183,36 +158,30 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// create package // create package
std::string packageFileDir = packageDirFileName + "/Contents/Packages/"; std::string packageFileDir = packageDirFileName + "/Contents/Packages/";
if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str())) if (!cmsys::SystemTools::MakeDirectory(packageFileDir.c_str())) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLog::LOG_ERROR,
"Problem creating component PostFlight Packages directory: " "Problem creating component PostFlight Packages directory: "
<< packageFileDir.c_str() << std::endl); << packageFileDir.c_str() << std::endl);
return 0; return 0;
} }
std::string packageFile = packageFileDir + std::string packageFile =
this->GetPackageName(PostFlightComponent); packageFileDir + this->GetPackageName(PostFlightComponent);
if (!this->GenerateComponentPackage(packageFile.c_str(), if (!this->GenerateComponentPackage(
packageDir.c_str(), packageFile.c_str(), packageDir.c_str(), PostFlightComponent)) {
PostFlightComponent))
{
return 0; return 0;
} }
// copy postflight script into resource directory of .pkg // copy postflight script into resource directory of .pkg
std::string resourceDir = packageFile + "/Contents/Resources"; std::string resourceDir = packageFile + "/Contents/Resources";
this->CopyInstallScript(resourceDir.c_str(), this->CopyInstallScript(resourceDir.c_str(), postflight, "postflight");
postflight,
"postflight");
} }
if (!this->Components.empty()) if (!this->Components.empty()) {
{
// Create the directory where component packages will be built. // Create the directory where component packages will be built.
std::string basePackageDir = packageDirFileName; std::string basePackageDir = packageDirFileName;
basePackageDir += "/Contents/Packages"; basePackageDir += "/Contents/Packages";
if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem creating component packages directory: " "Problem creating component packages directory: "
<< basePackageDir.c_str() << std::endl); << basePackageDir.c_str() << std::endl);
@ -224,12 +193,9 @@ int cmCPackPackageMakerGenerator::PackageFiles()
const char* userUploadDirectory = const char* userUploadDirectory =
this->GetOption("CPACK_UPLOAD_DIRECTORY"); this->GetOption("CPACK_UPLOAD_DIRECTORY");
std::string uploadDirectory; std::string uploadDirectory;
if (userUploadDirectory && *userUploadDirectory) if (userUploadDirectory && *userUploadDirectory) {
{
uploadDirectory = userUploadDirectory; uploadDirectory = userUploadDirectory;
} } else {
else
{
uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY"); uploadDirectory = this->GetOption("CPACK_PACKAGE_DIRECTORY");
uploadDirectory += "/CPackUploads"; uploadDirectory += "/CPackUploads";
} }
@ -239,32 +205,24 @@ int cmCPackPackageMakerGenerator::PackageFiles()
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end(); for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) ++compIt) {
{
std::string packageFile; std::string packageFile;
if (compIt->second.IsDownloaded) if (compIt->second.IsDownloaded) {
{
if (this->PackageCompatibilityVersion >= getVersion(10, 5) && if (this->PackageCompatibilityVersion >= getVersion(10, 5) &&
this->PackageMakerVersion >= 3.0) this->PackageMakerVersion >= 3.0) {
{
// Build this package within the upload directory. // Build this package within the upload directory.
packageFile = uploadDirectory; packageFile = uploadDirectory;
if(!cmSystemTools::FileExists(uploadDirectory.c_str())) if (!cmSystemTools::FileExists(uploadDirectory.c_str())) {
{ if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) {
if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str()))
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Unable to create package upload directory " "Unable to create package upload directory "
<< uploadDirectory << std::endl); << uploadDirectory << std::endl);
return 0; return 0;
} }
} }
} } else if (!warnedAboutDownloadCompatibility) {
else if (!warnedAboutDownloadCompatibility) if (this->PackageCompatibilityVersion < getVersion(10, 5)) {
{
if (this->PackageCompatibilityVersion < getVersion(10, 5))
{
cmCPackLogger( cmCPackLogger(
cmCPackLog::LOG_WARNING, cmCPackLog::LOG_WARNING,
"CPack warning: please set CPACK_OSX_PACKAGE_VERSION to 10.5 " "CPack warning: please set CPACK_OSX_PACKAGE_VERSION to 10.5 "
@ -273,8 +231,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
<< std::endl); << std::endl);
} }
if (this->PackageMakerVersion < 3) if (this->PackageMakerVersion < 3) {
{
cmCPackLogger(cmCPackLog::LOG_WARNING, cmCPackLogger(cmCPackLog::LOG_WARNING,
"CPack warning: unable to build downloaded " "CPack warning: unable to build downloaded "
"packages with PackageMaker versions prior " "packages with PackageMaker versions prior "
@ -286,8 +243,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
} }
} }
if (packageFile.empty()) if (packageFile.empty()) {
{
// Build this package within the overall distribution // Build this package within the overall distribution
// metapackage. // metapackage.
packageFile = basePackageDir; packageFile = basePackageDir;
@ -303,10 +259,8 @@ int cmCPackPackageMakerGenerator::PackageFiles()
std::string packageDir = toplevel; std::string packageDir = toplevel;
packageDir += '/'; packageDir += '/';
packageDir += compIt->first; packageDir += compIt->first;
if (!this->GenerateComponentPackage(packageFile.c_str(), if (!this->GenerateComponentPackage(
packageDir.c_str(), packageFile.c_str(), packageDir.c_str(), compIt->second)) {
compIt->second))
{
return 0; return 0;
} }
} }
@ -314,29 +268,24 @@ int cmCPackPackageMakerGenerator::PackageFiles()
this->SetOption("CPACK_MODULE_VERSION_SUFFIX", ""); this->SetOption("CPACK_MODULE_VERSION_SUFFIX", "");
// Copy or create all of the resource files we need. // Copy or create all of the resource files we need.
if ( !this->CopyCreateResourceFile("License", resDir.c_str()) if (!this->CopyCreateResourceFile("License", resDir.c_str()) ||
|| !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) ||
|| !this->CopyCreateResourceFile("Welcome", resDir.c_str()) !this->CopyCreateResourceFile("Welcome", resDir.c_str()) ||
|| !this->CopyResourcePlistFile("Info.plist") !this->CopyResourcePlistFile("Info.plist") ||
|| !this->CopyResourcePlistFile("Description.plist") ) !this->CopyResourcePlistFile("Description.plist")) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
<< std::endl); << std::endl);
return 0; return 0;
} }
if (this->Components.empty()) if (this->Components.empty()) {
{
// Use PackageMaker to build the package. // Use PackageMaker to build the package.
std::ostringstream pkgCmd; std::ostringstream pkgCmd;
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" -build -p \"" << packageDirFileName << "\""; << "\" -build -p \"" << packageDirFileName << "\"";
if (this->Components.empty()) if (this->Components.empty()) {
{
pkgCmd << " -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY"); pkgCmd << " -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY");
} } else {
else
{
pkgCmd << " -mi \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY") pkgCmd << " -mi \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY")
<< "/packages/"; << "/packages/";
} }
@ -346,15 +295,12 @@ int cmCPackPackageMakerGenerator::PackageFiles()
<< "/Info.plist\" -d \"" << "/Info.plist\" -d \""
<< this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << this->GetOption("CPACK_TOPLEVEL_DIRECTORY")
<< "/Description.plist\""; << "/Description.plist\"";
if ( this->PackageMakerVersion > 2.0 ) if (this->PackageMakerVersion > 2.0) {
{
pkgCmd << " -v"; pkgCmd << " -v";
} }
if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str())) if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str()))
return 0; return 0;
} } else {
else
{
// We have built the package in place. Generate the // We have built the package in place. Generate the
// distribution.dist file to describe it for the installer. // distribution.dist file to describe it for the installer.
WriteDistributionFile(packageDirFileName.c_str()); WriteDistributionFile(packageDirFileName.c_str());
@ -370,28 +316,26 @@ int cmCPackPackageMakerGenerator::PackageFiles()
int retVal = 1; int retVal = 1;
int numTries = 10; int numTries = 10;
bool res = false; bool res = false;
while(numTries > 0) while (numTries > 0) {
{ res =
res = cmSystemTools::RunSingleCommand( cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &output,
dmgCmd.str().c_str(), &output, &output,
&retVal, 0, this->GeneratorVerbose, 0); &retVal, 0, this->GeneratorVerbose, 0);
if ( res && !retVal ) if (res && !retVal) {
{
numTries = -1; numTries = -1;
break; break;
} }
cmSystemTools::Delay(500); cmSystemTools::Delay(500);
numTries--; numTries--;
} }
if ( !res || retVal ) if (!res || retVal) {
{
cmGeneratedFileStream ofs(tmpFile.c_str()); cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl ofs << "# Run command: " << dmgCmd.str().c_str() << std::endl
<< "# Output:" << std::endl << "# Output:" << std::endl
<< output.c_str() << std::endl; << output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: " cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running hdiutil command: "
<< dmgCmd.str().c_str() << std::endl << dmgCmd.str().c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl); << "Please check " << tmpFile.c_str() << " for errors"
<< std::endl);
return 0; return 0;
} }
@ -418,33 +362,24 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
// If found, save result in the CPACK_INSTALLER_PROGRAM variable. // If found, save result in the CPACK_INSTALLER_PROGRAM variable.
std::vector<std::string> paths; std::vector<std::string> paths;
paths.push_back( paths.push_back("/Applications/Xcode.app/Contents/Applications"
"/Applications/Xcode.app/Contents/Applications"
"/PackageMaker.app/Contents/MacOS"); "/PackageMaker.app/Contents/MacOS");
paths.push_back( paths.push_back("/Applications/Utilities"
"/Applications/Utilities"
"/PackageMaker.app/Contents/MacOS"); "/PackageMaker.app/Contents/MacOS");
paths.push_back( paths.push_back("/Applications"
"/Applications"
"/PackageMaker.app/Contents/MacOS"); "/PackageMaker.app/Contents/MacOS");
paths.push_back( paths.push_back("/Developer/Applications/Utilities"
"/Developer/Applications/Utilities"
"/PackageMaker.app/Contents/MacOS"); "/PackageMaker.app/Contents/MacOS");
paths.push_back( paths.push_back("/Developer/Applications"
"/Developer/Applications"
"/PackageMaker.app/Contents/MacOS"); "/PackageMaker.app/Contents/MacOS");
std::string pkgPath; std::string pkgPath;
const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM"); const char* inst_program = this->GetOption("CPACK_INSTALLER_PROGRAM");
if (inst_program && *inst_program) if (inst_program && *inst_program) {
{
pkgPath = inst_program; pkgPath = inst_program;
} } else {
else
{
pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false); pkgPath = cmSystemTools::FindProgram("PackageMaker", paths, false);
if ( pkgPath.empty() ) if (pkgPath.empty()) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler" cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find PackageMaker compiler"
<< std::endl); << std::endl);
return 0; return 0;
@ -461,20 +396,18 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
std::string versionFile = contents_dir + "/version.plist"; std::string versionFile = contents_dir + "/version.plist";
if ( !cmSystemTools::FileExists(versionFile.c_str()) ) if (!cmSystemTools::FileExists(versionFile.c_str())) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot find PackageMaker compiler version file: " "Cannot find PackageMaker compiler version file: "
<< versionFile.c_str() << versionFile.c_str() << std::endl);
<< std::endl);
return 0; return 0;
} }
cmsys::ifstream ifs(versionFile.c_str()); cmsys::ifstream ifs(versionFile.c_str());
if ( !ifs ) if (!ifs) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Cannot open PackageMaker compiler version file" << std::endl); "Cannot open PackageMaker compiler version file"
<< std::endl);
return 0; return 0;
} }
@ -483,32 +416,28 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>"); cmsys::RegularExpression rexVersion("<string>([0-9]+.[0-9.]+)</string>");
std::string line; std::string line;
bool foundKey = false; bool foundKey = false;
while ( cmSystemTools::GetLineFromStream(ifs, line) ) while (cmSystemTools::GetLineFromStream(ifs, line)) {
{ if (rexKey.find(line)) {
if ( rexKey.find(line) )
{
foundKey = true; foundKey = true;
break; break;
} }
} }
if ( !foundKey ) if (!foundKey) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLog::LOG_ERROR,
"Cannot find CFBundleShortVersionString in the PackageMaker compiler " "Cannot find CFBundleShortVersionString in the PackageMaker compiler "
"version file" << std::endl); "version file"
<< std::endl);
return 0; return 0;
} }
if ( !cmSystemTools::GetLineFromStream(ifs, line) || if (!cmSystemTools::GetLineFromStream(ifs, line) || !rexVersion.find(line)) {
!rexVersion.find(line) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem reading the PackageMaker compiler version file: " "Problem reading the PackageMaker compiler version file: "
<< versionFile.c_str() << std::endl); << versionFile.c_str() << std::endl);
return 0; return 0;
} }
this->PackageMakerVersion = atof(rexVersion.match(1).c_str()); this->PackageMakerVersion = atof(rexVersion.match(1).c_str());
if ( this->PackageMakerVersion < 1.0 ) if (this->PackageMakerVersion < 1.0) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher" cmCPackLogger(cmCPackLog::LOG_ERROR, "Require PackageMaker 1.0 or higher"
<< std::endl); << std::endl);
return 0; return 0;
@ -520,37 +449,28 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
// specified by the user, we define it based on which features the // specified by the user, we define it based on which features the
// user requested. // user requested.
const char* packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION"); const char* packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION");
if (packageCompat && *packageCompat) if (packageCompat && *packageCompat) {
{
unsigned int majorVersion = 10; unsigned int majorVersion = 10;
unsigned int minorVersion = 5; unsigned int minorVersion = 5;
int res = sscanf(packageCompat, "%u.%u", &majorVersion, &minorVersion); int res = sscanf(packageCompat, "%u.%u", &majorVersion, &minorVersion);
if (res == 2) if (res == 2) {
{
this->PackageCompatibilityVersion = this->PackageCompatibilityVersion =
getVersion(majorVersion, minorVersion); getVersion(majorVersion, minorVersion);
} }
} } else if (this->GetOption("CPACK_DOWNLOAD_SITE")) {
else if (this->GetOption("CPACK_DOWNLOAD_SITE"))
{
this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.5"); this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.5");
this->PackageCompatibilityVersion = getVersion(10, 5); this->PackageCompatibilityVersion = getVersion(10, 5);
} } else if (this->GetOption("CPACK_COMPONENTS_ALL")) {
else if (this->GetOption("CPACK_COMPONENTS_ALL"))
{
this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.4"); this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.4");
this->PackageCompatibilityVersion = getVersion(10, 4); this->PackageCompatibilityVersion = getVersion(10, 4);
} } else {
else
{
this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.3"); this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.3");
this->PackageCompatibilityVersion = getVersion(10, 3); this->PackageCompatibilityVersion = getVersion(10, 3);
} }
std::vector<std::string> no_paths; std::vector<std::string> no_paths;
pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false); pkgPath = cmSystemTools::FindProgram("hdiutil", no_paths, false);
if ( pkgPath.empty() ) if (pkgPath.empty()) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler" cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find hdiutil compiler"
<< std::endl); << std::endl);
return 0; return 0;
@ -562,33 +482,31 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
} }
bool cmCPackPackageMakerGenerator::CopyCreateResourceFile( bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
const std::string& name, const std::string& name, const std::string& dirName)
const std::string& dirName)
{ {
std::string uname = cmSystemTools::UpperCase(name); std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
const char* inFileName = this->GetOption(cpackVar.c_str()); const char* inFileName = this->GetOption(cpackVar.c_str());
if ( !inFileName ) if (!inFileName) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: "
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str() << cpackVar.c_str()
<< " not specified. It should point to " << " not specified. It should point to "
<< (!name.empty() ? name : "<empty>") << (!name.empty() ? name : "<empty>") << ".rtf, " << name
<< ".rtf, " << name
<< ".html, or " << name << ".txt file" << std::endl); << ".html, or " << name << ".txt file" << std::endl);
return false; return false;
} }
if ( !cmSystemTools::FileExists(inFileName) ) if (!cmSystemTools::FileExists(inFileName)) {
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find " cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
<< (!name.empty() ? name : "<empty>") << (!name.empty() ? name : "<empty>")
<< " resource file: " << inFileName << std::endl); << " resource file: " << inFileName << std::endl);
return false; return false;
} }
std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName); std::string ext = cmSystemTools::GetFilenameLastExtension(inFileName);
if ( ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt" ) if (ext != ".rtfd" && ext != ".rtf" && ext != ".html" && ext != ".txt") {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_ERROR, "Bad file extension specified: " cmCPackLog::LOG_ERROR, "Bad file extension specified: "
<< ext << ". Currently only .rtfd, .rtf, .html, and .txt files allowed." << ext
<< ". Currently only .rtfd, .rtf, .html, and .txt files allowed."
<< std::endl); << std::endl);
return false; return false;
} }
@ -603,18 +521,16 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
(name + ext).c_str()); (name + ext).c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: "
<< (inFileName ? inFileName : "(NULL)") << (inFileName ? inFileName : "(NULL)") << " to "
<< " to " << destFileName.c_str() << std::endl); << destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName, destFileName.c_str()); this->ConfigureFile(inFileName, destFileName.c_str());
return true; return true;
} }
bool cmCPackPackageMakerGenerator::CopyResourcePlistFile( bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
const std::string& name, const std::string& name, const char* outName)
const char* outName)
{
if (!outName)
{ {
if (!outName) {
outName = name.c_str(); outName = name.c_str();
} }
@ -622,10 +538,9 @@ bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
inFName += name; inFName += name;
inFName += ".in"; inFName += ".in";
std::string inFileName = this->FindTemplate(inFName.c_str()); std::string inFileName = this->FindTemplate(inFName.c_str());
if ( inFileName.empty() ) if (inFileName.empty()) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR,
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: " "Cannot find input file: " << inFName << std::endl);
<< inFName << std::endl);
return false; return false;
} }
@ -633,8 +548,9 @@ bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
destFileName += "/"; destFileName += "/";
destFileName += outName; destFileName += outName;
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " cmCPackLogger(cmCPackLog::LOG_VERBOSE,
<< inFileName.c_str() << " to " << destFileName.c_str() << std::endl); "Configure file: " << inFileName.c_str() << " to "
<< destFileName.c_str() << std::endl);
this->ConfigureFile(inFileName.c_str(), destFileName.c_str()); this->ConfigureFile(inFileName.c_str(), destFileName.c_str());
return true; return true;
} }
@ -649,78 +565,65 @@ bool cmCPackPackageMakerGenerator::RunPackageMaker(const char *command,
std::string output; std::string output;
int retVal = 1; int retVal = 1;
bool res = cmSystemTools::RunSingleCommand( bool res = cmSystemTools::RunSingleCommand(
command, &output, &output, command, &output, &output, &retVal, 0, this->GeneratorVerbose, 0);
&retVal, 0, this->GeneratorVerbose, 0);
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker" cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker"
<< std::endl); << std::endl);
if ( !res || retVal ) if (!res || retVal) {
{
cmGeneratedFileStream ofs(tmpFile.c_str()); cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << command << std::endl ofs << "# Run command: " << command << std::endl
<< "# Output:" << std::endl << "# Output:" << std::endl
<< output.c_str() << std::endl; << output.c_str() << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, cmCPackLogger(
"Problem running PackageMaker command: " << command cmCPackLog::LOG_ERROR, "Problem running PackageMaker command: "
<< std::endl << "Please check " << tmpFile.c_str() << " for errors" << command << std::endl
<< std::endl); << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
return false; return false;
} }
// sometimes the command finishes but the directory is not yet // sometimes the command finishes but the directory is not yet
// created, so try 10 times to see if it shows up // created, so try 10 times to see if it shows up
int tries = 10; int tries = 10;
while(tries > 0 && while (tries > 0 && !cmSystemTools::FileExists(packageFile)) {
!cmSystemTools::FileExists(packageFile))
{
cmSystemTools::Delay(500); cmSystemTools::Delay(500);
tries--; tries--;
} }
if(!cmSystemTools::FileExists(packageFile)) if (!cmSystemTools::FileExists(packageFile)) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR,
cmCPackLogger( "Problem running PackageMaker command: "
cmCPackLog::LOG_ERROR, << command << std::endl
"Problem running PackageMaker command: " << command << "Package not created: " << packageFile << std::endl);
<< std::endl << "Package not created: " << packageFile
<< std::endl);
return false; return false;
} }
return true; return true;
} }
std::string std::string cmCPackPackageMakerGenerator::GetPackageName(
cmCPackPackageMakerGenerator::GetPackageName(const cmCPackComponent& component) const cmCPackComponent& component)
{
if (component.ArchiveFile.empty())
{ {
if (component.ArchiveFile.empty()) {
std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packagesDir += ".dummy"; packagesDir += ".dummy";
std::ostringstream out; std::ostringstream out;
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) << "-"
<< "-" << component.Name << ".pkg"; << component.Name << ".pkg";
return out.str(); return out.str();
} } else {
else
{
return component.ArchiveFile + ".pkg"; return component.ArchiveFile + ".pkg";
} }
} }
bool bool cmCPackPackageMakerGenerator::GenerateComponentPackage(
cmCPackPackageMakerGenerator:: const char* packageFile, const char* packageDir,
GenerateComponentPackage(const char *packageFile,
const char *packageDir,
const cmCPackComponent& component) const cmCPackComponent& component)
{ {
cmCPackLogger(cmCPackLog::LOG_OUTPUT, cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Building component package: "
"- Building component package: " << << packageFile << std::endl);
packageFile << std::endl);
// The command that will be used to run PackageMaker // The command that will be used to run PackageMaker
std::ostringstream pkgCmd; std::ostringstream pkgCmd;
if (this->PackageCompatibilityVersion < getVersion(10, 5) || if (this->PackageCompatibilityVersion < getVersion(10, 5) ||
this->PackageMakerVersion < 3.0) this->PackageMakerVersion < 3.0) {
{
// Create Description.plist and Info.plist files for normal Mac OS // Create Description.plist and Info.plist files for normal Mac OS
// X packages, which work on Mac OS X 10.3 and newer. // X packages, which work on Mac OS X 10.3 and newer.
std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
@ -750,20 +653,17 @@ GenerateComponentPackage(const char *packageFile,
moduleVersionSuffix.c_str()); moduleVersionSuffix.c_str());
std::string infoFileName = component.Name; std::string infoFileName = component.Name;
infoFileName += "-Info.plist"; infoFileName += "-Info.plist";
if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) {
{
return false; return false;
} }
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" -build -p \"" << packageFile << "\"" << "\" -build -p \"" << packageFile << "\""
<< " -f \"" << packageDir << "\"" << " -f \"" << packageDir << "\""
<< " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/"
<< "/" << infoFileName << "\"" << infoFileName << "\""
<< " -d \"" << descriptionFile << "\""; << " -d \"" << descriptionFile << "\"";
} } else {
else
{
// Create a "flat" package on Mac OS X 10.5 and newer. Flat // Create a "flat" package on Mac OS X 10.5 and newer. Flat
// packages are stored in a single file, rather than a directory // packages are stored in a single file, rather than a directory
// like normal packages, and can be downloaded by the installer // like normal packages, and can be downloaded by the installer
@ -778,23 +678,21 @@ GenerateComponentPackage(const char *packageFile,
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" --root \"" << packageDir << "\"" << "\" --root \"" << packageDir << "\""
<< " --id " << pkgId << " --id " << pkgId << " --target "
<< " --target " << this->GetOption("CPACK_OSX_PACKAGE_VERSION") << this->GetOption("CPACK_OSX_PACKAGE_VERSION") << " --out \""
<< " --out \"" << packageFile << "\""; << packageFile << "\"";
} }
// Run PackageMaker // Run PackageMaker
return RunPackageMaker(pkgCmd.str().c_str(), packageFile); return RunPackageMaker(pkgCmd.str().c_str(), packageFile);
} }
void void cmCPackPackageMakerGenerator::WriteDistributionFile(
cmCPackPackageMakerGenerator:: const char* metapackageFile)
WriteDistributionFile(const char* metapackageFile)
{
std::string distributionTemplate
= this->FindTemplate("CPack.distribution.dist.in");
if ( distributionTemplate.empty() )
{ {
std::string distributionTemplate =
this->FindTemplate("CPack.distribution.dist.in");
if (distributionTemplate.empty()) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: " cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: "
<< distributionTemplate << std::endl); << distributionTemplate << std::endl);
return; return;
@ -811,11 +709,8 @@ WriteDistributionFile(const char* metapackageFile)
// Emit the outline for the groups // Emit the outline for the groups
std::map<std::string, cmCPackComponentGroup>::iterator groupIt; std::map<std::string, cmCPackComponentGroup>::iterator groupIt;
for (groupIt = this->ComponentGroups.begin(); for (groupIt = this->ComponentGroups.begin();
groupIt != this->ComponentGroups.end(); groupIt != this->ComponentGroups.end(); ++groupIt) {
++groupIt) if (groupIt->second.ParentGroup == 0) {
{
if (groupIt->second.ParentGroup == 0)
{
CreateChoiceOutline(groupIt->second, choiceOut); CreateChoiceOutline(groupIt->second, choiceOut);
} }
} }
@ -823,16 +718,13 @@ WriteDistributionFile(const char* metapackageFile)
// Emit the outline for the non-grouped components // Emit the outline for the non-grouped components
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt = this->Components.begin(); compIt != this->Components.end(); for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) ++compIt) {
{ if (!compIt->second.Group) {
if (!compIt->second.Group)
{
choiceOut << "<line choice=\"" << compIt->first << "Choice\"></line>" choiceOut << "<line choice=\"" << compIt->first << "Choice\"></line>"
<< std::endl; << std::endl;
} }
} }
if(!this->PostFlightComponent.Name.empty()) if (!this->PostFlightComponent.Name.empty()) {
{
choiceOut << "<line choice=\"" << PostFlightComponent.Name choiceOut << "<line choice=\"" << PostFlightComponent.Name
<< "Choice\"></line>" << std::endl; << "Choice\"></line>" << std::endl;
} }
@ -840,19 +732,15 @@ WriteDistributionFile(const char* metapackageFile)
// Create the actual choices // Create the actual choices
for (groupIt = this->ComponentGroups.begin(); for (groupIt = this->ComponentGroups.begin();
groupIt != this->ComponentGroups.end(); groupIt != this->ComponentGroups.end(); ++groupIt) {
++groupIt)
{
CreateChoice(groupIt->second, choiceOut); CreateChoice(groupIt->second, choiceOut);
} }
for (compIt = this->Components.begin(); compIt != this->Components.end(); for (compIt = this->Components.begin(); compIt != this->Components.end();
++compIt) ++compIt) {
{
CreateChoice(compIt->second, choiceOut); CreateChoice(compIt->second, choiceOut);
} }
if(!this->PostFlightComponent.Name.empty()) if (!this->PostFlightComponent.Name.empty()) {
{
CreateChoice(PostFlightComponent, choiceOut); CreateChoice(PostFlightComponent, choiceOut);
} }
@ -860,53 +748,44 @@ WriteDistributionFile(const char* metapackageFile)
// Create the distribution.dist file in the metapackage to turn it // Create the distribution.dist file in the metapackage to turn it
// into a distribution package. // into a distribution package.
this->ConfigureFile(distributionTemplate.c_str(), this->ConfigureFile(distributionTemplate.c_str(), distributionFile.c_str());
distributionFile.c_str());
} }
void void cmCPackPackageMakerGenerator::CreateChoiceOutline(
cmCPackPackageMakerGenerator:: const cmCPackComponentGroup& group, std::ostringstream& out)
CreateChoiceOutline(const cmCPackComponentGroup& group,
std::ostringstream& out)
{ {
out << "<line choice=\"" << group.Name << "Choice\">" << std::endl; out << "<line choice=\"" << group.Name << "Choice\">" << std::endl;
std::vector<cmCPackComponentGroup*>::const_iterator groupIt; std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end(); for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end();
++groupIt) ++groupIt) {
{
CreateChoiceOutline(**groupIt, out); CreateChoiceOutline(**groupIt, out);
} }
std::vector<cmCPackComponent*>::const_iterator compIt; std::vector<cmCPackComponent*>::const_iterator compIt;
for (compIt = group.Components.begin(); compIt != group.Components.end(); for (compIt = group.Components.begin(); compIt != group.Components.end();
++compIt) ++compIt) {
{
out << " <line choice=\"" << (*compIt)->Name << "Choice\"></line>" out << " <line choice=\"" << (*compIt)->Name << "Choice\"></line>"
<< std::endl; << std::endl;
} }
out << "</line>" << std::endl; out << "</line>" << std::endl;
} }
void void cmCPackPackageMakerGenerator::CreateChoice(
cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponentGroup& group, const cmCPackComponentGroup& group, std::ostringstream& out)
std::ostringstream& out)
{ {
out << "<choice id=\"" << group.Name << "Choice\" " out << "<choice id=\"" << group.Name << "Choice\" "
<< "title=\"" << group.DisplayName << "\" " << "title=\"" << group.DisplayName << "\" "
<< "start_selected=\"true\" " << "start_selected=\"true\" "
<< "start_enabled=\"true\" " << "start_enabled=\"true\" "
<< "start_visible=\"true\" "; << "start_visible=\"true\" ";
if (!group.Description.empty()) if (!group.Description.empty()) {
{ out << "description=\"" << EscapeForXML(group.Description) << "\"";
out << "description=\"" << EscapeForXML(group.Description)
<< "\"";
} }
out << "></choice>" << std::endl; out << "></choice>" << std::endl;
} }
void void cmCPackPackageMakerGenerator::CreateChoice(
cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component, const cmCPackComponent& component, std::ostringstream& out)
std::ostringstream& out)
{ {
std::string packageId = "com."; std::string packageId = "com.";
packageId += this->GetOption("CPACK_PACKAGE_VENDOR"); packageId += this->GetOption("CPACK_PACKAGE_VENDOR");
@ -918,21 +797,18 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
out << "<choice id=\"" << component.Name << "Choice\" " out << "<choice id=\"" << component.Name << "Choice\" "
<< "title=\"" << component.DisplayName << "\" " << "title=\"" << component.DisplayName << "\" "
<< "start_selected=\"" << "start_selected=\""
<< (component.IsDisabledByDefault && << (component.IsDisabledByDefault && !component.IsRequired ? "false"
!component.IsRequired? "false" : "true") : "true")
<< "\" " << "\" "
<< "start_enabled=\"" << "start_enabled=\"" << (component.IsRequired ? "false" : "true")
<< (component.IsRequired? "false" : "true")
<< "\" " << "\" "
<< "start_visible=\"" << (component.IsHidden? "false" : "true") << "\" "; << "start_visible=\"" << (component.IsHidden ? "false" : "true")
if (!component.Description.empty())
{
out << "description=\"" << EscapeForXML(component.Description)
<< "\" "; << "\" ";
if (!component.Description.empty()) {
out << "description=\"" << EscapeForXML(component.Description) << "\" ";
} }
if (!component.Dependencies.empty() || if (!component.Dependencies.empty() ||
!component.ReverseDependencies.empty()) !component.ReverseDependencies.empty()) {
{
// The "selected" expression is evaluated each time any choice is // The "selected" expression is evaluated each time any choice is
// selected, for all choices *except* the one that the user // selected, for all choices *except* the one that the user
// selected. A component is marked selected if it has been // selected. A component is marked selected if it has been
@ -968,65 +844,51 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
dirName += '/'; dirName += '/';
dirName += component.Name; dirName += component.Name;
dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
unsigned long installedSize unsigned long installedSize =
= component.GetInstalledSizeInKbytes(dirName.c_str()); component.GetInstalledSizeInKbytes(dirName.c_str());
out << "<pkg-ref id=\"" << packageId << "\" " out << "<pkg-ref id=\"" << packageId << "\" "
<< "version=\"" << this->GetOption("CPACK_PACKAGE_VERSION") << "\" " << "version=\"" << this->GetOption("CPACK_PACKAGE_VERSION") << "\" "
<< "installKBytes=\"" << installedSize << "\" " << "installKBytes=\"" << installedSize << "\" "
<< "auth=\"Admin\" onConclusion=\"None\">"; << "auth=\"Admin\" onConclusion=\"None\">";
if (component.IsDownloaded) if (component.IsDownloaded) {
{
out << this->GetOption("CPACK_DOWNLOAD_SITE") out << this->GetOption("CPACK_DOWNLOAD_SITE")
<< this->GetPackageName(component); << this->GetPackageName(component);
} } else {
else
{
out << "file:./" << relativePackageLocation; out << "file:./" << relativePackageLocation;
} }
out << "</pkg-ref>" << std::endl; out << "</pkg-ref>" << std::endl;
} }
void void cmCPackPackageMakerGenerator::AddDependencyAttributes(
cmCPackPackageMakerGenerator:: const cmCPackComponent& component,
AddDependencyAttributes(const cmCPackComponent& component, std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
std::set<const cmCPackComponent *>& visited,
std::ostringstream& out)
{
if (visited.find(&component) != visited.end())
{ {
if (visited.find(&component) != visited.end()) {
return; return;
} }
visited.insert(&component); visited.insert(&component);
std::vector<cmCPackComponent*>::const_iterator dependIt; std::vector<cmCPackComponent*>::const_iterator dependIt;
for (dependIt = component.Dependencies.begin(); for (dependIt = component.Dependencies.begin();
dependIt != component.Dependencies.end(); dependIt != component.Dependencies.end(); ++dependIt) {
++dependIt) out << " &amp;&amp; choices['" << (*dependIt)->Name << "Choice'].selected";
{
out << " &amp;&amp; choices['" <<
(*dependIt)->Name << "Choice'].selected";
AddDependencyAttributes(**dependIt, visited, out); AddDependencyAttributes(**dependIt, visited, out);
} }
} }
void void cmCPackPackageMakerGenerator::AddReverseDependencyAttributes(
cmCPackPackageMakerGenerator:: const cmCPackComponent& component,
AddReverseDependencyAttributes(const cmCPackComponent& component, std::set<const cmCPackComponent*>& visited, std::ostringstream& out)
std::set<const cmCPackComponent *>& visited,
std::ostringstream& out)
{
if (visited.find(&component) != visited.end())
{ {
if (visited.find(&component) != visited.end()) {
return; return;
} }
visited.insert(&component); visited.insert(&component);
std::vector<cmCPackComponent*>::const_iterator dependIt; std::vector<cmCPackComponent*>::const_iterator dependIt;
for (dependIt = component.ReverseDependencies.begin(); for (dependIt = component.ReverseDependencies.begin();
dependIt != component.ReverseDependencies.end(); dependIt != component.ReverseDependencies.end(); ++dependIt) {
++dependIt)
{
out << " || choices['" << (*dependIt)->Name << "Choice'].selected"; out << " || choices['" << (*dependIt)->Name << "Choice'].selected";
AddReverseDependencyAttributes(**dependIt, visited, out); AddReverseDependencyAttributes(**dependIt, visited, out);
} }

View File

@ -37,8 +37,7 @@ public:
virtual bool SupportsComponentInstallation() const; virtual bool SupportsComponentInstallation() const;
protected: protected:
int CopyInstallScript(const std::string& resdir, int CopyInstallScript(const std::string& resdir, const std::string& script,
const std::string& script,
const std::string& name); const std::string& name);
virtual int InitializeInternal(); virtual int InitializeInternal();
int PackageFiles(); int PackageFiles();
@ -87,10 +86,9 @@ protected:
// Subroutine of WriteDistributionFile that writes out the // Subroutine of WriteDistributionFile that writes out the
// reverse dependency attributes for inter-component dependencies. // reverse dependency attributes for inter-component dependencies.
void void AddReverseDependencyAttributes(
AddReverseDependencyAttributes(const cmCPackComponent& component, const cmCPackComponent& component,
std::set<const cmCPackComponent *>& visited, std::set<const cmCPackComponent*>& visited, std::ostringstream& out);
std::ostringstream& out);
// Generates XML that encodes the hierarchy of component groups and // Generates XML that encodes the hierarchy of component groups and
// their components in a form that can be used by distribution // their components in a form that can be used by distribution

View File

@ -25,8 +25,7 @@ cmCPackRPMGenerator::~cmCPackRPMGenerator()
int cmCPackRPMGenerator::InitializeInternal() int cmCPackRPMGenerator::InitializeInternal()
{ {
this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr"); this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr");
if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) {
{
this->SetOption("CPACK_SET_DESTDIR", "I_ON"); this->SetOption("CPACK_SET_DESTDIR", "I_ON");
} }
/* Replace space in CPACK_PACKAGE_NAME in order to avoid /* Replace space in CPACK_PACKAGE_NAME in order to avoid
@ -54,8 +53,7 @@ void cmCPackRPMGenerator::AddGeneratedPackageNames()
const char sep = ';'; const char sep = ';';
std::string::size_type pos1 = 0; std::string::size_type pos1 = 0;
std::string::size_type pos2 = fileNames.find(sep, pos1 + 1); std::string::size_type pos2 = fileNames.find(sep, pos1 + 1);
while(pos2 != std::string::npos) while (pos2 != std::string::npos) {
{
packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1)); packageFileNames.push_back(fileNames.substr(pos1, pos2 - pos1));
pos1 = pos2 + 1; pos1 = pos2 + 1;
pos2 = fileNames.find(sep, pos1 + 1); pos2 = fileNames.find(sep, pos1 + 1);
@ -69,15 +67,11 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
int retval = 1; int retval = 1;
// Begin the archive for this pack // Begin the archive for this pack
std::string localToplevel(initialToplevel); std::string localToplevel(initialToplevel);
std::string packageFileName( std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
cmSystemTools::GetParentDirectory(toplevel)
);
std::string outputFileName( std::string outputFileName(
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
packageName, packageName, true) +
true) this->GetOutputExtension());
+ this->GetOutputExtension()
);
localToplevel += "/" + packageName; localToplevel += "/" + packageName;
/* replace the TEMP DIRECTORY with the component one */ /* replace the TEMP DIRECTORY with the component one */
@ -95,10 +89,9 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
component_path += packageName; component_path += packageName;
this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH", this->SetOption("CPACK_RPM_PACKAGE_COMPONENT_PART_PATH",
component_path.c_str()); component_path.c_str());
if (!this->ReadListFile("CPackRPM.cmake")) if (!this->ReadListFile("CPackRPM.cmake")) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
cmCPackLogger(cmCPackLog::LOG_ERROR, << std::endl);
"Error while execution CPackRPM.cmake" << std::endl);
retval = 0; retval = 0;
} }
@ -115,27 +108,22 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
// The default behavior is to have one package by component group // The default behavior is to have one package by component group
// unless CPACK_COMPONENTS_IGNORE_GROUP is specified. // unless CPACK_COMPONENTS_IGNORE_GROUP is specified.
if (!ignoreGroup) if (!ignoreGroup) {
{
std::map<std::string, cmCPackComponentGroup>::iterator compGIt; std::map<std::string, cmCPackComponentGroup>::iterator compGIt;
for (compGIt = this->ComponentGroups.begin(); for (compGIt = this->ComponentGroups.begin();
compGIt!=this->ComponentGroups.end(); ++compGIt) compGIt != this->ComponentGroups.end(); ++compGIt) {
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: "
<< compGIt->first << compGIt->first << std::endl);
<< std::endl);
retval &= PackageOnePack(initialTopLevel, compGIt->first); retval &= PackageOnePack(initialTopLevel, compGIt->first);
} }
// Handle Orphan components (components not belonging to any groups) // Handle Orphan components (components not belonging to any groups)
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt=this->Components.begin(); for (compIt = this->Components.begin(); compIt != this->Components.end();
compIt!=this->Components.end(); ++compIt ) ++compIt) {
{
// Does the component belong to a group? // Does the component belong to a group?
if (compIt->second.Group==NULL) if (compIt->second.Group == NULL) {
{ cmCPackLogger(
cmCPackLogger(cmCPackLog::LOG_VERBOSE, cmCPackLog::LOG_VERBOSE, "Component <"
"Component <"
<< compIt->second.Name << compIt->second.Name
<< "> does not belong to any group, package it separately." << "> does not belong to any group, package it separately."
<< std::endl); << std::endl);
@ -145,18 +133,15 @@ int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup)
} }
// CPACK_COMPONENTS_IGNORE_GROUPS is set // CPACK_COMPONENTS_IGNORE_GROUPS is set
// We build 1 package per component // We build 1 package per component
else else {
{
std::map<std::string, cmCPackComponent>::iterator compIt; std::map<std::string, cmCPackComponent>::iterator compIt;
for (compIt=this->Components.begin(); for (compIt = this->Components.begin(); compIt != this->Components.end();
compIt!=this->Components.end(); ++compIt ) ++compIt) {
{
retval &= PackageOnePack(initialTopLevel, compIt->first); retval &= PackageOnePack(initialTopLevel, compIt->first);
} }
} }
if(retval) if (retval) {
{
AddGeneratedPackageNames(); AddGeneratedPackageNames();
} }
@ -179,13 +164,10 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
// The ALL GROUPS in ONE package case // The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel); std::string localToplevel(initialTopLevel);
std::string packageFileName( std::string packageFileName(cmSystemTools::GetParentDirectory(toplevel));
cmSystemTools::GetParentDirectory(toplevel)
);
std::string outputFileName( std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) +
+ this->GetOutputExtension() this->GetOutputExtension());
);
// all GROUP in one vs all COMPONENT in one // all GROUP in one vs all COMPONENT in one
localToplevel += "/" + compInstDirName; localToplevel += "/" + compInstDirName;
@ -198,8 +180,7 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME",
packageFileName.c_str()); packageFileName.c_str());
if(!compInstDirName.empty()) if (!compInstDirName.empty()) {
{
// Tell CPackRPM.cmake the path where the component is. // Tell CPackRPM.cmake the path where the component is.
std::string component_path = "/"; std::string component_path = "/";
component_path += compInstDirName; component_path += compInstDirName;
@ -207,14 +188,11 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
component_path.c_str()); component_path.c_str());
} }
if (this->ReadListFile("CPackRPM.cmake")) if (this->ReadListFile("CPackRPM.cmake")) {
{
AddGeneratedPackageNames(); AddGeneratedPackageNames();
} } else {
else cmCPackLogger(cmCPackLog::LOG_ERROR, "Error while execution CPackRPM.cmake"
{ << std::endl);
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error while execution CPackRPM.cmake" << std::endl);
retval = 0; retval = 0;
} }
@ -223,43 +201,36 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne(
int cmCPackRPMGenerator::PackageFiles() int cmCPackRPMGenerator::PackageFiles()
{ {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl);
<< toplevel << std::endl);
/* Are we in the component packaging case */ /* Are we in the component packaging case */
if (WantsComponentInstallation()) { if (WantsComponentInstallation()) {
// CASE 1 : COMPONENT ALL-IN-ONE package // CASE 1 : COMPONENT ALL-IN-ONE package
// If ALL COMPONENTS in ONE package has been requested // If ALL COMPONENTS in ONE package has been requested
// then the package file is unique and should be open here. // then the package file is unique and should be open here.
if (componentPackageMethod == ONE_PACKAGE) if (componentPackageMethod == ONE_PACKAGE) {
{
return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE"); return PackageComponentsAllInOne("ALL_COMPONENTS_IN_ONE");
} }
// CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one)
// There will be 1 package for each component group // There will be 1 package for each component group
// however one may require to ignore component group and // however one may require to ignore component group and
// in this case you'll get 1 package for each component. // in this case you'll get 1 package for each component.
else else {
{
return PackageComponents(componentPackageMethod == return PackageComponents(componentPackageMethod ==
ONE_PACKAGE_PER_COMPONENT); ONE_PACKAGE_PER_COMPONENT);
} }
} }
// CASE 3 : NON COMPONENT package. // CASE 3 : NON COMPONENT package.
else else {
{
return PackageComponentsAllInOne(""); return PackageComponentsAllInOne("");
} }
} }
bool cmCPackRPMGenerator::SupportsComponentInstallation() const bool cmCPackRPMGenerator::SupportsComponentInstallation() const
{ {
if (IsOn("CPACK_RPM_COMPONENT_INSTALL")) if (IsOn("CPACK_RPM_COMPONENT_INSTALL")) {
{
return true; return true;
} } else {
else
{
return false; return false;
} }
} }
@ -276,14 +247,11 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
} }
// We have to find the name of the COMPONENT GROUP // We have to find the name of the COMPONENT GROUP
// the current COMPONENT belongs to. // the current COMPONENT belongs to.
std::string groupVar = "CPACK_COMPONENT_" + std::string groupVar =
cmSystemTools::UpperCase(componentName) + "_GROUP"; "CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
if (NULL != GetOption(groupVar)) if (NULL != GetOption(groupVar)) {
{
return std::string(GetOption(groupVar)); return std::string(GetOption(groupVar));
} } else {
else
{
return componentName; return componentName;
} }
} }

View File

@ -37,10 +37,9 @@ int cmCPackSTGZGenerator::InitializeInternal()
this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0"); this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "0");
std::string inFile = this->FindTemplate("CPack.STGZ_Header.sh.in"); std::string inFile = this->FindTemplate("CPack.STGZ_Header.sh.in");
if ( inFile.empty() ) if (inFile.empty()) {
{ cmCPackLogger(cmCPackLog::LOG_ERROR,
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find template file: " "Cannot find template file: " << inFile << std::endl);
<< inFile << std::endl);
return 0; return 0;
} }
this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str()); this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str());
@ -52,8 +51,7 @@ int cmCPackSTGZGenerator::InitializeInternal()
int cmCPackSTGZGenerator::PackageFiles() int cmCPackSTGZGenerator::PackageFiles()
{ {
bool retval = true; bool retval = true;
if ( !this->Superclass::PackageFiles() ) if (!this->Superclass::PackageFiles()) {
{
return 0; return 0;
} }
@ -62,8 +60,7 @@ int cmCPackSTGZGenerator::PackageFiles()
* so we must iterate over generated packages. * so we must iterate over generated packages.
*/ */
for (std::vector<std::string>::iterator it = packageFileNames.begin(); for (std::vector<std::string>::iterator it = packageFileNames.begin();
it != packageFileNames.end(); ++it) it != packageFileNames.end(); ++it) {
{
retval &= cmSystemTools::SetPermissions((*it).c_str(), retval &= cmSystemTools::SetPermissions((*it).c_str(),
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__)
S_IREAD | S_IWRITE | S_IEXEC S_IREAD | S_IWRITE | S_IEXEC
@ -87,8 +84,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
std::string line; std::string line;
cmsys::ifstream ilfs(inLicFile.c_str()); cmsys::ifstream ilfs(inLicFile.c_str());
std::string licenseText; std::string licenseText;
while ( cmSystemTools::GetLineFromStream(ilfs, line) ) while (cmSystemTools::GetLineFromStream(ilfs, line)) {
{
licenseText += line + "\n"; licenseText += line + "\n";
} }
this->SetOptionIfNotSet("CPACK_RESOURCE_FILE_LICENSE_CONTENT", this->SetOptionIfNotSet("CPACK_RESOURCE_FILE_LICENSE_CONTENT",
@ -100,8 +96,7 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
std::string inFile = this->GetOption("CPACK_STGZ_HEADER_FILE"); std::string inFile = this->GetOption("CPACK_STGZ_HEADER_FILE");
cmsys::ifstream ifs(inFile.c_str()); cmsys::ifstream ifs(inFile.c_str());
std::string packageHeaderText; std::string packageHeaderText;
while ( cmSystemTools::GetLineFromStream(ifs, line) ) while (cmSystemTools::GetLineFromStream(ifs, line)) {
{
packageHeaderText += line + "\n"; packageHeaderText += line + "\n";
} }
@ -111,17 +106,15 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
// Count the lines // Count the lines
const char* ptr = res.c_str(); const char* ptr = res.c_str();
while ( *ptr ) while (*ptr) {
{ if (*ptr == '\n') {
if ( *ptr == '\n' )
{
counter++; counter++;
} }
++ptr; ++ptr;
} }
counter++; counter++;
cmCPackLogger(cmCPackLog::LOG_DEBUG, cmCPackLogger(cmCPackLog::LOG_DEBUG, "Number of lines: " << counter
"Number of lines: " << counter << std::endl); << std::endl);
char buffer[1024]; char buffer[1024];
sprintf(buffer, "%d", counter); sprintf(buffer, "%d", counter);
cmSystemTools::ReplaceString(res, headerLengthTag, buffer); cmSystemTools::ReplaceString(res, headerLengthTag, buffer);

View File

@ -13,12 +13,10 @@
#include "cmCPackTGZGenerator.h" #include "cmCPackTGZGenerator.h"
cmCPackTGZGenerator::cmCPackTGZGenerator() cmCPackTGZGenerator::cmCPackTGZGenerator()
:cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, : cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, "paxr")
"paxr")
{ {
} }
cmCPackTGZGenerator::~cmCPackTGZGenerator() cmCPackTGZGenerator::~cmCPackTGZGenerator()
{ {
} }

View File

@ -28,6 +28,7 @@ public:
*/ */
cmCPackTGZGenerator(); cmCPackTGZGenerator();
virtual ~cmCPackTGZGenerator(); virtual ~cmCPackTGZGenerator();
protected: protected:
virtual const char* GetOutputExtension() { return ".tar.gz"; } virtual const char* GetOutputExtension() { return ".tar.gz"; }
}; };

View File

@ -13,8 +13,7 @@
#include "cmCPackTXZGenerator.h" #include "cmCPackTXZGenerator.h"
cmCPackTXZGenerator::cmCPackTXZGenerator() cmCPackTXZGenerator::cmCPackTXZGenerator()
:cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr")
"paxr")
{ {
} }

View File

@ -28,6 +28,7 @@ public:
*/ */
cmCPackTXZGenerator(); cmCPackTXZGenerator();
virtual ~cmCPackTXZGenerator(); virtual ~cmCPackTXZGenerator();
protected: protected:
virtual const char* GetOutputExtension() { return ".tar.xz"; } virtual const char* GetOutputExtension() { return ".tar.xz"; }
}; };

View File

@ -13,12 +13,10 @@
#include "cmCPackTarBZip2Generator.h" #include "cmCPackTarBZip2Generator.h"
cmCPackTarBZip2Generator::cmCPackTarBZip2Generator() cmCPackTarBZip2Generator::cmCPackTarBZip2Generator()
:cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, : cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, "paxr")
"paxr")
{ {
} }
cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator() cmCPackTarBZip2Generator::~cmCPackTarBZip2Generator()
{ {
} }

View File

@ -27,6 +27,7 @@ public:
*/ */
cmCPackTarBZip2Generator(); cmCPackTarBZip2Generator();
virtual ~cmCPackTarBZip2Generator(); virtual ~cmCPackTarBZip2Generator();
protected: protected:
virtual const char* GetOutputExtension() { return ".tar.bz2"; } virtual const char* GetOutputExtension() { return ".tar.bz2"; }
}; };

View File

@ -13,12 +13,10 @@
#include "cmCPackTarCompressGenerator.h" #include "cmCPackTarCompressGenerator.h"
cmCPackTarCompressGenerator::cmCPackTarCompressGenerator() cmCPackTarCompressGenerator::cmCPackTarCompressGenerator()
:cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, : cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, "paxr")
"paxr")
{ {
} }
cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator() cmCPackTarCompressGenerator::~cmCPackTarCompressGenerator()
{ {
} }

View File

@ -13,12 +13,10 @@
#include "cmCPackZIPGenerator.h" #include "cmCPackZIPGenerator.h"
cmCPackZIPGenerator::cmCPackZIPGenerator() cmCPackZIPGenerator::cmCPackZIPGenerator()
:cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, : cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, "zip")
"zip")
{ {
} }
cmCPackZIPGenerator::~cmCPackZIPGenerator() cmCPackZIPGenerator::~cmCPackZIPGenerator()
{ {
} }

View File

@ -26,22 +26,17 @@
#include <cmsys/Encoding.hxx> #include <cmsys/Encoding.hxx>
#include <cmsys/SystemTools.hxx> #include <cmsys/SystemTools.hxx>
static const char * cmDocumentationName[][2] = static const char* cmDocumentationName[][2] = {
{ { 0, " cpack - Packaging driver provided by CMake." },
{0,
" cpack - Packaging driver provided by CMake."},
{ 0, 0 } { 0, 0 }
}; };
static const char * cmDocumentationUsage[][2] = static const char* cmDocumentationUsage[][2] = {
{ { 0, " cpack -G <generator> [options]" },
{0,
" cpack -G <generator> [options]"},
{ 0, 0 } { 0, 0 }
}; };
static const char * cmDocumentationOptions[][2] = static const char* cmDocumentationOptions[][2] = {
{
{ "-G <generator>", "Use the specified generator to generate package." }, { "-G <generator>", "Use the specified generator to generate package." },
{ "-C <Configuration>", "Specify the project configuration" }, { "-C <Configuration>", "Specify the project configuration" },
{ "-D <var>=<value>", "Set a CPack variable." }, { "-D <var>=<value>", "Set a CPack variable." },
@ -74,8 +69,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
cpackDefinitions* def = static_cast<cpackDefinitions*>(call_data); cpackDefinitions* def = static_cast<cpackDefinitions*>(call_data);
std::string value = cValue; std::string value = cValue;
size_t pos = value.find_first_of("="); size_t pos = value.find_first_of("=");
if ( pos == std::string::npos ) if (pos == std::string::npos) {
{
cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR, cmCPack_Log(def->Log, cmCPackLog::LOG_ERROR,
"Please specify CPack definitions as: KEY=VALUE" << std::endl); "Please specify CPack definitions as: KEY=VALUE" << std::endl);
return 0; return 0;
@ -88,7 +82,6 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
return 1; return 1;
} }
// this is CPack. // this is CPack.
int main(int argc, char const* const* argv) int main(int argc, char const* const* argv)
{ {
@ -107,10 +100,10 @@ int main (int argc, char const* const* argv)
cmSystemTools::EnableMSVCDebugHook(); cmSystemTools::EnableMSVCDebugHook();
if (cmSystemTools::GetCurrentWorkingDirectory().empty()) if (cmSystemTools::GetCurrentWorkingDirectory().empty()) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Current working directory cannot be established." << std::endl); "Current working directory cannot be established."
<< std::endl);
return 1; return 1;
} }
@ -155,33 +148,30 @@ int main (int argc, char const* const* argv)
"CPack configuration file"); "CPack configuration file");
arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig, arg.AddArgument("-C", argT::SPACE_ARGUMENT, &cpackBuildConfig,
"CPack build configuration"); "CPack build configuration");
arg.AddArgument("-G", argT::SPACE_ARGUMENT, arg.AddArgument("-G", argT::SPACE_ARGUMENT, &generator, "CPack generator");
&generator, "CPack generator"); arg.AddArgument("-P", argT::SPACE_ARGUMENT, &cpackProjectName,
arg.AddArgument("-P", argT::SPACE_ARGUMENT, "CPack project name");
&cpackProjectName, "CPack project name"); arg.AddArgument("-R", argT::SPACE_ARGUMENT, &cpackProjectVersion,
arg.AddArgument("-R", argT::SPACE_ARGUMENT, "CPack project version");
&cpackProjectVersion, "CPack project version"); arg.AddArgument("-B", argT::SPACE_ARGUMENT, &cpackProjectDirectory,
arg.AddArgument("-B", argT::SPACE_ARGUMENT, "CPack project directory");
&cpackProjectDirectory, "CPack project directory"); arg.AddArgument("--patch", argT::SPACE_ARGUMENT, &cpackProjectPatch,
arg.AddArgument("--patch", argT::SPACE_ARGUMENT, "CPack project patch");
&cpackProjectPatch, "CPack project patch"); arg.AddArgument("--vendor", argT::SPACE_ARGUMENT, &cpackProjectVendor,
arg.AddArgument("--vendor", argT::SPACE_ARGUMENT, "CPack project vendor");
&cpackProjectVendor, "CPack project vendor"); arg.AddCallback("-D", argT::SPACE_ARGUMENT, cpackDefinitionArgument,
arg.AddCallback("-D", argT::SPACE_ARGUMENT, &definitions, "CPack Definitions");
cpackDefinitionArgument, &definitions, "CPack Definitions");
arg.SetUnknownArgumentCallback(cpackUnknownArgument); arg.SetUnknownArgumentCallback(cpackUnknownArgument);
// Parse command line // Parse command line
int parsed = arg.Parse(); int parsed = arg.Parse();
// Setup logging // Setup logging
if ( verbose ) if (verbose) {
{
log.SetVerbose(verbose); log.SetVerbose(verbose);
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl); cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl);
} }
if ( debug ) if (debug) {
{
log.SetDebug(debug); log.SetDebug(debug);
cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl); cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Debug" << std::endl);
} }
@ -202,8 +192,7 @@ int main (int argc, char const* const* argv)
#endif #endif
bool cpackConfigFileSpecified = true; bool cpackConfigFileSpecified = true;
if ( cpackConfigFile.empty() ) if (cpackConfigFile.empty()) {
{
cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory(); cpackConfigFile = cmSystemTools::GetCurrentWorkingDirectory();
cpackConfigFile += "/CPackConfig.cmake"; cpackConfigFile += "/CPackConfig.cmake";
cpackConfigFileSpecified = false; cpackConfigFileSpecified = false;
@ -220,26 +209,21 @@ int main (int argc, char const* const* argv)
* should launch cpack using "cpackConfigFile" if it exists * should launch cpack using "cpackConfigFile" if it exists
* in the current directory. * in the current directory.
*/ */
if((doc.CheckOptions(argc, argv,"-G")) && !(argc==1)) if ((doc.CheckOptions(argc, argv, "-G")) && !(argc == 1)) {
{
help = true; help = true;
} } else {
else
{
help = false; help = false;
} }
// This part is used for cpack documentation lookup as well. // This part is used for cpack documentation lookup as well.
cminst.AddCMakePaths(); cminst.AddCMakePaths();
if ( parsed && !help ) if (parsed && !help) {
{
// find out which system cpack is running on, so it can setup the search // find out which system cpack is running on, so it can setup the search
// paths, so FIND_XXX() commands can be used in scripts // paths, so FIND_XXX() commands can be used in scripts
std::string systemFile = std::string systemFile =
globalMF->GetModulesFile("CMakeDetermineSystem.cmake"); globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
if (!globalMF->ReadListFile(systemFile.c_str())) if (!globalMF->ReadListFile(systemFile.c_str())) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeDetermineSystem.cmake" << std::endl); "Error reading CMakeDetermineSystem.cmake" << std::endl);
return 1; return 1;
@ -247,115 +231,91 @@ int main (int argc, char const* const* argv)
systemFile = systemFile =
globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake"); globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
if (!globalMF->ReadListFile(systemFile.c_str())) if (!globalMF->ReadListFile(systemFile.c_str())) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error reading CMakeSystemSpecificInformation.cmake" << std::endl); "Error reading CMakeSystemSpecificInformation.cmake"
<< std::endl);
return 1; return 1;
} }
if ( !cpackBuildConfig.empty() ) if (!cpackBuildConfig.empty()) {
{
globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str()); globalMF->AddDefinition("CPACK_BUILD_CONFIG", cpackBuildConfig.c_str());
} }
if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) ) if (cmSystemTools::FileExists(cpackConfigFile.c_str())) {
{ cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile);
cpackConfigFile =
cmSystemTools::CollapseFullPath(cpackConfigFile);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack configuration file: " << cpackConfigFile "Read CPack configuration file: " << cpackConfigFile
<< std::endl); << std::endl);
if ( !globalMF->ReadListFile(cpackConfigFile.c_str()) ) if (!globalMF->ReadListFile(cpackConfigFile.c_str())) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Problem reading CPack config file: \"" "Problem reading CPack config file: \""
<< cpackConfigFile << "\"" << std::endl); << cpackConfigFile << "\"" << std::endl);
return 1; return 1;
} }
} } else if (cpackConfigFileSpecified) {
else if ( cpackConfigFileSpecified )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot find CPack config file: \"" << "Cannot find CPack config file: \"" << cpackConfigFile
cpackConfigFile << "\"" << std::endl); << "\"" << std::endl);
return 1; return 1;
} }
if ( !generator.empty() ) if (!generator.empty()) {
{
globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str()); globalMF->AddDefinition("CPACK_GENERATOR", generator.c_str());
} }
if ( !cpackProjectName.empty() ) if (!cpackProjectName.empty()) {
{
globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str()); globalMF->AddDefinition("CPACK_PACKAGE_NAME", cpackProjectName.c_str());
} }
if ( !cpackProjectVersion.empty() ) if (!cpackProjectVersion.empty()) {
{
globalMF->AddDefinition("CPACK_PACKAGE_VERSION", globalMF->AddDefinition("CPACK_PACKAGE_VERSION",
cpackProjectVersion.c_str()); cpackProjectVersion.c_str());
} }
if ( !cpackProjectVendor.empty() ) if (!cpackProjectVendor.empty()) {
{
globalMF->AddDefinition("CPACK_PACKAGE_VENDOR", globalMF->AddDefinition("CPACK_PACKAGE_VENDOR",
cpackProjectVendor.c_str()); cpackProjectVendor.c_str());
} }
// if this is not empty it has been set on the command line // if this is not empty it has been set on the command line
// go for it. Command line override values set in config file. // go for it. Command line override values set in config file.
if ( !cpackProjectDirectory.empty() ) if (!cpackProjectDirectory.empty()) {
{
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY", globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
cpackProjectDirectory.c_str()); cpackProjectDirectory.c_str());
} }
// The value has not been set on the command line // The value has not been set on the command line
else else {
{
// get a default value (current working directory) // get a default value (current working directory)
cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory(); cpackProjectDirectory = cmsys::SystemTools::GetCurrentWorkingDirectory();
// use default value iff no value has been provided by the config file // use default value iff no value has been provided by the config file
if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) if (!globalMF->IsSet("CPACK_PACKAGE_DIRECTORY")) {
{
globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY", globalMF->AddDefinition("CPACK_PACKAGE_DIRECTORY",
cpackProjectDirectory.c_str()); cpackProjectDirectory.c_str());
} }
} }
cpackDefinitions::MapType::iterator cdit; cpackDefinitions::MapType::iterator cdit;
for ( cdit = definitions.Map.begin(); for (cdit = definitions.Map.begin(); cdit != definitions.Map.end();
cdit != definitions.Map.end(); ++cdit) {
++cdit )
{
globalMF->AddDefinition(cdit->first, cdit->second.c_str()); globalMF->AddDefinition(cdit->first, cdit->second.c_str());
} }
const char* cpackModulesPath = const char* cpackModulesPath =
globalMF->GetDefinition("CPACK_MODULE_PATH"); globalMF->GetDefinition("CPACK_MODULE_PATH");
if ( cpackModulesPath ) if (cpackModulesPath) {
{
globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath); globalMF->AddDefinition("CMAKE_MODULE_PATH", cpackModulesPath);
} }
const char* genList = globalMF->GetDefinition("CPACK_GENERATOR"); const char* genList = globalMF->GetDefinition("CPACK_GENERATOR");
if ( !genList ) if (!genList) {
{ cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "CPack generator not specified"
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, << std::endl);
"CPack generator not specified" << std::endl); } else {
}
else
{
std::vector<std::string> generatorsVector; std::vector<std::string> generatorsVector;
cmSystemTools::ExpandListArgument(genList, cmSystemTools::ExpandListArgument(genList, generatorsVector);
generatorsVector);
std::vector<std::string>::iterator it; std::vector<std::string>::iterator it;
for ( it = generatorsVector.begin(); for (it = generatorsVector.begin(); it != generatorsVector.end(); ++it) {
it != generatorsVector.end();
++it )
{
const char* gen = it->c_str(); const char* gen = it->c_str();
cmMakefile::ScopePushPop raii(globalMF.get()); cmMakefile::ScopePushPop raii(globalMF.get());
cmMakefile* mf = globalMF.get(); cmMakefile* mf = globalMF.get();
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Specified generator: " << gen << std::endl); "Specified generator: " << gen << std::endl);
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") ) if (parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME")) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack project name not specified" << std::endl); "CPack project name not specified" << std::endl);
parsed = 0; parsed = 0;
@ -364,38 +324,37 @@ int main (int argc, char const* const* argv)
!(mf->GetDefinition("CPACK_PACKAGE_VERSION") || !(mf->GetDefinition("CPACK_PACKAGE_VERSION") ||
(mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") && (mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") && mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR") &&
mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")))) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"CPack project version not specified" << std::endl "CPack project version not specified"
<< std::endl
<< "Specify CPACK_PACKAGE_VERSION, or " << "Specify CPACK_PACKAGE_VERSION, or "
"CPACK_PACKAGE_VERSION_MAJOR, " "CPACK_PACKAGE_VERSION_MAJOR, "
"CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH." "CPACK_PACKAGE_VERSION_MINOR, and "
"CPACK_PACKAGE_VERSION_PATCH."
<< std::endl); << std::endl);
parsed = 0; parsed = 0;
} }
if ( parsed ) if (parsed) {
{
cpackGenerator = generators.NewGenerator(gen); cpackGenerator = generators.NewGenerator(gen);
if ( !cpackGenerator ) if (!cpackGenerator) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize CPack generator: " "Cannot initialize CPack generator: " << gen
<< gen << std::endl); << std::endl);
parsed = 0; parsed = 0;
} }
if ( parsed && !cpackGenerator->Initialize(gen, mf) ) if (parsed && !cpackGenerator->Initialize(gen, mf)) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Cannot initialize the generator " << gen << std::endl); "Cannot initialize the generator " << gen
<< std::endl);
parsed = 0; parsed = 0;
} }
if (!mf->GetDefinition("CPACK_INSTALL_COMMANDS") && if (!mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
!mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") && !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
!mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") ) !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS")) {
{ cmCPack_Log(
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, &log, cmCPackLog::LOG_ERROR,
"Please specify build tree of the project that uses CMake " "Please specify build tree of the project that uses CMake "
"using CPACK_INSTALL_CMAKE_PROJECTS, specify " "using CPACK_INSTALL_CMAKE_PROJECTS, specify "
"CPACK_INSTALL_COMMANDS, or specify " "CPACK_INSTALL_COMMANDS, or specify "
@ -403,36 +362,33 @@ int main (int argc, char const* const* argv)
<< std::endl); << std::endl);
parsed = 0; parsed = 0;
} }
if ( parsed ) if (parsed) {
{
const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME"); const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: " cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
<< cpackGenerator->GetNameOfClass() << std::endl); << cpackGenerator->GetNameOfClass() << std::endl);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
<< projName << std::endl); "For project: " << projName << std::endl);
const char* projVersion = const char* projVersion =
mf->GetDefinition("CPACK_PACKAGE_VERSION"); mf->GetDefinition("CPACK_PACKAGE_VERSION");
if ( !projVersion ) if (!projVersion) {
{ const char* projVersionMajor =
const char* projVersionMajor mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR"); const char* projVersionMinor =
const char* projVersionMinor mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR"); const char* projVersionPatch =
const char* projVersionPatch mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
= mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
std::ostringstream ostr; std::ostringstream ostr;
ostr << projVersionMajor << "." << projVersionMinor << "." ostr << projVersionMajor << "." << projVersionMinor << "."
<< projVersionPatch; << projVersionPatch;
mf->AddDefinition("CPACK_PACKAGE_VERSION", mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str());
ostr.str().c_str());
} }
int res = cpackGenerator->DoPackage(); int res = cpackGenerator->DoPackage();
if ( !res ) if (!res) {
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR, cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Error when generating package: " << projName << std::endl); "Error when generating package: " << projName
<< std::endl);
return 1; return 1;
} }
} }
@ -445,8 +401,7 @@ int main (int argc, char const* const* argv)
* instance in order to create appropriate structure * instance in order to create appropriate structure
* in order to satisfy the appropriate --help-xxx request * in order to satisfy the appropriate --help-xxx request
*/ */
if ( help ) if (help) {
{
// Construct and print requested documentation. // Construct and print requested documentation.
doc.SetName("cpack"); doc.SetName("cpack");
@ -457,9 +412,7 @@ int main (int argc, char const* const* argv)
std::vector<cmDocumentationEntry> v; std::vector<cmDocumentationEntry> v;
cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt; cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt;
for (generatorIt = generators.GetGeneratorsList().begin(); for (generatorIt = generators.GetGeneratorsList().begin();
generatorIt != generators.GetGeneratorsList().end(); generatorIt != generators.GetGeneratorsList().end(); ++generatorIt) {
++ generatorIt )
{
cmDocumentationEntry e; cmDocumentationEntry e;
e.Name = generatorIt->first.c_str(); e.Name = generatorIt->first.c_str();
e.Brief = generatorIt->second.c_str(); e.Brief = generatorIt->second.c_str();
@ -472,8 +425,7 @@ int main (int argc, char const* const* argv)
#define cout no_cout_use_cmCPack_Log #define cout no_cout_use_cmCPack_Log
} }
if (cmSystemTools::GetErrorOccuredFlag()) if (cmSystemTools::GetErrorOccuredFlag()) {
{
return 1; return 1;
} }

View File

@ -19,45 +19,40 @@
#include <cm_expat.h> #include <cm_expat.h>
extern "C" extern "C" int cmBZRXMLParserUnknownEncodingHandler(void*,
int cmBZRXMLParserUnknownEncodingHandler(void*,
const XML_Char* name, const XML_Char* name,
XML_Encoding* info) XML_Encoding* info)
{ {
static const int latin1[]= static const int latin1[] = {
{ 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0010, 0x0011,
0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x0018, 0x0019, 0x001A,
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023,
0x0018, 0x0019, 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C,
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035,
0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E,
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x003F, 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x0050,
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059,
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x0060, 0x0061, 0x0062,
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B,
0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, 0x006C, 0x006D, 0x006E, 0x006F, 0x0070, 0x0071, 0x0072, 0x0073, 0x0074,
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D,
0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, 0x007E, 0x007F, 0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020,
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x2021, 0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F,
0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x007F, 0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x02DC,
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178, 0x00A0, 0x00A1,
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00A8, 0x00A9, 0x00AA,
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B1, 0x00B2, 0x00B3,
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC,
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00BD, 0x00BE, 0x00BF, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5,
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE,
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7, 0x00CF, 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0,
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E8, 0x00E9,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00F0, 0x00F1, 0x00F2,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F8, 0x00F9, 0x00FA, 0x00FB,
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00FC, 0x00FD, 0x00FE, 0x00FF
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF
}; };
// The BZR xml output plugin can use some encodings that are not // The BZR xml output plugin can use some encodings that are not
@ -65,17 +60,17 @@ int cmBZRXMLParserUnknownEncodingHandler(void*,
// parsing bzr log xml: unknown encoding", the following is a // parsing bzr log xml: unknown encoding", the following is a
// workaround for these unknown encodings. // workaround for these unknown encodings.
if (name == std::string("ascii") || name == std::string("cp1252") || if (name == std::string("ascii") || name == std::string("cp1252") ||
name == std::string("ANSI_X3.4-1968")) name == std::string("ANSI_X3.4-1968")) {
{ for (unsigned int i = 0; i < 256; ++i)
for(unsigned int i=0;i<256;++i) info->map[i] = latin1[i]; info->map[i] = latin1[i];
return 1; return 1;
} }
return 0; return 0;
} }
cmCTestBZR::cmCTestBZR(cmCTest* ct, std::ostream& log): cmCTestBZR::cmCTestBZR(cmCTest* ct, std::ostream& log)
cmCTestGlobalVC(ct, log) : cmCTestGlobalVC(ct, log)
{ {
this->PriorRev = this->Unknown; this->PriorRev = this->Unknown;
// Even though it is specified in the documentation, with bzr 1.13 // Even though it is specified in the documentation, with bzr 1.13
@ -91,13 +86,15 @@ cmCTestBZR::~cmCTestBZR()
class cmCTestBZR::InfoParser : public cmCTestVC::LineParser class cmCTestBZR::InfoParser : public cmCTestVC::LineParser
{ {
public: public:
InfoParser(cmCTestBZR* bzr, const char* prefix): InfoParser(cmCTestBZR* bzr, const char* prefix)
BZR(bzr), CheckOutFound(false) : BZR(bzr)
, CheckOutFound(false)
{ {
this->SetLog(&bzr->Log, prefix); this->SetLog(&bzr->Log, prefix);
this->RegexCheckOut.compile("checkout of branch: *([^\t\r\n]+)$"); this->RegexCheckOut.compile("checkout of branch: *([^\t\r\n]+)$");
this->RegexParent.compile("parent branch: *([^\t\r\n]+)$"); this->RegexParent.compile("parent branch: *([^\t\r\n]+)$");
} }
private: private:
cmCTestBZR* BZR; cmCTestBZR* BZR;
bool CheckOutFound; bool CheckOutFound;
@ -105,13 +102,10 @@ private:
cmsys::RegularExpression RegexParent; cmsys::RegularExpression RegexParent;
virtual bool ProcessLine() virtual bool ProcessLine()
{ {
if(this->RegexCheckOut.find(this->Line)) if (this->RegexCheckOut.find(this->Line)) {
{
this->BZR->URL = this->RegexCheckOut.match(1); this->BZR->URL = this->RegexCheckOut.match(1);
CheckOutFound = true; CheckOutFound = true;
} } else if (!CheckOutFound && this->RegexParent.find(this->Line)) {
else if(!CheckOutFound && this->RegexParent.find(this->Line))
{
this->BZR->URL = this->RegexParent.match(1); this->BZR->URL = this->RegexParent.match(1);
} }
return true; return true;
@ -121,19 +115,19 @@ private:
class cmCTestBZR::RevnoParser : public cmCTestVC::LineParser class cmCTestBZR::RevnoParser : public cmCTestVC::LineParser
{ {
public: public:
RevnoParser(cmCTestBZR* bzr, const char* prefix, std::string& rev): RevnoParser(cmCTestBZR* bzr, const char* prefix, std::string& rev)
Rev(rev) : Rev(rev)
{ {
this->SetLog(&bzr->Log, prefix); this->SetLog(&bzr->Log, prefix);
this->RegexRevno.compile("^([0-9]+)$"); this->RegexRevno.compile("^([0-9]+)$");
} }
private: private:
std::string& Rev; std::string& Rev;
cmsys::RegularExpression RegexRevno; cmsys::RegularExpression RegexRevno;
virtual bool ProcessLine() virtual bool ProcessLine()
{ {
if(this->RegexRevno.find(this->Line)) if (this->RegexRevno.find(this->Line)) {
{
this->Rev = this->RegexRevno.match(1); this->Rev = this->RegexRevno.match(1);
} }
return true; return true;
@ -181,22 +175,25 @@ class cmCTestBZR::LogParser: public cmCTestVC::OutputLogger,
private cmXMLParser private cmXMLParser
{ {
public: public:
LogParser(cmCTestBZR* bzr, const char* prefix): LogParser(cmCTestBZR* bzr, const char* prefix)
OutputLogger(bzr->Log, prefix), BZR(bzr), : OutputLogger(bzr->Log, prefix)
EmailRegex("(.*) <([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+)>") , BZR(bzr)
{ this->InitializeParser(); } , EmailRegex("(.*) <([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+)>")
{
this->InitializeParser();
}
~LogParser() { this->CleanupParser(); } ~LogParser() { this->CleanupParser(); }
virtual int InitializeParser() virtual int InitializeParser()
{ {
int res = cmXMLParser::InitializeParser(); int res = cmXMLParser::InitializeParser();
if (res) if (res) {
{
XML_SetUnknownEncodingHandler(static_cast<XML_Parser>(this->Parser), XML_SetUnknownEncodingHandler(static_cast<XML_Parser>(this->Parser),
cmBZRXMLParserUnknownEncodingHandler, 0); cmBZRXMLParserUnknownEncodingHandler, 0);
} }
return res; return res;
} }
private: private:
cmCTestBZR* BZR; cmCTestBZR* BZR;
@ -219,33 +216,23 @@ private:
virtual void StartElement(const std::string& name, const char**) virtual void StartElement(const std::string& name, const char**)
{ {
this->CData.clear(); this->CData.clear();
if(name == "log") if (name == "log") {
{
this->Rev = Revision(); this->Rev = Revision();
this->Changes.clear(); this->Changes.clear();
} }
// affected-files can contain blocks of // affected-files can contain blocks of
// modified, unknown, renamed, kind-changed, removed, conflicts, added // modified, unknown, renamed, kind-changed, removed, conflicts, added
else if(name == "modified" else if (name == "modified" || name == "renamed" ||
|| name == "renamed" name == "kind-changed") {
|| name == "kind-changed")
{
this->CurChange = Change(); this->CurChange = Change();
this->CurChange.Action = 'M'; this->CurChange.Action = 'M';
} } else if (name == "added") {
else if(name == "added")
{
this->CurChange = Change(); this->CurChange = Change();
this->CurChange = 'A'; this->CurChange = 'A';
} } else if (name == "removed") {
else if(name == "removed")
{
this->CurChange = Change(); this->CurChange = Change();
this->CurChange = 'D'; this->CurChange = 'D';
} } else if (name == "unknown" || name == "conflicts") {
else if(name == "unknown"
|| name == "conflicts")
{
// Should not happen here // Should not happen here
this->CurChange = Change(); this->CurChange = Change();
} }
@ -258,43 +245,29 @@ private:
virtual void EndElement(const std::string& name) virtual void EndElement(const std::string& name)
{ {
if(name == "log") if (name == "log") {
{
this->BZR->DoRevision(this->Rev, this->Changes); this->BZR->DoRevision(this->Rev, this->Changes);
} } else if (!this->CData.empty() &&
else if(!this->CData.empty() && (name == "file" || name == "directory")) {
(name == "file" || name == "directory"))
{
this->CurChange.Path.assign(&this->CData[0], this->CData.size()); this->CurChange.Path.assign(&this->CData[0], this->CData.size());
cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
this->Changes.push_back(this->CurChange); this->Changes.push_back(this->CurChange);
} } else if (!this->CData.empty() && name == "symlink") {
else if(!this->CData.empty() && name == "symlink")
{
// symlinks have an arobase at the end in the log // symlinks have an arobase at the end in the log
this->CurChange.Path.assign(&this->CData[0], this->CData.size() - 1); this->CurChange.Path.assign(&this->CData[0], this->CData.size() - 1);
cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
this->Changes.push_back(this->CurChange); this->Changes.push_back(this->CurChange);
} } else if (!this->CData.empty() && name == "committer") {
else if(!this->CData.empty() && name == "committer")
{
this->Rev.Author.assign(&this->CData[0], this->CData.size()); this->Rev.Author.assign(&this->CData[0], this->CData.size());
if(this->EmailRegex.find(this->Rev.Author)) if (this->EmailRegex.find(this->Rev.Author)) {
{
this->Rev.Author = this->EmailRegex.match(1); this->Rev.Author = this->EmailRegex.match(1);
this->Rev.EMail = this->EmailRegex.match(2); this->Rev.EMail = this->EmailRegex.match(2);
} }
} } else if (!this->CData.empty() && name == "timestamp") {
else if(!this->CData.empty() && name == "timestamp")
{
this->Rev.Date.assign(&this->CData[0], this->CData.size()); this->Rev.Date.assign(&this->CData[0], this->CData.size());
} } else if (!this->CData.empty() && name == "message") {
else if(!this->CData.empty() && name == "message")
{
this->Rev.Log.assign(&this->CData[0], this->CData.size()); this->Rev.Log.assign(&this->CData[0], this->CData.size());
} } else if (!this->CData.empty() && name == "revno") {
else if(!this->CData.empty() && name == "revno")
{
this->Rev.Rev.assign(&this->CData[0], this->CData.size()); this->Rev.Rev.assign(&this->CData[0], this->CData.size());
} }
this->CData.clear(); this->CData.clear();
@ -309,11 +282,13 @@ private:
class cmCTestBZR::UpdateParser : public cmCTestVC::LineParser class cmCTestBZR::UpdateParser : public cmCTestVC::LineParser
{ {
public: public:
UpdateParser(cmCTestBZR* bzr, const char* prefix): BZR(bzr) UpdateParser(cmCTestBZR* bzr, const char* prefix)
: BZR(bzr)
{ {
this->SetLog(&bzr->Log, prefix); this->SetLog(&bzr->Log, prefix);
this->RegexUpdate.compile("^([-+R?XCP ])([NDKM ])([* ]) +(.+)$"); this->RegexUpdate.compile("^([-+R?XCP ])([NDKM ])([* ]) +(.+)$");
} }
private: private:
cmCTestBZR* BZR; cmCTestBZR* BZR;
cmsys::RegularExpression RegexUpdate; cmsys::RegularExpression RegexUpdate;
@ -323,21 +298,16 @@ private:
bool last_is_new_line = (*first == '\r' || *first == '\n'); bool last_is_new_line = (*first == '\r' || *first == '\n');
const char* const last = first + length; const char* const last = first + length;
for(const char* c = first; c != last; ++c) for (const char* c = first; c != last; ++c) {
{ if (*c == '\r' || *c == '\n') {
if(*c == '\r' || *c == '\n') if (!last_is_new_line) {
{
if(!last_is_new_line)
{
// Log this line. // Log this line.
if(this->Log && this->Prefix) if (this->Log && this->Prefix) {
{
*this->Log << this->Prefix << this->Line << "\n"; *this->Log << this->Prefix << this->Line << "\n";
} }
// Hand this line to the subclass implementation. // Hand this line to the subclass implementation.
if(!this->ProcessLine()) if (!this->ProcessLine()) {
{
this->Line = ""; this->Line = "";
return false; return false;
} }
@ -345,9 +315,7 @@ private:
this->Line = ""; this->Line = "";
last_is_new_line = true; last_is_new_line = true;
} }
} } else {
else
{
// Append this character to the line under construction. // Append this character to the line under construction.
this->Line.append(1, *c); this->Line.append(1, *c);
last_is_new_line = false; last_is_new_line = false;
@ -358,32 +326,29 @@ private:
bool ProcessLine() bool ProcessLine()
{ {
if(this->RegexUpdate.find(this->Line)) if (this->RegexUpdate.find(this->Line)) {
{
this->DoPath(this->RegexUpdate.match(1)[0], this->DoPath(this->RegexUpdate.match(1)[0],
this->RegexUpdate.match(2)[0], this->RegexUpdate.match(2)[0],
this->RegexUpdate.match(3)[0], this->RegexUpdate.match(3)[0], this->RegexUpdate.match(4));
this->RegexUpdate.match(4));
} }
return true; return true;
} }
void DoPath(char c0, char c1, char c2, std::string path) void DoPath(char c0, char c1, char c2, std::string path)
{ {
if(path.empty()) return; if (path.empty())
return;
cmSystemTools::ConvertToUnixSlashes(path); cmSystemTools::ConvertToUnixSlashes(path);
const std::string dir = cmSystemTools::GetFilenamePath(path); const std::string dir = cmSystemTools::GetFilenamePath(path);
const std::string name = cmSystemTools::GetFilenameName(path); const std::string name = cmSystemTools::GetFilenameName(path);
if ( c0=='C' ) if (c0 == 'C') {
{
this->BZR->Dirs[dir][name].Status = PathConflicting; this->BZR->Dirs[dir][name].Status = PathConflicting;
return; return;
} }
if ( c1=='M' || c1=='K' || c1=='N' || c1=='D' || c2 =='*' ) if (c1 == 'M' || c1 == 'K' || c1 == 'N' || c1 == 'D' || c2 == '*') {
{
this->BZR->Dirs[dir][name].Status = PathUpdated; this->BZR->Dirs[dir][name].Status = PathUpdated;
return; return;
} }
@ -394,8 +359,7 @@ bool cmCTestBZR::UpdateImpl()
{ {
// Get user-specified update options. // Get user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions"); std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
if(opts.empty()) if (opts.empty()) {
{
opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions"); opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions");
} }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
@ -408,8 +372,7 @@ bool cmCTestBZR::UpdateImpl()
bzr_update.push_back("pull"); bzr_update.push_back("pull");
for (std::vector<std::string>::const_iterator ai = args.begin(); for (std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai) ai != args.end(); ++ai) {
{
bzr_update.push_back(ai->c_str()); bzr_update.push_back(ai->c_str());
} }
@ -427,25 +390,24 @@ void cmCTestBZR::LoadRevisions()
{ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n" " Gathering version information (one . per revision):\n"
" " << std::flush); " "
<< std::flush);
// We are interested in every revision included in the update. // We are interested in every revision included in the update.
this->Revisions.clear(); this->Revisions.clear();
std::string revs; std::string revs;
if(atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str())) if (atoi(this->OldRevision.c_str()) <= atoi(this->NewRevision.c_str())) {
{
// DoRevision takes care of discarding the information about OldRevision // DoRevision takes care of discarding the information about OldRevision
revs = this->OldRevision + ".." + this->NewRevision; revs = this->OldRevision + ".." + this->NewRevision;
} } else {
else
{
return; return;
} }
// Run "bzr log" to get all global revisions of interest. // Run "bzr log" to get all global revisions of interest.
const char* bzr = this->CommandLineTool.c_str(); const char* bzr = this->CommandLineTool.c_str();
const char* bzr_log[] = {bzr, "log", "-v", "-r", revs.c_str(), "--xml", const char* bzr_log[] = {
this->URL.c_str(), 0}; bzr, "log", "-v", "-r", revs.c_str(), "--xml", this->URL.c_str(), 0
};
{ {
LogParser out(this, "log-out> "); LogParser out(this, "log-out> ");
OutputLogger err(this->Log, "log-err> "); OutputLogger err(this->Log, "log-err> ");
@ -457,41 +419,39 @@ void cmCTestBZR::LoadRevisions()
class cmCTestBZR::StatusParser : public cmCTestVC::LineParser class cmCTestBZR::StatusParser : public cmCTestVC::LineParser
{ {
public: public:
StatusParser(cmCTestBZR* bzr, const char* prefix): BZR(bzr) StatusParser(cmCTestBZR* bzr, const char* prefix)
: BZR(bzr)
{ {
this->SetLog(&bzr->Log, prefix); this->SetLog(&bzr->Log, prefix);
this->RegexStatus.compile("^([-+R?XCP ])([NDKM ])([* ]) +(.+)$"); this->RegexStatus.compile("^([-+R?XCP ])([NDKM ])([* ]) +(.+)$");
} }
private: private:
cmCTestBZR* BZR; cmCTestBZR* BZR;
cmsys::RegularExpression RegexStatus; cmsys::RegularExpression RegexStatus;
bool ProcessLine() bool ProcessLine()
{ {
if(this->RegexStatus.find(this->Line)) if (this->RegexStatus.find(this->Line)) {
{
this->DoPath(this->RegexStatus.match(1)[0], this->DoPath(this->RegexStatus.match(1)[0],
this->RegexStatus.match(2)[0], this->RegexStatus.match(2)[0],
this->RegexStatus.match(3)[0], this->RegexStatus.match(3)[0], this->RegexStatus.match(4));
this->RegexStatus.match(4));
} }
return true; return true;
} }
void DoPath(char c0, char c1, char c2, std::string path) void DoPath(char c0, char c1, char c2, std::string path)
{ {
if(path.empty()) return; if (path.empty())
return;
cmSystemTools::ConvertToUnixSlashes(path); cmSystemTools::ConvertToUnixSlashes(path);
if ( c0=='C' ) if (c0 == 'C') {
{
this->BZR->DoModification(PathConflicting, path); this->BZR->DoModification(PathConflicting, path);
return; return;
} }
if ( c0 == '+' || c0 == 'R' || c0 == 'P' if (c0 == '+' || c0 == 'R' || c0 == 'P' || c1 == 'M' || c1 == 'K' ||
|| c1=='M' || c1=='K' || c1=='N' || c1=='D' c1 == 'N' || c1 == 'D' || c2 == '*') {
|| c2 =='*' )
{
this->BZR->DoModification(PathModified, path); this->BZR->DoModification(PathModified, path);
return; return;
} }

View File

@ -30,14 +30,13 @@ void cmCTestBatchTestHandler::RunTests()
void cmCTestBatchTestHandler::WriteBatchScript() void cmCTestBatchTestHandler::WriteBatchScript()
{ {
this->Script = this->CTest->GetBinaryDir() this->Script = this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt";
+ "/Testing/CTestBatch.txt";
cmsys::ofstream fout; cmsys::ofstream fout;
fout.open(this->Script.c_str()); fout.open(this->Script.c_str());
fout << "#!/bin/sh\n"; fout << "#!/bin/sh\n";
for(TestMap::iterator i = this->Tests.begin(); i != this->Tests.end(); ++i) for (TestMap::iterator i = this->Tests.begin(); i != this->Tests.end();
{ ++i) {
this->WriteSrunArgs(i->first, fout); this->WriteSrunArgs(i->first, fout);
this->WriteTestCommand(i->first, fout); this->WriteTestCommand(i->first, fout);
fout << "\n"; fout << "\n";
@ -66,12 +65,10 @@ void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout)
} }
fout << " "; fout << " ";
}*/ }*/
if(properties->RunSerial) if (properties->RunSerial) {
{
fout << "--exclusive "; fout << "--exclusive ";
} }
if(properties->Processors > 1) if (properties->Processors > 1) {
{
fout << "-n" << properties->Processors << " "; fout << "-n" << properties->Processors << " ";
} }
} }
@ -90,25 +87,21 @@ void cmCTestBatchTestHandler::WriteTestCommand(int test, cmsys::ofstream& fout)
processArgs.push_back(command); processArgs.push_back(command);
for (std::vector<std::string>::iterator arg = processArgs.begin(); for (std::vector<std::string>::iterator arg = processArgs.begin();
arg != processArgs.end(); ++arg) arg != processArgs.end(); ++arg) {
{
fout << *arg << " "; fout << *arg << " ";
} }
std::vector<std::string>::iterator i = args.begin(); std::vector<std::string>::iterator i = args.begin();
++i; // the test name ++i; // the test name
++i; // the executable (command) ++i; // the executable (command)
if(args.size() > 2) if (args.size() > 2) {
{
fout << "'"; fout << "'";
} }
while(i != args.end()) while (i != args.end()) {
{
fout << "\"" << *i << "\""; // args to the test executable fout << "\"" << *i << "\""; // args to the test executable
++i; ++i;
if(i == args.end() && args.size() > 2) if (i == args.end() && args.size() > 2) {
{
fout << "'"; fout << "'";
} }
fout << " "; fout << " ";
@ -123,8 +116,7 @@ void cmCTestBatchTestHandler::SubmitBatchScript()
std::vector<std::string> args; std::vector<std::string> args;
args.push_back(this->Script); args.push_back(this->Script);
args.push_back("-o"); args.push_back("-o");
args.push_back(this->CTest->GetBinaryDir() args.push_back(this->CTest->GetBinaryDir() + "/Testing/CTestBatch.txt");
+ "/Testing/CTestBatch.txt");
sbatch.SetCommand("sbatch"); sbatch.SetCommand("sbatch");
sbatch.SetCommandArguments(args); sbatch.SetCommandArguments(args);

View File

@ -30,6 +30,7 @@ class cmCTestBatchTestHandler : public cmCTestMultiProcessHandler
public: public:
~cmCTestBatchTestHandler(); ~cmCTestBatchTestHandler();
virtual void RunTests(); virtual void RunTests();
protected: protected:
void WriteBatchScript(); void WriteBatchScript();
void WriteSrunArgs(int test, cmsys::ofstream& fout); void WriteSrunArgs(int test, cmsys::ofstream& fout);

View File

@ -48,86 +48,70 @@ int cmCTestBuildAndTestHandler::ProcessHandler()
} }
int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
std::ostringstream &out, std::string &cmakeOutString, std::string &cwd, std::ostringstream& out,
cmake *cm) std::string& cmakeOutString,
std::string& cwd, cmake* cm)
{ {
unsigned int k; unsigned int k;
std::vector<std::string> args; std::vector<std::string> args;
args.push_back(cmSystemTools::GetCMakeCommand()); args.push_back(cmSystemTools::GetCMakeCommand());
args.push_back(this->SourceDir); args.push_back(this->SourceDir);
if(!this->BuildGenerator.empty()) if (!this->BuildGenerator.empty()) {
{
std::string generator = "-G"; std::string generator = "-G";
generator += this->BuildGenerator; generator += this->BuildGenerator;
args.push_back(generator); args.push_back(generator);
} }
if(!this->BuildGeneratorPlatform.empty()) if (!this->BuildGeneratorPlatform.empty()) {
{
std::string platform = "-A"; std::string platform = "-A";
platform += this->BuildGeneratorPlatform; platform += this->BuildGeneratorPlatform;
args.push_back(platform); args.push_back(platform);
} }
if(!this->BuildGeneratorToolset.empty()) if (!this->BuildGeneratorToolset.empty()) {
{
std::string toolset = "-T"; std::string toolset = "-T";
toolset += this->BuildGeneratorToolset; toolset += this->BuildGeneratorToolset;
args.push_back(toolset); args.push_back(toolset);
} }
const char* config = 0; const char* config = 0;
if (!this->CTest->GetConfigType().empty()) if (!this->CTest->GetConfigType().empty()) {
{
config = this->CTest->GetConfigType().c_str(); config = this->CTest->GetConfigType().c_str();
} }
#ifdef CMAKE_INTDIR #ifdef CMAKE_INTDIR
if(!config) if (!config) {
{
config = CMAKE_INTDIR; config = CMAKE_INTDIR;
} }
#endif #endif
if ( config ) if (config) {
{ std::string btype = "-DCMAKE_BUILD_TYPE:STRING=" + std::string(config);
std::string btype
= "-DCMAKE_BUILD_TYPE:STRING=" + std::string(config);
args.push_back(btype); args.push_back(btype);
} }
for(k=0; k < this->BuildOptions.size(); ++k) for (k = 0; k < this->BuildOptions.size(); ++k) {
{
args.push_back(this->BuildOptions[k]); args.push_back(this->BuildOptions[k]);
} }
if (cm->Run(args) != 0) if (cm->Run(args) != 0) {
{
out << "Error: cmake execution failed\n"; out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n"; out << cmakeOutString << "\n";
// return to the original directory // return to the original directory
cmSystemTools::ChangeDirectory(cwd); cmSystemTools::ChangeDirectory(cwd);
if(outstring) if (outstring) {
{
*outstring = out.str(); *outstring = out.str();
} } else {
else
{
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl);
} }
return 1; return 1;
} }
// do another config? // do another config?
if(this->BuildTwoConfig) if (this->BuildTwoConfig) {
{ if (cm->Run(args) != 0) {
if (cm->Run(args) != 0)
{
out << "Error: cmake execution failed\n"; out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n"; out << cmakeOutString << "\n";
// return to the original directory // return to the original directory
cmSystemTools::ChangeDirectory(cwd); cmSystemTools::ChangeDirectory(cwd);
if(outstring) if (outstring) {
{
*outstring = out.str(); *outstring = out.str();
} } else {
else
{
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, out.str() << std::endl);
} }
return 1; return 1;
@ -162,8 +146,10 @@ void CMakeOutputCallback(const char* m, size_t len, void* s)
class cmCTestBuildAndTestCaptureRAII class cmCTestBuildAndTestCaptureRAII
{ {
cmake& CM; cmake& CM;
public: public:
cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s): CM(cm) cmCTestBuildAndTestCaptureRAII(cmake& cm, std::string& s)
: CM(cm)
{ {
cmSystemTools::SetMessageCallback(CMakeMessageCallback, &s); cmSystemTools::SetMessageCallback(CMakeMessageCallback, &s);
cmSystemTools::SetStdoutCallback(CMakeOutputCallback, &s); cmSystemTools::SetStdoutCallback(CMakeOutputCallback, &s);
@ -182,12 +168,9 @@ public:
int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
{ {
// if the generator and make program are not specified then it is an error // if the generator and make program are not specified then it is an error
if (this->BuildGenerator.empty()) if (this->BuildGenerator.empty()) {
{ if (outstring) {
if(outstring) *outstring = "--build-and-test requires that the generator "
{
*outstring =
"--build-and-test requires that the generator "
"be provided using the --build-generator " "be provided using the --build-generator "
"command line option. "; "command line option. ";
} }
@ -202,26 +185,20 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
static_cast<void>(captureRAII); static_cast<void>(captureRAII);
std::ostringstream out; std::ostringstream out;
if ( this->CTest->GetConfigType().empty() && if (this->CTest->GetConfigType().empty() && !this->ConfigSample.empty()) {
!this->ConfigSample.empty())
{
// use the config sample to set the ConfigType // use the config sample to set the ConfigType
std::string fullPath; std::string fullPath;
std::string resultingConfig; std::string resultingConfig;
std::vector<std::string> extraPaths; std::vector<std::string> extraPaths;
std::vector<std::string> failed; std::vector<std::string> failed;
fullPath = fullPath = cmCTestTestHandler::FindExecutable(
cmCTestTestHandler::FindExecutable(this->CTest, this->CTest, this->ConfigSample.c_str(), resultingConfig, extraPaths,
this->ConfigSample.c_str(),
resultingConfig,
extraPaths,
failed); failed);
if (!fullPath.empty() && !resultingConfig.empty()) if (!fullPath.empty() && !resultingConfig.empty()) {
{
this->CTest->SetConfigType(resultingConfig.c_str()); this->CTest->SetConfigType(resultingConfig.c_str());
} }
out << "Using config sample with results: " out << "Using config sample with results: " << fullPath << " and "
<< fullPath << " and " << resultingConfig << std::endl; << resultingConfig << std::endl;
} }
// we need to honor the timeout specified, the timeout include cmake, build // we need to honor the timeout specified, the timeout include cmake, build
@ -230,51 +207,40 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
// make sure the binary dir is there // make sure the binary dir is there
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
out << "Internal cmake changing into directory: " out << "Internal cmake changing into directory: " << this->BinaryDir
<< this->BinaryDir << std::endl; << std::endl;
if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) if (!cmSystemTools::FileIsDirectory(this->BinaryDir)) {
{
cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
} }
cmSystemTools::ChangeDirectory(this->BinaryDir); cmSystemTools::ChangeDirectory(this->BinaryDir);
if(this->BuildNoCMake) if (this->BuildNoCMake) {
{
// Make the generator available for the Build call below. // Make the generator available for the Build call below.
cm.SetGlobalGenerator(cm.CreateGlobalGenerator( cm.SetGlobalGenerator(cm.CreateGlobalGenerator(this->BuildGenerator));
this->BuildGenerator));
cm.SetGeneratorPlatform(this->BuildGeneratorPlatform); cm.SetGeneratorPlatform(this->BuildGeneratorPlatform);
cm.SetGeneratorToolset(this->BuildGeneratorToolset); cm.SetGeneratorToolset(this->BuildGeneratorToolset);
// Load the cache to make CMAKE_MAKE_PROGRAM available. // Load the cache to make CMAKE_MAKE_PROGRAM available.
cm.LoadCache(this->BinaryDir); cm.LoadCache(this->BinaryDir);
} } else {
else
{
// do the cmake step, no timeout here since it is not a sub process // do the cmake step, no timeout here since it is not a sub process
if (this->RunCMake(outstring,out,cmakeOutString,cwd,&cm)) if (this->RunCMake(outstring, out, cmakeOutString, cwd, &cm)) {
{
return 1; return 1;
} }
} }
// do the build // do the build
std::vector<std::string>::iterator tarIt; std::vector<std::string>::iterator tarIt;
if (this->BuildTargets.empty()) if (this->BuildTargets.empty()) {
{
this->BuildTargets.push_back(""); this->BuildTargets.push_back("");
} }
for ( tarIt = this->BuildTargets.begin(); for (tarIt = this->BuildTargets.begin(); tarIt != this->BuildTargets.end();
tarIt != this->BuildTargets.end(); ++ tarIt ) ++tarIt) {
{
double remainingTime = 0; double remainingTime = 0;
if (this->Timeout > 0) if (this->Timeout > 0) {
{
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start; remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
if (remainingTime <= 0) if (remainingTime <= 0) {
{ if (outstring) {
if(outstring)
{
*outstring = "--build-and-test timeout exceeded. "; *outstring = "--build-and-test timeout exceeded. ";
} }
return 1; return 1;
@ -282,46 +248,36 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
} }
std::string output; std::string output;
const char* config = 0; const char* config = 0;
if (!this->CTest->GetConfigType().empty()) if (!this->CTest->GetConfigType().empty()) {
{
config = this->CTest->GetConfigType().c_str(); config = this->CTest->GetConfigType().c_str();
} }
#ifdef CMAKE_INTDIR #ifdef CMAKE_INTDIR
if(!config) if (!config) {
{
config = CMAKE_INTDIR; config = CMAKE_INTDIR;
} }
#endif #endif
if(!config) if (!config) {
{
config = "Debug"; config = "Debug";
} }
int retVal = cm.GetGlobalGenerator()->Build( int retVal = cm.GetGlobalGenerator()->Build(
this->SourceDir, this->BinaryDir, this->SourceDir, this->BinaryDir, this->BuildProject, *tarIt, output,
this->BuildProject, *tarIt, this->BuildMakeProgram, config, !this->BuildNoClean, false, false,
output, this->BuildMakeProgram, remainingTime);
config,
!this->BuildNoClean,
false, false, remainingTime);
out << output; out << output;
// if the build failed then return // if the build failed then return
if (retVal) if (retVal) {
{ if (outstring) {
if(outstring)
{
*outstring = out.str(); *outstring = out.str();
} }
return 1; return 1;
} }
} }
if(outstring) if (outstring) {
{
*outstring = out.str(); *outstring = out.str();
} }
// if no test was specified then we are done // if no test was specified then we are done
if (this->TestCommand.empty()) if (this->TestCommand.empty()) {
{
return 0; return 0;
} }
@ -331,8 +287,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::string resultingConfig; std::string resultingConfig;
std::vector<std::string> extraPaths; std::vector<std::string> extraPaths;
// if this->ExecutableDirectory is set try that as well // if this->ExecutableDirectory is set try that as well
if (!this->ExecutableDirectory.empty()) if (!this->ExecutableDirectory.empty()) {
{
std::string tempPath = this->ExecutableDirectory; std::string tempPath = this->ExecutableDirectory;
tempPath += "/"; tempPath += "/";
tempPath += this->TestCommand; tempPath += this->TestCommand;
@ -340,28 +295,20 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
} }
std::vector<std::string> failed; std::vector<std::string> failed;
fullPath = fullPath =
cmCTestTestHandler::FindExecutable(this->CTest, cmCTestTestHandler::FindExecutable(this->CTest, this->TestCommand.c_str(),
this->TestCommand.c_str(), resultingConfig, extraPaths, failed);
resultingConfig,
extraPaths,
failed);
if(!cmSystemTools::FileExists(fullPath.c_str())) if (!cmSystemTools::FileExists(fullPath.c_str())) {
{
out << "Could not find path to executable, perhaps it was not built: " out << "Could not find path to executable, perhaps it was not built: "
<< this->TestCommand << "\n"; << this->TestCommand << "\n";
out << "tried to find it in these places:\n"; out << "tried to find it in these places:\n";
out << fullPath.c_str() << "\n"; out << fullPath.c_str() << "\n";
for(unsigned int i=0; i < failed.size(); ++i) for (unsigned int i = 0; i < failed.size(); ++i) {
{
out << failed[i] << "\n"; out << failed[i] << "\n";
} }
if(outstring) if (outstring) {
{
*outstring = out.str(); *outstring = out.str();
} } else {
else
{
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str()); cmCTestLog(this->CTest, ERROR_MESSAGE, out.str());
} }
// return to the original directory // return to the original directory
@ -371,57 +318,47 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::vector<const char*> testCommand; std::vector<const char*> testCommand;
testCommand.push_back(fullPath.c_str()); testCommand.push_back(fullPath.c_str());
for(size_t k=0; k < this->TestCommandArgs.size(); ++k) for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
{
testCommand.push_back(this->TestCommandArgs[k].c_str()); testCommand.push_back(this->TestCommandArgs[k].c_str());
} }
testCommand.push_back(0); testCommand.push_back(0);
std::string outs; std::string outs;
int retval = 0; int retval = 0;
// run the test from the this->BuildRunDir if set // run the test from the this->BuildRunDir if set
if(!this->BuildRunDir.empty()) if (!this->BuildRunDir.empty()) {
{
out << "Run test in directory: " << this->BuildRunDir << "\n"; out << "Run test in directory: " << this->BuildRunDir << "\n";
cmSystemTools::ChangeDirectory(this->BuildRunDir); cmSystemTools::ChangeDirectory(this->BuildRunDir);
} }
out << "Running test command: \"" << fullPath << "\""; out << "Running test command: \"" << fullPath << "\"";
for(size_t k=0; k < this->TestCommandArgs.size(); ++k) for (size_t k = 0; k < this->TestCommandArgs.size(); ++k) {
{
out << " \"" << this->TestCommandArgs[k] << "\""; out << " \"" << this->TestCommandArgs[k] << "\"";
} }
out << "\n"; out << "\n";
// how much time is remaining // how much time is remaining
double remainingTime = 0; double remainingTime = 0;
if (this->Timeout > 0) if (this->Timeout > 0) {
{
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start; remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
if (remainingTime <= 0) if (remainingTime <= 0) {
{ if (outstring) {
if(outstring)
{
*outstring = "--build-and-test timeout exceeded. "; *outstring = "--build-and-test timeout exceeded. ";
} }
return 1; return 1;
} }
} }
int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, 0, int runTestRes =
remainingTime, 0); this->CTest->RunTest(testCommand, &outs, &retval, 0, remainingTime, 0);
if(runTestRes != cmsysProcess_State_Exited || retval != 0) if (runTestRes != cmsysProcess_State_Exited || retval != 0) {
{
out << "Test command failed: " << testCommand[0] << "\n"; out << "Test command failed: " << testCommand[0] << "\n";
retval = 1; retval = 1;
} }
out << outs << "\n"; out << outs << "\n";
if(outstring) if (outstring) {
{
*outstring = out.str(); *outstring = out.str();
} } else {
else
{
cmCTestLog(this->CTest, OUTPUT, out.str() << std::endl); cmCTestLog(this->CTest, OUTPUT, out.str() << std::endl);
} }
return retval; return retval;
@ -432,114 +369,89 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
const std::vector<std::string>& allArgs) const std::vector<std::string>& allArgs)
{ {
// --build-and-test options // --build-and-test options
if(currentArg.find("--build-and-test",0) == 0 && idx < allArgs.size() - 1) if (currentArg.find("--build-and-test", 0) == 0 &&
{ idx < allArgs.size() - 1) {
if(idx+2 < allArgs.size()) if (idx + 2 < allArgs.size()) {
{
idx++; idx++;
this->SourceDir = allArgs[idx]; this->SourceDir = allArgs[idx];
idx++; idx++;
this->BinaryDir = allArgs[idx]; this->BinaryDir = allArgs[idx];
// dir must exist before CollapseFullPath is called // dir must exist before CollapseFullPath is called
cmSystemTools::MakeDirectory(this->BinaryDir.c_str()); cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
this->BinaryDir this->BinaryDir = cmSystemTools::CollapseFullPath(this->BinaryDir);
= cmSystemTools::CollapseFullPath(this->BinaryDir); this->SourceDir = cmSystemTools::CollapseFullPath(this->SourceDir);
this->SourceDir } else {
= cmSystemTools::CollapseFullPath(this->SourceDir);
}
else
{
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"--build-and-test must have source and binary dir" << std::endl); "--build-and-test must have source and binary dir"
<< std::endl);
return 0; return 0;
} }
} }
if(currentArg.find("--build-target",0) == 0 && idx < allArgs.size() - 1) if (currentArg.find("--build-target", 0) == 0 && idx < allArgs.size() - 1) {
{
idx++; idx++;
this->BuildTargets.push_back(allArgs[idx]); this->BuildTargets.push_back(allArgs[idx]);
} }
if(currentArg.find("--build-nocmake",0) == 0) if (currentArg.find("--build-nocmake", 0) == 0) {
{
this->BuildNoCMake = true; this->BuildNoCMake = true;
} }
if(currentArg.find("--build-run-dir",0) == 0 && idx < allArgs.size() - 1) if (currentArg.find("--build-run-dir", 0) == 0 && idx < allArgs.size() - 1) {
{
idx++; idx++;
this->BuildRunDir = allArgs[idx]; this->BuildRunDir = allArgs[idx];
} }
if(currentArg.find("--build-two-config",0) == 0) if (currentArg.find("--build-two-config", 0) == 0) {
{
this->BuildTwoConfig = true; this->BuildTwoConfig = true;
} }
if(currentArg.find("--build-exe-dir",0) == 0 && idx < allArgs.size() - 1) if (currentArg.find("--build-exe-dir", 0) == 0 && idx < allArgs.size() - 1) {
{
idx++; idx++;
this->ExecutableDirectory = allArgs[idx]; this->ExecutableDirectory = allArgs[idx];
} }
if(currentArg.find("--test-timeout",0) == 0 && idx < allArgs.size() - 1) if (currentArg.find("--test-timeout", 0) == 0 && idx < allArgs.size() - 1) {
{
idx++; idx++;
this->Timeout = atof(allArgs[idx].c_str()); this->Timeout = atof(allArgs[idx].c_str());
} }
if(currentArg == "--build-generator" && idx < allArgs.size() - 1) if (currentArg == "--build-generator" && idx < allArgs.size() - 1) {
{
idx++; idx++;
this->BuildGenerator = allArgs[idx]; this->BuildGenerator = allArgs[idx];
} }
if(currentArg == "--build-generator-platform" && if (currentArg == "--build-generator-platform" && idx < allArgs.size() - 1) {
idx < allArgs.size() - 1)
{
idx++; idx++;
this->BuildGeneratorPlatform = allArgs[idx]; this->BuildGeneratorPlatform = allArgs[idx];
} }
if(currentArg == "--build-generator-toolset" && if (currentArg == "--build-generator-toolset" && idx < allArgs.size() - 1) {
idx < allArgs.size() - 1)
{
idx++; idx++;
this->BuildGeneratorToolset = allArgs[idx]; this->BuildGeneratorToolset = allArgs[idx];
} }
if(currentArg.find("--build-project",0) == 0 && idx < allArgs.size() - 1) if (currentArg.find("--build-project", 0) == 0 && idx < allArgs.size() - 1) {
{
idx++; idx++;
this->BuildProject = allArgs[idx]; this->BuildProject = allArgs[idx];
} }
if (currentArg.find("--build-makeprogram", 0) == 0 && if (currentArg.find("--build-makeprogram", 0) == 0 &&
idx < allArgs.size() - 1) idx < allArgs.size() - 1) {
{
idx++; idx++;
this->BuildMakeProgram = allArgs[idx]; this->BuildMakeProgram = allArgs[idx];
} }
if (currentArg.find("--build-config-sample", 0) == 0 && if (currentArg.find("--build-config-sample", 0) == 0 &&
idx < allArgs.size() - 1) idx < allArgs.size() - 1) {
{
idx++; idx++;
this->ConfigSample = allArgs[idx]; this->ConfigSample = allArgs[idx];
} }
if(currentArg.find("--build-noclean",0) == 0) if (currentArg.find("--build-noclean", 0) == 0) {
{
this->BuildNoClean = true; this->BuildNoClean = true;
} }
if(currentArg.find("--build-options",0) == 0) if (currentArg.find("--build-options", 0) == 0) {
{ while (idx + 1 < allArgs.size() && allArgs[idx + 1] != "--build-target" &&
while(idx+1 < allArgs.size() && allArgs[idx + 1] != "--test-command") {
allArgs[idx+1] != "--build-target" &&
allArgs[idx+1] != "--test-command")
{
++idx; ++idx;
this->BuildOptions.push_back(allArgs[idx]); this->BuildOptions.push_back(allArgs[idx]);
} }
} }
if(currentArg.find("--test-command",0) == 0 && idx < allArgs.size() - 1) if (currentArg.find("--test-command", 0) == 0 && idx < allArgs.size() - 1) {
{
++idx; ++idx;
this->TestCommand = allArgs[idx]; this->TestCommand = allArgs[idx];
while(idx+1 < allArgs.size()) while (idx + 1 < allArgs.size()) {
{
++idx; ++idx;
this->TestCommandArgs.push_back(allArgs[idx]); this->TestCommandArgs.push_back(allArgs[idx]);
} }
} }
return 1; return 1;
} }

View File

@ -13,7 +13,6 @@
#ifndef cmCTestBuildAndTestHandler_h #ifndef cmCTestBuildAndTestHandler_h
#define cmCTestBuildAndTestHandler_h #define cmCTestBuildAndTestHandler_h
#include "cmCTestGenericHandler.h" #include "cmCTestGenericHandler.h"
#include "cmListFileCache.h" #include "cmListFileCache.h"
@ -51,8 +50,7 @@ protected:
///! Run CMake and build a test and then run it as a single test. ///! Run CMake and build a test and then run it as a single test.
int RunCMakeAndTest(std::string* output); int RunCMakeAndTest(std::string* output);
int RunCMake(std::string* outstring, std::ostringstream& out, int RunCMake(std::string* outstring, std::ostringstream& out,
std::string &cmakeOutString, std::string& cmakeOutString, std::string& cwd, cmake* cm);
std::string &cwd, cmake *cm);
std::string Output; std::string Output;
@ -77,4 +75,3 @@ protected:
}; };
#endif #endif

View File

@ -17,7 +17,6 @@
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include "cmake.h" #include "cmake.h"
cmCTestBuildCommand::cmCTestBuildCommand() cmCTestBuildCommand::cmCTestBuildCommand()
{ {
this->GlobalGenerator = 0; this->GlobalGenerator = 0;
@ -33,8 +32,7 @@ cmCTestBuildCommand::cmCTestBuildCommand()
cmCTestBuildCommand::~cmCTestBuildCommand() cmCTestBuildCommand::~cmCTestBuildCommand()
{ {
if ( this->GlobalGenerator ) if (this->GlobalGenerator) {
{
delete this->GlobalGenerator; delete this->GlobalGenerator;
this->GlobalGenerator = 0; this->GlobalGenerator = 0;
} }
@ -42,28 +40,23 @@ cmCTestBuildCommand::~cmCTestBuildCommand()
cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler() cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
{ {
cmCTestGenericHandler* handler cmCTestGenericHandler* handler = this->CTest->GetInitializedHandler("build");
= this->CTest->GetInitializedHandler("build"); if (!handler) {
if ( !handler )
{
this->SetError("internal CTest error. Cannot instantiate build handler"); this->SetError("internal CTest error. Cannot instantiate build handler");
return 0; return 0;
} }
this->Handler = (cmCTestBuildHandler*)handler; this->Handler = (cmCTestBuildHandler*)handler;
const char* ctestBuildCommand const char* ctestBuildCommand =
= this->Makefile->GetDefinition("CTEST_BUILD_COMMAND"); this->Makefile->GetDefinition("CTEST_BUILD_COMMAND");
if ( ctestBuildCommand && *ctestBuildCommand ) if (ctestBuildCommand && *ctestBuildCommand) {
{
this->CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand, this->CTest->SetCTestConfiguration("MakeCommand", ctestBuildCommand,
this->Quiet); this->Quiet);
} } else {
else const char* cmakeGeneratorName =
{ this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
const char* cmakeGeneratorName const char* cmakeProjectName =
= this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); (this->Values[ctb_PROJECT_NAME] && *this->Values[ctb_PROJECT_NAME])
const char* cmakeProjectName
= (this->Values[ctb_PROJECT_NAME] && *this->Values[ctb_PROJECT_NAME])
? this->Values[ctb_PROJECT_NAME] ? this->Values[ctb_PROJECT_NAME]
: this->Makefile->GetDefinition("CTEST_PROJECT_NAME"); : this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
@ -72,46 +65,40 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
// CTEST_CONFIGURATION_TYPE script variable, or ctest -C command // CTEST_CONFIGURATION_TYPE script variable, or ctest -C command
// line argument... in that order. // line argument... in that order.
// //
const char* ctestBuildConfiguration const char* ctestBuildConfiguration =
= this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION"); this->Makefile->GetDefinition("CTEST_BUILD_CONFIGURATION");
const char* cmakeBuildConfiguration const char* cmakeBuildConfiguration =
= (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION]) (this->Values[ctb_CONFIGURATION] && *this->Values[ctb_CONFIGURATION])
? this->Values[ctb_CONFIGURATION] ? this->Values[ctb_CONFIGURATION]
: ((ctestBuildConfiguration && *ctestBuildConfiguration) : ((ctestBuildConfiguration && *ctestBuildConfiguration)
? ctestBuildConfiguration ? ctestBuildConfiguration
: this->CTest->GetConfigType().c_str()); : this->CTest->GetConfigType().c_str());
const char* cmakeBuildAdditionalFlags const char* cmakeBuildAdditionalFlags =
= (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS]) (this->Values[ctb_FLAGS] && *this->Values[ctb_FLAGS])
? this->Values[ctb_FLAGS] ? this->Values[ctb_FLAGS]
: this->Makefile->GetDefinition("CTEST_BUILD_FLAGS"); : this->Makefile->GetDefinition("CTEST_BUILD_FLAGS");
const char* cmakeBuildTarget const char* cmakeBuildTarget =
= (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET]) (this->Values[ctb_TARGET] && *this->Values[ctb_TARGET])
? this->Values[ctb_TARGET] ? this->Values[ctb_TARGET]
: this->Makefile->GetDefinition("CTEST_BUILD_TARGET"); : this->Makefile->GetDefinition("CTEST_BUILD_TARGET");
if ( cmakeGeneratorName && *cmakeGeneratorName && if (cmakeGeneratorName && *cmakeGeneratorName && cmakeProjectName &&
cmakeProjectName && *cmakeProjectName ) *cmakeProjectName) {
{ if (!cmakeBuildConfiguration) {
if ( !cmakeBuildConfiguration )
{
cmakeBuildConfiguration = "Release"; cmakeBuildConfiguration = "Release";
} }
if ( this->GlobalGenerator ) if (this->GlobalGenerator) {
{ if (this->GlobalGenerator->GetName() != cmakeGeneratorName) {
if ( this->GlobalGenerator->GetName() != cmakeGeneratorName )
{
delete this->GlobalGenerator; delete this->GlobalGenerator;
this->GlobalGenerator = 0; this->GlobalGenerator = 0;
} }
} }
if ( !this->GlobalGenerator ) if (!this->GlobalGenerator) {
{
this->GlobalGenerator = this->GlobalGenerator =
this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGeneratorName); cmakeGeneratorName);
if(!this->GlobalGenerator) if (!this->GlobalGenerator) {
{
std::string e = "could not create generator named \""; std::string e = "could not create generator named \"";
e += cmakeGeneratorName; e += cmakeGeneratorName;
e += "\""; e += "\"";
@ -120,33 +107,29 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
return 0; return 0;
} }
} }
if(strlen(cmakeBuildConfiguration) == 0) if (strlen(cmakeBuildConfiguration) == 0) {
{
const char* config = 0; const char* config = 0;
#ifdef CMAKE_INTDIR #ifdef CMAKE_INTDIR
config = CMAKE_INTDIR; config = CMAKE_INTDIR;
#endif #endif
if(!config) if (!config) {
{
config = "Debug"; config = "Debug";
} }
cmakeBuildConfiguration = config; cmakeBuildConfiguration = config;
} }
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory"); std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
std::string buildCommand std::string buildCommand =
= this->GlobalGenerator-> this->GlobalGenerator->GenerateCMakeBuildCommand(
GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "", cmakeBuildTarget ? cmakeBuildTarget : "", cmakeBuildConfiguration,
cmakeBuildConfiguration,
cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "",
this->Makefile->IgnoreErrorsCMP0061()); this->Makefile->IgnoreErrorsCMP0061());
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetMakeCommand:" << buildCommand << "\n", this->Quiet); "SetMakeCommand:" << buildCommand << "\n",
this->Quiet);
this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str(), this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str(),
this->Quiet); this->Quiet);
} } else {
else
{
std::ostringstream ostr; std::ostringstream ostr;
/* clang-format off */ /* clang-format off */
ostr << "has no project to build. If this is a " ostr << "has no project to build. If this is a "
@ -167,8 +150,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
} }
if (const char* useLaunchers = if (const char* useLaunchers =
this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) this->Makefile->GetDefinition("CTEST_USE_LAUNCHERS")) {
{
this->CTest->SetCTestConfiguration("UseLaunchers", useLaunchers, this->CTest->SetCTestConfiguration("UseLaunchers", useLaunchers,
this->Quiet); this->Quiet);
} }
@ -177,25 +159,22 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
return handler; return handler;
} }
bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args, bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) cmExecutionStatus& status)
{ {
bool ret = cmCTestHandlerCommand::InitialPass(args, status); bool ret = cmCTestHandlerCommand::InitialPass(args, status);
if ( this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS]) if (this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS]) {
{
std::ostringstream str; std::ostringstream str;
str << this->Handler->GetTotalErrors(); str << this->Handler->GetTotalErrors();
this->Makefile->AddDefinition( this->Makefile->AddDefinition(this->Values[ctb_NUMBER_ERRORS],
this->Values[ctb_NUMBER_ERRORS], str.str().c_str()); str.str().c_str());
} }
if ( this->Values[ctb_NUMBER_WARNINGS] if (this->Values[ctb_NUMBER_WARNINGS] &&
&& *this->Values[ctb_NUMBER_WARNINGS]) *this->Values[ctb_NUMBER_WARNINGS]) {
{
std::ostringstream str; std::ostringstream str;
str << this->Handler->GetTotalWarnings(); str << this->Handler->GetTotalWarnings();
this->Makefile->AddDefinition( this->Makefile->AddDefinition(this->Values[ctb_NUMBER_WARNINGS],
this->Values[ctb_NUMBER_WARNINGS], str.str().c_str()); str.str().c_str());
} }
return ret; return ret;
} }

View File

@ -25,7 +25,6 @@ class cmCTestBuildHandler;
class cmCTestBuildCommand : public cmCTestHandlerCommand class cmCTestBuildCommand : public cmCTestHandlerCommand
{ {
public: public:
cmCTestBuildCommand(); cmCTestBuildCommand();
~cmCTestBuildCommand(); ~cmCTestBuildCommand();
@ -54,7 +53,8 @@ public:
protected: protected:
cmCTestBuildHandler* Handler; cmCTestBuildHandler* Handler;
enum { enum
{
ctb_BUILD = ct_LAST, ctb_BUILD = ct_LAST,
ctb_NUMBER_ERRORS, ctb_NUMBER_ERRORS,
ctb_NUMBER_WARNINGS, ctb_NUMBER_WARNINGS,
@ -68,5 +68,4 @@ protected:
cmCTestGenericHandler* InitializeHandler(); cmCTestGenericHandler* InitializeHandler();
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -55,11 +55,11 @@ private:
//! Run command specialized for make and configure. Returns process status //! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception. // and retVal is return value or exception.
int RunMakeCommand(const char* command, int RunMakeCommand(const char* command, int* retVal, const char* dir,
int* retVal, const char* dir, int timeout, int timeout, std::ostream& ofs);
std::ostream& ofs);
enum { enum
{
b_REGULAR_LINE, b_REGULAR_LINE,
b_WARNING_LINE, b_WARNING_LINE,
b_ERROR_LINE b_ERROR_LINE
@ -115,7 +115,8 @@ private:
typedef std::deque<char> t_BuildProcessingQueueType; typedef std::deque<char> t_BuildProcessingQueueType;
void ProcessBuffer(const char* data, int length, size_t& tick, void ProcessBuffer(const char* data, int length, size_t& tick,
size_t tick_len, std::ostream& ofs, t_BuildProcessingQueueType* queue); size_t tick_len, std::ostream& ofs,
t_BuildProcessingQueueType* queue);
int ProcessSingleLine(const char* data); int ProcessSingleLine(const char* data);
t_BuildProcessingQueueType BuildProcessingQueue; t_BuildProcessingQueueType BuildProcessingQueue;

View File

@ -18,7 +18,8 @@
#include <cmsys/FStream.hxx> #include <cmsys/FStream.hxx>
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log) cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log)
: cmCTestVC(ct, log)
{ {
} }
@ -29,7 +30,8 @@ cmCTestCVS::~cmCTestCVS()
class cmCTestCVS::UpdateParser : public cmCTestVC::LineParser class cmCTestCVS::UpdateParser : public cmCTestVC::LineParser
{ {
public: public:
UpdateParser(cmCTestCVS* cvs, const char* prefix): CVS(cvs) UpdateParser(cmCTestCVS* cvs, const char* prefix)
: CVS(cvs)
{ {
this->SetLog(&cvs->Log, prefix); this->SetLog(&cvs->Log, prefix);
// See "man cvs", section "update output". // See "man cvs", section "update output".
@ -42,6 +44,7 @@ public:
"cvs[^ ]* update: " "cvs[^ ]* update: "
"warning: `?([^']*)'? is not \\(any longer\\) pertinent"); "warning: `?([^']*)'? is not \\(any longer\\) pertinent");
} }
private: private:
cmCTestCVS* CVS; cmCTestCVS* CVS;
cmsys::RegularExpression RegexFileUpdated; cmsys::RegularExpression RegexFileUpdated;
@ -52,24 +55,15 @@ private:
virtual bool ProcessLine() virtual bool ProcessLine()
{ {
if(this->RegexFileUpdated.find(this->Line)) if (this->RegexFileUpdated.find(this->Line)) {
{
this->DoFile(PathUpdated, this->RegexFileUpdated.match(2)); this->DoFile(PathUpdated, this->RegexFileUpdated.match(2));
} } else if (this->RegexFileModified.find(this->Line)) {
else if(this->RegexFileModified.find(this->Line))
{
this->DoFile(PathModified, this->RegexFileModified.match(2)); this->DoFile(PathModified, this->RegexFileModified.match(2));
} } else if (this->RegexFileConflicting.find(this->Line)) {
else if(this->RegexFileConflicting.find(this->Line))
{
this->DoFile(PathConflicting, this->RegexFileConflicting.match(2)); this->DoFile(PathConflicting, this->RegexFileConflicting.match(2));
} } else if (this->RegexFileRemoved1.find(this->Line)) {
else if(this->RegexFileRemoved1.find(this->Line))
{
this->DoFile(PathUpdated, this->RegexFileRemoved1.match(1)); this->DoFile(PathUpdated, this->RegexFileRemoved1.match(1));
} } else if (this->RegexFileRemoved2.find(this->Line)) {
else if(this->RegexFileRemoved2.find(this->Line))
{
this->DoFile(PathUpdated, this->RegexFileRemoved2.match(1)); this->DoFile(PathUpdated, this->RegexFileRemoved2.match(1));
} }
return true; return true;
@ -87,19 +81,16 @@ bool cmCTestCVS::UpdateImpl()
{ {
// Get user-specified update options. // Get user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions"); std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
if(opts.empty()) if (opts.empty()) {
{
opts = this->CTest->GetCTestConfiguration("CVSUpdateOptions"); opts = this->CTest->GetCTestConfiguration("CVSUpdateOptions");
if(opts.empty()) if (opts.empty()) {
{
opts = "-dP"; opts = "-dP";
} }
} }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
// Specify the start time for nightly testing. // Specify the start time for nightly testing.
if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) {
{
args.push_back("-D" + this->GetNightlyTime() + " UTC"); args.push_back("-D" + this->GetNightlyTime() + " UTC");
} }
@ -109,8 +100,7 @@ bool cmCTestCVS::UpdateImpl()
cvs_update.push_back("-z3"); cvs_update.push_back("-z3");
cvs_update.push_back("update"); cvs_update.push_back("update");
for (std::vector<std::string>::const_iterator ai = args.begin(); for (std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai) ai != args.end(); ++ai) {
{
cvs_update.push_back(ai->c_str()); cvs_update.push_back(ai->c_str());
} }
cvs_update.push_back(0); cvs_update.push_back(0);
@ -124,67 +114,61 @@ class cmCTestCVS::LogParser: public cmCTestVC::LineParser
{ {
public: public:
typedef cmCTestCVS::Revision Revision; typedef cmCTestCVS::Revision Revision;
LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs): LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs)
CVS(cvs), Revisions(revs), Section(SectionHeader) : CVS(cvs)
, Revisions(revs)
, Section(SectionHeader)
{ {
this->SetLog(&cvs->Log, prefix), this->SetLog(&cvs->Log, prefix),
this->RegexRevision.compile("^revision +([^ ]*) *$"); this->RegexRevision.compile("^revision +([^ ]*) *$");
this->RegexBranches.compile("^branches: .*$"); this->RegexBranches.compile("^branches: .*$");
this->RegexPerson.compile("^date: +([^;]+); +author: +([^;]+);"); this->RegexPerson.compile("^date: +([^;]+); +author: +([^;]+);");
} }
private: private:
cmCTestCVS* CVS; cmCTestCVS* CVS;
std::vector<Revision>& Revisions; std::vector<Revision>& Revisions;
cmsys::RegularExpression RegexRevision; cmsys::RegularExpression RegexRevision;
cmsys::RegularExpression RegexBranches; cmsys::RegularExpression RegexBranches;
cmsys::RegularExpression RegexPerson; cmsys::RegularExpression RegexPerson;
enum SectionType { SectionHeader, SectionRevisions, SectionEnd }; enum SectionType
{
SectionHeader,
SectionRevisions,
SectionEnd
};
SectionType Section; SectionType Section;
Revision Rev; Revision Rev;
virtual bool ProcessLine() virtual bool ProcessLine()
{ {
if (this->Line == ("=======================================" if (this->Line == ("======================================="
"======================================")) "======================================")) {
{
// This line ends the revision list. // This line ends the revision list.
if(this->Section == SectionRevisions) if (this->Section == SectionRevisions) {
{
this->FinishRevision(); this->FinishRevision();
} }
this->Section = SectionEnd; this->Section = SectionEnd;
} } else if (this->Line == "----------------------------") {
else if(this->Line == "----------------------------")
{
// This line divides revisions from the header and each other. // This line divides revisions from the header and each other.
if(this->Section == SectionHeader) if (this->Section == SectionHeader) {
{
this->Section = SectionRevisions; this->Section = SectionRevisions;
} } else if (this->Section == SectionRevisions) {
else if(this->Section == SectionRevisions)
{
this->FinishRevision(); this->FinishRevision();
} }
} } else if (this->Section == SectionRevisions) {
else if(this->Section == SectionRevisions) if (!this->Rev.Log.empty()) {
{
if(!this->Rev.Log.empty())
{
// Continue the existing log. // Continue the existing log.
this->Rev.Log += this->Line; this->Rev.Log += this->Line;
this->Rev.Log += "\n"; this->Rev.Log += "\n";
} } else if (this->Rev.Rev.empty() &&
else if(this->Rev.Rev.empty() && this->RegexRevision.find(this->Line)) this->RegexRevision.find(this->Line)) {
{
this->Rev.Rev = this->RegexRevision.match(1); this->Rev.Rev = this->RegexRevision.match(1);
} } else if (this->Rev.Date.empty() &&
else if(this->Rev.Date.empty() && this->RegexPerson.find(this->Line)) this->RegexPerson.find(this->Line)) {
{
this->Rev.Date = this->RegexPerson.match(1); this->Rev.Date = this->RegexPerson.match(1);
this->Rev.Author = this->RegexPerson.match(2); this->Rev.Author = this->RegexPerson.match(2);
} } else if (!this->RegexBranches.find(this->Line)) {
else if(!this->RegexBranches.find(this->Line))
{
// Start the log. // Start the log.
this->Rev.Log += this->Line; this->Rev.Log += this->Line;
this->Rev.Log += "\n"; this->Rev.Log += "\n";
@ -195,8 +179,7 @@ private:
void FinishRevision() void FinishRevision()
{ {
if(!this->Rev.Rev.empty()) if (!this->Rev.Rev.empty()) {
{
// Record this revision. // Record this revision.
/* clang-format off */ /* clang-format off */
this->CVS->Log << "Found revision " << this->Rev.Rev << "\n" this->CVS->Log << "Found revision " << this->Rev.Rev << "\n"
@ -206,8 +189,7 @@ private:
this->Revisions.push_back(this->Rev); this->Revisions.push_back(this->Rev);
// We only need two revisions. // We only need two revisions.
if(this->Revisions.size() >= 2) if (this->Revisions.size() >= 2) {
{
this->Section = SectionEnd; this->Section = SectionEnd;
} }
} }
@ -219,8 +201,7 @@ std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir)
{ {
// Compute the tag file location for this directory. // Compute the tag file location for this directory.
std::string tagFile = this->SourceDirectory; std::string tagFile = this->SourceDirectory;
if(!dir.empty()) if (!dir.empty()) {
{
tagFile += "/"; tagFile += "/";
tagFile += dir; tagFile += dir;
} }
@ -230,38 +211,32 @@ std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir)
std::string tagLine; std::string tagLine;
cmsys::ifstream tagStream(tagFile.c_str()); cmsys::ifstream tagStream(tagFile.c_str());
if (tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) && if (tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) &&
tagLine.size() > 1 && tagLine[0] == 'T') tagLine.size() > 1 && tagLine[0] == 'T') {
{
// Use the branch specified in the tag file. // Use the branch specified in the tag file.
std::string flag = "-r"; std::string flag = "-r";
flag += tagLine.substr(1); flag += tagLine.substr(1);
return flag; return flag;
} } else {
else
{
// Use the default branch. // Use the default branch.
return "-b"; return "-b";
} }
} }
void cmCTestCVS::LoadRevisions(std::string const& file, void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag,
const char* branchFlag,
std::vector<Revision>& revisions) std::vector<Revision>& revisions)
{ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
// Run "cvs log" to get revisions of this file on this branch. // Run "cvs log" to get revisions of this file on this branch.
const char* cvs = this->CommandLineTool.c_str(); const char* cvs = this->CommandLineTool.c_str();
const char* cvs_log[] = const char* cvs_log[] = { cvs, "log", "-N", branchFlag, file.c_str(), 0 };
{cvs, "log", "-N", branchFlag, file.c_str(), 0};
LogParser out(this, "log-out> ", revisions); LogParser out(this, "log-out> ", revisions);
OutputLogger err(this->Log, "log-err> "); OutputLogger err(this->Log, "log-err> ");
this->RunChild(cvs_log, &out, &err); this->RunChild(cvs_log, &out, &err);
} }
void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path,
std::string const& path,
Directory const& dir) Directory const& dir)
{ {
const char* slash = path.empty() ? "" : "/"; const char* slash = path.empty() ? "" : "/";
@ -273,14 +248,12 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml,
// Load revisions and write an entry for each file in this directory. // Load revisions and write an entry for each file in this directory.
std::vector<Revision> revisions; std::vector<Revision> revisions;
for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
{
std::string full = path + slash + fi->first; std::string full = path + slash + fi->first;
// Load two real or unknown revisions. // Load two real or unknown revisions.
revisions.clear(); revisions.clear();
if(fi->second != PathUpdated) if (fi->second != PathUpdated) {
{
// For local modifications the current rev is unknown and the // For local modifications the current rev is unknown and the
// prior rev is the latest from cvs. // prior rev is the latest from cvs.
revisions.push_back(this->Unknown); revisions.push_back(this->Unknown);
@ -299,11 +272,12 @@ bool cmCTestCVS::WriteXMLUpdates(cmXMLWriter& xml)
{ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per updated file):\n" " Gathering version information (one . per updated file):\n"
" " << std::flush); " "
<< std::flush);
for(std::map<std::string, Directory>::const_iterator for (std::map<std::string, Directory>::const_iterator di =
di = this->Dirs.begin(); di != this->Dirs.end(); ++di) this->Dirs.begin();
{ di != this->Dirs.end(); ++di) {
this->WriteXMLDirectory(xml, di->first, di->second); this->WriteXMLDirectory(xml, di->first, di->second);
} }

View File

@ -32,7 +32,9 @@ private:
virtual bool WriteXMLUpdates(cmXMLWriter& xml); virtual bool WriteXMLUpdates(cmXMLWriter& xml);
// Update status for files in each directory. // Update status for files in each directory.
class Directory: public std::map<std::string, PathStatus> {}; class Directory : public std::map<std::string, PathStatus>
{
};
std::map<std::string, Directory> Dirs; std::map<std::string, Directory> Dirs;
std::string ComputeBranchFlag(std::string const& dir); std::string ComputeBranchFlag(std::string const& dir);

View File

@ -27,8 +27,11 @@ class cmCTestScriptHandler;
class cmCTestCommand : public cmCommand class cmCTestCommand : public cmCommand
{ {
public: public:
cmCTestCommand()
cmCTestCommand() {this->CTest = 0; this->CTestScriptHandler = 0;} {
this->CTest = 0;
this->CTestScriptHandler = 0;
}
cmCTest* CTest; cmCTest* CTest;
cmCTestScriptHandler* CTestScriptHandler; cmCTestScriptHandler* CTestScriptHandler;
@ -36,5 +39,4 @@ public:
cmTypeMacro(cmCTestCommand, cmCommand); cmTypeMacro(cmCTestCommand, cmCommand);
}; };
#endif #endif

View File

@ -26,49 +26,42 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
{ {
std::vector<std::string> options; std::vector<std::string> options;
if (this->Values[ctc_OPTIONS]) if (this->Values[ctc_OPTIONS]) {
{
cmSystemTools::ExpandListArgument(this->Values[ctc_OPTIONS], options); cmSystemTools::ExpandListArgument(this->Values[ctc_OPTIONS], options);
} }
if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() ) if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) {
{ this->SetError(
this->SetError("Build directory not specified. Either use BUILD " "Build directory not specified. Either use BUILD "
"argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY " "argument to CTEST_CONFIGURE command or set CTEST_BINARY_DIRECTORY "
"variable"); "variable");
return 0; return 0;
} }
const char* ctestConfigureCommand const char* ctestConfigureCommand =
= this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND"); this->Makefile->GetDefinition("CTEST_CONFIGURE_COMMAND");
if ( ctestConfigureCommand && *ctestConfigureCommand ) if (ctestConfigureCommand && *ctestConfigureCommand) {
{
this->CTest->SetCTestConfiguration("ConfigureCommand", this->CTest->SetCTestConfiguration("ConfigureCommand",
ctestConfigureCommand, this->Quiet); ctestConfigureCommand, this->Quiet);
} } else {
else const char* cmakeGeneratorName =
{ this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR");
const char* cmakeGeneratorName if (cmakeGeneratorName && *cmakeGeneratorName) {
= this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR"); const std::string& source_dir =
if ( cmakeGeneratorName && *cmakeGeneratorName ) this->CTest->GetCTestConfiguration("SourceDirectory");
{ if (source_dir.empty()) {
const std::string& source_dir this->SetError(
= this->CTest->GetCTestConfiguration("SourceDirectory"); "Source directory not specified. Either use SOURCE "
if ( source_dir.empty() )
{
this->SetError("Source directory not specified. Either use SOURCE "
"argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY " "argument to CTEST_CONFIGURE command or set CTEST_SOURCE_DIRECTORY "
"variable"); "variable");
return 0; return 0;
} }
const std::string cmakelists_file = source_dir + "/CMakeLists.txt"; const std::string cmakelists_file = source_dir + "/CMakeLists.txt";
if ( !cmSystemTools::FileExists(cmakelists_file.c_str()) ) if (!cmSystemTools::FileExists(cmakelists_file.c_str())) {
{
std::ostringstream e; std::ostringstream e;
e << "CMakeLists.txt file does not exist [" e << "CMakeLists.txt file does not exist [" << cmakelists_file << "]";
<< cmakelists_file << "]";
this->SetError(e.str()); this->SetError(e.str());
return 0; return 0;
} }
@ -79,8 +72,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
cmGlobalGenerator* gg = cmGlobalGenerator* gg =
this->Makefile->GetCMakeInstance()->CreateGlobalGenerator( this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGeneratorName); cmakeGeneratorName);
if(gg) if (gg) {
{
multiConfig = gg->IsMultiConfig(); multiConfig = gg->IsMultiConfig();
delete gg; delete gg;
} }
@ -91,8 +83,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
std::vector<std::string>::const_iterator it; std::vector<std::string>::const_iterator it;
std::string option; std::string option;
for (it= options.begin(); it!=options.end(); ++it) for (it = options.begin(); it != options.end(); ++it) {
{
option = *it; option = *it;
cmakeConfigureCommand += " \""; cmakeConfigureCommand += " \"";
@ -100,15 +91,13 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
if ((0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) || if ((0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE=")) ||
(0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) (0 != strstr(option.c_str(), "CMAKE_BUILD_TYPE:STRING="))) {
{
cmakeBuildTypeInOptions = true; cmakeBuildTypeInOptions = true;
} }
} }
if (!multiConfig && !cmakeBuildTypeInOptions && if (!multiConfig && !cmakeBuildTypeInOptions &&
!this->CTest->GetConfigType().empty()) !this->CTest->GetConfigType().empty()) {
{
cmakeConfigureCommand += " \"-DCMAKE_BUILD_TYPE:STRING="; cmakeConfigureCommand += " \"-DCMAKE_BUILD_TYPE:STRING=";
cmakeConfigureCommand += this->CTest->GetConfigType(); cmakeConfigureCommand += this->CTest->GetConfigType();
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
@ -120,8 +109,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
const char* cmakeGeneratorPlatform = const char* cmakeGeneratorPlatform =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM"); this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_PLATFORM");
if(cmakeGeneratorPlatform && *cmakeGeneratorPlatform) if (cmakeGeneratorPlatform && *cmakeGeneratorPlatform) {
{
cmakeConfigureCommand += " \"-A"; cmakeConfigureCommand += " \"-A";
cmakeConfigureCommand += cmakeGeneratorPlatform; cmakeConfigureCommand += cmakeGeneratorPlatform;
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
@ -129,8 +117,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
const char* cmakeGeneratorToolset = const char* cmakeGeneratorToolset =
this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET"); this->Makefile->GetDefinition("CTEST_CMAKE_GENERATOR_TOOLSET");
if(cmakeGeneratorToolset && *cmakeGeneratorToolset) if (cmakeGeneratorToolset && *cmakeGeneratorToolset) {
{
cmakeConfigureCommand += " \"-T"; cmakeConfigureCommand += " \"-T";
cmakeConfigureCommand += cmakeGeneratorToolset; cmakeConfigureCommand += cmakeGeneratorToolset;
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
@ -140,22 +127,20 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
cmakeConfigureCommand += source_dir; cmakeConfigureCommand += source_dir;
cmakeConfigureCommand += "\""; cmakeConfigureCommand += "\"";
this->CTest->SetCTestConfiguration("ConfigureCommand", this->CTest->SetCTestConfiguration(
cmakeConfigureCommand.c_str(), this->Quiet); "ConfigureCommand", cmakeConfigureCommand.c_str(), this->Quiet);
} } else {
else this->SetError(
{ "Configure command is not specified. If this is a "
this->SetError("Configure command is not specified. If this is a "
"\"built with CMake\" project, set CTEST_CMAKE_GENERATOR. If not, " "\"built with CMake\" project, set CTEST_CMAKE_GENERATOR. If not, "
"set CTEST_CONFIGURE_COMMAND."); "set CTEST_CONFIGURE_COMMAND.");
return 0; return 0;
} }
} }
cmCTestGenericHandler* handler cmCTestGenericHandler* handler =
= this->CTest->GetInitializedHandler("configure"); this->CTest->GetInitializedHandler("configure");
if ( !handler ) if (!handler) {
{
this->SetError( this->SetError(
"internal CTest error. Cannot instantiate configure handler"); "internal CTest error. Cannot instantiate configure handler");
return 0; return 0;

View File

@ -45,12 +45,12 @@ public:
protected: protected:
cmCTestGenericHandler* InitializeHandler(); cmCTestGenericHandler* InitializeHandler();
enum { enum
{
ctc_FIRST = ct_LAST, ctc_FIRST = ct_LAST,
ctc_OPTIONS, ctc_OPTIONS,
ctc_LAST ctc_LAST
}; };
}; };
#endif #endif

View File

@ -18,7 +18,6 @@
#include "cmake.h" #include "cmake.h"
#include <cmsys/Process.h> #include <cmsys/Process.h>
cmCTestConfigureHandler::cmCTestConfigureHandler() cmCTestConfigureHandler::cmCTestConfigureHandler()
{ {
} }
@ -34,20 +33,18 @@ int cmCTestConfigureHandler::ProcessHandler()
{ {
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
"Configure project" << std::endl, this->Quiet); "Configure project" << std::endl, this->Quiet);
std::string cCommand std::string cCommand =
= this->CTest->GetCTestConfiguration("ConfigureCommand"); this->CTest->GetCTestConfiguration("ConfigureCommand");
if (cCommand.empty()) if (cCommand.empty()) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find ConfigureCommand key in the DartConfiguration.tcl" "Cannot find ConfigureCommand key in the DartConfiguration.tcl"
<< std::endl); << std::endl);
return -1; return -1;
} }
std::string buildDirectory std::string buildDirectory =
= this->CTest->GetCTestConfiguration("BuildDirectory"); this->CTest->GetCTestConfiguration("BuildDirectory");
if (buildDirectory.empty()) if (buildDirectory.empty()) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find BuildDirectory key in the DartConfiguration.tcl" "Cannot find BuildDirectory key in the DartConfiguration.tcl"
<< std::endl); << std::endl);
@ -58,34 +55,30 @@ int cmCTestConfigureHandler::ProcessHandler()
std::string output; std::string output;
int retVal = 0; int retVal = 0;
int res = 0; int res = 0;
if ( !this->CTest->GetShowOnly() ) if (!this->CTest->GetShowOnly()) {
{
cmGeneratedFileStream os; cmGeneratedFileStream os;
if(!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os)) if (!this->StartResultingXML(cmCTest::PartConfigure, "Configure", os)) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open configure file" cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open configure file"
<< std::endl); << std::endl);
return 1; return 1;
} }
std::string start_time = this->CTest->CurrentTime(); std::string start_time = this->CTest->CurrentTime();
unsigned int start_time_time = static_cast<unsigned int>( unsigned int start_time_time =
cmSystemTools::GetTime()); static_cast<unsigned int>(cmSystemTools::GetTime());
cmGeneratedFileStream ofs; cmGeneratedFileStream ofs;
this->StartLogFile("Configure", ofs); this->StartLogFile("Configure", ofs);
cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Configure with command: " << cCommand << std::endl, this->Quiet); "Configure with command: " << cCommand << std::endl,
res = this->CTest->RunMakeCommand(cCommand.c_str(), output, this->Quiet);
&retVal, buildDirectory.c_str(), res = this->CTest->RunMakeCommand(cCommand.c_str(), output, &retVal,
0, ofs); buildDirectory.c_str(), 0, ofs);
if ( ofs ) if (ofs) {
{
ofs.close(); ofs.close();
} }
if ( os ) if (os) {
{
cmXMLWriter xml(os); cmXMLWriter xml(os);
this->CTest->StartXML(xml, this->AppendXML); this->CTest->StartXML(xml, this->AppendXML);
xml.StartElement("Configure"); xml.StartElement("Configure");
@ -98,19 +91,19 @@ int cmCTestConfigureHandler::ProcessHandler()
xml.Element("EndDateTime", this->CTest->CurrentTime()); xml.Element("EndDateTime", this->CTest->CurrentTime());
xml.Element("EndConfigureTime", xml.Element("EndConfigureTime",
static_cast<unsigned int>(cmSystemTools::GetTime())); static_cast<unsigned int>(cmSystemTools::GetTime()));
xml.Element("ElapsedMinutes", static_cast<int>( xml.Element(
(cmSystemTools::GetTime() - elapsed_time_start)/6)/10.0); "ElapsedMinutes",
static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
10.0);
xml.EndElement(); // Configure xml.EndElement(); // Configure
this->CTest->EndXML(xml); this->CTest->EndXML(xml);
} }
} } else {
else
{
cmCTestOptionalLog(this->CTest, DEBUG, cmCTestOptionalLog(this->CTest, DEBUG,
"Configure with command: " << cCommand << std::endl, this->Quiet); "Configure with command: " << cCommand << std::endl,
this->Quiet);
} }
if (! res || retVal ) if (!res || retVal) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Error(s) when configuring the project" << std::endl); "Error(s) when configuring the project" << std::endl);
return -1; return -1;

View File

@ -21,21 +21,20 @@ cmCTestCoverageCommand::cmCTestCoverageCommand()
cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler() cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
{ {
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(
"CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet); this->Makefile, "CoverageCommand", "CTEST_COVERAGE_COMMAND", this->Quiet);
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile, this->CTest->SetCTestConfigurationFromCMakeVariable(
"CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS", this->Quiet); this->Makefile, "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS",
this->Quiet);
cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>( cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
this->CTest->GetInitializedHandler("coverage")); this->CTest->GetInitializedHandler("coverage"));
if ( !handler ) if (!handler) {
{
this->SetError("internal CTest error. Cannot instantiate test handler"); this->SetError("internal CTest error. Cannot instantiate test handler");
return 0; return 0;
} }
// If a LABELS option was given, select only files with the labels. // If a LABELS option was given, select only files with the labels.
if(this->LabelsMentioned) if (this->LabelsMentioned) {
{
handler->SetLabelFilter(this->Labels); handler->SetLabelFilter(this->Labels);
} }
@ -46,8 +45,7 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg) bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
{ {
// Look for arguments specific to this command. // Look for arguments specific to this command.
if(arg == "LABELS") if (arg == "LABELS") {
{
this->ArgumentDoing = ArgumentDoingLabels; this->ArgumentDoing = ArgumentDoingLabels;
this->LabelsMentioned = true; this->LabelsMentioned = true;
return true; return true;
@ -60,8 +58,7 @@ bool cmCTestCoverageCommand::CheckArgumentKeyword(std::string const& arg)
bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg) bool cmCTestCoverageCommand::CheckArgumentValue(std::string const& arg)
{ {
// Handle states specific to this command. // Handle states specific to this command.
if(this->ArgumentDoing == ArgumentDoingLabels) if (this->ArgumentDoing == ArgumentDoingLabels) {
{
this->Labels.insert(arg); this->Labels.insert(arg);
return true; return true;
} }

View File

@ -22,7 +22,6 @@
class cmCTestCoverageCommand : public cmCTestHandlerCommand class cmCTestCoverageCommand : public cmCTestHandlerCommand
{ {
public: public:
cmCTestCoverageCommand(); cmCTestCoverageCommand();
/** /**
@ -59,6 +58,4 @@ protected:
std::set<std::string> Labels; std::set<std::string> Labels;
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -103,22 +103,15 @@ private:
std::vector<std::string>& files, std::vector<std::string>& files,
std::vector<std::string>& filesFullPath); std::vector<std::string>& filesFullPath);
int RunBullseyeCommand( int RunBullseyeCommand(cmCTestCoverageHandlerContainer* cont,
cmCTestCoverageHandlerContainer* cont, const char* cmd, const char* arg,
const char* cmd,
const char* arg,
std::string& outputFile); std::string& outputFile);
bool ParseBullsEyeCovsrcLine( bool ParseBullsEyeCovsrcLine(std::string const& inputLine,
std::string const& inputLine, std::string& sourceFile, int& functionsCalled,
std::string& sourceFile, int& totalFunctions, int& percentFunction,
int& functionsCalled, int& branchCovered, int& totalBranches,
int& totalFunctions,
int& percentFunction,
int& branchCovered,
int& totalBranches,
int& percentBranch); int& percentBranch);
bool GetNextInt(std::string const& inputLine, bool GetNextInt(std::string const& inputLine, std::string::size_type& pos,
std::string::size_type& pos,
int& value); int& value);
//! Handle Python coverage using Python's Trace.py //! Handle Python coverage using Python's Trace.py
int HandleTracePyCoverage(cmCTestCoverageHandlerContainer* cont); int HandleTracePyCoverage(cmCTestCoverageHandlerContainer* cont);
@ -134,9 +127,10 @@ private:
std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex; std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex;
std::vector<std::string> ExtraCoverageGlobs; std::vector<std::string> ExtraCoverageGlobs;
// Map from source file to label ids. // Map from source file to label ids.
class LabelSet: public std::set<int> {}; class LabelSet : public std::set<int>
{
};
typedef std::map<std::string, LabelSet> LabelMapType; typedef std::map<std::string, LabelSet> LabelMapType;
LabelMapType SourceLabels; LabelMapType SourceLabels;
LabelMapType TargetDirs; LabelMapType TargetDirs;

View File

@ -42,45 +42,36 @@ std::string cmCTestCurl::Escape(std::string const& source)
return ret; return ret;
} }
namespace namespace {
{ static size_t curlWriteMemoryCallback(void* ptr, size_t size, size_t nmemb,
static size_t
curlWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
void* data) void* data)
{ {
int realsize = (int)(size * nmemb); int realsize = (int)(size * nmemb);
std::vector<char> *vec std::vector<char>* vec = static_cast<std::vector<char>*>(data);
= static_cast<std::vector<char>* >(data);
const char* chPtr = static_cast<char*>(ptr); const char* chPtr = static_cast<char*>(ptr);
vec->insert(vec->end(), chPtr, chPtr + realsize); vec->insert(vec->end(), chPtr, chPtr + realsize);
return realsize; return realsize;
} }
static size_t static size_t curlDebugCallback(CURL*, curl_infotype, char* chPtr, size_t size,
curlDebugCallback(CURL *, curl_infotype, char *chPtr, void* data)
size_t size, void *data)
{ {
std::vector<char> *vec std::vector<char>* vec = static_cast<std::vector<char>*>(data);
= static_cast<std::vector<char>* >(data);
vec->insert(vec->end(), chPtr, chPtr + size); vec->insert(vec->end(), chPtr, chPtr + size);
return size; return size;
} }
} }
void cmCTestCurl::SetCurlOptions(std::vector<std::string> const& args) void cmCTestCurl::SetCurlOptions(std::vector<std::string> const& args)
{ {
for (std::vector<std::string>::const_iterator i = args.begin(); for (std::vector<std::string>::const_iterator i = args.begin();
i != args.end(); ++i) i != args.end(); ++i) {
{ if (*i == "CURLOPT_SSL_VERIFYPEER_OFF") {
if(*i == "CURLOPT_SSL_VERIFYPEER_OFF")
{
this->VerifyPeerOff = true; this->VerifyPeerOff = true;
} }
if(*i == "CURLOPT_SSL_VERIFYHOST_OFF") if (*i == "CURLOPT_SSL_VERIFYHOST_OFF") {
{
this->VerifyHostOff = true; this->VerifyHostOff = true;
} }
} }
@ -88,30 +79,24 @@ void cmCTestCurl::SetCurlOptions(std::vector<std::string> const& args)
bool cmCTestCurl::InitCurl() bool cmCTestCurl::InitCurl()
{ {
if(!this->Curl) if (!this->Curl) {
{
return false; return false;
} }
if(this->VerifyPeerOff) if (this->VerifyPeerOff) {
{
curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYPEER, 0);
} }
if(this->VerifyHostOff) if (this->VerifyHostOff) {
{
curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYHOST, 0); curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYHOST, 0);
} }
if(this->HTTPProxy.size()) if (this->HTTPProxy.size()) {
{
curl_easy_setopt(this->Curl, CURLOPT_PROXY, this->HTTPProxy.c_str()); curl_easy_setopt(this->Curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
curl_easy_setopt(this->Curl, CURLOPT_PROXYTYPE, this->HTTPProxyType); curl_easy_setopt(this->Curl, CURLOPT_PROXYTYPE, this->HTTPProxyType);
if (this->HTTPProxyAuth.size() > 0) if (this->HTTPProxyAuth.size() > 0) {
{
curl_easy_setopt(this->Curl, CURLOPT_PROXYUSERPWD, curl_easy_setopt(this->Curl, CURLOPT_PROXYUSERPWD,
this->HTTPProxyAuth.c_str()); this->HTTPProxyAuth.c_str());
} }
} }
if(this->UseHttp10) if (this->UseHttp10) {
{
curl_easy_setopt(this->Curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); curl_easy_setopt(this->Curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
} }
// enable HTTP ERROR parsing // enable HTTP ERROR parsing
@ -119,23 +104,19 @@ bool cmCTestCurl::InitCurl()
return true; return true;
} }
bool cmCTestCurl::UploadFile(std::string const& local_file, bool cmCTestCurl::UploadFile(std::string const& local_file,
std::string const& url, std::string const& url, std::string const& fields,
std::string const& fields,
std::string& response) std::string& response)
{ {
response = ""; response = "";
if(!this->InitCurl()) if (!this->InitCurl()) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed"); cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
return false; return false;
} }
/* enable uploading */ /* enable uploading */
curl_easy_setopt(this->Curl, CURLOPT_UPLOAD, 1); curl_easy_setopt(this->Curl, CURLOPT_UPLOAD, 1);
// if there is little to no activity for too long stop submitting // if there is little to no activity for too long stop submitting
if(this->TimeOutSeconds) if (this->TimeOutSeconds) {
{
::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_LIMIT, 1); ::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_LIMIT, 1);
::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_TIME, ::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_TIME,
this->TimeOutSeconds); this->TimeOutSeconds);
@ -145,8 +126,7 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
::curl_easy_setopt(this->Curl, CURLOPT_VERBOSE, 1); ::curl_easy_setopt(this->Curl, CURLOPT_VERBOSE, 1);
FILE* ftpfile = cmsys::SystemTools::Fopen(local_file, "rb"); FILE* ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
if(!ftpfile) if (!ftpfile) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Could not open file for upload: " << local_file << "\n"); "Could not open file for upload: " << local_file << "\n");
return false; return false;
@ -164,11 +144,10 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
static_cast<long>(filelen)); static_cast<long>(filelen));
::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION, ::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
curlWriteMemoryCallback); curlWriteMemoryCallback);
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
curlDebugCallback);
// Be sure to set Content-Type to satisfy fussy modsecurity rules // Be sure to set Content-Type to satisfy fussy modsecurity rules
struct curl_slist *headers = ::curl_slist_append(NULL, struct curl_slist* headers =
"Content-Type: text/xml"); ::curl_slist_append(NULL, "Content-Type: text/xml");
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers); ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
std::vector<char> responseData; std::vector<char> responseData;
std::vector<char> debugData; std::vector<char> debugData;
@ -181,37 +160,32 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, NULL); ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, NULL);
::curl_slist_free_all(headers); ::curl_slist_free_all(headers);
if ( responseData.size() > 0 ) if (responseData.size() > 0) {
{
response = std::string(responseData.begin(), responseData.end()); response = std::string(responseData.begin(), responseData.end());
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Curl response: ["
"Curl response: [" << response << "]\n"); << response << "]\n");
} }
std::string curlDebug; std::string curlDebug;
if ( debugData.size() > 0 ) if (debugData.size() > 0) {
{
curlDebug = std::string(debugData.begin(), debugData.end()); curlDebug = std::string(debugData.begin(), debugData.end());
cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n"); cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
} }
if(response.size() == 0) if (response.size() == 0) {
{ cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n"
cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n" << << curlDebug);
curlDebug);
return false; return false;
} }
return true; return true;
} }
bool cmCTestCurl::HttpRequest(std::string const& url, bool cmCTestCurl::HttpRequest(std::string const& url,
std::string const& fields, std::string const& fields, std::string& response)
std::string& response)
{ {
response = ""; response = "";
cmCTestLog(this->CTest, DEBUG, "HttpRequest\n" cmCTestLog(this->CTest, DEBUG, "HttpRequest\n"
<< "url: " << url << "\n" << "url: " << url << "\n"
<< "fields " << fields << "\n"); << "fields " << fields << "\n");
if(!this->InitCurl()) if (!this->InitCurl()) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed"); cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
return false; return false;
} }
@ -222,8 +196,7 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
// set response options // set response options
::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION, ::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
curlWriteMemoryCallback); curlWriteMemoryCallback);
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
curlDebugCallback);
std::vector<char> responseData; std::vector<char> responseData;
std::vector<char> debugData; std::vector<char> debugData;
::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData); ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void*)&responseData);
@ -232,13 +205,11 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
CURLcode res = ::curl_easy_perform(this->Curl); CURLcode res = ::curl_easy_perform(this->Curl);
if ( responseData.size() > 0 ) if (responseData.size() > 0) {
{
response = std::string(responseData.begin(), responseData.end()); response = std::string(responseData.begin(), responseData.end());
cmCTestLog(this->CTest, DEBUG, "Curl response: [" << response << "]\n"); cmCTestLog(this->CTest, DEBUG, "Curl response: [" << response << "]\n");
} }
if ( debugData.size() > 0 ) if (debugData.size() > 0) {
{
std::string curlDebug = std::string(debugData.begin(), debugData.end()); std::string curlDebug = std::string(debugData.begin(), debugData.end());
cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n"); cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
} }
@ -248,39 +219,29 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
void cmCTestCurl::SetProxyType() void cmCTestCurl::SetProxyType()
{ {
if ( cmSystemTools::GetEnv("HTTP_PROXY") ) if (cmSystemTools::GetEnv("HTTP_PROXY")) {
{
this->HTTPProxy = cmSystemTools::GetEnv("HTTP_PROXY"); this->HTTPProxy = cmSystemTools::GetEnv("HTTP_PROXY");
if ( cmSystemTools::GetEnv("HTTP_PROXY_PORT") ) if (cmSystemTools::GetEnv("HTTP_PROXY_PORT")) {
{
this->HTTPProxy += ":"; this->HTTPProxy += ":";
this->HTTPProxy += cmSystemTools::GetEnv("HTTP_PROXY_PORT"); this->HTTPProxy += cmSystemTools::GetEnv("HTTP_PROXY_PORT");
} }
if ( cmSystemTools::GetEnv("HTTP_PROXY_TYPE") ) if (cmSystemTools::GetEnv("HTTP_PROXY_TYPE")) {
{
// this is the default // this is the default
this->HTTPProxyType = CURLPROXY_HTTP; this->HTTPProxyType = CURLPROXY_HTTP;
std::string type = cmSystemTools::GetEnv("HTTP_PROXY_TYPE"); std::string type = cmSystemTools::GetEnv("HTTP_PROXY_TYPE");
// HTTP/SOCKS4/SOCKS5 // HTTP/SOCKS4/SOCKS5
if ( type == "HTTP" ) if (type == "HTTP") {
{
this->HTTPProxyType = CURLPROXY_HTTP; this->HTTPProxyType = CURLPROXY_HTTP;
} } else if (type == "SOCKS4") {
else if ( type == "SOCKS4" )
{
this->HTTPProxyType = CURLPROXY_SOCKS4; this->HTTPProxyType = CURLPROXY_SOCKS4;
} } else if (type == "SOCKS5") {
else if ( type == "SOCKS5" )
{
this->HTTPProxyType = CURLPROXY_SOCKS5; this->HTTPProxyType = CURLPROXY_SOCKS5;
} }
} }
if ( cmSystemTools::GetEnv("HTTP_PROXY_USER") ) if (cmSystemTools::GetEnv("HTTP_PROXY_USER")) {
{
this->HTTPProxyAuth = cmSystemTools::GetEnv("HTTP_PROXY_USER"); this->HTTPProxyAuth = cmSystemTools::GetEnv("HTTP_PROXY_USER");
} }
if ( cmSystemTools::GetEnv("HTTP_PROXY_PASSWD") ) if (cmSystemTools::GetEnv("HTTP_PROXY_PASSWD")) {
{
this->HTTPProxyAuth += ":"; this->HTTPProxyAuth += ":";
this->HTTPProxyAuth += cmSystemTools::GetEnv("HTTP_PROXY_PASSWD"); this->HTTPProxyAuth += cmSystemTools::GetEnv("HTTP_PROXY_PASSWD");
} }

View File

@ -23,12 +23,9 @@ class cmCTestCurl
public: public:
cmCTestCurl(cmCTest*); cmCTestCurl(cmCTest*);
~cmCTestCurl(); ~cmCTestCurl();
bool UploadFile(std::string const& url, bool UploadFile(std::string const& url, std::string const& file,
std::string const& file, std::string const& fields, std::string& response);
std::string const& fields, bool HttpRequest(std::string const& url, std::string const& fields,
std::string& response);
bool HttpRequest(std::string const& url,
std::string const& fields,
std::string& response); std::string& response);
// currently only supports CURLOPT_SSL_VERIFYPEER_OFF // currently only supports CURLOPT_SSL_VERIFYPEER_OFF
// and CURLOPT_SSL_VERIFYHOST_OFF // and CURLOPT_SSL_VERIFYHOST_OFF
@ -36,9 +33,11 @@ public:
void SetUseHttp10On() { this->UseHttp10 = true; } void SetUseHttp10On() { this->UseHttp10 = true; }
void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s; } void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s; }
std::string Escape(std::string const& source); std::string Escape(std::string const& source);
protected: protected:
void SetProxyType(); void SetProxyType();
bool InitCurl(); bool InitCurl();
private: private:
cmCTest* CTest; cmCTest* CTest;
CURL* Curl; CURL* Curl;

View File

@ -13,17 +13,15 @@
#include "cmCTestScriptHandler.h" #include "cmCTestScriptHandler.h"
bool cmCTestEmptyBinaryDirectoryCommand bool cmCTestEmptyBinaryDirectoryCommand::InitialPass(
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) std::vector<std::string> const& args, cmExecutionStatus&)
{
if(args.size() != 1 )
{ {
if (args.size() != 1) {
this->SetError("called with incorrect number of arguments"); this->SetError("called with incorrect number of arguments");
return false; return false;
} }
if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) ) if (!cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str())) {
{
std::ostringstream ostr; std::ostringstream ostr;
ostr << "problem removing the binary directory: " << args[0]; ostr << "problem removing the binary directory: " << args[0];
this->SetError(ostr.str()); this->SetError(ostr.str());
@ -32,5 +30,3 @@ bool cmCTestEmptyBinaryDirectoryCommand
return true; return true;
} }

View File

@ -23,7 +23,6 @@
class cmCTestEmptyBinaryDirectoryCommand : public cmCTestCommand class cmCTestEmptyBinaryDirectoryCommand : public cmCTestCommand
{ {
public: public:
cmCTestEmptyBinaryDirectoryCommand() {} cmCTestEmptyBinaryDirectoryCommand() {}
/** /**
@ -31,8 +30,8 @@ public:
*/ */
virtual cmCommand* Clone() virtual cmCommand* Clone()
{ {
cmCTestEmptyBinaryDirectoryCommand* ni cmCTestEmptyBinaryDirectoryCommand* ni =
= new cmCTestEmptyBinaryDirectoryCommand; new cmCTestEmptyBinaryDirectoryCommand;
ni->CTest = this->CTest; ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler; ni->CTestScriptHandler = this->CTestScriptHandler;
return ni; return ni;
@ -48,11 +47,12 @@ public:
/** /**
* The name of the command as specified in CMakeList.txt. * The name of the command as specified in CMakeList.txt.
*/ */
virtual std::string GetName() const { return "ctest_empty_binary_directory";} virtual std::string GetName() const
{
return "ctest_empty_binary_directory";
}
cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand); cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand);
}; };
#endif #endif

View File

@ -30,8 +30,8 @@ static unsigned int cmCTestGITVersion(unsigned int epic, unsigned int major,
return fix + minor * 1000 + major * 100000 + epic * 10000000; return fix + minor * 1000 + major * 100000 + epic * 10000000;
} }
cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log): cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log)
cmCTestGlobalVC(ct, log) : cmCTestGlobalVC(ct, log)
{ {
this->PriorRev = this->Unknown; this->PriorRev = this->Unknown;
this->CurrentGitVersion = 0; this->CurrentGitVersion = 0;
@ -44,11 +44,12 @@ cmCTestGIT::~cmCTestGIT()
class cmCTestGIT::OneLineParser : public cmCTestVC::LineParser class cmCTestGIT::OneLineParser : public cmCTestVC::LineParser
{ {
public: public:
OneLineParser(cmCTestGIT* git, const char* prefix, OneLineParser(cmCTestGIT* git, const char* prefix, std::string& l)
std::string& l): Line1(l) : Line1(l)
{ {
this->SetLog(&git->Log, prefix); this->SetLog(&git->Log, prefix);
} }
private: private:
std::string& Line1; std::string& Line1;
virtual bool ProcessLine() virtual bool ProcessLine()
@ -96,35 +97,30 @@ std::string cmCTestGIT::FindGitDir()
std::string git_dir_line; std::string git_dir_line;
OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line); OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line);
OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); OutputLogger rev_parse_err(this->Log, "rev-parse-err> ");
if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err)) if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err)) {
{
git_dir = git_dir_line; git_dir = git_dir_line;
} }
if(git_dir.empty()) if (git_dir.empty()) {
{
git_dir = ".git"; git_dir = ".git";
} }
// Git reports a relative path only when the .git directory is in // Git reports a relative path only when the .git directory is in
// the current directory. // the current directory.
if(git_dir[0] == '.') if (git_dir[0] == '.') {
{
git_dir = this->SourceDirectory + "/" + git_dir; git_dir = this->SourceDirectory + "/" + git_dir;
} }
#if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) && !defined(__CYGWIN__)
else if(git_dir[0] == '/') else if (git_dir[0] == '/') {
{
// Cygwin Git reports a full path that Cygwin understands, but we // Cygwin Git reports a full path that Cygwin understands, but we
// are a Windows application. Run "cygpath" to get Windows path. // are a Windows application. Run "cygpath" to get Windows path.
std::string cygpath_exe = cmSystemTools::GetFilenamePath(git); std::string cygpath_exe = cmSystemTools::GetFilenamePath(git);
cygpath_exe += "/cygpath.exe"; cygpath_exe += "/cygpath.exe";
if(cmSystemTools::FileExists(cygpath_exe.c_str())) if (cmSystemTools::FileExists(cygpath_exe.c_str())) {
{ char const* cygpath[] = { cygpath_exe.c_str(), "-w", git_dir.c_str(),
char const* cygpath[] = {cygpath_exe.c_str(), "-w", git_dir.c_str(), 0}; 0 };
OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line); OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line);
OutputLogger cygpath_err(this->Log, "cygpath-err> "); OutputLogger cygpath_err(this->Log, "cygpath-err> ");
if(this->RunChild(cygpath, &cygpath_out, &cygpath_err)) if (this->RunChild(cygpath, &cygpath_out, &cygpath_err)) {
{
git_dir = git_dir_line; git_dir = git_dir_line;
} }
} }
@ -144,8 +140,7 @@ std::string cmCTestGIT::FindTopDir()
OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup); OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup);
OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); OutputLogger rev_parse_err(this->Log, "rev-parse-err> ");
if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) && if (this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) &&
!cdup.empty()) !cdup.empty()) {
{
top_dir += "/"; top_dir += "/";
top_dir += cdup; top_dir += cdup;
top_dir = cmSystemTools::CollapseFullPath(top_dir); top_dir = cmSystemTools::CollapseFullPath(top_dir);
@ -164,14 +159,12 @@ bool cmCTestGIT::UpdateByFetchAndReset()
// Add user-specified update options. // Add user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions"); std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
if(opts.empty()) if (opts.empty()) {
{
opts = this->CTest->GetCTestConfiguration("GITUpdateOptions"); opts = this->CTest->GetCTestConfiguration("GITUpdateOptions");
} }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
for (std::vector<std::string>::const_iterator ai = args.begin(); for (std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai) ai != args.end(); ++ai) {
{
git_fetch.push_back(ai->c_str()); git_fetch.push_back(ai->c_str());
} }
@ -181,8 +174,7 @@ bool cmCTestGIT::UpdateByFetchAndReset()
// Fetch upstream refs. // Fetch upstream refs.
OutputLogger fetch_out(this->Log, "fetch-out> "); OutputLogger fetch_out(this->Log, "fetch-out> ");
OutputLogger fetch_err(this->Log, "fetch-err> "); OutputLogger fetch_err(this->Log, "fetch-err> ");
if(!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err)) if (!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err)) {
{
return false; return false;
} }
@ -191,26 +183,21 @@ bool cmCTestGIT::UpdateByFetchAndReset()
{ {
std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD"; std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD";
cmsys::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary); cmsys::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary);
if(!fin) if (!fin) {
{
this->Log << "Unable to open " << fetch_head << "\n"; this->Log << "Unable to open " << fetch_head << "\n";
return false; return false;
} }
std::string line; std::string line;
while(sha1.empty() && cmSystemTools::GetLineFromStream(fin, line)) while (sha1.empty() && cmSystemTools::GetLineFromStream(fin, line)) {
{
this->Log << "FETCH_HEAD> " << line << "\n"; this->Log << "FETCH_HEAD> " << line << "\n";
if(line.find("\tnot-for-merge\t") == line.npos) if (line.find("\tnot-for-merge\t") == line.npos) {
{
std::string::size_type pos = line.find('\t'); std::string::size_type pos = line.find('\t');
if(pos != line.npos) if (pos != line.npos) {
{
sha1 = line.substr(0, pos); sha1 = line.substr(0, pos);
} }
} }
} }
if(sha1.empty()) if (sha1.empty()) {
{
this->Log << "FETCH_HEAD has no upstream branch candidate!\n"; this->Log << "FETCH_HEAD has no upstream branch candidate!\n";
return false; return false;
} }
@ -228,9 +215,8 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom)
std::vector<std::string> git_custom_command; std::vector<std::string> git_custom_command;
cmSystemTools::ExpandListArgument(custom, git_custom_command, true); cmSystemTools::ExpandListArgument(custom, git_custom_command, true);
std::vector<char const*> git_custom; std::vector<char const*> git_custom;
for(std::vector<std::string>::const_iterator for (std::vector<std::string>::const_iterator i = git_custom_command.begin();
i = git_custom_command.begin(); i != git_custom_command.end(); ++i) i != git_custom_command.end(); ++i) {
{
git_custom.push_back(i->c_str()); git_custom.push_back(i->c_str());
} }
git_custom.push_back(0); git_custom.push_back(0);
@ -243,8 +229,7 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom)
bool cmCTestGIT::UpdateInternal() bool cmCTestGIT::UpdateInternal()
{ {
std::string custom = this->CTest->GetCTestConfiguration("GITUpdateCustom"); std::string custom = this->CTest->GetCTestConfiguration("GITUpdateCustom");
if(!custom.empty()) if (!custom.empty()) {
{
return this->UpdateByCustom(custom); return this->UpdateByCustom(custom);
} }
return this->UpdateByFetchAndReset(); return this->UpdateByFetchAndReset();
@ -252,8 +237,7 @@ bool cmCTestGIT::UpdateInternal()
bool cmCTestGIT::UpdateImpl() bool cmCTestGIT::UpdateImpl()
{ {
if(!this->UpdateInternal()) if (!this->UpdateInternal()) {
{
return false; return false;
} }
@ -263,23 +247,19 @@ bool cmCTestGIT::UpdateImpl()
const char* sync_recursive = "--recursive"; const char* sync_recursive = "--recursive";
// Git < 1.6.5 did not support submodule --recursive // Git < 1.6.5 did not support submodule --recursive
if(this->GetGitVersion() < cmCTestGITVersion(1,6,5,0)) if (this->GetGitVersion() < cmCTestGITVersion(1, 6, 5, 0)) {
{
recursive = 0; recursive = 0;
// No need to require >= 1.6.5 if there are no submodules. // No need to require >= 1.6.5 if there are no submodules.
if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
{
this->Log << "Git < 1.6.5 cannot update submodules recursively\n"; this->Log << "Git < 1.6.5 cannot update submodules recursively\n";
} }
} }
// Git < 1.8.1 did not support sync --recursive // Git < 1.8.1 did not support sync --recursive
if(this->GetGitVersion() < cmCTestGITVersion(1,8,1,0)) if (this->GetGitVersion() < cmCTestGITVersion(1, 8, 1, 0)) {
{
sync_recursive = 0; sync_recursive = 0;
// No need to require >= 1.8.1 if there are no submodules. // No need to require >= 1.8.1 if there are no submodules.
if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) if (cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) {
{
this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n"; this->Log << "Git < 1.8.1 cannot synchronize submodules recursively\n";
} }
} }
@ -291,14 +271,12 @@ bool cmCTestGIT::UpdateImpl()
std::string init_submodules = std::string init_submodules =
this->CTest->GetCTestConfiguration("GITInitSubmodules"); this->CTest->GetCTestConfiguration("GITInitSubmodules");
if (cmSystemTools::IsOn(init_submodules.c_str())) if (cmSystemTools::IsOn(init_submodules.c_str())) {
{
char const* git_submodule_init[] = { git, "submodule", "init", 0 }; char const* git_submodule_init[] = { git, "submodule", "init", 0 };
ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err, ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err,
top_dir.c_str()); top_dir.c_str());
if (!ret) if (!ret) {
{
return false; return false;
} }
} }
@ -308,8 +286,7 @@ bool cmCTestGIT::UpdateImpl()
ret = this->RunChild(git_submodule_sync, &submodule_out, &submodule_err, ret = this->RunChild(git_submodule_sync, &submodule_out, &submodule_err,
top_dir.c_str()); top_dir.c_str());
if (!ret) if (!ret) {
{
return false; return false;
} }
@ -320,8 +297,7 @@ bool cmCTestGIT::UpdateImpl()
unsigned int cmCTestGIT::GetGitVersion() unsigned int cmCTestGIT::GetGitVersion()
{ {
if(!this->CurrentGitVersion) if (!this->CurrentGitVersion) {
{
const char* git = this->CommandLineTool.c_str(); const char* git = this->CommandLineTool.c_str();
char const* git_version[] = { git, "--version", 0 }; char const* git_version[] = { git, "--version", 0 };
std::string version; std::string version;
@ -329,9 +305,8 @@ unsigned int cmCTestGIT::GetGitVersion()
OutputLogger version_err(this->Log, "version-err> "); OutputLogger version_err(this->Log, "version-err> ");
unsigned int v[4] = { 0, 0, 0, 0 }; unsigned int v[4] = { 0, 0, 0, 0 };
if (this->RunChild(git_version, &version_out, &version_err) && if (this->RunChild(git_version, &version_out, &version_err) &&
sscanf(version.c_str(), "git version %u.%u.%u.%u", sscanf(version.c_str(), "git version %u.%u.%u.%u", &v[0], &v[1], &v[2],
&v[0], &v[1], &v[2], &v[3]) >= 3) &v[3]) >= 3) {
{
this->CurrentGitVersion = cmCTestGITVersion(v[0], v[1], v[2], v[3]); this->CurrentGitVersion = cmCTestGITVersion(v[0], v[1], v[2], v[3]);
} }
} }
@ -351,18 +326,26 @@ unsigned int cmCTestGIT::GetGitVersion()
class cmCTestGIT::DiffParser : public cmCTestVC::LineParser class cmCTestGIT::DiffParser : public cmCTestVC::LineParser
{ {
public: public:
DiffParser(cmCTestGIT* git, const char* prefix): DiffParser(cmCTestGIT* git, const char* prefix)
LineParser('\0', false), GIT(git), DiffField(DiffFieldNone) : LineParser('\0', false)
, GIT(git)
, DiffField(DiffFieldNone)
{ {
this->SetLog(&git->Log, prefix); this->SetLog(&git->Log, prefix);
} }
typedef cmCTestGIT::Change Change; typedef cmCTestGIT::Change Change;
std::vector<Change> Changes; std::vector<Change> Changes;
protected: protected:
cmCTestGIT* GIT; cmCTestGIT* GIT;
enum DiffFieldType { DiffFieldNone, DiffFieldChange, enum DiffFieldType
DiffFieldSrc, DiffFieldDst }; {
DiffFieldNone,
DiffFieldChange,
DiffFieldSrc,
DiffFieldDst
};
DiffFieldType DiffField; DiffFieldType DiffField;
Change CurChange; Change CurChange;
@ -374,16 +357,13 @@ protected:
virtual bool ProcessLine() virtual bool ProcessLine()
{ {
if(this->Line[0] == ':') if (this->Line[0] == ':') {
{
this->DiffField = DiffFieldChange; this->DiffField = DiffFieldChange;
this->CurChange = Change(); this->CurChange = Change();
} }
if(this->DiffField == DiffFieldChange) if (this->DiffField == DiffFieldChange) {
{
// :src-mode dst-mode src-sha1 dst-sha1 status // :src-mode dst-mode src-sha1 dst-sha1 status
if(this->Line[0] != ':') if (this->Line[0] != ':') {
{
this->DiffField = DiffFieldNone; this->DiffField = DiffFieldNone;
return true; return true;
} }
@ -397,27 +377,19 @@ protected:
const char* dst_sha1_last = this->ConsumeField(dst_sha1_first); const char* dst_sha1_last = this->ConsumeField(dst_sha1_first);
const char* status_first = this->ConsumeSpace(dst_sha1_last); const char* status_first = this->ConsumeSpace(dst_sha1_last);
const char* status_last = this->ConsumeField(status_first); const char* status_last = this->ConsumeField(status_first);
if(status_first != status_last) if (status_first != status_last) {
{
this->CurChange.Action = *status_first; this->CurChange.Action = *status_first;
this->DiffField = DiffFieldSrc; this->DiffField = DiffFieldSrc;
} } else {
else
{
this->DiffField = DiffFieldNone; this->DiffField = DiffFieldNone;
} }
} } else if (this->DiffField == DiffFieldSrc) {
else if(this->DiffField == DiffFieldSrc)
{
// src-path // src-path
if(this->CurChange.Action == 'C') if (this->CurChange.Action == 'C') {
{
// Convert copy to addition of destination. // Convert copy to addition of destination.
this->CurChange.Action = 'A'; this->CurChange.Action = 'A';
this->DiffField = DiffFieldDst; this->DiffField = DiffFieldDst;
} } else if (this->CurChange.Action == 'R') {
else if(this->CurChange.Action == 'R')
{
// Convert rename to deletion of source and addition of destination. // Convert rename to deletion of source and addition of destination.
this->CurChange.Action = 'D'; this->CurChange.Action = 'D';
this->CurChange.Path = this->Line; this->CurChange.Path = this->Line;
@ -425,16 +397,12 @@ protected:
this->CurChange = Change('A'); this->CurChange = Change('A');
this->DiffField = DiffFieldDst; this->DiffField = DiffFieldDst;
} } else {
else
{
this->CurChange.Path = this->Line; this->CurChange.Path = this->Line;
this->Changes.push_back(this->CurChange); this->Changes.push_back(this->CurChange);
this->DiffField = this->DiffFieldNone; this->DiffField = this->DiffFieldNone;
} }
} } else if (this->DiffField == DiffFieldDst) {
else if(this->DiffField == DiffFieldDst)
{
// dst-path // dst-path
this->CurChange.Path = this->Line; this->CurChange.Path = this->Line;
this->Changes.push_back(this->CurChange); this->Changes.push_back(this->CurChange);
@ -445,12 +413,16 @@ protected:
const char* ConsumeSpace(const char* c) const char* ConsumeSpace(const char* c)
{ {
while(*c && isspace(*c)) { ++c; } while (*c && isspace(*c)) {
++c;
}
return c; return c;
} }
const char* ConsumeField(const char* c) const char* ConsumeField(const char* c)
{ {
while(*c && !isspace(*c)) { ++c; } while (*c && !isspace(*c)) {
++c;
}
return c; return c;
} }
}; };
@ -477,15 +449,22 @@ protected:
class cmCTestGIT::CommitParser : public cmCTestGIT::DiffParser class cmCTestGIT::CommitParser : public cmCTestGIT::DiffParser
{ {
public: public:
CommitParser(cmCTestGIT* git, const char* prefix): CommitParser(cmCTestGIT* git, const char* prefix)
DiffParser(git, prefix), Section(SectionHeader) : DiffParser(git, prefix)
, Section(SectionHeader)
{ {
this->Separator = SectionSep[this->Section]; this->Separator = SectionSep[this->Section];
} }
private: private:
typedef cmCTestGIT::Revision Revision; typedef cmCTestGIT::Revision Revision;
enum SectionType { SectionHeader, SectionBody, SectionDiff, SectionCount }; enum SectionType
{
SectionHeader,
SectionBody,
SectionDiff,
SectionCount
};
static char const SectionSep[SectionCount]; static char const SectionSep[SectionCount];
SectionType Section; SectionType Section;
Revision Rev; Revision Rev;
@ -496,23 +475,37 @@ private:
std::string EMail; std::string EMail;
unsigned long Time; unsigned long Time;
long TimeZone; long TimeZone;
Person(): Name(), EMail(), Time(0), TimeZone(0) {} Person()
: Name()
, EMail()
, Time(0)
, TimeZone(0)
{
}
}; };
void ParsePerson(const char* str, Person& person) void ParsePerson(const char* str, Person& person)
{ {
// Person Name <person@domain.com> 1234567890 +0000 // Person Name <person@domain.com> 1234567890 +0000
const char* c = str; const char* c = str;
while(*c && isspace(*c)) { ++c; } while (*c && isspace(*c)) {
++c;
}
const char* name_first = c; const char* name_first = c;
while(*c && *c != '<') { ++c; } while (*c && *c != '<') {
++c;
}
const char* name_last = c; const char* name_last = c;
while(name_last != name_first && isspace(*(name_last-1))) { --name_last; } while (name_last != name_first && isspace(*(name_last - 1))) {
--name_last;
}
person.Name.assign(name_first, name_last - name_first); person.Name.assign(name_first, name_last - name_first);
const char* email_first = *c ? ++c : c; const char* email_first = *c ? ++c : c;
while(*c && *c != '>') { ++c; } while (*c && *c != '>') {
++c;
}
const char* email_last = *c ? c++ : c; const char* email_last = *c ? c++ : c;
person.EMail.assign(email_first, email_last - email_first); person.EMail.assign(email_first, email_last - email_first);
@ -522,23 +515,25 @@ private:
virtual bool ProcessLine() virtual bool ProcessLine()
{ {
if(this->Line.empty()) if (this->Line.empty()) {
{ if (this->Section == SectionBody && this->LineEnd == '\0') {
if(this->Section == SectionBody && this->LineEnd == '\0')
{
// Skip SectionDiff // Skip SectionDiff
this->NextSection(); this->NextSection();
} }
this->NextSection(); this->NextSection();
} } else {
else switch (this->Section) {
{ case SectionHeader:
switch(this->Section) this->DoHeaderLine();
{ break;
case SectionHeader: this->DoHeaderLine(); break; case SectionBody:
case SectionBody: this->DoBodyLine(); break; this->DoBodyLine();
case SectionDiff: this->DiffParser::ProcessLine(); break; break;
case SectionCount: break; // never happens case SectionDiff:
this->DiffParser::ProcessLine();
break;
case SectionCount:
break; // never happens
} }
} }
return true; return true;
@ -548,8 +543,7 @@ private:
{ {
this->Section = SectionType((this->Section + 1) % SectionCount); this->Section = SectionType((this->Section + 1) % SectionCount);
this->Separator = SectionSep[this->Section]; this->Separator = SectionSep[this->Section];
if(this->Section == SectionHeader) if (this->Section == SectionHeader) {
{
this->GIT->DoRevision(this->Rev, this->Changes); this->GIT->DoRevision(this->Rev, this->Changes);
this->Rev = Revision(); this->Rev = Revision();
this->DiffReset(); this->DiffReset();
@ -559,20 +553,15 @@ private:
void DoHeaderLine() void DoHeaderLine()
{ {
// Look for header fields that we need. // Look for header fields that we need.
if(cmHasLiteralPrefix(this->Line.c_str(), "commit ")) if (cmHasLiteralPrefix(this->Line.c_str(), "commit ")) {
{
this->Rev.Rev = this->Line.c_str() + 7; this->Rev.Rev = this->Line.c_str() + 7;
} } else if (cmHasLiteralPrefix(this->Line.c_str(), "author ")) {
else if(cmHasLiteralPrefix(this->Line.c_str(), "author "))
{
Person author; Person author;
this->ParsePerson(this->Line.c_str() + 7, author); this->ParsePerson(this->Line.c_str() + 7, author);
this->Rev.Author = author.Name; this->Rev.Author = author.Name;
this->Rev.EMail = author.EMail; this->Rev.EMail = author.EMail;
this->Rev.Date = this->FormatDateTime(author); this->Rev.Date = this->FormatDateTime(author);
} } else if (cmHasLiteralPrefix(this->Line.c_str(), "committer ")) {
else if(cmHasLiteralPrefix(this->Line.c_str(), "committer "))
{
Person committer; Person committer;
this->ParsePerson(this->Line.c_str() + 10, committer); this->ParsePerson(this->Line.c_str() + 10, committer);
this->Rev.Committer = committer.Name; this->Rev.Committer = committer.Name;
@ -584,8 +573,7 @@ private:
void DoBodyLine() void DoBodyLine()
{ {
// Commit log lines are indented by 4 spaces. // Commit log lines are indented by 4 spaces.
if(this->Line.size() >= 4) if (this->Line.size() >= 4) {
{
this->Rev.Log += this->Line.substr(4); this->Rev.Log += this->Line.substr(4);
} }
this->Rev.Log += "\n"; this->Rev.Log += "\n";
@ -598,19 +586,15 @@ private:
time_t seconds = static_cast<time_t>(person.Time); time_t seconds = static_cast<time_t>(person.Time);
struct tm* t = gmtime(&seconds); struct tm* t = gmtime(&seconds);
char dt[1024]; char dt[1024];
sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", t->tm_year + 1900,
t->tm_year+1900, t->tm_mon+1, t->tm_mday, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec);
t->tm_hour, t->tm_min, t->tm_sec);
std::string out = dt; std::string out = dt;
// Add the time-zone field "+zone" or "-zone". // Add the time-zone field "+zone" or "-zone".
char tz[32]; char tz[32];
if(person.TimeZone >= 0) if (person.TimeZone >= 0) {
{
sprintf(tz, " +%04ld", person.TimeZone); sprintf(tz, " +%04ld", person.TimeZone);
} } else {
else
{
sprintf(tz, " -%04ld", -person.TimeZone); sprintf(tz, " -%04ld", -person.TimeZone);
} }
out += tz; out += tz;
@ -618,19 +602,20 @@ private:
} }
}; };
char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = { '\n', '\n',
{'\n', '\n', '\0'}; '\0' };
void cmCTestGIT::LoadRevisions() void cmCTestGIT::LoadRevisions()
{ {
// Use 'git rev-list ... | git diff-tree ...' to get revisions. // Use 'git rev-list ... | git diff-tree ...' to get revisions.
std::string range = this->OldRevision + ".." + this->NewRevision; std::string range = this->OldRevision + ".." + this->NewRevision;
const char* git = this->CommandLineTool.c_str(); const char* git = this->CommandLineTool.c_str();
const char* git_rev_list[] = const char* git_rev_list[] = { git, "rev-list", "--reverse",
{git, "rev-list", "--reverse", range.c_str(), "--", 0}; range.c_str(), "--", 0 };
const char* git_diff_tree[] = const char* git_diff_tree[] = {
{git, "diff-tree", "--stdin", "--always", "-z", "-r", "--pretty=raw", git, "diff-tree", "--stdin", "--always", "-z",
"--encoding=utf-8", 0}; "-r", "--pretty=raw", "--encoding=utf-8", 0
};
this->Log << this->ComputeCommandLine(git_rev_list) << " | " this->Log << this->ComputeCommandLine(git_rev_list) << " | "
<< this->ComputeCommandLine(git_diff_tree) << "\n"; << this->ComputeCommandLine(git_diff_tree) << "\n";
@ -666,8 +651,7 @@ void cmCTestGIT::LoadModifications()
this->RunChild(git_diff_index, &out, &err); this->RunChild(git_diff_index, &out, &err);
for (std::vector<Change>::const_iterator ci = out.Changes.begin(); for (std::vector<Change>::const_iterator ci = out.Changes.begin();
ci != out.Changes.end(); ++ci) ci != out.Changes.end(); ++ci) {
{
this->DoModification(PathModified, ci->Path); this->DoModification(PathModified, ci->Path);
} }
} }

View File

@ -46,7 +46,6 @@ private:
// "public" needed by older Sun compilers // "public" needed by older Sun compilers
public: public:
// Parsing helper classes. // Parsing helper classes.
class OneLineParser; class OneLineParser;
class DiffParser; class DiffParser;

View File

@ -32,12 +32,10 @@ cmCTestGenericHandler::~cmCTestGenericHandler()
void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
{ {
if ( !value ) if (!value) {
{ cmCTestGenericHandler::t_StringToString::iterator remit =
cmCTestGenericHandler::t_StringToString::iterator remit this->Options.find(op);
= this->Options.find(op); if (remit != this->Options.end()) {
if ( remit != this->Options.end() )
{
this->Options.erase(remit); this->Options.erase(remit);
} }
return; return;
@ -50,12 +48,10 @@ void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
const char* value) const char* value)
{ {
this->SetOption(op, value); this->SetOption(op, value);
if ( !value ) if (!value) {
{ cmCTestGenericHandler::t_StringToString::iterator remit =
cmCTestGenericHandler::t_StringToString::iterator remit this->PersistentOptions.find(op);
= this->PersistentOptions.find(op); if (remit != this->PersistentOptions.end()) {
if ( remit != this->PersistentOptions.end() )
{
this->PersistentOptions.erase(remit); this->PersistentOptions.erase(remit);
} }
return; return;
@ -71,19 +67,16 @@ void cmCTestGenericHandler::Initialize()
this->Options.clear(); this->Options.clear();
t_StringToString::iterator it; t_StringToString::iterator it;
for (it = this->PersistentOptions.begin(); for (it = this->PersistentOptions.begin();
it != this->PersistentOptions.end(); it != this->PersistentOptions.end(); ++it) {
++ it )
{
this->Options[it->first] = it->second.c_str(); this->Options[it->first] = it->second.c_str();
} }
} }
const char* cmCTestGenericHandler::GetOption(const std::string& op) const char* cmCTestGenericHandler::GetOption(const std::string& op)
{ {
cmCTestGenericHandler::t_StringToString::iterator remit cmCTestGenericHandler::t_StringToString::iterator remit =
= this->Options.find(op); this->Options.find(op);
if ( remit == this->Options.end() ) if (remit == this->Options.end()) {
{
return 0; return 0;
} }
return remit->second.c_str(); return remit->second.c_str();
@ -93,8 +86,7 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
const char* name, const char* name,
cmGeneratedFileStream& xofs) cmGeneratedFileStream& xofs)
{ {
if ( !name ) if (!name) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create resulting XML file without providing the name" "Cannot create resulting XML file without providing the name"
<< std::endl;); << std::endl;);
@ -102,27 +94,24 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
} }
std::ostringstream ostr; std::ostringstream ostr;
ostr << name; ostr << name;
if ( this->SubmitIndex > 0 ) if (this->SubmitIndex > 0) {
{
ostr << "_" << this->SubmitIndex; ostr << "_" << this->SubmitIndex;
} }
ostr << ".xml"; ostr << ".xml";
if(this->CTest->GetCurrentTag().empty()) if (this->CTest->GetCurrentTag().empty()) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Current Tag empty, this may mean NightlyStartTime / " "Current Tag empty, this may mean NightlyStartTime / "
"CTEST_NIGHTLY_START_TIME was not set correctly. Or " "CTEST_NIGHTLY_START_TIME was not set correctly. Or "
"maybe you forgot to call ctest_start() before calling " "maybe you forgot to call ctest_start() before calling "
"ctest_configure()." << std::endl); "ctest_configure()."
<< std::endl);
cmSystemTools::SetFatalErrorOccured(); cmSystemTools::SetFatalErrorOccured();
return false; return false;
} }
if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), if (!this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), ostr.str(),
ostr.str(), xofs, true) ) xofs, true)) {
{ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create resulting XML file: "
cmCTestLog(this->CTest, ERROR_MESSAGE, << ostr.str() << std::endl);
"Cannot create resulting XML file: " << ostr.str()
<< std::endl);
return false; return false;
} }
this->CTest->AddSubmitFile(part, ostr.str().c_str()); this->CTest->AddSubmitFile(part, ostr.str().c_str());
@ -132,27 +121,24 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
bool cmCTestGenericHandler::StartLogFile(const char* name, bool cmCTestGenericHandler::StartLogFile(const char* name,
cmGeneratedFileStream& xofs) cmGeneratedFileStream& xofs)
{ {
if ( !name ) if (!name) {
{
cmCTestLog(this->CTest, ERROR_MESSAGE, cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot create log file without providing the name" << std::endl;); "Cannot create log file without providing the name"
<< std::endl;);
return false; return false;
} }
std::ostringstream ostr; std::ostringstream ostr;
ostr << "Last" << name; ostr << "Last" << name;
if ( this->SubmitIndex > 0 ) if (this->SubmitIndex > 0) {
{
ostr << "_" << this->SubmitIndex; ostr << "_" << this->SubmitIndex;
} }
if ( !this->CTest->GetCurrentTag().empty() ) if (!this->CTest->GetCurrentTag().empty()) {
{
ostr << "_" << this->CTest->GetCurrentTag(); ostr << "_" << this->CTest->GetCurrentTag();
} }
ostr << ".log"; ostr << ".log";
if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) ) if (!this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs)) {
{ cmCTestLog(this->CTest, ERROR_MESSAGE,
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: " "Cannot create log file: " << ostr.str() << std::endl);
<< ostr.str() << std::endl);
return false; return false;
} }
return true; return true;

View File

@ -33,8 +33,10 @@ public:
* If verbose then more informaiton is printed out * If verbose then more informaiton is printed out
*/ */
void SetVerbose(bool val) void SetVerbose(bool val)
{ this->HandlerVerbose = val ? {
cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; } this->HandlerVerbose =
val ? cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE;
}
/** /**
* Populate internals from CTest custom scripts * Populate internals from CTest custom scripts
@ -52,7 +54,10 @@ public:
*/ */
virtual int ProcessCommandLineArguments( virtual int ProcessCommandLineArguments(
const std::string& /*currentArg*/, size_t& /*idx*/, const std::string& /*currentArg*/, size_t& /*idx*/,
const std::vector<std::string>& /*allArgs*/) { return 1; } const std::vector<std::string>& /*allArgs*/)
{
return 1;
}
/** /**
* Initialize handler * Initialize handler
@ -73,15 +78,11 @@ public:
typedef std::map<std::string, std::string> t_StringToString; typedef std::map<std::string, std::string> t_StringToString;
void SetPersistentOption(const std::string& op, const char* value); void SetPersistentOption(const std::string& op, const char* value);
void SetOption(const std::string& op, const char* value); void SetOption(const std::string& op, const char* value);
const char* GetOption(const std::string& op); const char* GetOption(const std::string& op);
void SetCommand(cmCTestCommand* command) void SetCommand(cmCTestCommand* command) { this->Command = command; }
{
this->Command = command;
}
void SetSubmitIndex(int idx) { this->SubmitIndex = idx; } void SetSubmitIndex(int idx) { this->SubmitIndex = idx; }
int GetSubmitIndex() { return this->SubmitIndex; } int GetSubmitIndex() { return this->SubmitIndex; }
@ -93,8 +94,8 @@ public:
unsigned long GetTestLoad() const { return this->TestLoad; } unsigned long GetTestLoad() const { return this->TestLoad; }
protected: protected:
bool StartResultingXML(cmCTest::Part part, bool StartResultingXML(cmCTest::Part part, const char* name,
const char* name, cmGeneratedFileStream& xofs); cmGeneratedFileStream& xofs);
bool StartLogFile(const char* name, cmGeneratedFileStream& xofs); bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
bool AppendXML; bool AppendXML;
@ -110,4 +111,3 @@ protected:
}; };
#endif #endif

View File

@ -17,8 +17,8 @@
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log): cmCTestGlobalVC::cmCTestGlobalVC(cmCTest* ct, std::ostream& log)
cmCTestVC(ct, log) : cmCTestVC(ct, log)
{ {
this->PriorRev = this->Unknown; this->PriorRev = this->Unknown;
} }
@ -36,8 +36,7 @@ void cmCTestGlobalVC::DoRevision(Revision const& revision,
std::vector<Change> const& changes) std::vector<Change> const& changes)
{ {
// Ignore changes in the old revision. // Ignore changes in the old revision.
if(revision.Rev == this->OldRevision) if (revision.Rev == this->OldRevision) {
{
this->PriorRev = revision; this->PriorRev = revision;
return; return;
} }
@ -58,16 +57,15 @@ void cmCTestGlobalVC::DoRevision(Revision const& revision,
// Update information about revisions of the changed files. // Update information about revisions of the changed files.
for (std::vector<Change>::const_iterator ci = changes.begin(); for (std::vector<Change>::const_iterator ci = changes.begin();
ci != changes.end(); ++ci) ci != changes.end(); ++ci) {
{ if (const char* local = this->LocalPath(ci->Path)) {
if(const char* local = this->LocalPath(ci->Path))
{
std::string dir = cmSystemTools::GetFilenamePath(local); std::string dir = cmSystemTools::GetFilenamePath(local);
std::string name = cmSystemTools::GetFilenameName(local); std::string name = cmSystemTools::GetFilenameName(local);
File& file = this->Dirs[dir][name]; File& file = this->Dirs[dir][name];
file.PriorRev = file.Rev ? file.Rev : &this->PriorRev; file.PriorRev = file.Rev ? file.Rev : &this->PriorRev;
file.Rev = &rev; file.Rev = &rev;
this->Log << " " << ci->Action << " " << local << " " << "\n"; this->Log << " " << ci->Action << " " << local << " "
<< "\n";
} }
} }
} }
@ -81,8 +79,7 @@ void cmCTestGlobalVC::DoModification(PathStatus status,
file.Status = status; file.Status = status;
// For local modifications the current rev is unknown and the // For local modifications the current rev is unknown and the
// prior rev is the latest from svn. // prior rev is the latest from svn.
if(!file.Rev && !file.PriorRev) if (!file.Rev && !file.PriorRev) {
{
file.PriorRev = &this->PriorRev; file.PriorRev = &this->PriorRev;
} }
} }
@ -94,8 +91,7 @@ void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
const char* slash = path.empty() ? "" : "/"; const char* slash = path.empty() ? "" : "/";
xml.StartElement("Directory"); xml.StartElement("Directory");
xml.Element("Name", path); xml.Element("Name", path);
for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) {
{
std::string full = path + slash + fi->first; std::string full = path + slash + fi->first;
this->WriteXMLEntry(xml, path, fi->first, full, fi->second); this->WriteXMLEntry(xml, path, fi->first, full, fi->second);
} }
@ -104,12 +100,10 @@ void cmCTestGlobalVC::WriteXMLDirectory(cmXMLWriter& xml,
void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml) void cmCTestGlobalVC::WriteXMLGlobal(cmXMLWriter& xml)
{ {
if(!this->NewRevision.empty()) if (!this->NewRevision.empty()) {
{
xml.Element("Revision", this->NewRevision); xml.Element("Revision", this->NewRevision);
} }
if(!this->OldRevision.empty() && this->OldRevision != this->NewRevision) if (!this->OldRevision.empty() && this->OldRevision != this->NewRevision) {
{
xml.Element("PriorRevision", this->OldRevision); xml.Element("PriorRevision", this->OldRevision);
} }
} }
@ -118,7 +112,8 @@ bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
{ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestLog(this->CTest, HANDLER_OUTPUT,
" Gathering version information (one . per revision):\n" " Gathering version information (one . per revision):\n"
" " << std::flush); " "
<< std::flush);
this->LoadRevisions(); this->LoadRevisions();
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl);
@ -126,9 +121,9 @@ bool cmCTestGlobalVC::WriteXMLUpdates(cmXMLWriter& xml)
this->WriteXMLGlobal(xml); this->WriteXMLGlobal(xml);
for(std::map<std::string, Directory>::const_iterator for (std::map<std::string, Directory>::const_iterator di =
di = this->Dirs.begin(); di != this->Dirs.end(); ++di) this->Dirs.begin();
{ di != this->Dirs.end(); ++di) {
this->WriteXMLDirectory(xml, di->first, di->second); this->WriteXMLDirectory(xml, di->first, di->second);
} }

View File

@ -37,11 +37,16 @@ protected:
{ {
char Action; char Action;
std::string Path; std::string Path;
Change(char a = '?'): Action(a) {} Change(char a = '?')
: Action(a)
{
}
}; };
// Update status for files in each directory. // Update status for files in each directory.
class Directory: public std::map<std::string, File> {}; class Directory : public std::map<std::string, File>
{
};
std::map<std::string, Directory> Dirs; std::map<std::string, Directory> Dirs;
// Old and new repository revisions. // Old and new repository revisions.

View File

@ -17,8 +17,8 @@
#include <cmsys/RegularExpression.hxx> #include <cmsys/RegularExpression.hxx>
cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log): cmCTestHG::cmCTestHG(cmCTest* ct, std::ostream& log)
cmCTestGlobalVC(ct, log) : cmCTestGlobalVC(ct, log)
{ {
this->PriorRev = this->Unknown; this->PriorRev = this->Unknown;
} }
@ -30,20 +30,20 @@ cmCTestHG::~cmCTestHG()
class cmCTestHG::IdentifyParser : public cmCTestVC::LineParser class cmCTestHG::IdentifyParser : public cmCTestVC::LineParser
{ {
public: public:
IdentifyParser(cmCTestHG* hg, const char* prefix, IdentifyParser(cmCTestHG* hg, const char* prefix, std::string& rev)
std::string& rev): Rev(rev) : Rev(rev)
{ {
this->SetLog(&hg->Log, prefix); this->SetLog(&hg->Log, prefix);
this->RegexIdentify.compile("^([0-9a-f]+)"); this->RegexIdentify.compile("^([0-9a-f]+)");
} }
private: private:
std::string& Rev; std::string& Rev;
cmsys::RegularExpression RegexIdentify; cmsys::RegularExpression RegexIdentify;
bool ProcessLine() bool ProcessLine()
{ {
if(this->RegexIdentify.find(this->Line)) if (this->RegexIdentify.find(this->Line)) {
{
this->Rev = this->RegexIdentify.match(1); this->Rev = this->RegexIdentify.match(1);
return false; return false;
} }
@ -54,7 +54,8 @@ private:
class cmCTestHG::StatusParser : public cmCTestVC::LineParser class cmCTestHG::StatusParser : public cmCTestVC::LineParser
{ {
public: public:
StatusParser(cmCTestHG* hg, const char* prefix): HG(hg) StatusParser(cmCTestHG* hg, const char* prefix)
: HG(hg)
{ {
this->SetLog(&hg->Log, prefix); this->SetLog(&hg->Log, prefix);
this->RegexStatus.compile("([MARC!?I]) (.*)"); this->RegexStatus.compile("([MARC!?I]) (.*)");
@ -66,25 +67,30 @@ private:
bool ProcessLine() bool ProcessLine()
{ {
if(this->RegexStatus.find(this->Line)) if (this->RegexStatus.find(this->Line)) {
{ this->DoPath(this->RegexStatus.match(1)[0], this->RegexStatus.match(2));
this->DoPath(this->RegexStatus.match(1)[0],
this->RegexStatus.match(2));
} }
return true; return true;
} }
void DoPath(char status, std::string const& path) void DoPath(char status, std::string const& path)
{ {
if(path.empty()) return; if (path.empty())
return;
// See "hg help status". Note that there is no 'conflict' status. // See "hg help status". Note that there is no 'conflict' status.
switch(status) switch (status) {
{ case 'M':
case 'M': case 'A': case '!': case 'R': case 'A':
case '!':
case 'R':
this->HG->DoModification(PathModified, path); this->HG->DoModification(PathModified, path);
break; break;
case 'I': case '?': case 'C': case ' ': default: case 'I':
case '?':
case 'C':
case ' ':
default:
break; break;
} }
} }
@ -137,14 +143,12 @@ bool cmCTestHG::UpdateImpl()
// Add user-specified update options. // Add user-specified update options.
std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions"); std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions");
if(opts.empty()) if (opts.empty()) {
{
opts = this->CTest->GetCTestConfiguration("HGUpdateOptions"); opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
} }
std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
for (std::vector<std::string>::const_iterator ai = args.begin(); for (std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai) ai != args.end(); ++ai) {
{
hg_update.push_back(ai->c_str()); hg_update.push_back(ai->c_str());
} }
@ -160,8 +164,12 @@ class cmCTestHG::LogParser: public cmCTestVC::OutputLogger,
private cmXMLParser private cmXMLParser
{ {
public: public:
LogParser(cmCTestHG* hg, const char* prefix): LogParser(cmCTestHG* hg, const char* prefix)
OutputLogger(hg->Log, prefix), HG(hg) { this->InitializeParser(); } : OutputLogger(hg->Log, prefix)
, HG(hg)
{
this->InitializeParser();
}
~LogParser() { this->CleanupParser(); } ~LogParser() { this->CleanupParser(); }
private: private:
cmCTestHG* HG; cmCTestHG* HG;
@ -183,11 +191,9 @@ private:
virtual void StartElement(const std::string& name, const char** atts) virtual void StartElement(const std::string& name, const char** atts)
{ {
this->CData.clear(); this->CData.clear();
if(name == "logentry") if (name == "logentry") {
{
this->Rev = Revision(); this->Rev = Revision();
if(const char* rev = this->FindAttribute(atts, "revision")) if (const char* rev = this->FindAttribute(atts, "revision")) {
{
this->Rev.Rev = rev; this->Rev.Rev = rev;
} }
this->Changes.clear(); this->Changes.clear();
@ -201,56 +207,36 @@ private:
virtual void EndElement(const std::string& name) virtual void EndElement(const std::string& name)
{ {
if(name == "logentry") if (name == "logentry") {
{
this->HG->DoRevision(this->Rev, this->Changes); this->HG->DoRevision(this->Rev, this->Changes);
} } else if (!this->CData.empty() && name == "author") {
else if(!this->CData.empty() && name == "author")
{
this->Rev.Author.assign(&this->CData[0], this->CData.size()); this->Rev.Author.assign(&this->CData[0], this->CData.size());
} } else if (!this->CData.empty() && name == "email") {
else if(!this->CData.empty() && name == "email")
{
this->Rev.EMail.assign(&this->CData[0], this->CData.size()); this->Rev.EMail.assign(&this->CData[0], this->CData.size());
} } else if (!this->CData.empty() && name == "date") {
else if(!this->CData.empty() && name == "date")
{
this->Rev.Date.assign(&this->CData[0], this->CData.size()); this->Rev.Date.assign(&this->CData[0], this->CData.size());
} } else if (!this->CData.empty() && name == "msg") {
else if(!this->CData.empty() && name == "msg")
{
this->Rev.Log.assign(&this->CData[0], this->CData.size()); this->Rev.Log.assign(&this->CData[0], this->CData.size());
} } else if (!this->CData.empty() && name == "files") {
else if(!this->CData.empty() && name == "files")
{
std::vector<std::string> paths = this->SplitCData(); std::vector<std::string> paths = this->SplitCData();
for(unsigned int i = 0; i < paths.size(); ++i) for (unsigned int i = 0; i < paths.size(); ++i) {
{
// Updated by default, will be modified using file_adds and // Updated by default, will be modified using file_adds and
// file_dels. // file_dels.
this->CurChange = Change('U'); this->CurChange = Change('U');
this->CurChange.Path = paths[i]; this->CurChange.Path = paths[i];
this->Changes.push_back(this->CurChange); this->Changes.push_back(this->CurChange);
} }
} } else if (!this->CData.empty() && name == "file_adds") {
else if(!this->CData.empty() && name == "file_adds")
{
std::string added_paths(this->CData.begin(), this->CData.end()); std::string added_paths(this->CData.begin(), this->CData.end());
for(unsigned int i = 0; i < this->Changes.size(); ++i) for (unsigned int i = 0; i < this->Changes.size(); ++i) {
{ if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
if(added_paths.find(this->Changes[i].Path) != std::string::npos)
{
this->Changes[i].Action = 'A'; this->Changes[i].Action = 'A';
} }
} }
} } else if (!this->CData.empty() && name == "file_dels") {
else if(!this->CData.empty() && name == "file_dels")
{
std::string added_paths(this->CData.begin(), this->CData.end()); std::string added_paths(this->CData.begin(), this->CData.end());
for(unsigned int i = 0; i < this->Changes.size(); ++i) for (unsigned int i = 0; i < this->Changes.size(); ++i) {
{ if (added_paths.find(this->Changes[i].Path) != std::string::npos) {
if(added_paths.find(this->Changes[i].Path) != std::string::npos)
{
this->Changes[i].Action = 'D'; this->Changes[i].Action = 'D';
} }
} }
@ -262,14 +248,10 @@ private:
{ {
std::vector<std::string> output; std::vector<std::string> output;
std::string currPath; std::string currPath;
for(unsigned int i=0; i < this->CData.size(); ++i) for (unsigned int i = 0; i < this->CData.size(); ++i) {
{ if (this->CData[i] != ' ') {
if(this->CData[i] != ' ')
{
currPath += this->CData[i]; currPath += this->CData[i];
} } else {
else
{
output.push_back(currPath); output.push_back(currPath);
currPath = ""; currPath = "";
} }
@ -294,8 +276,7 @@ void cmCTestHG::LoadRevisions()
// proper XML escapes. // proper XML escapes.
std::string range = this->OldRevision + ":" + this->NewRevision; std::string range = this->OldRevision + ":" + this->NewRevision;
const char* hg = this->CommandLineTool.c_str(); const char* hg = this->CommandLineTool.c_str();
const char* hgXMLTemplate = const char* hgXMLTemplate = "<logentry\n"
"<logentry\n"
" revision=\"{node|short}\">\n" " revision=\"{node|short}\">\n"
" <author>{author|person}</author>\n" " <author>{author|person}</author>\n"
" <email>{author|email}</email>\n" " <email>{author|email}</email>\n"
@ -305,8 +286,9 @@ void cmCTestHG::LoadRevisions()
" <file_adds>{file_adds}</file_adds>\n" " <file_adds>{file_adds}</file_adds>\n"
" <file_dels>{file_dels}</file_dels>\n" " <file_dels>{file_dels}</file_dels>\n"
"</logentry>\n"; "</logentry>\n";
const char* hg_log[] = {hg, "log","--removed", "-r", range.c_str(), const char* hg_log[] = {
"--template", hgXMLTemplate, 0}; hg, "log", "--removed", "-r", range.c_str(), "--template", hgXMLTemplate, 0
};
LogParser out(this, "log-out> "); LogParser out(this, "log-out> ");
out.Process("<?xml version=\"1.0\"?>\n" out.Process("<?xml version=\"1.0\"?>\n"

View File

@ -19,8 +19,7 @@ cmCTestHandlerCommand::cmCTestHandlerCommand()
const size_t INIT_SIZE = 100; const size_t INIT_SIZE = 100;
size_t cc; size_t cc;
this->Arguments.reserve(INIT_SIZE); this->Arguments.reserve(INIT_SIZE);
for ( cc = 0; cc < INIT_SIZE; ++ cc ) for (cc = 0; cc < INIT_SIZE; ++cc) {
{
this->Arguments.push_back(0); this->Arguments.push_back(0);
} }
this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE"; this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE";
@ -32,8 +31,8 @@ cmCTestHandlerCommand::cmCTestHandlerCommand()
this->Quiet = false; this->Quiet = false;
} }
bool cmCTestHandlerCommand bool cmCTestHandlerCommand::InitialPass(std::vector<std::string> const& args,
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) cmExecutionStatus&)
{ {
// Allocate space for argument values. // Allocate space for argument values.
this->Values.clear(); this->Values.clear();
@ -41,12 +40,10 @@ bool cmCTestHandlerCommand
// Process input arguments. // Process input arguments.
this->ArgumentDoing = ArgumentDoingNone; this->ArgumentDoing = ArgumentDoingNone;
for(unsigned int i=0; i < args.size(); ++i) for (unsigned int i = 0; i < args.size(); ++i) {
{
// Check this argument. // Check this argument.
if (!this->CheckArgumentKeyword(args[i]) && if (!this->CheckArgumentKeyword(args[i]) &&
!this->CheckArgumentValue(args[i])) !this->CheckArgumentValue(args[i])) {
{
std::ostringstream e; std::ostringstream e;
e << "called with unknown argument \"" << args[i] << "\"."; e << "called with unknown argument \"" << args[i] << "\".";
this->SetError(e.str()); this->SetError(e.str());
@ -54,8 +51,7 @@ bool cmCTestHandlerCommand
} }
// Quit if an argument is invalid. // Quit if an argument is invalid.
if(this->ArgumentDoing == ArgumentDoingError) if (this->ArgumentDoing == ArgumentDoingError) {
{
return false; return false;
} }
} }
@ -66,80 +62,70 @@ bool cmCTestHandlerCommand
// line. // line.
const char* ctestConfigType = const char* ctestConfigType =
this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE"); this->Makefile->GetDefinition("CTEST_CONFIGURATION_TYPE");
if (ctestConfigType) if (ctestConfigType) {
{
this->CTest->SetConfigType(ctestConfigType); this->CTest->SetConfigType(ctestConfigType);
} }
if ( this->Values[ct_BUILD] ) if (this->Values[ct_BUILD]) {
{ this->CTest->SetCTestConfiguration(
this->CTest->SetCTestConfiguration("BuildDirectory", "BuildDirectory",
cmSystemTools::CollapseFullPath( cmSystemTools::CollapseFullPath(this->Values[ct_BUILD]).c_str(),
this->Values[ct_BUILD]).c_str(), this->Quiet); this->Quiet);
} } else {
else
{
const char* bdir = const char* bdir =
this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY"); this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
if(bdir) if (bdir) {
{ this->CTest->SetCTestConfiguration(
this-> "BuildDirectory", cmSystemTools::CollapseFullPath(bdir).c_str(),
CTest->SetCTestConfiguration("BuildDirectory", this->Quiet);
cmSystemTools::CollapseFullPath(bdir).c_str(), this->Quiet); } else {
} cmCTestLog(this->CTest, ERROR_MESSAGE, "CTEST_BINARY_DIRECTORY not set"
else << std::endl;);
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"CTEST_BINARY_DIRECTORY not set" << std::endl;);
} }
} }
if ( this->Values[ct_SOURCE] ) if (this->Values[ct_SOURCE]) {
{ cmCTestLog(this->CTest, DEBUG, "Set source directory to: "
cmCTestLog(this->CTest, DEBUG, << this->Values[ct_SOURCE] << std::endl);
"Set source directory to: " << this->Values[ct_SOURCE] << std::endl); this->CTest->SetCTestConfiguration(
this->CTest->SetCTestConfiguration("SourceDirectory", "SourceDirectory",
cmSystemTools::CollapseFullPath(this->Values[ct_SOURCE]).c_str(),
this->Quiet);
} else {
this->CTest->SetCTestConfiguration(
"SourceDirectory",
cmSystemTools::CollapseFullPath( cmSystemTools::CollapseFullPath(
this->Values[ct_SOURCE]).c_str(), this->Quiet); this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY"))
} .c_str(),
else
{
this->CTest->SetCTestConfiguration("SourceDirectory",
cmSystemTools::CollapseFullPath(
this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")).c_str(),
this->Quiet); this->Quiet);
} }
if (const char* changeId = if (const char* changeId =
this->Makefile->GetDefinition("CTEST_CHANGE_ID")) this->Makefile->GetDefinition("CTEST_CHANGE_ID")) {
{
this->CTest->SetCTestConfiguration("ChangeId", changeId, this->Quiet); this->CTest->SetCTestConfiguration("ChangeId", changeId, this->Quiet);
} }
cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;); cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;);
cmCTestGenericHandler* handler = this->InitializeHandler(); cmCTestGenericHandler* handler = this->InitializeHandler();
if ( !handler ) if (!handler) {
{ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot instantiate test handler "
cmCTestLog(this->CTest, ERROR_MESSAGE, << this->GetName() << std::endl);
"Cannot instantiate test handler " << this->GetName()
<< std::endl);
return false; return false;
} }
handler->SetAppendXML(this->AppendXML); handler->SetAppendXML(this->AppendXML);
handler->PopulateCustomVectors(this->Makefile); handler->PopulateCustomVectors(this->Makefile);
if ( this->Values[ct_SUBMIT_INDEX] ) if (this->Values[ct_SUBMIT_INDEX]) {
{ if (!this->CTest->GetDropSiteCDash() &&
if(!this->CTest->GetDropSiteCDash() && this->CTest->GetDartVersion() <= 1) this->CTest->GetDartVersion() <= 1) {
{ cmCTestLog(
cmCTestLog(this->CTest, ERROR_MESSAGE, this->CTest, ERROR_MESSAGE,
"Dart before version 2.0 does not support collecting submissions." "Dart before version 2.0 does not support collecting submissions."
<< std::endl << std::endl
<< "Please upgrade the server to Dart 2 or higher, or do not use " << "Please upgrade the server to Dart 2 or higher, or do not use "
"SUBMIT_INDEX." << std::endl); "SUBMIT_INDEX."
} << std::endl);
else } else {
{
handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX])); handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
} }
} }
@ -147,12 +133,11 @@ bool cmCTestHandlerCommand
cmSystemTools::ChangeDirectory( cmSystemTools::ChangeDirectory(
this->CTest->GetCTestConfiguration("BuildDirectory")); this->CTest->GetCTestConfiguration("BuildDirectory"));
int res = handler->ProcessHandler(); int res = handler->ProcessHandler();
if ( this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) if (this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE]) {
{
std::ostringstream str; std::ostringstream str;
str << res; str << res;
this->Makefile->AddDefinition( this->Makefile->AddDefinition(this->Values[ct_RETURN_VALUE],
this->Values[ct_RETURN_VALUE], str.str().c_str()); str.str().c_str());
} }
cmSystemTools::ChangeDirectory(current_dir); cmSystemTools::ChangeDirectory(current_dir);
return true; return true;
@ -161,24 +146,20 @@ bool cmCTestHandlerCommand
bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg) bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg)
{ {
// Look for non-value arguments common to all commands. // Look for non-value arguments common to all commands.
if(arg == "APPEND") if (arg == "APPEND") {
{
this->ArgumentDoing = ArgumentDoingNone; this->ArgumentDoing = ArgumentDoingNone;
this->AppendXML = true; this->AppendXML = true;
return true; return true;
} }
if(arg == "QUIET") if (arg == "QUIET") {
{
this->ArgumentDoing = ArgumentDoingNone; this->ArgumentDoing = ArgumentDoingNone;
this->Quiet = true; this->Quiet = true;
return true; return true;
} }
// Check for a keyword in our argument/value table. // Check for a keyword in our argument/value table.
for(unsigned int k=0; k < this->Arguments.size(); ++k) for (unsigned int k = 0; k < this->Arguments.size(); ++k) {
{ if (this->Arguments[k] && arg == this->Arguments[k]) {
if(this->Arguments[k] && arg == this->Arguments[k])
{
this->ArgumentDoing = ArgumentDoingKeyword; this->ArgumentDoing = ArgumentDoingKeyword;
this->ArgumentIndex = k; this->ArgumentIndex = k;
return true; return true;
@ -189,12 +170,10 @@ bool cmCTestHandlerCommand::CheckArgumentKeyword(std::string const& arg)
bool cmCTestHandlerCommand::CheckArgumentValue(std::string const& arg) bool cmCTestHandlerCommand::CheckArgumentValue(std::string const& arg)
{ {
if(this->ArgumentDoing == ArgumentDoingKeyword) if (this->ArgumentDoing == ArgumentDoingKeyword) {
{
this->ArgumentDoing = ArgumentDoingNone; this->ArgumentDoing = ArgumentDoingNone;
unsigned int k = this->ArgumentIndex; unsigned int k = this->ArgumentIndex;
if(this->Values[k]) if (this->Values[k]) {
{
std::ostringstream e; std::ostringstream e;
e << "Called with more than one value for " << this->Arguments[k]; e << "Called with more than one value for " << this->Arguments[k];
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@ -202,8 +181,8 @@ bool cmCTestHandlerCommand::CheckArgumentValue(std::string const& arg)
return true; return true;
} }
this->Values[k] = arg.c_str(); this->Values[k] = arg.c_str();
cmCTestLog(this->CTest, DEBUG, "Set " << this->Arguments[k] cmCTestLog(this->CTest, DEBUG, "Set " << this->Arguments[k] << " to "
<< " to " << arg << "\n"); << arg << "\n");
return true; return true;
} }
return false; return false;

Some files were not shown because too many files have changed in this diff Show More