[vala] codewriter: Update timestamps of generated c-files if needed
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codewriter: Update timestamps of generated c-files if needed
- Date: Sun, 30 Apr 2017 16:29:58 +0000 (UTC)
commit 3c8489c202692a230914ede35320ced13a9fe05b
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Feb 24 22:22:21 2017 +0100
codewriter: Update timestamps of generated c-files if needed
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 | 8 ++++++++
vapi/glib-2.0.vapi | 3 +++
2 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index 281ff6e..2e58a41 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -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);
+ }
+ }
}
}
}
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 67b0623..65233d9 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -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")]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]