diff options
| author | Jamie Madill <jmadill@chromium.org> | 2016-05-04 08:17:33 -0700 |
|---|---|---|
| committer | Dustin Graves <dustin@lunarg.com> | 2016-05-05 11:30:31 -0600 |
| commit | 706824fc21202d112e98de3239705a8cffa5914b (patch) | |
| tree | 44859338afb637d9cd573ecf27afa3b992da78b6 | |
| parent | a52c492233432111f5769c03c53cbb213b3cccce (diff) | |
| download | usermoji-706824fc21202d112e98de3239705a8cffa5914b.tar.xz | |
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
| -rw-r--r-- | generator.py | 13 | ||||
| -rwxr-xr-x | genvk.py | 16 |
2 files changed, 24 insertions, 5 deletions
diff --git a/generator.py b/generator.py index 16d52435..d44bc621 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): @@ -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 |
