diff options
-rw-r--r-- | games/mame/complay.py | 152 | ||||
-rw-r--r-- | games/mame/mame.SlackBuild | 16 | ||||
-rw-r--r-- | games/mame/mame.info | 6 |
3 files changed, 168 insertions, 6 deletions
diff --git a/games/mame/complay.py b/games/mame/complay.py new file mode 100644 index 000000000000..4eecaa97353c --- /dev/null +++ b/games/mame/complay.py @@ -0,0 +1,152 @@ +#!/usr/bin/python +## +## license:BSD-3-Clause +## copyright-holders:Vas Crabb + +import os +import sys +import xml.sax +import xml.sax.saxutils +import zlib + + +class ErrorHandler(object): + def __init__(self, **kwargs): + super(ErrorHandler, self).__init__(**kwargs) + self.errors = 0 + self.warnings = 0 + + def error(self, exception): + self.errors += 1 + sys.stderr.write('error: %s' % (exception)) + + def fatalError(self, exception): + raise exception + + def warning(self, exception): + self.warnings += 1 + sys.stderr.write('warning: %s' % (exception)) + + +class Minifyer(object): + def __init__(self, output, **kwargs): + super(Minifyer, self).__init__(**kwargs) + + self.output = output + self.incomplete_tag = False + self.element_content = '' + + def setDocumentLocator(self, locator): + pass + + def startDocument(self): + self.output('<?xml version="1.0"?>') + + def endDocument(self): + self.output('\n') + + def startElement(self, name, attrs): + self.flushElementContent() + if self.incomplete_tag: + self.output('>') + self.output('<%s' % (name)) + for name in attrs.getNames(): + self.output(' %s=%s' % (name, xml.sax.saxutils.quoteattr(attrs[name]))) + self.incomplete_tag = True + + def endElement(self, name): + self.flushElementContent() + if self.incomplete_tag: + self.output('/>') + else: + self.output('</%s>' % (name)) + self.incomplete_tag = False + + def characters(self, content): + self.element_content += content + + def ignorableWhitespace(self, whitespace): + pass + + def processingInstruction(self, target, data): + pass + + def flushElementContent(self): + self.element_content = self.element_content.strip() + if self.element_content: + if self.incomplete_tag: + self.output('>') + self.incomplete_tag = False + self.output(xml.sax.saxutils.escape(self.element_content)) + self.element_content = '' + + +class XmlError(Exception): + pass + + +def compressLayout(src, dst, comp): + state = [0, 0] + def write(block): + for ch in bytearray(block): + if 0 == state[0]: + dst('\t') + elif 0 == (state[0] % 32): + dst(',\n\t') + else: + dst(', ') + state[0] += 1 + dst('%3u' % (ch)) + + def output(text): + block = text.encode('UTF-8') + state[1] += len(block) + write(comp.compress(block)) + + error_handler = ErrorHandler() + content_handler = Minifyer(output) + parser = xml.sax.make_parser() + parser.setErrorHandler(error_handler) + parser.setContentHandler(content_handler) + try: + parser.parse(src) + write(comp.flush()) + dst('\n') + except xml.sax.SAXException as exception: + print('fatal error: %s' % (exception)) + raise XmlError('Fatal error parsing XML') + if (error_handler.errors > 0) or (error_handler.warnings > 0): + raise XmlError('Error(s) and/or warning(s) parsing XML') + + return state[1], state[0] + + +if __name__ == '__main__': + if len(sys.argv) != 4: + print('Usage:') + print(' complay <source.lay> <output.h> <varname>') + sys.exit(0 if len(sys.argv) <= 1 else 1) + + srcfile = sys.argv[1] + dstfile = sys.argv[2] + varname = sys.argv[3] + + comp_type = 1 + try: + dst = open(dstfile,'w') + dst.write('static const unsigned char %s_data[] = {\n' % (varname)) + byte_count, comp_size = compressLayout(srcfile, lambda x: dst.write(x), zlib.compressobj()) + dst.write('};\n\n') + dst.write('const internal_layout %s = {\n' % (varname)) + dst.write('\t%d, sizeof(%s_data), %d, %s_data\n' % (byte_count, varname, comp_type, varname)) + dst.write('};\n') + dst.close() + except XmlError: + dst.close() + os.remove(dstfile) + sys.exit(2) + except IOError: + sys.stderr.write("Unable to open output file '%s'\n" % dstfile) + os.remove(dstfile) + dst.close() + sys.exit(3) diff --git a/games/mame/mame.SlackBuild b/games/mame/mame.SlackBuild index b499fac9ae78..fce5d18287ac 100644 --- a/games/mame/mame.SlackBuild +++ b/games/mame/mame.SlackBuild @@ -9,6 +9,9 @@ # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details. +# 20170726 bkw: +# - Updated for v0.188. + # 20170702 bkw: # - Updated for v0.187. @@ -82,7 +85,7 @@ # - Update .ini file slightly (sound=sdl, not sound=1) PRGNAM=mame -VERSION=${VERSION:-0.187} +VERSION=${VERSION:-0.188} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} @@ -134,11 +137,11 @@ chown -R root:root . find -L . \ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \ -o -perm 511 \) -print0 | \ - xargs -0 chmod 755 + xargs -r -0 chmod 755 find -L . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -print0 | \ - xargs -0 chmod 644 + xargs -r -0 chmod 644 # OK, building modern mame is a bit of a PITA. It uses genie (written # in lua, a fork of premake), but you don't get to run genie directly, @@ -146,6 +149,13 @@ find -L . \ # genie with arguments based on the options in the main makefile. Also, # it uses python to convert XML layout files to C++ code. +# complay.py is the layout compressor. Layouts are XML, complay +# compresses them and also seems to generate C code. The script got +# updated between mame 0.187 and 0.188, and the new version doesn't +# work. I don't know enough about Python to fix this in a timely +# manner, so for now I'll just use the old version of the script. +cp $CWD/complay.py scripts/build/complay.py + # Where possible, use system libraries instead of building the ones # bundled with the mame source. However, SBo's lua is (still!) too old # for mame. diff --git a/games/mame/mame.info b/games/mame/mame.info index 79c92ddb72cb..fb7a2407b727 100644 --- a/games/mame/mame.info +++ b/games/mame/mame.info @@ -1,8 +1,8 @@ PRGNAM="mame" -VERSION="0.187" +VERSION="0.188" HOMEPAGE="http://mamedev.org/" -DOWNLOAD="https://github.com/mamedev/mame/archive/mame0187/mame-mame0187.tar.gz" -MD5SUM="304ad6657fa5b6928fa0257f91be10c1" +DOWNLOAD="https://github.com/mamedev/mame/archive/mame0188/mame-mame0188.tar.gz" +MD5SUM="d0811c2cfe39bf8b622c35b4012c8392" DOWNLOAD_x86_64="" MD5SUM_x86_64="" REQUIRES="SDL2_ttf" |