From: Jamie Madill Date: Wed, 4 May 2016 15:17:33 +0000 (-0700) Subject: Add an output directory option to genvk.py. X-Git-Tag: upstream/1.1.92~3170 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=706824fc21202d112e98de3239705a8cffa5914b;p=platform%2Fupstream%2FVulkan-Tools.git Add an output directory option to genvk.py. Currently for the threading utils and parameter checker generator, the script is hard-coded to write to the current directory. Add an option to add a custom output directory. Change-Id: Id1b72a934ead74d2f6c01ad4e581af83067d3f49 --- diff --git a/generator.py b/generator.py index 16d5243..d44bc62 100644 --- a/generator.py +++ b/generator.py @@ -322,7 +322,8 @@ class ThreadGeneratorOptions(GeneratorOptions): apientryp = '', indentFuncProto = True, indentFuncPointer = False, - alignFuncParam = 0): + alignFuncParam = 0, + genDirectory = None): GeneratorOptions.__init__(self, filename, apiname, profile, versions, emitversions, defaultExtensions, addExtensions, removeExtensions, sortProcedure) @@ -338,6 +339,7 @@ class ThreadGeneratorOptions(GeneratorOptions): self.indentFuncProto = indentFuncProto self.indentFuncPointer = indentFuncPointer self.alignFuncParam = alignFuncParam + self.genDirectory = genDirectory # ParamCheckerGeneratorOptions - subclass of GeneratorOptions. @@ -396,7 +398,8 @@ class ParamCheckerGeneratorOptions(GeneratorOptions): apientryp = '', indentFuncProto = True, indentFuncPointer = False, - alignFuncParam = 0): + alignFuncParam = 0, + genDirectory = None): GeneratorOptions.__init__(self, filename, apiname, profile, versions, emitversions, defaultExtensions, addExtensions, removeExtensions, sortProcedure) @@ -412,6 +415,7 @@ class ParamCheckerGeneratorOptions(GeneratorOptions): self.indentFuncProto = indentFuncProto self.indentFuncPointer = indentFuncPointer self.alignFuncParam = alignFuncParam + self.genDirectory = genDirectory # OutputGenerator - base class for generating API interfaces. @@ -561,7 +565,10 @@ class OutputGenerator: # Open specified output file. Not done in constructor since a # Generator can be used without writing to a file. if (self.genOpts.filename != None): - self.outFile = open(self.genOpts.filename, 'w') + if (self.genOpts.genDirectory != None): + self.outFile = open(os.path.join(self.genOpts.genDirectory, self.genOpts.filename), 'w') + else: + self.outFile = open(self.genOpts.filename, 'w') else: self.outFile = sys.stdout def endFile(self): diff --git a/genvk.py b/genvk.py index 5ffd5e4..ad1ff55 100755 --- a/genvk.py +++ b/genvk.py @@ -38,6 +38,7 @@ validate= False errFilename = None diagFilename = 'diag.txt' regFilename = 'vk.xml' +outDir = '.' if __name__ == '__main__': i = 1 @@ -66,6 +67,10 @@ if __name__ == '__main__': elif (arg == '-validate'): write('Enabling group validation (-validate)', file=sys.stderr) validate = True + elif (arg == '-outdir'): + outDir = sys.argv[i] + i = i+1 + write('Using output directory ', outDir, file=sys.stderr) elif (arg[0:1] == '-'): write('Unrecognized argument:', arg, file=sys.stderr) exit(1) @@ -278,7 +283,8 @@ buildList = [ apicall = '', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + genDirectory = outDir) ], [ ParamCheckerOutputGenerator, ParamCheckerGeneratorOptions( @@ -299,7 +305,8 @@ buildList = [ apicall = 'VKAPI_ATTR ', apientry = 'VKAPI_CALL ', apientryp = 'VKAPI_PTR *', - alignFuncParam = 48) + alignFuncParam = 48, + genDirectory = outDir) ], None ] @@ -311,6 +318,11 @@ else: errWarn = sys.stderr diag = open(diagFilename, 'w') +# check that output directory exists +if (not os.path.isdir(outDir)): + write('Output directory does not exist: ', outDir) + raise + def genHeaders(): # Loop over targets, building each generated = 0