# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-

VERSION='0.1'
APPNAME='ndnjs'

YUICOMPRESSOR_URL="http://github.com/downloads/yui/yuicompressor/"
YUICOMPRESSOR_NAME="yuicompressor-2.4.7"

CLOSURE_COMPILER="http://closure-compiler.googlecode.com/files/compiler-20121212.zip"

from waflib import Task, TaskGen, Utils, Logs
import urllib, subprocess, os, shutil

def options (opt):
    js = opt.add_option_group ("ndn.js compilation options")

    js.add_option('--no-js',action='store_false',default=True,dest='js',
                  help='''Disable ndn.js compilation and installation''')
    js.add_option('--js-dir',action='store',dest='jsdir',
                  help='''Directory where .js files will be installed (Default: ${PREFIX}/share/ndn-js)''')
    js.add_option('--yui',action='store_true',default=False,dest='yui',
                  help='''Download and use yuicompressor-2.4.7 (http://yui.github.com/yuicompressor/)''')
    js.add_option('--compiler',action='store_true',default=False,dest='compiler',
                  help='''Download and use closure-compiler-r2388 (https://code.google.com/p/closure-compiler/)''')

    ws = opt.add_option_group ("ws-proxy options")
    ws.add_option ('--no-ws',action='store_false',default=True,dest='ws',
                   help='''Disable ws-proxy installation''')

def configure (conf):
    if conf.options.js:
        conf.env.JS = 1
        if not conf.env.JSDIR:
            if conf.options.jsdir or Utils.is_win32:
                conf.env.JSDIR=os.path.abspath (os.path.expanduser (conf.options.jsdir))
            else:
                conf.env.JSDIR=Utils.subst_vars ('${PREFIX}/bin',conf.env)

        if conf.options.yui:
            conf.start_msg ("Checking for yuicompressor")
            if os.path.exists('tools/yuicompressor.jar'):
                conf.end_msg('tools/yuicompressor.jar')
                conf.env.HAVE_YUI = 1
            else:
                conf.end_msg('not found','YELLOW')
                url="%s%s.zip" % (YUICOMPRESSOR_URL, YUICOMPRESSOR_NAME)
                Logs.info ("Downloading yuicompressor from %s..." % url)
                urllib.urlretrieve (url, "build/yuicompressor.zip")

                filename='%s/build/%s.jar' % (YUICOMPRESSOR_NAME,YUICOMPRESSOR_NAME)
                subprocess.check_call (['unzip', '-qq', '-o', '-j', 'build/yuicompressor.zip',
                                        filename, '-d', 'tools/'])
                os.rename ("tools/%s.jar" % YUICOMPRESSOR_NAME, "tools/yuicompressor.jar")
                conf.env.HAVE_YUI = 1

        if conf.options.compiler:
            conf.start_msg ("Checking for closure-compiler")
            if os.path.exists('tools/compiler.jar'):
                conf.end_msg('tools/compiler.jar')
                conf.env.HAVE_COMPILER = 1
            else:
                conf.end_msg('not found','YELLOW')
                Logs.info ("Downloading closure-compiler from %s..." % CLOSURE_COMPILER)
                urllib.urlretrieve (CLOSURE_COMPILER, "build/closure-compiler.zip")

                subprocess.check_call (['unzip', '-qq', '-o', '-j', 'build/closure-compiler.zip', 'compiler.jar', '-d', 'tools/'])
                conf.env.HAVE_COMPILER = 1

    if conf.options.ws:
        conf.env.WS = 1

def build (bld):
    if bld.env['JS']:
        securityLib = ["contrib/securityLib/sha256.js",
                       "contrib/securityLib/base64.js",
                       "contrib/securityLib/rsa.js",
                       "contrib/securityLib/rsa2.js",
                       "contrib/securityLib/rsapem-1.1.js",
                       "contrib/securityLib/rsasign-1.2.js",
                       "contrib/securityLib/asn1hex-1.1.js",
                       "contrib/securityLib/x509-1.1.js",
                       "contrib/securityLib/jsbn.js",
                       "contrib/securityLib/jsbn2.js"]

        ndnjs = ["js/Closure.js",
                 "js/WebSocketTransport.js",
                 "js/util/CCNProtocolDTags.js",
                 "js/util/CCNTime.js",
                 "js/util/ExponentialReExpressClosure.js",
                 "js/Name.js",
                 "js/ContentObject.js",
                 "js/encoding/DateFormat.js",
                 "js/Interest.js",
                 "js/Key.js",
                 "js/PublisherID.js",
                 "js/PublisherPublicKeyDigest.js",
                 "js/FaceInstance.js",
                 "js/ForwardingEntry.js",
                 "js/encoding/DynamicUint8Array.js",
                 "js/encoding/BinaryXMLEncoder.js",
                 "js/encoding/BinaryXMLDecoder.js",
                 "js/encoding/BinaryXMLStructureDecoder.js",
                 "js/encoding/DataUtils.js",
                 "js/encoding/EncodingUtils.js",
                 "js/security/KeyManager.js",
                 "js/security/Witness.js"] + securityLib + ["js/NDN.js"]

        ndnjs = bld (features="combine",
                     target="ndn-js",
                     source=ndnjs,
                     install_path="${JSDIR}")

        if bld.env['HAVE_YUI']:
            ndnjs.yui = True

        if bld.env['HAVE_COMPILER']:
            ndnjs.compiler = True

    if bld.env['WS']:
        bld.install_as ('${BINDIR}/ccnx-wsproxy-tcp.js', 'wsproxy/wsproxy-tcp.js', chmod=Utils.O755)
        bld.install_as ('${BINDIR}/ccnx-wsproxy-udp.js', 'wsproxy/wsproxy-udp.js', chmod=Utils.O755)

@TaskGen.extension('.js')
def js_hook(self, node):
    node.sig=Utils.h_file (node.abspath())

@TaskGen.feature('combine')
@TaskGen.after_method('process_source')
def apply_combine(self):
    out = "%s.js" % self.target
    tasks = []
    task = self.create_task ('combine', self.source)
    task.set_outputs (task.generator.path.find_or_declare (out))
    tasks.append (task)

    if getattr(self, 'yui', False):
        out_yui = "%s.min.yui.js" % self.target
        yui = self.create_task ('yuicompressor')
        yui.combine = task
        yui.set_outputs (yui.generator.path.find_or_declare (out_yui))
        tasks.append (yui)

    if getattr(self, 'compiler', False):
        out_min = "%s.min.js" % self.target
        compiler = self.create_task ('closure_compiler')
        compiler.combine = task
        compiler.set_outputs (compiler.generator.path.find_or_declare (out_min))
        tasks.append (compiler)

    try:
        for task in tasks:
            self.bld.install_files (self.install_path, task.outputs[:], env=self.env)
    except:
        pass

class combine (Task.Task):
    def run(self):
        outFile = self.outputs[0]
        self.outputs[0].write ("", "w") # make file empty
        for inFile in self.inputs:
            self.outputs[0].write (inFile.read (), 'a')

class yuicompressor (Task.Task):
    after="combine"
    color='PINK'
    def __str__(self):
        src_str=self.combine.outputs[0].nice_path()
        tgt_str=self.outputs[0].nice_path()
        return'%s: %s -> %s\n'%(self.__class__.__name__.replace('_task',''),src_str,tgt_str)

    def run(self):
        return self.exec_command(['java',
                                  '-jar', '../tools/yuicompressor.jar',
                                  '-o', self.outputs[0].abspath(),
                                  self.combine.outputs[0].abspath()])

class closure_compiler (Task.Task):
    after="combine"
    color='PINK'
    def __str__(self):
        src_str=self.combine.outputs[0].nice_path()
        tgt_str=self.outputs[0].nice_path()
        return'%s: %s -> %s\n'%(self.__class__.__name__.replace('_task',''),src_str,tgt_str)

    def run(self):
        return self.exec_command(['java',
                                  '-jar', '../tools/compiler.jar',
                                  '--js', self.combine.outputs[0].abspath(),
                                  '--js_output_file', self.outputs[0].abspath()])
