#!/usr/bin/lua -- Copyright 2007-2013 Mitchell mitchell.att.foicica.com. See LICENSE. -- This script generates the "Info.plist" file for the Mac OSX App bundle. local lang, exts local languages, extensions = {}, {} -- Read languages and extensions. local f = io.open('../modules/textadept/file_types.lua') local types = f:read('*all'):match('M.extensions = (%b{})'):sub(2) f:close() for type in types:gmatch('(.-)[%],}]+') do if type:find('^%-%-') then lang, exts = type:match('([^%[]+)$'), {} if lang then languages[#languages + 1], extensions[lang] = lang, exts end else exts[#exts + 1] = type:match('^%[?\'?([^\'=]+)') end end -- Generate and write the XML. local xml = {[[ CFBundleDevelopmentRegion English CFBundleDocumentTypes ]]} for i = 1, #languages do lang, exts = languages[i], extensions[languages[i]] if #exts > 0 then xml[#xml + 1] = "\t\t" xml[#xml + 1] = "\t\t\tCFBundleTypeExtensions" xml[#xml + 1] = "\t\t\t" for j = 1, #exts do xml[#xml + 1] = "\t\t\t\t"..exts[j].."" end xml[#xml + 1] = "\t\t\t" xml[#xml + 1] = "\t\t\tCFBundleTypeName" xml[#xml + 1] = "\t\t\t"..lang.." source" xml[#xml + 1] = "\t\t\tCFBundleTypeRole" xml[#xml + 1] = "\t\t\tEditor" xml[#xml + 1] = "\t\t" end end xml[#xml + 1] = [[ CFBundleTypeExtensions * CFBundleTypeName Document CFBundleTypeRole Editor CFBundleTypeName Document CFBundleTypeOSTypes **** CFBundleTypeRole Editor CFBundleExecutable textadept_osx CFBundleIconFile textadept.icns CFBundleIdentifier com.textadept CFBundleInfoDictionaryVersion 6.0 CFBundleName Textadept CFBundlePackageType APPL CFBundleSignature ???? CFBundleVersion 7.0 beta NSHighResolutionCapable ]] f = io.open('../src/Info.plist', 'w') f:write(table.concat(xml, '\n')) f:close()