Commits

Virgil Dupras committed b70af70

Only copy XiblessSupport unit when it changed, thus avoiding needless recompilation.

  • Participants
  • Parent commits b6038e8

Comments (0)

Files changed (2)

File xibless/gen.py

 from .segment import SegmentedControl
 from .slider import Slider
 from .layout import HLayout, VLayout, VHLayout
+from .util import modified_after
 
 try:
     execfile
     DATA_PATH = op.join(op.dirname(__file__), 'data')
     if not op.exists(destfolder):
         os.makedirs(destfolder)
-    shutil.copy(op.join(DATA_PATH, 'XiblessSupport.h'), destfolder)
-    shutil.copy(op.join(DATA_PATH, 'XiblessSupport.m'), destfolder)
+    if modified_after(op.join(DATA_PATH, 'XiblessSupport.h'), op.join(destfolder, 'XiblessSupport.h')):
+        shutil.copy(op.join(DATA_PATH, 'XiblessSupport.h'), destfolder)
+    if modified_after(op.join(DATA_PATH, 'XiblessSupport.m'), op.join(destfolder, 'XiblessSupport.m')):
+        shutil.copy(op.join(DATA_PATH, 'XiblessSupport.m'), destfolder)

File xibless/util.py

+import os
+
+def modified_after(first_path, second_path):
+    """Returns True if first_path's mtime is higher than second_path's mtime."""
+    try:
+        first_mtime = os.stat(first_path).st_mtime
+    except EnvironmentError:
+        return False
+    try:
+        second_mtime = os.stat(second_path).st_mtime
+    except EnvironmentError:
+        return True
+    return first_mtime > second_mtime