Combine extinst-name and extinst-output-base into one arg. (#3200)

* Combine the extinst-name and extinst-output-base into one arg.

Some build systems such as Android blueprints require that the inputs
and outputs of generator scripts are all provided as arguments.  These
two arguments to generate_language_headers.py are combined to form the
output path in the script.  This change simply lets the user provide the
whole output path as an argument.

* Fix typo in build_defs.bzl and update Android.mk
diff --git a/Android.mk b/Android.mk
index 4fab1ec..db4f43b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -235,9 +235,8 @@
         $(LOCAL_PATH)/utils/generate_language_headers.py \
         $(3)
 		@$(HOST_PYTHON) $(LOCAL_PATH)/utils/generate_language_headers.py \
-		    --extinst-name=$(2) \
 		    --extinst-grammar=$(3) \
-		    --extinst-output-base=$(1)/$(2)
+		    --extinst-output-path=$(1)/$(2).h
 		@echo "[$(TARGET_ARCH_ABI)] Generate language specific header for $(2): headers <= grammar"
 $(foreach F,$(SPVTOOLS_SRC_FILES) $(SPVTOOLS_OPT_SRC_FILES),$(LOCAL_PATH)/$F ) \
 	: $(1)/$(2).h
diff --git a/BUILD.gn b/BUILD.gn
index b7cde34..1337059 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -186,21 +186,19 @@
     script = "utils/generate_language_headers.py"
 
     name = invoker.name
-    extinst_output_base = "${target_gen_dir}/${name}"
+    extinst_output_path = "${target_gen_dir}/${name}.h"
 
     args = [
-      "--extinst-name",
-      "${name}",
       "--extinst-grammar",
       rebase_path(invoker.grammar_file, root_build_dir),
-      "--extinst-output-base",
-      rebase_path(extinst_output_base, root_build_dir),
+      "--extinst-output-path",
+      rebase_path(extinst_output_path, root_build_dir),
     ]
     inputs = [
       invoker.grammar_file,
     ]
     outputs = [
-      "${extinst_output_base}.h",
+      "${extinst_output_path}",
     ]
   }
 }
diff --git a/build_defs.bzl b/build_defs.bzl
index 5d913a1..15b70c7 100644
--- a/build_defs.bzl
+++ b/build_defs.bzl
@@ -167,16 +167,16 @@
 def generate_extinst_lang_headers(name, grammar = None):
     if not grammar:
         fail("Must specify grammar", "grammar")
-    fmtargs = [name]
+    outs = [name + ".h"]
+    fmtargs = outs
     native.genrule(
         name = "gen_extinst_lang_headers_" + name,
         srcs = [grammar],
-        outs = [name + ".h"],
+        outs = outs,
         cmd = (
             "$(location :generate_language_headers) " +
-            "--extinst-name={0} " +
             "--extinst-grammar=$< " +
-            "--extinst-output-base=$(@D)/{0}"
+            "--extinst-output-path=$(location {0})"
         ).format(*fmtargs),
         tools = [":generate_language_headers"],
         visibility = ["//visibility:private"],
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 4e7e10c..708ca84 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -126,13 +126,11 @@
 endmacro(spvtools_vendor_tables)
 
 macro(spvtools_extinst_lang_headers NAME GRAMMAR_FILE)
-  set(OUTBASE ${spirv-tools_BINARY_DIR}/${NAME})
-  set(OUT_H ${OUTBASE}.h)
+  set(OUT_H ${spirv-tools_BINARY_DIR}/${NAME}.h)
   add_custom_command(OUTPUT ${OUT_H}
     COMMAND ${PYTHON_EXECUTABLE} ${LANG_HEADER_PROCESSING_SCRIPT}
-      --extinst-name=${NAME}
       --extinst-grammar=${GRAMMAR_FILE}
-      --extinst-output-base=${OUTBASE}
+      --extinst-output-path=${OUT_H}
     DEPENDS ${LANG_HEADER_PROCESSING_SCRIPT} ${GRAMMAR_FILE}
     COMMENT "Generate language specific header for ${NAME}.")
   add_custom_target(spirv-tools-header-${NAME} DEPENDS ${OUT_H})
diff --git a/utils/generate_language_headers.py b/utils/generate_language_headers.py
index 0296163..83fa99e 100755
--- a/utils/generate_language_headers.py
+++ b/utils/generate_language_headers.py
@@ -159,27 +159,25 @@
     import argparse
     parser = argparse.ArgumentParser(description='Generate language headers from a JSON grammar')
 
-    parser.add_argument('--extinst-name',
-                        type=str, required=True,
-                        help='The name to use in tokens')
     parser.add_argument('--extinst-grammar', metavar='<path>',
                         type=str, required=True,
                         help='input JSON grammar file for extended instruction set')
-    parser.add_argument('--extinst-output-base', metavar='<path>',
+    parser.add_argument('--extinst-output-path', metavar='<path>',
                         type=str, required=True,
-                        help='Basename of the language-specific output file.')
+                        help='Path of the language-specific output file.')
     args = parser.parse_args()
 
     with open(args.extinst_grammar) as json_file:
         grammar_json = json.loads(json_file.read())
-        grammar = ExtInstGrammar(name = args.extinst_name,
+        grammar_name = os.path.splitext(os.path.basename(args.extinst_output_path))[0]
+        grammar = ExtInstGrammar(name = grammar_name,
                                  copyright = grammar_json['copyright'],
                                  instructions = grammar_json['instructions'],
                                  operand_kinds = grammar_json['operand_kinds'],
                                  version = grammar_json['version'],
                                  revision = grammar_json['revision'])
-        make_path_to_file(args.extinst_output_base)
-        with open(args.extinst_output_base + '.h', 'w') as f:
+        make_path_to_file(args.extinst_output_path)
+        with open(args.extinst_output_path, 'w') as f:
             f.write(CGenerator().generate(grammar))