Jason McKesson avatar Jason McKesson committed ef61e4c

Added a tool to generate a file containing all extensions for a particular spec.

Comments (0)

Files changed (1)

+assert(arg and arg[0], "You ran this script incorrectly.")
+
+--Get the location of our modules relative to here.
+local baseDir = arg[0]:match("^(.*[\\/])")
+baseDir = baseDir or "./"
+assert(baseDir, arg[0] .. " No directory")
+
+--Fixup the package path to be relative to this directory.
+package.path = baseDir .. "modules/?.lua;" .. package.path
+
+--Make a function to get the correct directory name.
+function SysRelPath(relativePath)
+	return baseDir .. relativePath
+end
+FixupPath = SysRelPath --Older name.
+
+local cmd = require "CmdLineOptions"
+local Specs = require "Specs"
+
+local parseOpts = cmd.CreateOptionGroup()
+parseOpts:enum(
+	"spec",
+	"spec",
+	"Specification to use.",
+	{"gl", "glX", "wgl"})
+parseOpts:pos_opt(
+	1,
+	"outname",
+	"Output filename to generate.",
+	"outname")
+
+local options, pos_args = parseOpts:ProcessCmdLine(arg)
+
+local dups = {}
+local exts = {}
+
+local spec = Specs.GetSpec(options.spec)
+local specData = spec.LoadSpec()
+
+local coreExts = spec.GetCoreExts()
+
+for _, version in ipairs(spec.GetVersions()) do
+	if(coreExts[version]) then
+		for _, extName in ipairs(coreExts[version]) do
+			if(not dups[extName]) then
+				exts[#exts + 1] = extName
+				dups[extName] = true
+			end
+		end
+	end
+end
+
+local sortExts = {}
+
+for _, extName in ipairs(specData.extensions) do
+	if(not dups[extName]) then
+		sortExts[#sortExts + 1] = extName
+		dups[extName] = true
+	end
+end
+
+table.sort(sortExts)
+
+local hFile = io.open(options.outname, "w")
+for _, extName in ipairs(exts) do
+	hFile:write(extName, "\n")
+end
+for _, extName in ipairs(sortExts) do
+	hFile:write(extName, "\n")
+end
+hFile:close()
+
+	
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.