[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    icecream
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2012-07-13 20:18:44
Message-ID: 20120713201845.03983AC7A9 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1305557 by lunakl:

rebuild environment if the compiler changes

Otherwise updating the compiler does not in practice take effect
until daemon restart.



 M  +1 -0      NEWS  
 M  +66 -1     daemon/environment.cpp  
 M  +2 -0      daemon/environment.h  
 M  +7 -0      daemon/main.cpp  


--- trunk/icecream/NEWS #1305556:1305557
@@ -4,6 +4,7 @@
   Clang with -Wp,-rewrite-includes option is recommended (3.2+ or patched).
 - support 'icecc <compilername>' properly
 - try to avoid compiling on the local machine if it is busy
+- do not use old compiler if it was changed while icecream daemon was running
 
 0.9.7 (1232780)
 - bug fix for -MD and -MF
--- trunk/icecream/daemon/environment.cpp #1305556:1305557
@@ -209,6 +209,60 @@
     return envs;
 }
 
+// Timestamps for compiler binaries, if they have changed since the time
+// native env was built, it needs to be rebuilt.
+static time_t gcc_bin_timestamp = 0;
+static time_t gpp_bin_timestamp = 0;
+static time_t clang_bin_timestamp = 0;
+
+static void save_native_env_timestamp()
+{
+    struct stat st;
+    if( stat( "/usr/bin/gcc", &st ) == 0 )
+        gcc_bin_timestamp = st.st_mtime;
+    else
+        gcc_bin_timestamp = 0;
+    if( stat( "/usr/bin/gcc", &st ) == 0 )
+        gcc_bin_timestamp = st.st_mtime;
+    else
+        gcc_bin_timestamp = 0;
+    if( stat( "/usr/bin/g++", &st ) == 0 )
+        gpp_bin_timestamp = st.st_mtime;
+    else
+        gpp_bin_timestamp = 0;
+    if( stat( "/usr/bin/clang", &st ) == 0 )
+        clang_bin_timestamp = st.st_mtime;
+    else
+        clang_bin_timestamp = 0;
+}
+
+bool native_env_uptodate()
+{
+    struct stat st;
+    if( stat( "/usr/bin/gcc", &st ) == 0 ) {
+        if( st.st_mtime != gcc_bin_timestamp )
+            return false;
+    } else {
+        if( gcc_bin_timestamp != 0 )
+            return false;
+    }
+    if( stat( "/usr/bin/g++", &st ) == 0 ) {
+        if( st.st_mtime != gpp_bin_timestamp )
+            return false;
+    } else {
+        if( gpp_bin_timestamp != 0 )
+            return false;
+    }
+    if( stat( "/usr/bin/clang", &st ) == 0 ) {
+        if( st.st_mtime != clang_bin_timestamp )
+            return false;
+    } else {
+        if( clang_bin_timestamp != 0 )
+            return false;
+    }
+    return true;
+}
+
 size_t setup_env_cache(const string &basedir, string &native_environment, uid_t \
nobody_uid, gid_t nobody_gid)  {
     native_environment = "";
@@ -223,7 +277,7 @@
     if ( !ok )
 	return 0;
 
-    if ( mkdir( nativedir.c_str(), 0775 ) )
+    if ( mkdir( nativedir.c_str(), 0775 ) && errno != EEXIST )
    	return 0; 
 
     if ( chown( nativedir.c_str(), 0, nobody_gid ) ||
@@ -251,6 +305,7 @@
             return 0;
         }
         else {
+            save_native_env_timestamp();
             return sumup_dir( nativedir );
         }
     }
@@ -440,3 +495,13 @@
 
     _exit(execv(argv[0], argv));
 }
+
+size_t remove_native_environment( const string &basedir, const string &env )
+{
+    if ( env.empty() )
+        return 0;
+    string nativedir = basedir + "/native/";
+    size_t size = sumup_dir( nativedir );
+    unlink( env.c_str());
+    return size;
+}
--- trunk/icecream/daemon/environment.h #1305556:1305557
@@ -30,6 +30,7 @@
 extern size_t setup_env_cache(const std::string &basedir,
                      std::string &native_environment, uid_t nobody_uid, gid_t \
nobody_gid);  Environments available_environmnents(const std::string &basename);
+extern bool native_env_uptodate();
 extern pid_t start_install_environment( const std::string &basename,
                             const std::string &target,
                             const std::string &name,
@@ -39,5 +40,6 @@
 extern size_t finalize_install_environment( const std::string &basename, const \
std::string& target,  pid_t pid, gid_t nobody_gid );
 extern size_t remove_environment( const std::string &basedir, const std::string \
&env); +extern size_t remove_native_environment( const std::string &basedir, const \
std::string &env );  
 #endif
--- trunk/icecream/daemon/main.cpp #1305556:1305557
@@ -872,6 +872,13 @@
 
 bool Daemon::handle_get_native_env( Client *client )
 {
+    if ( !native_env_uptodate())
+    {
+        trace() << "native_env needs rebuild" << endl;
+        cache_size -= remove_native_environment( envbasedir, native_environment );
+        native_environment.clear();
+    }
+
     trace() << "get_native_env " << native_environment << endl;
 
     if ( !native_environment.length() ) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic