all repos — mgba @ 732ed5fa4d91c339a3591529ba9e88d03659919b

mGBA Game Boy Advance Emulator

Python: Export version info
Vicki Pfau vi@endrift.com
Wed, 14 Jun 2017 16:25:12 -0700
commit

732ed5fa4d91c339a3591529ba9e88d03659919b

parent

aa8f77c18f33515af4b90b1dd9ab20c66846bf49

M src/platform/python/_builder.hsrc/platform/python/_builder.h

@@ -30,6 +30,7 @@

#include <mgba/core/core.h> #include <mgba/core/mem-search.h> #include <mgba/core/tile-cache.h> +#include <mgba/core/version.h> #define PYEXPORT extern "Python+C" #include "platform/python/log.h"
M src/platform/python/_builder.pysrc/platform/python/_builder.py

@@ -23,6 +23,7 @@ #include <mgba/core/core.h>

#include <mgba/core/log.h> #include <mgba/core/mem-search.h> #include <mgba/core/tile-cache.h> +#include <mgba/core/version.h> #include <mgba/internal/arm/arm.h> #include <mgba/internal/gba/gba.h> #include <mgba/internal/gba/input.h>
M src/platform/python/mgba/__init__.pysrc/platform/python/mgba/__init__.py

@@ -5,6 +5,8 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this

# file, You can obtain one at http://mozilla.org/MPL/2.0/. from ._pylib import ffi, lib +from collections import namedtuple + def createCallback(structName, cbName, funcName=None): funcName = funcName or "_py{}{}".format(structName, cbName[0].upper() + cbName[1:]) fullStruct = "struct {}*".format(structName)

@@ -13,3 +15,19 @@ h = ffi.cast(fullStruct, handle)

return getattr(ffi.from_handle(h.pyobj), cbName)(*args) return ffi.def_extern(name=funcName)(cb) + +version = ffi.string(lib.projectVersion).decode('utf-8') + +GitInfo = namedtuple("GitInfo", "commit commitShort branch revision") + +git = {} +if lib.gitCommit and lib.gitCommit != "(unknown)": + git['commit'] = ffi.string(lib.gitCommit).decode('utf-8') +if lib.gitCommitShort and lib.gitCommitShort != "(unknown)": + git['commitShort'] = ffi.string(lib.gitCommitShort).decode('utf-8') +if lib.gitBranch and lib.gitBranch != "(unknown)": + git['branch'] = ffi.string(lib.gitBranch).decode('utf-8') +if lib.gitRevision > 0: + git['revision'] = lib.gitRevision + +git = GitInfo(**git)