Jason McKesson avatar Jason McKesson committed 0dd7ffe

Improved directory and #include support for extension files.
Added useful extension library files.

Comments (0)

Files changed (10)

 package.path = baseDir .. "modules/?.lua;" .. package.path
 
 --Make a function to get the correct directory name.
-function FixupPath(relativePath)
+function SysRelPath(relativePath)
 	return baseDir .. relativePath
 end
+FixupPath = SysRelPath --Older name.
 
 local opts = require "GetOptions"
 local gen = require "Generate"

extfiles/gl_AMD_3_3.txt

+--ARB extensions implemented on 3.3 hardware by AMD.
+
+ARB_transform_feedback2
+ARB_transform_feedback3
+ARB_texture_buffer_object_rgb32
+ARB_shader_precision
+ARB_draw_buffers_blend

extfiles/gl_core_post_3_3.txt

+--Core extensions frequently provided for 3.3-class hardware, yet aren't part of core 3.3.
+--The extensions were added after 3.3 and there was no 3.4 to drop them into.
+
+ARB_compressed_texture_pixel_storage
+ARB_conservative_depth
+ARB_ES2_compatibility
+ARB_get_program_binary
+ARB_explicit_uniform_location
+ARB_internalformat_query
+ARB_internalformat_query2
+ARB_map_buffer_alignment
+ARB_program_interface_query
+ARB_separate_shader_objects
+ARB_shading_language_420pack
+ARB_shading_language_packing
+ARB_texture_buffer_range
+ARB_texture_storage
+ARB_texture_view
+ARB_vertex_attrib_binding
+ARB_viewport_array
+ARB_arrays_of_arrays
+ARB_clear_buffer_object
+ARB_copy_image
+ARB_ES3_compatibility
+ARB_explicit_uniform_location
+ARB_fragment_layer_viewport
+ARB_framebuffer_no_attachments
+ARB_invalidate_subdata
+ARB_program_interface_query
+ARB_robust_buffer_access_behavior
+ARB_stencil_texturing
+ARB_texture_buffer_range
+ARB_texture_query_levels
+ARB_texture_storage_multisample
+ARB_texture_view
+ARB_vertex_attrib_binding
+KHR_debug

extfiles/gl_plat_3_3.txt

+-- Platform-specific non-core extensions that provide access to hardware features.
+-- These extensions are fairly widely implemented.
+
+NV_texture_barrier 

extfiles/gl_ubiquitous.txt

+--Extensions that are *widely* available and vital for basic functionality.
+--IE: things that should be core, but aren't.
+EXT_texture_compression_s3tc
+EXT_texture_sRGB
+EXT_texture_filter_anisotropic

extfiles/wgl_AMD.txt

+AMD_gpu_association
+

extfiles/wgl_NV.txt

+NV_present_video
+NV_video_output
+NV_gpu_affinity
+NV_video_capture
+NV_copy_image
+NV_multisample_coverage
+NV_DX_interop
+NV_DX_interop2

extfiles/wgl_commonexts.txt

+ARB_multisample
+ARB_extensions_string
+ARB_pixel_format
+ARB_pixel_format_float
+ARB_framebuffer_sRGB
+ARB_create_context
+ARB_create_context_profile
+ARB_create_context_robustness
+EXT_swap_control
+EXT_pixel_format_packed_float
+EXT_create_context_es2_profile
+EXT_swap_control_tear
+NV_swap_group

modules/Generate.lua

 	--Load the spec data.
 	local spec = Specs.GetSpec(options.spec)
 	local specData = spec.LoadSpec()
+	
+	--Verify that every extension in `options.extensions` is a real extension.
+	local badExts = {}
+	for _, extName in ipairs(options.extensions) do
+		if(not specData.extdefs[extName]) then
+			badExts[#badExts + 1] = extName
+		end
+	end
+	
+	if(#badExts > 0) then
+		io.stdout:write("The following extensions are not in the spec ", options.spec, ":\n")
+		for _, extName in ipairs(badExts) do
+			io.stdout:write("\t", extName, "\n")
+		end
+		return
+	end
 
 	--Extract the path and base-filename from the options.
 	local simplename = options.outname:match("([^\\/]+)$")

modules/GetOptions.lua

 parseOpts:enum(
 	"spec",
 	"spec",
-	"Specification to use. One of the following:",
+	"Specification to use.",
 	{"gl", "glX", "wgl"},
 	1)
 parseOpts:value(
 	{"A file to load extensions from.", "Files are always relative to the current directory."},
 	nil,
 	true)
+parseOpts:array_single(
+	"stdext",
+	"stdexts",
+	{"A file to load extensions from.", "These file paths are relative to the distribution directory."},
+	nil,
+	true)
 parseOpts:value(
 	"prefix",
 	"prefix",
 	"outname",
 	"Base filename (sans extension)",
 	"outname")
-	
+
+local extFileLines;
+
 local function LoadExtFile(extensions, extfilename, baseDir)
 	if(baseDir) then
 		extfilename = baseDir .. extfilename
 	local hFile = assert(io.open(extfilename, "rt"), "Could not find the file " .. extfilename)
 	
 	for line in hFile:lines() do
-		local ext = line:match("(%S+)")
-		if(ext) then
-			if(ext == "#include") then
-				local file = line:match('%#include [%"](.+)[%"]')
-				assert(file, "Bad #include statement in extension file " ..
-					extfilename)
-				if(file) then
-					local name, dir = util.ParsePath(file)
-					if(baseDir and dir) then
-						dir = baseDir .. dir
-					elseif(baseDir) then
-						dir = baseDir
-					end
-					
-					file = name
-					
-					LoadExtFile(extensions, file, dir)
-				end
-			else
-				table.insert(extensions, ext)
+		for _, test in ipairs(extFileLines) do
+			local matches = {line:match(test.pttrn)}
+			if(#matches ~= 0) then
+				test.proc(extensions, baseDir, unpack(matches))
+				break
 			end
 		end
 	end
 	hFile:close()
 end
 
+--Function gets the list of extensions, the base directory of the currently
+--processing file, and whatever matches came from the pattern.
+extFileLines =
+{
+	{
+		pttrn = '^%s*%#include [%"](.+)[%"]',
+		proc = function(extensions, basedir, file)
+			local name, dir = util.ParsePath(file)
+			if(baseDir and dir) then
+				dir = baseDir .. dir
+			elseif(baseDir) then
+				dir = baseDir
+			end
+			
+			file = name
+			
+			LoadExtFile(extensions, file, dir)
+		end,
+	},
+	{
+		pttrn = '^%s*%#include [%<](.+)[%>]',
+		proc = function(extensions, basedir, file)
+			local name, dir = util.ParsePath(SysRelPath(file))
+			--Ignore the base directory; we start with the system directory.
+			
+			LoadExtFile(extensions, name, dir)
+		end,
+	},
+	{
+		pttrn = '^%s*%-%-',
+		proc = function(extensions, basedir) --[[Ignore the line. Comment]] end,
+	},
+	{
+		pttrn = '^%s*%/%/',
+		proc = function(extensions, basedir) --[[Ignore the line. Comment]] end,
+	},
+	{
+		pttrn = '(%S+)',
+		proc = function(extensions, basedir, ext)
+			table.insert(extensions, ext)
+		end,
+	},
+}
+
+
 local function FixupExtname(ext)
 	--Cull the (W)GL(X)_ part of the name, if any.
 	
 		LoadExtFile(options.extensions, util.ParsePath(file)) --vararg
 	end
 	
+	--Standard extension files.
+	for _, file in ipairs(options.stdexts) do
+		LoadExtFile(options.extensions, util.ParsePath(SysRelPath(file))) --vararg
+	end
+	
 	--Fixup names and remove duplicates.
 	local dups = {}
 	local exts = {}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.