summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackNSISGenerator.cxx
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2006-02-16 20:20:23 (GMT)
committerAndy Cedilnik <andy.cedilnik@kitware.com>2006-02-16 20:20:23 (GMT)
commitb07ece004c197b5430d0e84d9460e400e0acab7e (patch)
treecc3e7e7d0e6f84d0d4682c92bf506c515c295b9c /Source/CPack/cmCPackNSISGenerator.cxx
parent537e2b4ed57d5a84f140f9b9bde427e7b604b330 (diff)
downloadCMake-b07ece004c197b5430d0e84d9460e400e0acab7e.zip
CMake-b07ece004c197b5430d0e84d9460e400e0acab7e.tar.gz
CMake-b07ece004c197b5430d0e84d9460e400e0acab7e.tar.bz2
ENH: More work on NSI to improve installing and uninstalling
Diffstat (limited to 'Source/CPack/cmCPackNSISGenerator.cxx')
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx59
1 files changed, 58 insertions, 1 deletions
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 415129d..9f1e9e2 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -26,6 +26,7 @@
#include <cmsys/SystemTools.hxx>
#include <cmsys/Glob.hxx>
+#include <cmsys/Directory.hxx>
//----------------------------------------------------------------------
cmCPackNSISGenerator::cmCPackNSISGenerator()
@@ -43,7 +44,6 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* top
{
(void)outFileName; // TODO: Fix nsis to force out file name
(void)toplevel;
- (void)files;
std::string nsisInFileName = this->FindTemplate("NSIS.template.in");
if ( nsisInFileName.size() == 0 )
{
@@ -54,6 +54,35 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, const char* top
std::string tmpFile = nsisFileName;
tmpFile += "/NSISOutput.log";
nsisFileName += "/project.nsi";
+ cmOStringStream str;
+ std::vector<std::string>::const_iterator it;
+ for ( it = files.begin(); it != files.end(); ++ it )
+ {
+ std::string fileN = cmSystemTools::RelativePath(toplevel,
+ it->c_str());
+ cmSystemTools::ReplaceString(fileN, "/", "\\");
+ str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: " << str.str().c_str() << std::endl);
+ this->SetOption("CPACK_NSIS_DELETE_FILES", str.str().c_str());
+ std::vector<std::string> dirs;
+ this->GetListOfSubdirectories(toplevel, dirs);
+ std::vector<std::string>::const_iterator sit;
+ cmOStringStream dstr;
+ for ( sit = dirs.begin(); sit != dirs.end(); ++ sit )
+ {
+ std::string fileN = cmSystemTools::RelativePath(toplevel,
+ sit->c_str());
+ if ( fileN.empty() )
+ {
+ continue;
+ }
+ cmSystemTools::ReplaceString(fileN, "/", "\\");
+ dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
+ }
+ cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str().c_str() << std::endl);
+ this->SetOption("CPACK_NSIS_DELETE_DIRECTORIES", dstr.str().c_str());
+
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName << " to " << nsisFileName << std::endl);
this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str());
std::string nsisCmd = "\"";
@@ -132,3 +161,31 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
return res;
}
+//----------------------------------------------------------------------
+bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, std::vector<std::string>& dirs)
+{
+ cmsys::Directory dir;
+ dir.Load(topdir);
+ size_t fileNum;
+ for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
+ {
+ if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
+ strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".."))
+ {
+ kwsys_stl::string fullPath = topdir;
+ fullPath += "/";
+ fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
+ if(cmsys::SystemTools::FileIsDirectory(fullPath.c_str()) &&
+ !cmsys::SystemTools::FileIsSymlink(fullPath.c_str()))
+ {
+ if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs))
+ {
+ return false;
+ }
+ }
+ }
+ }
+ dirs.push_back(topdir);
+ return true;
+}
+