vk/glsl: Reject invalid options
authorChad Versace <chad.versace@intel.com>
Wed, 27 May 2015 23:14:26 +0000 (16:14 -0700)
committerChad Versace <chad.versace@intel.com>
Wed, 27 May 2015 23:14:26 +0000 (16:14 -0700)
The script incorrectly interpreted --blah as the input filename.

src/vulkan/glsl_scraper.py

index c2f0495d4bcec53a9fadfd77e413835b9b54c95c..c213f702b18aa3985dc8aa0395eea52a3e1b2ad7 100644 (file)
@@ -26,6 +26,11 @@ def print_usage(err):
          --with-glslang=PATH  Full path to the glslangValidator program"""))
    exit(err)
 
+def usage_error(msg):
+   print('usage error: {}'.format(msg))
+   print('')
+   print_usage(1)
+
 class Shader:
    def __init__(self, stage):
       self.stream = cStringIO.StringIO()
@@ -217,6 +222,8 @@ while arg_idx < len(sys.argv):
       glslang = sys.argv[arg_idx][len('--with-glslang='):]
    elif sys.argv[arg_idx] == '--glsl-only':
       glsl_only = True;
+   elif sys.argv[arg_idx].startswith('-'):
+      usage_error('unknown option {!r}'.format(sys.argv[arg_idx]))
    else:
       infname = sys.argv[arg_idx]
       break