[Mesa-dev] [PATCH 07/15] main: Add -o option to es_generator.py

Chad Versace chad at chad-versace.us
Thu Aug 4 02:47:16 PDT 2011


The -o option specifies the output file.

This is to pacify the Android build system, whose built-in rules for
generated files become grumpy when shell redirection is used.

Note: This is in preparation for porting i965 to Android.
CC: Chia-I Wu <olv at lunarg.com>,
CC: Chih-Wei Huang <cwhuang at android-x86.org>
Signed-off-by: Chad Versace <chad at chad-versace.us>
---
 src/mesa/main/es_generator.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/es_generator.py b/src/mesa/main/es_generator.py
index c0b0a44..21f59b4 100644
--- a/src/mesa/main/es_generator.py
+++ b/src/mesa/main/es_generator.py
@@ -125,10 +125,11 @@ program = os.path.basename(sys.argv[0])
 verbose = 0
 functionList = "APIspec.xml"
 version = "GLES1.1"
+outputFile = None
 
 # Allow for command-line switches
 import getopt, time
-options = "hvV:S:"
+options = "hvV:S:o:"
 try:
     optlist, args = getopt.getopt(sys.argv[1:], options)
 except getopt.GetoptError, message:
@@ -145,6 +146,7 @@ for option, optarg in optlist:
         for key in VersionSpecificValues.keys():
             sys.stderr.write("    %s - %s\n" % (key, VersionSpecificValues[key]['description']))
         sys.stderr.write("-S specifies API specification file to use [%s]\n" % functionList)
+        sys.stderr.write("-o specifies output file [%s]\n")
         sys.exit(1)
     elif option == "-v":
         verbose += 1
@@ -152,6 +154,8 @@ for option, optarg in optlist:
         version = optarg
     elif option == "-S":
         functionList = optarg
+    elif option == "-o":
+        outputFile = optarg
 
 # Beyond switches, we support no further command-line arguments
 if len(args) >  0:
@@ -168,6 +172,10 @@ versionHeader = VersionSpecificValues[version]['header']
 versionExtHeader = VersionSpecificValues[version]['extheader']
 shortname = VersionSpecificValues[version]['shortname']
 
+# Redirect output if option -o was given.
+if outputFile is not None:
+    sys.stdout = open(outputFile, 'w')
+
 # If we get to here, we're good to go.  The "version" parameter
 # directs GetDispatchedFunctions to only allow functions from
 # that "category" (version in our parlance).  This allows 
-- 
1.7.6



More information about the mesa-dev mailing list