summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-07-01 11:00:34 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-07-01 11:00:42 (GMT)
commit0ca6bb85755c5db38c5b6a9d6b6e19f85e51a3c5 (patch)
tree56e33f8055cef66ffde63925bd0ea0f4c1f8cdff /Source
parent208b8a81ce3b61188214819090278e1b3437d609 (diff)
parentbbcff21f716f25649d744553b9085c8e6c0c1a35 (diff)
downloadCMake-0ca6bb85755c5db38c5b6a9d6b6e19f85e51a3c5.zip
CMake-0ca6bb85755c5db38c5b6a9d6b6e19f85e51a3c5.tar.gz
CMake-0ca6bb85755c5db38c5b6a9d6b6e19f85e51a3c5.tar.bz2
Merge topic 'file-ARCHIVE-files-dirs' into release-3.18
bbcff21f71 file(ARCHIVE*): Collapse FILES and DIRECTORY options Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4955
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileCommand.cxx57
1 files changed, 22 insertions, 35 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index cb0f05f..7101e22 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -8,7 +8,6 @@
#include <cmath>
#include <cstdio>
#include <cstdlib>
-#include <iterator>
#include <map>
#include <set>
#include <sstream>
@@ -2945,8 +2944,7 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
std::string Compression;
std::string MTime;
bool Verbose = false;
- std::vector<std::string> Files;
- std::vector<std::string> Directories;
+ std::vector<std::string> Paths;
};
static auto const parser = cmArgumentParser<Arguments>{}
@@ -2955,8 +2953,7 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
.Bind("COMPRESSION"_s, &Arguments::Compression)
.Bind("MTIME"_s, &Arguments::MTime)
.Bind("VERBOSE"_s, &Arguments::Verbose)
- .Bind("FILES"_s, &Arguments::Files)
- .Bind("DIRECTORY"_s, &Arguments::Directories);
+ .Bind("PATHS"_s, &Arguments::Paths);
std::vector<std::string> unrecognizedArguments;
std::vector<std::string> keywordsMissingValues;
@@ -2970,9 +2967,9 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
return false;
}
- const std::vector<std::string> LIST_ARGS = {
- "OUTPUT", "FORMAT", "COMPRESSION", "MTIME", "FILES", "DIRECTORY",
- };
+ const std::vector<std::string> LIST_ARGS = { "OUTPUT", "FORMAT",
+ "COMPRESSION", "MTIME",
+ "PATHS" };
auto kwbegin = keywordsMissingValues.cbegin();
auto kwend = cmRemoveMatching(keywordsMissingValues, LIST_ARGS);
if (kwend != kwbegin) {
@@ -3010,11 +3007,6 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
{ "XZ", cmSystemTools::TarCompressXZ },
{ "Zstd", cmSystemTools::TarCompressZstd } };
- std::string const& outFile = parsedArgs.Output;
- std::vector<std::string> files = parsedArgs.Files;
- std::copy(parsedArgs.Directories.begin(), parsedArgs.Directories.end(),
- std::back_inserter(files));
-
cmSystemTools::cmTarCompression compress = cmSystemTools::TarCompressNone;
auto typeIt = compressionTypeMap.find(parsedArgs.Compression);
if (typeIt != compressionTypeMap.end()) {
@@ -3026,14 +3018,16 @@ bool HandleArchiveCreateCommand(std::vector<std::string> const& args,
return false;
}
- if (files.empty()) {
- status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING,
- "No files or directories specified");
+ if (parsedArgs.Paths.empty()) {
+ status.SetError("ARCHIVE_CREATE requires a non-empty list of PATHS");
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
}
- if (!cmSystemTools::CreateTar(outFile, files, compress, parsedArgs.Verbose,
- parsedArgs.MTime, parsedArgs.Format)) {
- status.SetError(cmStrCat("failed to compress: ", outFile));
+ if (!cmSystemTools::CreateTar(parsedArgs.Output, parsedArgs.Paths, compress,
+ parsedArgs.Verbose, parsedArgs.MTime,
+ parsedArgs.Format)) {
+ status.SetError(cmStrCat("failed to compress: ", parsedArgs.Output));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -3050,8 +3044,7 @@ bool HandleArchiveExtractCommand(std::vector<std::string> const& args,
bool Verbose = false;
bool ListOnly = false;
std::string Destination;
- std::vector<std::string> Files;
- std::vector<std::string> Directories;
+ std::vector<std::string> Patterns;
};
static auto const parser = cmArgumentParser<Arguments>{}
@@ -3059,8 +3052,7 @@ bool HandleArchiveExtractCommand(std::vector<std::string> const& args,
.Bind("VERBOSE"_s, &Arguments::Verbose)
.Bind("LIST_ONLY"_s, &Arguments::ListOnly)
.Bind("DESTINATION"_s, &Arguments::Destination)
- .Bind("FILES"_s, &Arguments::Files)
- .Bind("DIRECTORY"_s, &Arguments::Directories);
+ .Bind("PATTERNS"_s, &Arguments::Patterns);
std::vector<std::string> unrecognizedArguments;
std::vector<std::string> keywordsMissingValues;
@@ -3074,12 +3066,8 @@ bool HandleArchiveExtractCommand(std::vector<std::string> const& args,
return false;
}
- const std::vector<std::string> LIST_ARGS = {
- "INPUT",
- "DESTINATION",
- "FILES",
- "DIRECTORY",
- };
+ const std::vector<std::string> LIST_ARGS = { "INPUT", "DESTINATION",
+ "PATTERNS" };
auto kwbegin = keywordsMissingValues.cbegin();
auto kwend = cmRemoveMatching(keywordsMissingValues, LIST_ARGS);
if (kwend != kwbegin) {
@@ -3090,18 +3078,16 @@ bool HandleArchiveExtractCommand(std::vector<std::string> const& args,
}
std::string inFile = parsedArgs.Input;
- std::vector<std::string> files = parsedArgs.Files;
- std::copy(parsedArgs.Directories.begin(), parsedArgs.Directories.end(),
- std::back_inserter(files));
if (parsedArgs.ListOnly) {
- if (!cmSystemTools::ListTar(inFile, files, parsedArgs.Verbose)) {
+ if (!cmSystemTools::ListTar(inFile, parsedArgs.Patterns,
+ parsedArgs.Verbose)) {
status.SetError(cmStrCat("failed to list: ", inFile));
cmSystemTools::SetFatalErrorOccured();
return false;
}
} else {
- std::string destDir = cmSystemTools::GetCurrentWorkingDirectory();
+ std::string destDir = status.GetMakefile().GetCurrentBinaryDirectory();
if (!parsedArgs.Destination.empty()) {
if (cmSystemTools::FileIsFullPath(parsedArgs.Destination)) {
destDir = parsedArgs.Destination;
@@ -3129,7 +3115,8 @@ bool HandleArchiveExtractCommand(std::vector<std::string> const& args,
return false;
}
- if (!cmSystemTools::ExtractTar(inFile, files, parsedArgs.Verbose)) {
+ if (!cmSystemTools::ExtractTar(inFile, parsedArgs.Patterns,
+ parsedArgs.Verbose)) {
status.SetError(cmStrCat("failed to extract: ", inFile));
cmSystemTools::SetFatalErrorOccured();
return false;