예제 #1
0
파일: Logging.py 프로젝트: 1and1/qooxdoo
        def getNodeAttribs(classId, useCompiledSize=False, optimize=[]):
            # return color according to size
            attribs = []
            color = fontsize = None
            sizes = {      # (big-threshold, medium-threshold)
                'compiled' : (8000, 2000),
                'source'   : (20000, 5000)
            }
            compOptions = CompileOptions()
            compOptions.optimize = optimize
            compOptions.variantset = variants
            compOptions.format = True # guess it's most likely
            if classId in script.classesAll:
                if useCompiledSize:
                    fsize = script.classesAll[classId].getCompiledSize(compOptions, featuremap=script._featureMap)
                    mode  = 'compiled'
                else:
                    fsize = script.classesAll[classId].size
                    mode  = 'source'

                if fsize > sizes[mode][0]:
                    color = "red"
                    fontsize = 15
                elif fsize > sizes[mode][1]:
                    color = "green"
                    fontsize = 13
                else:
                    color = "blue"
                    fontsize = 10

            if fontsize:
                attribs.append(("fontsize",fontsize))
            if color:
                attribs.append(("color",color))
            return attribs
예제 #2
0
    def _computePackageSize(self, package, variants, script):
        packageSize = 0
        compOptions = CompileOptions()
        compOptions.optimize = script.optimize
        compOptions.format = True
        compOptions.variantset = variants

        self._console.indent()
        for clazz in package.classes:
            packageSize += clazz.getCompiledSize(compOptions, featuremap=script._featureMap)
        self._console.outdent()

        return packageSize
예제 #3
0
    def _computePackageSize(self, package, variants, script):
        packageSize = 0
        compOptions = CompileOptions()
        compOptions.optimize = script.optimize
        compOptions.format = True
        compOptions.variantset = variants

        self._console.indent()
        for clazz in package.classes:
            packageSize += clazz.getCompiledSize(compOptions, featuremap=script._featureMap)
        self._console.outdent()

        return packageSize
예제 #4
0
 def _compileClassesXX(self, classes, variants, optimize, format_):
     content = []
     length = len(classes)
     compOptions = CompileOptions()
     compOptions.optimize = optimize
     compOptions.format = format_
     compOptions.variantset = variants
     
     for pos, classId in enumerate(classes):
         self._console.progress(pos + 1, length)
         #content.append( self.getCompiled(classId, variants, optimize, format) )
         content.append( self._classes[fileId].getCode(compOptions) )
         
     return u''.join(content)
예제 #5
0
    def _computePackageSize(self, package, variants, script):
        packageSize = 0
        compOptions = CompileOptions()
        compOptions.optimize = script.optimize
        compOptions.format = True
        compOptions.variantset = variants
        classesObj = dict((x.id, x) for x in script.classesObj if x.id in package.classes)

        self._console.indent()
        for classId in package.classes:
            packageSize += classesObj[classId].getCompiledSize(compOptions)
        self._console.outdent()

        return packageSize
예제 #6
0
    def optimizeTree(self, variantSet, scriptClasses, treegen=treegenerator):
        relevantVariants = self.projectClassVariantsToCurrent(self.classVariants(), variantSet)
        cacheId = "tree%s-%s-%s" % (treegen.tag, self.path, util.toString(relevantVariants))
        compOpts = CompileOptions(optimize=["variants"], variants=variantSet)
        compOpts.allClassVariants = scriptClasses

        tree = self.optimizeEnvironmentClass(compOpts)
        ## this is for the side-effect of leaving a modified tree for qx.core.Environmet
        ## in the cache!
        self.context["cache"].write(cacheId, tree, memory=True, writeToFile=False)
        ## this is for the side-effect of re-calculating the transitive dependencies
        ## of qx.core.Environment!
        _ = self.dependencies(variantSet, force=True)
        return
예제 #7
0
파일: qcEnvClass.py 프로젝트: w495/acv
    def optimizeTree(self, variantSet, scriptClasses, treegen=treegenerator):
        relevantVariants = self.projectClassVariantsToCurrent(
            self.classVariants(), variantSet)
        cacheId = "tree%s-%s-%s" % (treegen.tag, self.path,
                                    util.toString(relevantVariants))
        compOpts = CompileOptions(optimize=["variants"], variants=variantSet)
        compOpts.allClassVariants = scriptClasses

        tree = self.optimizeEnvironmentClass(compOpts)
        ## this is for the side-effect of leaving a modified tree for qx.core.Environmet
        ## in the cache!
        self.context['cache'].write(cacheId,
                                    tree,
                                    memory=True,
                                    writeToFile=False)
        ## this is for the side-effect of re-calculating the transitive dependencies
        ## of qx.core.Environment!
        _ = self.dependencies(variantSet, force=True)
        return
예제 #8
0
        def compileAndWritePackage(package, compConf):
            def compiledFilename(compiled):
                hash_ = sha.getHash(compiled)[:12]
                fname = self._fileNameWithHash(script.baseScriptPath, hash_)
                return fname

            def compileAndAdd(compiledClasses, packageUris):
                compiled = compileClasses(compiledClasses, compOptions)
                filename = compiledFilename(compiled)
                self.writePackage(compiled, filename, script)
                filename = OsPath(os.path.basename(filename))
                shortUri = Uri(filename.toUri())
                packageUris.append("%s:%s" %
                                   ("__out__", shortUri.encodedValue()))

                return packageUris

            # ------------------------------------
            packageUris = []
            compiledClasses = []
            optimize = compConf.get("code/optimize", [])
            sourceFilter = ClassMatchList(compConf.get("code/except", []))
            compOptions = CompileOptions(optimize=optimize)

            ##
            # This somewhat overlaps with packageUrisToJS
            package_classes = [
                y for x in package.classes for y in script.classesObj
                if y.id == x
            ]  # TODO: i need to make package.classes [Class]!
            for clazz in package_classes:
                if sourceFilter.match(clazz.id):
                    if compiledClasses:
                        # treat compiled classes so far
                        packageUris = compileAndAdd(compiledClasses,
                                                    packageUris)
                        compiledClasses = []  # reset the collection
                    # for a source class, just include the file uri
                    clazzRelpath = clazz.id.replace(".", "/") + ".js"
                    relpath = OsPath(clazzRelpath)
                    shortUri = Uri(relpath.toUri())
                    packageUris.append(
                        "%s:%s" %
                        (clazz.library.namespace, shortUri.encodedValue()))
                else:
                    compiledClasses.append(clazz)
            else:
                # treat remaining to-be-compiled classes
                if compiledClasses:
                    packageUris = compileAndAdd(compiledClasses, packageUris)

            package.files = packageUris

            return package
예제 #9
0
        def getNodeAttribs(classId, useCompiledSize=False, optimize=[]):
            # return color according to size
            attribs = []
            color = fontsize = None
            sizes = {  # (big-threshold, medium-threshold)
                'compiled': (8000, 2000),
                'source': (20000, 5000)
            }
            compOptions = CompileOptions()
            compOptions.optimize = optimize
            compOptions.variantset = variants
            compOptions.format = True  # guess it's most likely
            if classId in script.classesAll:
                if useCompiledSize:
                    fsize = script.classesAll[classId].getCompiledSize(
                        compOptions, featuremap=script._featureMap)
                    mode = 'compiled'
                else:
                    fsize = script.classesAll[classId].size
                    mode = 'source'

                if fsize > sizes[mode][0]:
                    color = "red"
                    fontsize = 15
                elif fsize > sizes[mode][1]:
                    color = "green"
                    fontsize = 13
                else:
                    color = "blue"
                    fontsize = 10

            if fontsize:
                attribs.append(("fontsize", fontsize))
            if color:
                attribs.append(("color", color))
            return attribs
예제 #10
0
def _handleCode(script, generator):

    approot = context.jobconf.get("provider/app-root", "./provider")
    builds = context.jobconf.get("provider/compile", ["source"])

    for buildtype in builds:
        context.console.info("Processing %s version of classes:\t" % buildtype,
                             False)
        if buildtype == "source":
            targetdir = approot + "/code"
            filetool.directory(targetdir)
        elif buildtype == "build":
            targetdir = approot + "/code-build"
            filetool.directory(targetdir)
            optimize = context.jobconf.get(
                "compile-options/code/optimize",
                ["variables", "basecalls", "strings"])
            variantsettings = context.jobconf.get("variants", {})
            variantSets = util.computeCombinations(variantsettings)
        else:
            raise ConfigurationError("Unknown provider compile type '%s'" %
                                     buildtype)

        numClasses = len(script.classesObj)
        for num, clazz in enumerate(script.classesObj):
            context.console.progress(num + 1, numClasses)
            # register library (for _handleResources)
            if clazz.library.namespace not in libraries:
                libraries[clazz.library.namespace] = clazz.library

            if passesOutputfilter(clazz.id, ):
                classAId = clazz.id.replace(".", "/") + ".js"
                targetpath = targetdir + "/" + classAId
                filetool.directory(os.path.dirname(targetpath))
                if buildtype == "source":
                    shutil.copy(clazz.path, targetpath)
                elif buildtype == "build":
                    compOptions = CompileOptions(
                        optimize, variantSets[0]
                    )  # only support for a single variant set!
                    code = clazz.getCode(compOptions)
                    filetool.save(targetpath, code)

    return
예제 #11
0
                for item in includeWithDeps:
                    depsItem = DependencyItem(item, '', '|config|')
                    # calculate dependencies and add required classes
                    classlistFromClassRecursive(depsItem, excludeWithDeps, variants, result, warn_deps, [], allowBlockLoaddeps)
                    #classlistFromClassIterative(depsItem, excludeWithDeps, variants, result, warn_deps, [], allowBlockLoaddeps)

                self._console.dotclear()
                #print len(result),"  ",

                # process qx.core.Environment
                if ("qx.core.Environment" in resultNames 
                    and "variants" in script.optimize
                    and not processedEnvironment):
                    envObj = self._classesObj["qx.core.Environment"]
                    envTreeId = "tree-%s-%s" % (envObj.path, util.toString({})) # TODO: {} is a temp. hack
                    compOpts = CompileOptions(optimize=[], variants=variants)
                    compOpts.allClassVariants = script.classVariants([self._classesObj[x] for x in resultNames])
                    tree = Class.optimizeEnvironmentClass(envObj, compOpts)
                    self._cache.write(envTreeId, tree, memory=True, writeToFile=False)
                    # this is for the side-effect of leaving a modified tree for qx.core.Environmet
                    # in the cache!
                    _ = envObj.dependencies(variants, force=True)
                    # this is for the side-effect of re-calculating the transitive dependencies
                    # of qx.core.Environment!
                    processedEnvironment = True
                else:
                    # We currently know that one additional iteration is enough,
                    # after optimizeEnvironmentClass() has run. This has to do
                    # with the fact that it only removes dependencies to
                    # qx.bom.client.* classes, which in turn do not use
                    # qx.core.Env calls. So after calculating the new class
예제 #12
0
        def compileAndWritePackage(package, compConf, allClassVariants):

            def compiledFilename(compiled):
                hash_ = sha.getHash(compiled)[:12]
                fname = self._resolveFileName(script.baseScriptPath, script.variants, {}, "")
                fname = self._fileNameWithHash(fname, hash_)
                return fname

            def compileAndAdd(compiledClasses, packageUris, prelude='', wrap=''):
                compiled = compileClasses(compiledClasses, compOptions, log_progress)
                if wrap:
                    compiled = wrap % compiled
                if prelude:
                    compiled = prelude + compiled
                filename = compiledFilename(compiled)
                self.writePackage(compiled, filename, script)
                filename = OsPath(os.path.basename(filename))
                shortUri = Uri(filename.toUri())
                entry = "%s:%s" % ("__out__", shortUri.encodedValue())
                packageUris.append(entry)

                return packageUris

            # ------------------------------------
            packageUris = []
            optimize = compConf.get("code/optimize", [])
            format_   = compConf.get("code/format", False)
            variantSet= script.variants
            sourceFilter = ClassMatchList(compConf.get("code/except", []))
            compOptions  = CompileOptions(optimize=optimize, variants=variantSet, _format=format_)
            compOptions.allClassVariants = allClassVariants

            ##
            # This somewhat overlaps with packageUrisToJS
            compiledClasses = []
            packageData = getPackageData(package)
            packageData = ("qx.$$packageData['%s']=" % package.id) + packageData
            package_classes = [y for x in package.classes for y in script.classesObj if y.id == x] # TODO: i need to make package.classes [Class]!

            #self._console.info("Package #%s:" % package.id, feed=False)
            len_pack_classes = len(package_classes)
            # helper log function, to log progress here, but also in compileClasses()
            def log_progress(c=[0]):
                c[0]+=1
                #self._console.progress(c[0],len_pack_classes)
                self._console.dot()

            for pos,clazz in enumerate(package_classes):
                if sourceFilter.match(clazz.id):
                    package.has_source = True
                    if packageData or compiledClasses:
                        # treat compiled classes so far
                        packageUris = compileAndAdd(compiledClasses, packageUris, packageData)
                        compiledClasses = []  # reset the collection
                        packageData = ""
                    # for a source class, just include the file uri
                    clazzRelpath = clazz.id.replace(".", "/") + ".js"
                    relpath  = OsPath(clazzRelpath)
                    shortUri = Uri(relpath.toUri())
                    entry    = "%s:%s" % (clazz.library.namespace, shortUri.encodedValue())
                    packageUris.append(entry)
                    log_progress()
                else:
                    compiledClasses.append(clazz)
            else:
                # treat remaining to-be-compiled classes
                if compiledClasses:
                    closureWrap = ''
                    if isClosurePackage(package, bootPackageId(script)):
                        closureWrap = u'''qx.Part.$$notifyLoad("%s", function() {\n%%s\n});''' % package.id
                    packageUris = compileAndAdd(compiledClasses, packageUris, packageData, closureWrap)

            package.files = packageUris
            return package