mirror of https://github.com/mgba-emu/mgba.git
Python: Export version info
This commit is contained in:
parent
aa8f77c18f
commit
732ed5fa4d
|
@ -30,6 +30,7 @@ void free(void*);
|
|||
#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"
|
||||
|
|
|
@ -23,6 +23,7 @@ ffi.set_source("mgba._pylib", """
|
|||
#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>
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
# 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 @@ def createCallback(structName, cbName, funcName=None):
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue