[Cmake-commits] [cmake-commits] david.cole committed cmSystemTools.cxx 1.426 1.427 cmSystemTools.h 1.168 1.169

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Dec 23 14:34:48 EST 2009


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

Modified Files:
	cmSystemTools.cxx cmSystemTools.h 
Log Message:
Preserve environment variables across calls to cmCTestScriptHandler::RunConfigurationScript. This will help prevent problems like we are currently experiencing (regarding CMake continuous dashboards only running once each day because the HOME environment variable is modified indirectly by a command in a called script, but affects the environment in the calling script).


Index: cmSystemTools.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.h,v
retrieving revision 1.168
retrieving revision 1.169
diff -C 2 -d -r1.168 -r1.169
*** cmSystemTools.h	22 Dec 2009 19:37:06 -0000	1.168
--- cmSystemTools.h	23 Dec 2009 19:34:46 -0000	1.169
***************
*** 359,362 ****
--- 359,376 ----
        was. */
    static void RestoreEnv(const std::vector<std::string>& env);
+ 
+   /** Helper class to save and restore the environment.
+       Instantiate this class as an automatic variable on
+       the stack. Its constructor saves a copy of the current
+       environment and then its destructor restores the
+       original environment. */
+   class SaveRestoreEnvironment
+   {
+   public:
+     SaveRestoreEnvironment();
+     virtual ~SaveRestoreEnvironment();
+   private:
+     std::vector<std::string> Env;
+   };
  #endif
  

Index: cmSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.cxx,v
retrieving revision 1.426
retrieving revision 1.427
diff -C 2 -d -r1.426 -r1.427
*** cmSystemTools.cxx	22 Dec 2009 19:37:06 -0000	1.426
--- cmSystemTools.cxx	23 Dec 2009 19:34:46 -0000	1.427
***************
*** 1674,1677 ****
--- 1674,1689 ----
      }
  }
+ 
+ //----------------------------------------------------------------------
+ cmSystemTools::SaveRestoreEnvironment::SaveRestoreEnvironment()
+ {
+   this->Env = cmSystemTools::GetEnvironmentVariables();
+ }
+ 
+ //----------------------------------------------------------------------
+ cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment()
+ {
+   cmSystemTools::RestoreEnv(this->Env);
+ }
  #endif
  



More information about the Cmake-commits mailing list