Просмотр исходного кода

cmake -E tar: add support for .xz files with 'J'

Ben Boeckel 11 лет назад
Родитель
Сommit
df16dcfb44
5 измененных файлов с 19 добавлено и 6 удалено
  1. 5 0
      Help/release/dev/add-xz-support.rst
  2. 2 1
      Source/cmCTest.cxx
  3. 4 2
      Source/cmSystemTools.cxx
  4. 1 1
      Source/cmSystemTools.h
  5. 7 2
      Source/cmcmd.cxx

+ 5 - 0
Help/release/dev/add-xz-support.rst

@@ -0,0 +1,5 @@
+add-xz-support
+--------------
+
+* The :manual:`cmake(1)` ``-E tar`` command now supports creating
+  ``.xz``-compressed archives with the ``J`` flag.

+ 2 - 1
Source/cmCTest.cxx

@@ -1674,7 +1674,8 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file)
   std::vector<std::string> files;
   files.push_back(file);
 
-  if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false))
+  if(!cmSystemTools::CreateTar(tarFile.c_str(), files,
+                               true, false, false, false))
     {
     cmCTestLog(this, ERROR_MESSAGE, "Error creating tar while "
       "encoding file: " << file << std::endl);

+ 4 - 2
Source/cmSystemTools.cxx

@@ -1482,7 +1482,8 @@ bool cmSystemTools::IsPathToFramework(const char* path)
 
 bool cmSystemTools::CreateTar(const char* outFileName,
                               const std::vector<std::string>& files,
-                              bool gzip, bool bzip2, bool verbose)
+                              bool gzip, bool bzip2, bool xz,
+                              bool verbose)
 {
 #if defined(CMAKE_BUILD_WITH_CMAKE)
   std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
@@ -1498,7 +1499,8 @@ bool cmSystemTools::CreateTar(const char* outFileName,
     }
   cmArchiveWrite a(fout, (gzip? cmArchiveWrite::CompressGZip :
                           (bzip2? cmArchiveWrite::CompressBZip2 :
-                           cmArchiveWrite::CompressNone)),
+                           (xz? cmArchiveWrite::CompressXZ :
+                           cmArchiveWrite::CompressNone))),
                            cmArchiveWrite::TypeTAR);
   a.SetVerbose(verbose);
   for(std::vector<std::string>::const_iterator i = files.begin();

+ 1 - 1
Source/cmSystemTools.h

@@ -387,7 +387,7 @@ public:
                       bool gzip, bool verbose);
   static bool CreateTar(const char* outFileName,
                         const std::vector<std::string>& files, bool gzip,
-                        bool bzip2, bool verbose);
+                        bool bzip2, bool xz, bool verbose);
   static bool ExtractTar(const char* inFileName, bool gzip,
                          bool verbose);
   // This should be called first thing in main

+ 7 - 2
Source/cmcmd.cxx

@@ -71,7 +71,7 @@ void CMakeCommandUsage(const char* program)
     << "  remove_directory dir      - remove a directory and its contents\n"
     << "  rename oldname newname    - rename a file or directory "
        "(on one volume)\n"
-    << "  tar [cxt][vf][zj] file.tar [file/dir1 file/dir2 ...]\n"
+    << "  tar [cxt][vf][zjJ] file.tar [file/dir1 file/dir2 ...]\n"
     << "                            - create or extract a tar or zip archive\n"
     << "  sleep <number>...         - sleep for given number of seconds\n"
     << "  time command [args] ...   - run command and return elapsed time\n"
@@ -735,11 +735,16 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
         }
       bool gzip = false;
       bool bzip2 = false;
+      bool xz = false;
       bool verbose = false;
       if ( flags.find_first_of('j') != flags.npos )
         {
         bzip2 = true;
         }
+      if ( flags.find_first_of('J') != flags.npos )
+        {
+        xz = true;
+        }
       if ( flags.find_first_of('z') != flags.npos )
         {
         gzip = true;
@@ -760,7 +765,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       else if ( flags.find_first_of('c') != flags.npos )
         {
         if ( !cmSystemTools::CreateTar(
-               outFile.c_str(), files, gzip, bzip2, verbose) )
+               outFile.c_str(), files, gzip, bzip2, xz, verbose) )
           {
           cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
           return 1;