Created
February 10, 2012 08:40
-
-
Save csakatoku/1787832 to your computer and use it in GitHub Desktop.
jasyscript.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env jasy | |
# | |
# Utils | |
# | |
def getSession(): | |
session = Session() | |
session.addProject(Project("external/core")) | |
session.addProject(Project(".")) | |
return session | |
# | |
# Tasks | |
# | |
@task | |
def clean(): | |
logging.info("Clearing cache...") | |
session = getSession() | |
session.clearCache() | |
session.close() | |
@task | |
def build(): | |
session = getSession() | |
# Configure permutations | |
session.setField("es5", True) | |
session.permutateField("debug") | |
# Prepare assets | |
resolver = Resolver(session.getProjects()) | |
resolver.addClassName("p.helloworld.App") | |
assets = Asset(session, resolver.getIncludedClasses()).exportBuild() | |
# Write kernel script | |
includedByKernel = storeKernel("build/loader.js", session, assets=assets) | |
# Copy files from source | |
for staticFile in ["index.html"]: | |
updateFile("source/%s" % staticFile, "build/%s" % staticFile) | |
# Compiler configuration | |
optimization = Optimization("variables", "declarations", "blocks") | |
formatting = Formatting() | |
# Process every possible permutation | |
for permutation in session.getPermutations(): | |
# Resolving dependencies | |
resolver = Resolver(session.getProjects(), permutation) | |
resolver.addClassName("p.helloworld.App") | |
resolver.excludeClasses(includedByKernel) | |
# Compressing classes | |
classes = Sorter(resolver, permutation).getSortedClasses() | |
compressedCode = storeCompressed("build/helloworld-%s.js" % permutation.getChecksum(), classes, | |
permutation=permutation, optimization=optimization, formatting=formatting, bootCode="new p.helloworld.App();") | |
session.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment