[Cmake-commits] [cmake-commits] king committed cmake.cxx 1.433 1.434 cmake.h 1.121 1.122

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Oct 21 13:10:27 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv10163/Source

Modified Files:
	cmake.cxx cmake.h 
Log Message:
Factor out "cmake -E cmake_symlink_*" code

We factor the implementation of

   cmake -E cmake_symlink_library
   cmake -E cmake_symlink_executable

out of cmake::ExecuteCMakeCommand into methods

   cmake::SymlinkLibrary
   cmake::SymlinkExecutable

plus a helper method cmake::SymlinkInternal.


Index: cmake.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.h,v
retrieving revision 1.121
retrieving revision 1.122
diff -C 2 -d -r1.121 -r1.122
*** cmake.h	28 Sep 2009 15:42:50 -0000	1.121
--- cmake.h	21 Oct 2009 17:10:24 -0000	1.122
***************
*** 415,418 ****
--- 415,422 ----
    void GenerateGraphViz(const char* fileName) const;
  
+   static int SymlinkLibrary(std::vector<std::string>& args);
+   static int SymlinkExecutable(std::vector<std::string>& args);
+   static bool SymlinkInternal(std::string const& file,
+                               std::string const& link);
    static int ExecuteEchoColor(std::vector<std::string>& args);
    static int ExecuteLinkScript(std::vector<std::string>& args);

Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.433
retrieving revision 1.434
diff -C 2 -d -r1.433 -r1.434
*** cmake.cxx	8 Oct 2009 18:54:19 -0000	1.433
--- cmake.cxx	21 Oct 2009 17:10:22 -0000	1.434
***************
*** 1378,1436 ****
      else if (args[1] == "cmake_symlink_library" && args.size() == 5)
        {
!       int result = 0;
!       std::string realName = args[2];
!       std::string soName = args[3];
!       std::string name = args[4];
!       if(soName != realName)
!         {
!         std::string fname = cmSystemTools::GetFilenameName(realName);
!         if(cmSystemTools::FileExists(soName.c_str()) ||
!            cmSystemTools::FileIsSymlink(soName.c_str()))
!           {
!           cmSystemTools::RemoveFile(soName.c_str());
!           }
!         if(!cmSystemTools::CreateSymlink(fname.c_str(), soName.c_str()))
!           {
!           cmSystemTools::ReportLastSystemError("cmake_symlink_library");
!           result = 1;
!           }
!         }
!       if(name != soName)
!         {
!         std::string fname = cmSystemTools::GetFilenameName(soName);
!         if(cmSystemTools::FileExists(name.c_str()) ||
!            cmSystemTools::FileIsSymlink(name.c_str()))
!           {
!           cmSystemTools::RemoveFile(name.c_str());
!           }
!         if(!cmSystemTools::CreateSymlink(fname.c_str(), name.c_str()))
!           {
!           cmSystemTools::ReportLastSystemError("cmake_symlink_library");
!           result = 1;
!           }
!         }
!       return result;
        }
      // Internal CMake versioned executable support.
      else if (args[1] == "cmake_symlink_executable" && args.size() == 4)
        {
!       int result = 0;
!       std::string realName = args[2];
!       std::string name = args[3];
!       if(name != realName)
!         {
!         std::string fname = cmSystemTools::GetFilenameName(realName);
!         if(cmSystemTools::FileExists(name.c_str()) ||
!            cmSystemTools::FileIsSymlink(name.c_str()))
!           {
!           cmSystemTools::RemoveFile(name.c_str());
!           }
!         if(!cmSystemTools::CreateSymlink(fname.c_str(), name.c_str()))
!           {
!           cmSystemTools::ReportLastSystemError("cmake_symlink_executable");
!           result = 1;
!           }
!         }
!       return result;
        }
  
--- 1378,1387 ----
      else if (args[1] == "cmake_symlink_library" && args.size() == 5)
        {
!       return cmake::SymlinkLibrary(args);
        }
      // Internal CMake versioned executable support.
      else if (args[1] == "cmake_symlink_executable" && args.size() == 4)
        {
!       return cmake::SymlinkExecutable(args);
        }
  
***************
*** 3129,3132 ****
--- 3080,3138 ----
  
  //----------------------------------------------------------------------------
+ int cmake::SymlinkLibrary(std::vector<std::string>& args)
+ {
+   int result = 0;
+   std::string realName = args[2];
+   std::string soName = args[3];
+   std::string name = args[4];
+   if(soName != realName)
+     {
+     if(!cmake::SymlinkInternal(realName, soName))
+       {
+       cmSystemTools::ReportLastSystemError("cmake_symlink_library");
+       result = 1;
+       }
+     }
+   if(name != soName)
+     {
+     if(!cmake::SymlinkInternal(soName, name))
+       {
+       cmSystemTools::ReportLastSystemError("cmake_symlink_library");
+       result = 1;
+       }
+     }
+   return result;
+ }
+ 
+ //----------------------------------------------------------------------------
+ int cmake::SymlinkExecutable(std::vector<std::string>& args)
+ {
+   int result = 0;
+   std::string realName = args[2];
+   std::string name = args[3];
+   if(name != realName)
+     {
+     if(!cmake::SymlinkInternal(realName, name))
+       {
+       cmSystemTools::ReportLastSystemError("cmake_symlink_executable");
+       result = 1;
+       }
+     }
+   return result;
+ }
+ 
+ //----------------------------------------------------------------------------
+ bool cmake::SymlinkInternal(std::string const& file, std::string const& link)
+ {
+   if(cmSystemTools::FileExists(link.c_str()) ||
+      cmSystemTools::FileIsSymlink(link.c_str()))
+     {
+     cmSystemTools::RemoveFile(link.c_str());
+     }
+   std::string linktext = cmSystemTools::GetFilenameName(file);
+   return cmSystemTools::CreateSymlink(linktext.c_str(), link.c_str());
+ }
+ 
+ //----------------------------------------------------------------------------
  #ifdef CMAKE_BUILD_WITH_CMAKE
  int cmake::ExecuteEchoColor(std::vector<std::string>& args)



More information about the Cmake-commits mailing list