X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/blobdiff_plain/a409b906a936ea2b311a0a5b676360e779444a14..00238eb840d539a30fe92d33f7d1507b0073c25f:/bin/compile.py diff --git a/bin/compile.py b/bin/compile.py index bde88c0..da2e198 100644 --- a/bin/compile.py +++ b/bin/compile.py @@ -2,7 +2,7 @@ import dependencies dependencies.vcheck() -import pages, os, subprocess, pagegen, shutil, sys +import pages, os, subprocess, pagegen, shutil, sys, time COPYRIGHT = open("js/copyright.js", "rb").read() @@ -11,7 +11,7 @@ class MinifyException(Exception): def jarit(src): try: - p = subprocess.Popen(["java", "-jar", "bin/yuicompressor-2.3.5.jar", src], stdout=subprocess.PIPE) + p = subprocess.Popen(["java", "-jar", "bin/yuicompressor-2.4.8.jar", src], stdout=subprocess.PIPE, shell=os.name == "nt") except Exception, e: if hasattr(e, "errno") and e.errno == 2: raise MinifyException, "unable to run java" @@ -22,7 +22,7 @@ def jarit(src): return data JAVA_WARNING_SURPRESSED = False -def jmerge_files(prefix, suffix, output, files, *args): +def jmerge_files(prefix, suffix, output, files, *args, **kwargs): global COPYRIGHT output = output + "." + suffix o = os.path.join(prefix, "compiled", output) @@ -42,10 +42,18 @@ def jmerge_files(prefix, suffix, output, files, *args): finally: f.close() - os.unlink(o) + try: + os.unlink(o) + except: + time.sleep(1) # windows sucks + os.unlink(o) f = open(os.path.join(prefix, "static", suffix, output), "wb") f.write(COPYRIGHT) + + if kwargs.get("file_prefix"): + f.write(kwargs.get("file_prefix")) + f.write(compiled) f.close() @@ -53,8 +61,10 @@ def merge_files(output, files, root_path=lambda x: x): f = open(output, "wb") for x in files: + if x.startswith("//"): + continue f2 = open(root_path(x), "rb") - f.write(f2.read()) + f.write(f2.read() + "\n") f2.close() f.close() @@ -80,9 +90,16 @@ def main(outputdir=".", produce_debug=True): csssrc = pagegen.csslist(uiname, True) jmerge_files(outputdir, "css", uiname + "-" + ID, csssrc) shutil.copy2(os.path.join(outputdir, "static", "css", uiname + "-" + ID + ".css"), os.path.join(outputdir, "static", "css", uiname + ".css")) + + mcssname = os.path.join("css", uiname + ".mcss") + if os.path.exists(mcssname): + mcssdest = os.path.join(outputdir, "static", "css", uiname + ".mcss") + shutil.copy2(mcssname, mcssdest) + shutil.copy2(mcssdest, os.path.join(outputdir, "static", "css", uiname + "-" + ID + ".mcss")) + #jmerge_files(outputdir, "js", uiname, value["uifiles"], lambda x: os.path.join("js", "ui", "frontends", x + ".js")) - alljs = [] + alljs = ["js/debugdisabled.js"] for y in pages.JS_BASE: alljs.append(os.path.join("static", "js", y + ".js")) for y in value.get("buildextra", []): @@ -91,8 +108,8 @@ 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 + "-" + ID, alljs) - + jmerge_files(outputdir, "js", uiname + "-" + ID, alljs, file_prefix="QWEBIRC_BUILD=\"" + ID + "\";\n") + os.rmdir(coutputdir) f = open(".compiled", "w") @@ -124,4 +141,4 @@ def vcheck(): if __name__ == "__main__": main() - \ No newline at end of file +