[Cmake-commits] [cmake-commits] king committed cmFileCommand.cxx 1.129 1.130 cmFileCommand.h 1.46 1.47
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Apr 29 13:13:31 EDT 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv23741/Source
Modified Files:
cmFileCommand.cxx cmFileCommand.h
Log Message:
ENH: Create file(COPY) command signature
The file(INSTALL) command has long been undocumented and used only to
implement install() scripts. We now document it and provide a similar
file(COPY) signature which is useful in general-purpose scripts. It
provides the capabilities of install(DIRECTORY) and install(FILES) but
operates immediately instead of contributing to install scripts.
Index: cmFileCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFileCommand.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -C 2 -d -r1.46 -r1.47
*** cmFileCommand.h 29 Apr 2009 17:12:58 -0000 1.46
--- cmFileCommand.h 29 Apr 2009 17:13:25 -0000 1.47
***************
*** 158,162 ****
"numeric error means no error in the operation. "
"If TIMEOUT time is specified, the operation will "
! "timeout after time seconds, time can be specified as a float.\n";
}
--- 158,197 ----
"numeric error means no error in the operation. "
"If TIMEOUT time is specified, the operation will "
! "timeout after time seconds, time can be specified as a float."
! "\n"
! "The file() command also provides COPY and INSTALL signatures:\n"
! " file(<COPY|INSTALL> files... DESTINATION <dir>\n"
! " [FILE_PERMISSIONS permissions...]\n"
! " [DIRECTORY_PERMISSIONS permissions...]\n"
! " [NO_SOURCE_PERMISSIONS] [USE_SOURCE_PERMISSIONS]\n"
! " [FILES_MATCHING]\n"
! " [[PATTERN <pattern> | REGEX <regex>]\n"
! " [EXCLUDE] [PERMISSIONS permissions...]] [...])\n"
! "The COPY signature copies files, directories, and symlinks to a "
! "destination folder. "
! "Relative input paths are evaluated with respect to the current "
! "source directory, and a relative destination is evaluated with "
! "respect to the current build directory. "
! "Copying preserves input file timestamps, and optimizes out a file "
! "if it exists at the destination with the same timestamp. "
! "Copying preserves input permissions unless explicit permissions or "
! "NO_SOURCE_PERMISSIONS are given (default is USE_SOURCE_PERMISSIONS). "
! "See the install(DIRECTORY) command for documentation of permissions, "
! "PATTERN, REGEX, and EXCLUDE options. "
! "\n"
! "The INSTALL signature differs slightly from COPY: "
! "it prints status messages, and NO_SOURCE_PERMISSIONS is default. "
! "Installation scripts generated by the install() command use this "
! "signature (with some undocumented options for internal use)."
! // Undocumented INSTALL options:
! // - RENAME <name>
! // - OPTIONAL
! // - FILES keyword to re-enter files... list
! // - PERMISSIONS before REGEX is alias for FILE_PERMISSIONS
! // - DIR_PERMISSIONS is alias for DIRECTORY_PERMISSIONS
! // - TYPE <FILE|DIRECTORY|EXECUTABLE|PROGRAM|
! // STATIC_LIBRARY|SHARED_LIBRARY|MODULE>
! // - COMPONENTS, CONFIGURATIONS, PROPERTIES (ignored for compat)
! ;
}
***************
*** 180,183 ****
--- 215,219 ----
bool HandleDifferentCommand(std::vector<std::string> const& args);
+ bool HandleCopyCommand(std::vector<std::string> const& args);
bool HandleInstallCommand(std::vector<std::string> const& args);
bool HandleDownloadCommand(std::vector<std::string> const& args);
Index: cmFileCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmFileCommand.cxx,v
retrieving revision 1.129
retrieving revision 1.130
diff -C 2 -d -r1.129 -r1.130
*** cmFileCommand.cxx 29 Apr 2009 17:13:08 -0000 1.129
--- cmFileCommand.cxx 29 Apr 2009 17:13:23 -0000 1.130
***************
*** 113,116 ****
--- 113,120 ----
return this->HandleRemove(args, true);
}
+ else if ( subCommand == "COPY" )
+ {
+ return this->HandleCopyCommand(args);
+ }
else if ( subCommand == "INSTALL" )
{
***************
*** 904,910 ****
struct cmFileCopier
{
! cmFileCopier(cmFileCommand* command):
FileCommand(command),
Makefile(command->GetMakefile()),
Always(false),
MatchlessFiles(true),
--- 908,915 ----
struct cmFileCopier
{
! cmFileCopier(cmFileCommand* command, const char* name = "COPY"):
FileCommand(command),
Makefile(command->GetMakefile()),
+ Name(name),
Always(false),
MatchlessFiles(true),
***************
*** 914,918 ****
UseGivenPermissionsFile(false),
UseGivenPermissionsDir(false),
! UseSourcePermissions(false),
Doing(DoingNone)
{
--- 919,923 ----
UseGivenPermissionsFile(false),
UseGivenPermissionsDir(false),
! UseSourcePermissions(true),
Doing(DoingNone)
{
***************
*** 924,927 ****
--- 929,933 ----
cmFileCommand* FileCommand;
cmMakefile* Makefile;
+ const char* Name;
bool Always;
cmFileTimeComparison FileTimes;
***************
*** 985,989 ****
{
cmOStringStream e;
! e << "INSTALL cannot set permissions on \"" << toFile << "\"";
this->FileCommand->SetError(e.str().c_str());
return false;
--- 991,995 ----
{
cmOStringStream e;
! e << this->Name << " cannot set permissions on \"" << toFile << "\"";
this->FileCommand->SetError(e.str().c_str());
return false;
***************
*** 1009,1013 ****
{
cmOStringStream e;
! e << "INSTALL given invalid permission \"" << arg << "\".";
this->FileCommand->SetError(e.str().c_str());
return false;
--- 1015,1019 ----
{
cmOStringStream e;
! e << this->Name << " given invalid permission \"" << arg << "\".";
this->FileCommand->SetError(e.str().c_str());
return false;
***************
*** 1036,1040 ****
// The input file does not exist and installation is not optional.
cmOStringStream e;
! e << "INSTALL cannot find \"" << fromFile << "\".";
this->FileCommand->SetError(e.str().c_str());
return false;
--- 1042,1046 ----
// The input file does not exist and installation is not optional.
cmOStringStream e;
! e << this->Name << " cannot find \"" << fromFile << "\".";
this->FileCommand->SetError(e.str().c_str());
return false;
***************
*** 1056,1059 ****
--- 1062,1066 ----
DoingDestination,
DoingFiles,
+ DoingPattern,
DoingRegex,
DoingPermissionsFile,
***************
*** 1068,1072 ****
{
cmOStringStream e;
! e << "option " << arg << " may not appear before REGEX.";
this->FileCommand->SetError(e.str().c_str());
this->Doing = DoingError;
--- 1075,1079 ----
{
cmOStringStream e;
! e << "option " << arg << " may not appear before PATTERN or REGEX.";
this->FileCommand->SetError(e.str().c_str());
this->Doing = DoingError;
***************
*** 1075,1079 ****
{
cmOStringStream e;
! e << "option " << arg << " may not appear after REGEX.";
this->FileCommand->SetError(e.str().c_str());
this->Doing = DoingError;
--- 1082,1086 ----
{
cmOStringStream e;
! e << "option " << arg << " may not appear after PATTERN or REGEX.";
this->FileCommand->SetError(e.str().c_str());
this->Doing = DoingError;
***************
*** 1129,1133 ****
{
cmOStringStream e;
! e << "INSTALL given no DESTINATION";
this->FileCommand->SetError(e.str().c_str());
return false;
--- 1136,1140 ----
{
cmOStringStream e;
! e << this->Name << " given no DESTINATION";
this->FileCommand->SetError(e.str().c_str());
return false;
***************
*** 1163,1166 ****
--- 1170,1177 ----
}
}
+ else if(arg == "PATTERN")
+ {
+ this->Doing = DoingPattern;
+ }
else if(arg == "REGEX")
{
***************
*** 1180,1183 ****
--- 1191,1229 ----
}
}
+ else if(arg == "PERMISSIONS")
+ {
+ if(this->CurrentMatchRule)
+ {
+ this->Doing = DoingPermissionsMatch;
+ }
+ else
+ {
+ this->NotBeforeMatch(arg);
+ }
+ }
+ else if(arg == "FILE_PERMISSIONS")
+ {
+ if(this->CurrentMatchRule)
+ {
+ this->NotAfterMatch(arg);
+ }
+ else
+ {
+ this->Doing = DoingPermissionsFile;
+ this->UseGivenPermissionsFile = true;
+ }
+ }
+ else if(arg == "DIRECTORY_PERMISSIONS")
+ {
+ if(this->CurrentMatchRule)
+ {
+ this->NotAfterMatch(arg);
+ }
+ else
+ {
+ this->Doing = DoingPermissionsDir;
+ this->UseGivenPermissionsDir = true;
+ }
+ }
else if(arg == "USE_SOURCE_PERMISSIONS")
{
***************
*** 1192,1195 ****
--- 1238,1253 ----
}
}
+ else if(arg == "NO_SOURCE_PERMISSIONS")
+ {
+ if(this->CurrentMatchRule)
+ {
+ this->NotAfterMatch(arg);
+ }
+ else
+ {
+ this->Doing = DoingNone;
+ this->UseSourcePermissions = false;
+ }
+ }
else if(arg == "FILES_MATCHING")
{
***************
*** 1240,1243 ****
--- 1298,1325 ----
this->Doing = DoingNone;
break;
+ case DoingPattern:
+ {
+ // Convert the pattern to a regular expression. Require a
+ // leading slash and trailing end-of-string in the matched
+ // string to make sure the pattern matches only whole file
+ // names.
+ std::string regex = "/";
+ regex += cmsys::Glob::PatternToRegex(arg, false);
+ regex += "$";
+ this->MatchRules.push_back(MatchRule(regex));
+ this->CurrentMatchRule = &*(this->MatchRules.end()-1);
+ if(this->CurrentMatchRule->Regex.is_valid())
+ {
+ this->Doing = DoingNone;
+ }
+ else
+ {
+ cmOStringStream e;
+ e << "could not compile PATTERN \"" << arg << "\".";
+ this->FileCommand->SetError(e.str().c_str());
+ this->Doing = DoingError;
+ }
+ }
+ break;
case DoingRegex:
this->MatchRules.push_back(MatchRule(arg));
***************
*** 1371,1375 ****
{
cmOStringStream e;
! e << "INSTALL cannot read symlink \"" << fromFile
<< "\" to duplicate at \"" << toFile << "\".";
this->FileCommand->SetError(e.str().c_str());
--- 1453,1457 ----
{
cmOStringStream e;
! e << this->Name << " cannot read symlink \"" << fromFile
<< "\" to duplicate at \"" << toFile << "\".";
this->FileCommand->SetError(e.str().c_str());
***************
*** 1404,1408 ****
{
cmOStringStream e;
! e << "INSTALL cannot duplicate symlink \"" << fromFile
<< "\" at \"" << toFile << "\".";
this->FileCommand->SetError(e.str().c_str());
--- 1486,1490 ----
{
cmOStringStream e;
! e << this->Name << " cannot duplicate symlink \"" << fromFile
<< "\" at \"" << toFile << "\".";
this->FileCommand->SetError(e.str().c_str());
***************
*** 1436,1440 ****
{
cmOStringStream e;
! e << "INSTALL cannot copy file \"" << fromFile
<< "\" to \"" << toFile << "\".";
this->FileCommand->SetError(e.str().c_str());
--- 1518,1522 ----
{
cmOStringStream e;
! e << this->Name << " cannot copy file \"" << fromFile
<< "\" to \"" << toFile << "\".";
this->FileCommand->SetError(e.str().c_str());
***************
*** 1448,1452 ****
{
cmOStringStream e;
! e << "INSTALL cannot set modification time on \"" << toFile << "\"";
this->FileCommand->SetError(e.str().c_str());
return false;
--- 1530,1535 ----
{
cmOStringStream e;
! e << this->Name << " cannot set modification time on \""
! << toFile << "\"";
this->FileCommand->SetError(e.str().c_str());
return false;
***************
*** 1478,1482 ****
{
cmOStringStream e;
! e << "INSTALL cannot make directory \"" << destination << "\": "
<< cmSystemTools::GetLastSystemError();
this->FileCommand->SetError(e.str().c_str());
--- 1561,1565 ----
{
cmOStringStream e;
! e << this->Name << " cannot make directory \"" << destination << "\": "
<< cmSystemTools::GetLastSystemError();
this->FileCommand->SetError(e.str().c_str());
***************
*** 1550,1561 ****
//----------------------------------------------------------------------------
struct cmFileInstaller: public cmFileCopier
{
cmFileInstaller(cmFileCommand* command):
! cmFileCopier(command),
InstallType(cmTarget::INSTALL_FILES),
Optional(false),
DestDirLength(0)
{
// Check whether to copy files always or only if they have changed.
this->Always =
--- 1633,1653 ----
//----------------------------------------------------------------------------
+ bool cmFileCommand::HandleCopyCommand(std::vector<std::string> const& args)
+ {
+ cmFileCopier copier(this);
+ return copier.Run(args);
+ }
+
+ //----------------------------------------------------------------------------
struct cmFileInstaller: public cmFileCopier
{
cmFileInstaller(cmFileCommand* command):
! cmFileCopier(command, "INSTALL"),
InstallType(cmTarget::INSTALL_FILES),
Optional(false),
DestDirLength(0)
{
+ // Installation does not use source permissions by default.
+ this->UseSourcePermissions = false;
// Check whether to copy files always or only if they have changed.
this->Always =
***************
*** 1737,1740 ****
--- 1829,1833 ----
else
{
+ // file(INSTALL) aliases PERMISSIONS to FILE_PERMISSIONS
this->Doing = DoingPermissionsFile;
this->UseGivenPermissionsFile = true;
***************
*** 1749,1752 ****
--- 1842,1846 ----
else
{
+ // file(INSTALL) aliases DIR_PERMISSIONS to DIRECTORY_PERMISSIONS
this->Doing = DoingPermissionsDir;
this->UseGivenPermissionsDir = true;
More information about the Cmake-commits
mailing list