def genExtDepArray(extDepsName, extDepsDict):
yield 'static const std::pair<const char*, const char*>\t%s[]\t=' % extDepsName
yield '{'
- for ext in sorted(extDepsDict.iterkeys()):
+ for ext in sorted(extDepsDict.keys()):
for dep in extDepsDict[ext]:
yield '\tstd::make_pair("%s", "%s"),' % (ext, dep)
yield '};'
allExtDepsDict[VK_DEV_EXT_DEP_1_0] = {}
allExtDepsDict[VK_DEV_EXT_DEP_1_1] = {}
- for ext, info in extInfoDict.iteritems():
+ for ext, info in extInfoDict.items():
if info.deps == None:
continue
self.arraySize = arraySize
def contains(self, big, small):
- for i in xrange(len(big)-len(small)+1):
- for j in xrange(len(small)):
+ for i in range(len(big)-len(small)+1):
+ for j in range(len(small)):
if big[i+j] != small[j]:
break
else:
self.extensions = extensions
def readFile (filename):
- with open(filename, 'rb') as f:
+ with open(filename, 'rt') as f:
return f.read()
IDENT_PTRN = r'[a-zA-Z_][a-zA-Z0-9_]*'
import sys
import shutil
-from common import *
-from config import *
+from . common import *
+from . config import *
def initBuildDir (config, generator):
cfgArgs = []
try:
initBuildDir(config, generator)
except Exception as e:
- print e
- print "WARNING: Using existing build directory failed; re-creating build directory"
+ print(e)
+ print("WARNING: Using existing build directory failed; re-creating build directory")
shutil.rmtree(config.buildDir)
initBuildDir(config, generator)
else:
raise Exception("Failed to execute '%s', got %d" % (str(args), retcode))
def readFile (filename):
- f = open(filename, 'rb')
+ f = open(filename, 'rt')
data = f.read()
f.close()
return data
def writeFile (filename, data):
- f = open(filename, 'wb')
+ f = open(filename, 'wt')
f.write(data)
f.close()
import copy
import multiprocessing
-from common import which, HostInfo, DEQP_DIR
+from . common import which, HostInfo, DEQP_DIR
try:
- import _winreg
+ if sys.version_info < (3, 0):
+ import _winreg
+ else:
+ import winreg
+ _winreg = winreg
except:
_winreg = None
modules = getBuiltModules(buildCfg)
for module in modules:
- print "Generating test case list for %s" % module.name
+ print("Generating test case list for %s" % module.name)
genAndCopyCaseList(buildCfg, generator, module, args.dst, args.caseListType)
def writeFileIfChanged (filename, data):
if not os.path.exists(filename) or readFile(filename) != data:
- f = open(filename, 'wb')
+ f = open(filename, 'wt')
f.write(data)
f.close()
text += "\n"
writeFileIfChanged(filename, text)
- print filename
+ print(filename)
def writeInlFile (filename, header, source):
writeLines(filename, chain([header], source))
name, api, alias = (item.get(attrib) for attrib in ['name', 'api', 'alias'])
return [(name, api)] + ([(alias, api)] if alias is not None else [])
- def duplicateKey(self, (name, api), item):
+ def duplicateKey(self, nameapipair, item):
+ (name, api) = nameapipair
if name == item.get('alias'):
warnElem(item, "Alias already present: %s", name)
else:
self.apis = {}
for eFeature in self.features:
self.apis.setdefault(eFeature.get('api'), []).append(eFeature)
- for apiFeatures in self.apis.itervalues():
+ for apiFeatures in self.apis.values():
apiFeatures.sort(key=lambda eFeature: eFeature.get('number'))
self.extensions = ElemNameIndex(eRegistry.findall('extensions/extension'))
self.element = eRegistry
ptype=extractPtype(eProto),
group=extractGroup(eProto),
alias=extractAlias(eCmd),
- params=NameIndex(map(parseParam, eCmd.findall('param'))))
+ params=NameIndex(list(map(parseParam, eCmd.findall('param')))))
def createGroup(name):
info('Add group %s', name)
return NameIndex(sorted(items, key=lambda item: item.location))
groups = NameIndex(createMissing=createGroup, kind="group")
- types = NameIndex(map(createType, spec.types),
+ types = NameIndex(list(map(createType, spec.types)),
createMissing=createType, kind="type")
- enums = NameIndex(map(createEnum, spec.enums),
+ enums = NameIndex(list(map(createEnum, spec.enums)),
createMissing=Enum, kind="enum")
- commands = NameIndex(map(createCommand, spec.commands),
+ commands = NameIndex(list(map(createCommand, spec.commands)),
createMissing=Command, kind="command")
versions = sorted(spec.versions)
import os
import sys
-import urllib2
import hashlib
-import registry
+from . import registry
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
return self.filename
def computeChecksum (data):
- return hashlib.sha256(data).hexdigest()
+ return hashlib.sha256(data.replace('\r','').encode("utf-8")).hexdigest()
def makeSourceUrl (repository, revision, filename):
return "%s/%s/%s" % (repository, revision, filename)
popWorkingDir()
def checkoutFile (repository, revision, filename, cacheDir):
+ if sys.version_info < (3, 0):
+ from urllib2 import urlopen
+ else:
+ from urllib.request import urlopen
+
try:
- req = urllib2.urlopen(makeSourceUrl(repository, revision, filename))
+ req = urlopen(makeSourceUrl(repository, revision, filename))
data = req.read()
except IOError:
fullDstPath = os.path.join(cacheDir, "git")
checkoutGit(repository, revision, fullDstPath)
- f = open(os.path.join(fullDstPath, filename), "r")
+ f = open(os.path.join(fullDstPath, filename), "rt")
data = f.read()
f.close()
except:
- print "Unexpected error:", sys.exc_info()[0]
+ print(("Unexpected error:", sys.exc_info()[0]))
return data
def fetchFile (dstPath, repository, revision, filename, checksum, cacheDir):
def writeFile (filename, data):
- f = open(filename, 'wb')
+ f = open(filename, 'wt')
f.write(data)
f.close()
if not os.path.exists(os.path.dirname(dstPath)):
os.makedirs(os.path.dirname(dstPath))
- print "Fetching %s/%s@%s" % (repository, filename, revision)
+ print(("Fetching %s/%s@%s" % (repository, filename, revision)))
data = checkoutFile(repository, revision, filename, cacheDir)
gotChecksum = computeChecksum(data)
def checkFile (filename, checksum):
def readFile (filename):
- f = open(filename, 'rb')
+ f = open(filename, 'rt')
data = f.read()
f.close()
return data
def readCaseList (filename):
cases = []
- with open(filename, 'rb') as f:
+ with open(filename, 'rt') as f:
for line in f:
if line[:6] == "TEST: ":
cases.append(line[6:].strip())
def readPatternList (filename):
ptrns = []
- with open(filename, 'rb') as f:
+ with open(filename, 'rt') as f:
for line in f:
line = line.strip()
if len(line) > 0 and line[0] != '#':
curList = [c for c in curList if c not in matched]
for pattern, reason in errors:
- print "ERROR: %s: %s" % (reason, pattern)
+ print("ERROR: %s: %s" % (reason, pattern))
if len(errors) > 0:
die("Found %s invalid patterns while processing file %s" % (len(errors), filename))
return configElement
def genMustpass (mustpass, moduleCaseLists):
- print "Generating mustpass '%s'" % mustpass.version
+ print("Generating mustpass '%s'" % mustpass.version)
patternLists = readPatternLists(mustpass)
filtered = applyFilters(allCasesInPkg, patternLists, config.filters)
dstFile = getDstCaseListPath(mustpass, package, config)
- print " Writing deqp caselist: " + dstFile
+ print(" Writing deqp caselist: " + dstFile)
writeFile(dstFile, "\n".join(filtered) + "\n")
specXML = genSpecXML(mustpass)
specFilename = os.path.join(mustpass.project.path, mustpass.version, "mustpass.xml")
- print " Writing spec: " + specFilename
- writeFile(specFilename, prettifyXML(specXML))
+ print(" Writing spec: " + specFilename)
+ writeFile(specFilename, prettifyXML(specXML).decode())
# TODO: Which is the best selector mechanism?
if (mustpass.version == "master"):
androidTestXML = genAndroidTestXml(mustpass)
androidTestFilename = os.path.join(mustpass.project.path, "AndroidTest.xml")
- print " Writing AndroidTest.xml: " + androidTestFilename
- writeFile(androidTestFilename, prettifyXML(androidTestXML))
+ print(" Writing AndroidTest.xml: " + androidTestFilename)
+ writeFile(androidTestFilename, prettifyXML(androidTestXML).decode())
- print "Done!"
+ print("Done!")
def genMustpassLists (mustpassLists, generator, buildCfg):
moduleCaseLists = {}