]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Produce compiled files based on hg id.
authorChris Porter <redacted>
Mon, 2 Feb 2009 02:29:39 +0000 (02:29 +0000)
committerChris Porter <redacted>
Mon, 2 Feb 2009 02:29:39 +0000 (02:29 +0000)
bin/compile.py
bin/pagegen.py
clean.py

index bb270561b7d8af4fd9cee9d8c88614f12c74419f..c287bc7c9a80b110243f7f728e7293d2b00bc088 100644 (file)
@@ -28,6 +28,8 @@ def merge_files(output, files, root_path=lambda x: x):
   f.close()
 
 def main(outputdir=".", produce_debug=True):
+  ID = pagegen.gethgid()
+  
   pagegen.main(outputdir, produce_debug=produce_debug)
 
   coutputdir = os.path.join(outputdir, "compiled")
@@ -45,7 +47,7 @@ def main(outputdir=".", produce_debug=True):
 
   for uiname, value in pages.UIs.items():
     csssrc = pagegen.csslist(uiname, True)
-    jmerge_files(outputdir, "css", uiname, csssrc)
+    jmerge_files(outputdir, "css", uiname + "-" + ID, csssrc)
     #jmerge_files(outputdir, "js", uiname, value["uifiles"], lambda x: os.path.join("js", "ui", "frontends", x + ".js"))
     
     alljs = []
@@ -57,7 +59,7 @@ def main(outputdir=".", produce_debug=True):
       alljs.append(os.path.join("js", y + ".js"))
     for y in value["uifiles"]:
       alljs.append(os.path.join("js", "ui", "frontends", y + ".js"))
-    jmerge_files(outputdir, "js", uiname, alljs)
+    jmerge_files(outputdir, "js", uiname + "-" + ID, alljs)
     
   os.rmdir(coutputdir)
   
index d7891a4eb3e46b8b66640143a847202e56840207..7ae247591f9d82a00cff12a01e14e72a6045b59b 100644 (file)
@@ -1,21 +1,31 @@
-import os, sys, pages
+import os, sys, pages, subprocess, re
 
 def jslist(name, debug):
   ui = pages.UIs[name]
   if debug:
     x = [pages.JS_BASE, ui.get("extra", []), pages.DEBUG, ["debug/ui/frontends/%s" % y for y in ui["uifiles"]]]
+    hgid = ""
   else:
     #x = [pages.JS_BASE, ui.get("buildextra", ui.get("extra", [])), pages.BUILD_BASE, name]
     x = [name]
-    
-  return list("js/%s.js" % y for y in pages.flatten(x))
+    hgid = "-" + gethgid()  
+  
+  return list("js/%s%s.js" % (y, hgid) for y in pages.flatten(x))
 
 def csslist(name, debug, gen=False):
   if not debug:
-    return ["css/%s.css" % name]
+    return ["css/%s-%s.css" % (name, gethgid())]
   ui = pages.UIs[name]
   return list("css/%s%s.css" % ("debug/" if gen else "", x) for x in pages.flatten([ui.get("extracss", []), "colours", "dialogs", "%s" % name]))
 
+HGID = None
+def gethgid():
+  global HGID
+  if HGID is None:
+    hgid = subprocess.Popen(["hg", "id"], stdout=subprocess.PIPE).communicate()[0]
+    HGID = re.match("^([0-9a-f]+).*", hgid).group(1)
+  return HGID
+
 def producehtml(name, debug):
   ui = pages.UIs[name]
   js = jslist(name, debug)
index c6f30a265043647af6b24df56a008d188078b3b4..d371bd763eb27da59c132c497b174a7c3fe94d67 100644 (file)
--- a/clean.py
+++ b/clean.py
@@ -1,12 +1,15 @@
 #!/usr/bin/env python
 
-import bin.pages as pages, os, bin.cleanpyc as cleanpyc
+import bin.pages as pages, os, bin.cleanpyc as cleanpyc, glob
 from bin.cleanpyc import tryunlink
   
 for x in pages.UIs:
+  for y in glob.glob(os.path.join("static", "js", "%s-*.js" % x)):
+    tryunlink(y)
+  for y in glob.glob(os.path.join("static", "css", "%s-*.js" % x)):
+    tryunlink(y)
   tryunlink("static", "%s.html" % x)
   tryunlink("static", "%sdebug.html" % x)  
-  tryunlink("static", "js", "%s.js" % x)
 
 if __name__ == "__main__":
   tryunlink("static", "js", "qwebirc.js")