def packageUrisToJS(packages, version): allUris = [] for packageId, package in enumerate(packages): packageUris = [] if package.file: # build namespace = "__out__" fileId = package.file relpath = OsPath(fileId) shortUri = Uri(relpath.toUri()) entry = "%s:%s" % (namespace, shortUri.encodedValue()) packageUris.append(entry) package.files.append(entry) # TODO: make package.file obsolete elif package.files: # hybrid packageUris = package.files else: # "source" : for clazz in package.classes: namespace = self._classes[clazz].library.namespace relpath = OsPath(self._classes[clazz].relpath) shortUri = Uri(relpath.toUri()) entry = "%s:%s" % (namespace, shortUri.encodedValue()) packageUris.append(entry) package.files.append(entry) # TODO: this should done be elsewhere?! allUris.append(packageUris) return allUris
def _computeResourceUri(self, lib, resourcePath, rType="class", appRoot=None): '''computes a complete resource URI for the given resource type rType, from the information given in lib and, if lib doesn't provide a general uri prefix for it, use appRoot and lib path to construct one''' if 'uri' in lib: libBaseUri = Uri(lib['uri']) elif appRoot: libBaseUri = Uri(Path.rel_from_to(self._config.absPath(appRoot), lib['path'])) else: raise RuntimeError, "Need either lib['uri'] or appRoot, to calculate final URI" #libBaseUri = Uri(libBaseUri.toUri()) if rType in lib: libInternalPath = OsPath(lib[rType]) else: raise RuntimeError, "No such resource type: \"%s\"" % rType # process the second part of the target uri uri = libInternalPath.join(resourcePath) uri = Uri(uri.toUri()) libBaseUri.ensureTrailingSlash() uri = libBaseUri.join(uri) return uri
def packageUrisToJS1(packages, version, namespace=None): # Translate URI data to JavaScript # using Package objects if version == "build" and not namespace: # TODO: gosh, the next is an ugly hack! # all name spaces point to the same paths in the libinfo struct, so any of them will do #namespace = self._resourceHandler._genobj._namespaces[0] namespace = self.getAppName() allUris = [] for packageId, package in enumerate(packages): packageUris = [] if package.file: namespace = "__out__" fileId = package.file relpath = OsPath(fileId) shortUri = Uri(relpath.toUri()) packageUris.append("%s:%s" % (namespace, shortUri.encodedValue())) else: # "source" : for clazz in package.classes: namespace = self._classes[clazz]["namespace"] relpath = OsPath(self._classes[clazz]["relpath"]) shortUri = Uri(relpath.toUri()) packageUris.append("%s:%s" % (namespace, shortUri.encodedValue())) allUris.append(packageUris) return allUris
def generateLibInfoCode(self, libs, format, forceResourceUri=None, forceScriptUri=None): qxlibs = {} for lib in libs: # add library key qxlibs[lib['namespace']] = {} # add resource root URI if forceResourceUri: resUriRoot = forceResourceUri else: resUriRoot = self._computeResourceUri(lib, OsPath(""), rType="resource", appRoot=self.approot) resUriRoot = resUriRoot.encodedValue() qxlibs[lib['namespace']]['resourceUri'] = "%s" % (resUriRoot,) # add code root URI if forceScriptUri: sourceUriRoot = forceScriptUri else: sourceUriRoot = self._computeResourceUri(lib, OsPath(""), rType="class", appRoot=self.approot) sourceUriRoot = sourceUriRoot.encodedValue() qxlibs[lib['namespace']]['sourceUri'] = "%s" % (sourceUriRoot,) # TODO: Add version, svn revision, maybe even authors, but at least homepage link, ... # add version info if 'version' in lib: qxlibs[lib['namespace']]['version'] = "%s" % lib['version'] return qxlibs
def _computeResourceUri(self, lib, resourcePath, rType="class", appRoot=None): if 'uri' in lib: libBaseUri = Uri(lib['uri']) elif appRoot: libBaseUri = Uri(Path.rel_from_to(self._config.absPath(appRoot), lib['path'])) else: raise RuntimeError, "Need either lib['uri'] or appRoot, to calculate final URI" #libBaseUri = Uri(libBaseUri.toUri()) if rType in lib: libInternalPath = OsPath(lib[rType]) else: raise RuntimeError, "No such resource type: \"%s\"" % rType # process the second part of the target uri uri = libInternalPath.join(resourcePath) uri = Uri(uri.toUri()) libBaseUri.ensureTrailingSlash() uri = libBaseUri.join(uri) # strip dangling "/", e.g. when we have no resourcePath uri.ensureNoTrailingSlash() return uri
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
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
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
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
def packageUrisToJS(packages, version): allUris = [] for packageId, package in enumerate(packages): packageUris = [] if package.file: # build namespace = "__out__" fileId = package.file relpath = OsPath(fileId) shortUri = Uri(relpath.toUri()) packageUris.append("%s:%s" % (namespace, shortUri.encodedValue())) else: # "source" : for clazz in package.classes: namespace = self._classes[clazz]["namespace"] relpath = OsPath(self._classes[clazz]["relpath"]) shortUri = Uri(relpath.toUri()) packageUris.append("%s:%s" % (namespace, shortUri.encodedValue())) allUris.append(packageUris) return allUris
def packageUrisToJS1(packages, version, namespace=None): # Translate URI data to JavaScript allUris = [] for packageId, package in enumerate(packages): packageUris = [] for fileId in package: if version == "build": # TODO: gosh, the next is an ugly hack! #namespace = self._resourceHandler._genobj._namespaces[0] # all name spaces point to the same paths in the libinfo struct, so any of them will do if not namespace: namespace = script.namespace # all name spaces point to the same paths in the libinfo struct, so any of them will do relpath = OsPath(fileId) else: namespace = self._classes[fileId]["namespace"] relpath = OsPath(self._classes[fileId]["relpath"]) shortUri = Uri(relpath.toUri()) packageUris.append("%s:%s" % (namespace, shortUri.encodedValue())) allUris.append(packageUris) return allUris
def _computeResourceUri(self, lib_, resourcePath, rType="class", appRoot=None): # i still use dict-type lib representation to create _output_ pseudo-lib if isinstance(lib_, generator.resource.Library.Library): lib = { 'class' : lib_.classPath, 'uri' : lib_.uri, 'path' : lib_.path, 'resource' : lib_.resourcePath, } else: lib = lib_ if 'uri' in lib and lib['uri'] is not None: libBaseUri = Uri(lib['uri']) elif appRoot: libBaseUri = Uri(Path.rel_from_to(self._config.absPath(appRoot), lib['path'])) else: raise RuntimeError, "Need either lib.uri or appRoot, to calculate final URI" #libBaseUri = Uri(libBaseUri.toUri()) if rType in lib: libInternalPath = OsPath(lib[rType]) else: raise RuntimeError, "No such resource type: \"%s\"" % rType # process the second part of the target uri uri = libInternalPath.join(resourcePath) uri = Uri(uri.toUri()) libBaseUri.ensureTrailingSlash() uri = libBaseUri.join(uri) # strip dangling "/", e.g. when we have no resourcePath uri.ensureNoTrailingSlash() return uri
def runCompiled(self, script, treeCompiler, version="build"): def getOutputFile(compileType): filePath = compConf.get("paths/file") if not filePath: filePath = os.path.join(compileType, "script", script.namespace + ".js") return filePath def getFileUri(scriptUri): appfile = os.path.basename(fileRelPath) fileUri = os.path.join(scriptUri, appfile) # make complete with file name fileUri = Path.posifyPath(fileUri) return fileUri ## # returns the Javascript code for the initial ("boot") script as a string, # using the loader.tmpl template and filling its placeholders def generateBootCode(parts, packages, boot, script, compConf, variants, settings, bootCode, globalCodes, version="source", decodeUrisFile=None, format=False): ## # create a map with part names as key and array of package id's and # return as string def partsMap(script): partData = {} packages = script.packagesSortedSimple() #print "packages: %r" % packages for part in script.parts: partData[part] = script.parts[part].packagesAsIndices(packages) #print "part '%s': %r" % (part, script.parts[part].packages) partData = json.dumpsCode(partData) return partData def fillTemplate(vals, template): # Fill the code template with various vals templ = MyTemplate(template) result = templ.safe_substitute(vals) return result def packageUrisToJS1(packages, version, namespace=None): # Translate URI data to JavaScript allUris = [] for packageId, package in enumerate(packages): packageUris = [] for fileId in package: if version == "build": # TODO: gosh, the next is an ugly hack! #namespace = self._resourceHandler._genobj._namespaces[0] # all name spaces point to the same paths in the libinfo struct, so any of them will do if not namespace: namespace = script.namespace # all name spaces point to the same paths in the libinfo struct, so any of them will do relpath = OsPath(fileId) else: namespace = self._classes[fileId]["namespace"] relpath = OsPath(self._classes[fileId]["relpath"]) shortUri = Uri(relpath.toUri()) packageUris.append("%s:%s" % (namespace, shortUri.encodedValue())) allUris.append(packageUris) return allUris ## # Translate URI data to JavaScript # using Package objects def packageUrisToJS(packages, version): allUris = [] for packageId, package in enumerate(packages): packageUris = [] if package.file: # build namespace = "__out__" fileId = package.file relpath = OsPath(fileId) shortUri = Uri(relpath.toUri()) packageUris.append("%s:%s" % (namespace, shortUri.encodedValue())) else: # "source" : for clazz in package.classes: namespace = self._classes[clazz]["namespace"] relpath = OsPath(self._classes[clazz]["relpath"]) shortUri = Uri(relpath.toUri()) packageUris.append("%s:%s" % (namespace, shortUri.encodedValue())) allUris.append(packageUris) return allUris def loadTemplate(bootCode): # try custom loader templates loaderFile = compConf.get("paths/loader-template", None) if not loaderFile: # use default templates if version=="build": #loaderFile = os.path.join(filetool.root(), os.pardir, "data", "generator", "loader-build.tmpl.js") # TODO: test-wise using generic template loaderFile = os.path.join(filetool.root(), os.pardir, "data", "generator", "loader.tmpl.js") else: #loaderFile = os.path.join(filetool.root(), os.pardir, "data", "generator", "loader-source.tmpl.js") loaderFile = os.path.join(filetool.root(), os.pardir, "data", "generator", "loader.tmpl.js") template = filetool.read(loaderFile) return template # --------------------------------------------------------------- if not parts: return "" result = "" vals = {} packages = script.packagesSortedSimple() loader_with_boot = self._job.get("packages/loader-with-boot", True) # stringify data in globalCodes for entry in globalCodes: globalCodes[entry] = json.dumpsCode(globalCodes[entry]) # undo damage done by simplejson to raw strings with escapes \\ -> \ globalCodes[entry] = globalCodes[entry].replace('\\\\\\', '\\').replace(r'\\', '\\') # " gets tripple escaped, therefore the first .replace() vals.update(globalCodes) if version=="build": vals["Resources"] = json.dumpsCode({}) # TODO: undo Resources from globalCodes!!! vals["Boot"] = '"%s"' % boot if version == "build": vals["BootPart"] = bootCode else: vals["BootPart"] = "" # fake package data for key, package in enumerate(packages): vals["BootPart"] += "qx.$$packageData['%d']={};\n" % key # Translate part information to JavaScript vals["Parts"] = partsMap(script) # Translate URI data to JavaScript #vals["Uris"] = packageUrisToJS1(packages, version) vals["Uris"] = packageUrisToJS(packages, version) vals["Uris"] = json.dumpsCode(vals["Uris"]) # Add potential extra scripts vals["UrisBefore"] = [] if self._job.get("add-script", False): additional_scripts = self._job.get("add-script",[]) for additional_script in additional_scripts: vals["UrisBefore"].append(additional_script["uri"]) vals["UrisBefore"] = json.dumpsCode(vals["UrisBefore"]) # Whether boot package is inline if version == "source": vals["BootIsInline"] = json.dumpsCode(False) else: vals["BootIsInline"] = json.dumpsCode(loader_with_boot) # Closure package information cParts = {} if version == "build": for part in script.parts: if not loader_with_boot or part != "boot": cParts[part] = True vals["ClosureParts"] = json.dumpsCode(cParts) # Package Hashes vals["PackageHashes"] = {} for key, package in enumerate(packages): if package.hash: vals["PackageHashes"][key] = package.hash else: vals["PackageHashes"][key] = "%d" % key # fake code package hashes in source ver. vals["PackageHashes"] = json.dumpsCode(vals["PackageHashes"]) # Script hook for qx.$$loader.decodeUris() function vals["DecodeUrisPlug"] = "" if decodeUrisFile: plugCode = filetool.read(self._config.absPath(decodeUrisFile)) # let it bomb if file can't be read vals["DecodeUrisPlug"] = plugCode.strip() # Enable "?nocache=...." for script loading? vals["NoCacheParam"] = "true" if self._job.get("compile-options/uris/add-nocache-param", True) else "false" # Locate and load loader basic script template = loadTemplate(bootCode) # Fill template gives result result = fillTemplate(vals, template) return result ## # shallow layer above generateBootCode(), and its only client def generateBootScript(globalCodes, script, bootPackage="", compileType="build"): self._console.info("Generating boot script...") if not self._job.get("packages/i18n-with-boot", True): # remove I18N info from globalCodes, so they don't go into the loader globalCodes["Translations"] = {} globalCodes["Locales"] = {} else: if compileType == "build": # also remove them here, as this info is now with the packages globalCodes["Translations"] = {} globalCodes["Locales"] = {} plugCodeFile = compConf.get("code/decode-uris-plug", False) if compileType == "build": filepackages = [(x.file,) for x in packages] bootContent = generateBootCode(parts, filepackages, boot, script, compConf, variants, settings, bootPackage, globalCodes, compileType, plugCodeFile, format) else: filepackages = [x.classes for x in packages] bootContent = generateBootCode(parts, filepackages, boot, script, compConf, variants={}, settings={}, bootCode=None, globalCodes=globalCodes, version=compileType, decodeUrisFile=plugCodeFile, format=format) return bootContent def getPackageData(package): data = {} data["resources"] = package.data.resources data["translations"] = package.data.translations data["locales"] = package.data.locales data = json.dumpsCode(data) data += ';\n' return data def compilePackage(packageIndex, package): self._console.info("Compiling package #%s:" % packageIndex, False) self._console.indent() # Compile file content pkgCode = self._treeCompiler.compileClasses(package.classes, variants, optimize, format) pkgData = getPackageData(package) hash = sha.getHash(pkgData + pkgCode)[:12] # first 12 chars should be enough isBootPackage = packageIndex == 0 if isBootPackage: compiledContent = ("qx.$$packageData['%s']=" % hash) + pkgData + pkgCode else: compiledContent = u'''qx.$$packageData['%s']=%s\n''' % (hash, pkgData) compiledContent += u'''qx.Part.$$notifyLoad("%s", function() {\n%s\n});''' % (hash, pkgCode) # package.hash = hash # to fill qx.$$loader.packageHashes in generateBootScript() self._console.debug("Done: %s" % self._computeContentSize(compiledContent)) self._console.outdent() return compiledContent ## # takes an array of (po-data, locale-data) dict pairs # merge all po data and all cldr data in a single dict each def mergeTranslationMaps(transMaps): poData = {} cldrData = {} for pac_dat, loc_dat in transMaps: for loc in pac_dat: if loc not in poData: poData[loc] = {} poData[loc].update(pac_dat[loc]) for loc in loc_dat: if loc not in cldrData: cldrData[loc] = {} cldrData[loc].update(loc_dat[loc]) return (poData, cldrData) # -- Main - runCompiled ------------------------------------------------ # Early return compileType = self._job.get("compile/type", "") if compileType not in ("build", "source"): return packages = script.packagesSortedSimple() parts = script.parts boot = script.boot variants = script.variants libraries = script.libraries self._treeCompiler = treeCompiler self._variants = variants self._script = script self._console.info("Generate %s version..." % compileType) self._console.indent() # - Evaluate job config --------------------- # Compile config compConf = self._job.get("compile-options") compConf = ExtMap(compConf) # Whether the code should be formatted format = compConf.get("code/format", False) script.scriptCompress = compConf.get("paths/gzip", False) # Read in settings settings = self.getSettings() script.settings = settings # Read libraries libs = self._job.get("library", []) # Get translation maps locales = compConf.get("code/locales", []) translationMaps = self.getTranslationMaps(packages, variants, locales) # Read in base file name fileRelPath = getOutputFile(compileType) filePath = self._config.absPath(fileRelPath) script.baseScriptPath = filePath if compileType == "build": # read in uri prefixes scriptUri = compConf.get('uris/script', 'script') scriptUri = Path.posifyPath(scriptUri) fileUri = getFileUri(scriptUri) # for resource list resourceUri = compConf.get('uris/resource', 'resource') resourceUri = Path.posifyPath(resourceUri) else: # source version needs place where the app HTML ("index.html") lives self.approot = self._config.absPath(compConf.get("paths/app-root", "")) resourceUri = None scriptUri = None # Get global script data (like qxlibraries, qxresources,...) globalCodes = {} globalCodes["Settings"] = settings globalCodes["Variants"] = self.generateVariantsCode(variants) globalCodes["Libinfo"] = self.generateLibInfoCode(libs, format, resourceUri, scriptUri) # add synthetic output lib if scriptUri: out_sourceUri= scriptUri else: out_sourceUri = self._computeResourceUri({'class': ".", 'path': os.path.dirname(script.baseScriptPath)}, OsPath(""), rType="class", appRoot=self.approot) out_sourceUri = os.path.normpath(out_sourceUri.encodedValue()) globalCodes["Libinfo"]['__out__'] = { 'sourceUri': out_sourceUri } globalCodes["Resources"] = self.generateResourceInfoCode(script, settings, libraries, format) globalCodes["Translations"],\ globalCodes["Locales"] = mergeTranslationMaps(translationMaps) # Potentally create dedicated I18N packages i18n_as_parts = not self._job.get("packages/i18n-with-boot", True) if i18n_as_parts: script = self.generateI18NParts(script, globalCodes) self.writePackages([p for p in script.packages if getattr(p, "__localeflag", False)], script) if compileType == "build": # - Specific job config --------------------- # read in compiler options optimize = compConf.get("code/optimize", []) self._treeCompiler.setOptimize(optimize) # - Generating packages --------------------- self._console.info("Generating packages...") self._console.indent() bootPackage = "" for packageIndex, package in enumerate(packages): package.compiled = compilePackage(packageIndex, package) self._console.outdent() if not len(packages): raise RuntimeError("No valid boot package generated.") # - Put loader and packages together ------- loader_with_boot = self._job.get("packages/loader-with-boot", True) # handle loader and boot package if not loader_with_boot: loadPackage = Package(0) # make a dummy Package for the loader packages.insert(0, loadPackage) # attach file names (do this before calling generateBootScript) for package, fileName in zip(packages, self.packagesFileNames(script.baseScriptPath, len(packages))): package.file = os.path.basename(fileName) if self._job.get("compile-options/paths/scripts-add-hash", False): package.file = self._fileNameWithHash(package.file, package.hash) # generate and integrate boot code if loader_with_boot: # merge loader code with first package bootCode = generateBootScript(globalCodes, script, packages[0].compiled) packages[0].compiled = bootCode else: loaderCode = generateBootScript(globalCodes, script) packages[0].compiled = loaderCode # write packages self.writePackages(packages, script) # ---- 'source' version ------------------------------------------------ else: sourceContent = generateBootScript(globalCodes, script, bootPackage="", compileType=compileType) # Construct file name resolvedFilePath = self._resolveFileName(filePath, variants, settings) # Save result file filetool.save(resolvedFilePath, sourceContent) if compConf.get("paths/gzip"): filetool.gzip(resolvedFilePath, sourceContent) self._console.outdent() self._console.debug("Done: %s" % self._computeContentSize(sourceContent)) self._console.outdent() self._console.outdent() return # runCompiled()
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