]> git.tdb.fi Git - libs/gl.git/blobdiff - scripts/extgen.py
Don't crash if an explicitly specified backport extension is not found
[libs/gl.git] / scripts / extgen.py
index 8d7bfcb1ec1e91c663b33b8aaeec2115b340e05f..c7c06b2c07c115a11bf6986f8f52d2761ef87999 100755 (executable)
@@ -375,10 +375,11 @@ if backport_ext:
        if backport_ext=="none":
                backport_ext = None
        else:
-               backport_ext = extensions[backport_ext]
+               bpe_name = backport_ext
+               backport_ext = extensions.get(backport_ext)
 
                if backport_ext not in backport_ext_candidates:
-                       print "Warning: explicitly specified backport extension %s does not look like a backport extension"
+                       print "Warning: explicitly specified backport extension %s does not look like a backport extension"%bpe_name
 elif backport_ext_candidates:
        if len(backport_ext_candidates)>1:
                print "Warning: multiple backport extension candidates: %s"%(" ".join(e.name for e in backport_ext_candidates))
@@ -518,6 +519,7 @@ for f in funcs:
 out.write("\nExtension::SupportLevel init_%s()\n{\n"%target_ext.name.lower())
 if core_version:
        out.write("\tif(is_disabled(\"GL_%s\"))\n\t\treturn Extension::UNSUPPORTED;\n"%target_ext.name)
+       out.write("#if !defined(__APPLE__) || defined(GL_VERSION_%d_%d)\n"%tuple(core_version))
        out.write("\tif(")
        if backport_ext:
                out.write("is_supported(\"GL_%s\") || "%backport_ext.name)
@@ -533,7 +535,9 @@ if core_version:
                        out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS%s(%s));\n"%(f.name, f.typedef, gpa_suffix, f.name))
        out.write("\t\treturn Extension::CORE;\n")
        out.write("\t}\n")
+       out.write("#endif\n")
 if source_ext and source_ext!=backport_ext:
+       out.write("#if !defined(__APPLE__) || defined(GL_%s)\n"%target_ext.name)
        out.write("\tif(is_supported(\"GL_%s\"))\n\t{\n"%(source_ext.name))
        for f in funcs:
                if f.sources:
@@ -553,6 +557,7 @@ if source_ext and source_ext!=backport_ext:
                        out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS(%s));\n"%(f.name, f.typedef, src.name))
        out.write("\t\treturn Extension::EXTENSION;\n")
        out.write("\t}\n")
+       out.write("#endif\n")
 out.write("\treturn Extension::UNSUPPORTED;\n")
 out.write("}\n")