]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codewriter: Update timestamps of generated c-files if needed
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 24 Feb 2017 21:22:21 +0000 (22:22 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 30 Apr 2017 16:29:19 +0000 (18:29 +0200)
If a changed source-file produces the same ccode we currently leave
existing files untouched. Although it is better to update the modification
timestamp of those to at least meet the one of associated source-file.

https://bugzilla.gnome.org/show_bug.cgi?id=683286

ccode/valaccodewriter.vala
vapi/glib-2.0.vapi

index 281ff6e435fcb349e864f855c83ed48ee8e8c369..2e58a41b3dc40d72e583917363f7383100d422b9 100644 (file)
@@ -138,6 +138,14 @@ public class Vala.CCodeWriter {
                                FileUtils.rename (temp_filename, filename);
                        } else {
                                FileUtils.unlink (temp_filename);
+                               if (source_filename != null) {
+                                       var stats = Stat (source_filename);
+                                       var target_stats = Stat (filename);
+                                       if (stats.st_mtime >= target_stats.st_mtime) {
+                                               UTimBuf timebuf = { stats.st_atime + 1, stats.st_mtime + 1 };
+                                               FileUtils.utime (filename, timebuf);
+                                       }
+                               }
                        }
                }
        }
index 67b06234e2f60365f12935f7249f9c7a416dbba6..65233d953b56805ffc9ae39bf5a668fd03d96f4d 100644 (file)
@@ -3618,6 +3618,9 @@ namespace GLib {
 
        [CCode (cname = "struct stat", cheader_filename = "sys/stat.h,glib/gstdio.h")]
        public struct Stat {
+               public time_t st_atime;
+               public time_t st_mtime;
+               public time_t st_ctime;
                [CCode (cname = "g_stat", instance_pos = -1)]
                public Stat (string filename);
                [Version (since = "2.6")]