Skip to content

Commit

Permalink
Packaging fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kozec committed Jul 6, 2018
1 parent 5be6a59 commit b8debc4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
3 changes: 2 additions & 1 deletion retrotouch/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@
CORE_CONFIG_OVERRIDE = {
# Overrides some core-specific settings
"desmume_pointer_type": "touch",
"desmume_pointer_mouse": "enabled"
"desmume_pointer_mouse": "enabled",
}

CORE_CONFIG_DEFAULTS = {
# Overrides defaults for core-specific settings
"desmume_num_cores": "2",
"ppsspp_separate_io_thread": "enabled",
"picodrive_input1": "6 button pad",
}

CSS = """
Expand Down
6 changes: 3 additions & 3 deletions retrotouch/native/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, app, parent, core, game):
self.proc = subprocess.Popen([ "gdb", sys.executable ],
env=env, stdin=subprocess.PIPE)
print >>self.proc.stdin, " ".join([
"run", "retrotouch/native_runner.py",
"run", "-m", "retrotouch.native_runner",
"'%s'" % (self.core,) , "'%s'" % (self.game,),
])
print >>self.proc.stdin, "bt"
Expand All @@ -62,12 +62,12 @@ def __init__(self, app, parent, core, game):
"valgrind",
"--suppressions=resources/valgrind-python.supp",
"--tool=memcheck",
"python", "retrotouch/native_runner.py",
"python", "-m", "retrotouch.native_runner",
self.core, self.game,
], env=env)
else:
self.proc = subprocess.Popen([
sys.executable, "retrotouch/native_runner.py",
sys.executable, "-m", "retrotouch.native_runner",
self.core, self.game], env=env)
log.debug("Subprocess started")
os.close(his_rfd); os.close(his_wfd)
Expand Down
3 changes: 2 additions & 1 deletion retrotouch/native_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from retrotouch.native.shared_data import SharedData
from retrotouch.data import CORE_CONFIG_OVERRIDE, CORE_CONFIG_DEFAULTS
from retrotouch.tools import load_core_config, save_core_config
from retrotouch.tools import find_library
from retrotouch.paths import get_share_path, get_data_path
from retrotouch.rpc import RPC
import sys, os, logging, ctypes
Expand Down Expand Up @@ -47,7 +48,7 @@ class LibraryData(ctypes.Structure):
class Native:

def __init__(self, parent, shm_fname):
self._lib = ctypes.CDLL("./libnative_runner.so")
self._lib = find_library("libnative_runner")
self._lib.rt_init.restype = ctypes.c_int
self._lib.rt_check_saving_supported.restype = ctypes.c_int
self._lib.rt_check_error.restype = ctypes.c_char_p
Expand Down
33 changes: 31 additions & 2 deletions retrotouch/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
from __future__ import unicode_literals
from retrotouch.paths import get_config_path

import os, json, logging
import os, sys, imp, ctypes, json, logging

log = logging.getLogger("tools.py")
_ = lambda x : x

LOG_FORMAT = "%(levelname)s %(name)-13s %(message)s"
LOG_FORMAT = "%(levelname)s %(name)-13s %(message)s"

def init_logging(prefix="", suffix=""):
"""
Expand Down Expand Up @@ -57,6 +57,35 @@ def set_logging_level(verbose, debug):
logger.setLevel(20)


def find_library(libname):
"""
Search for 'libname.so'.
Returns library loaded with ctypes.CDLL
Raises OSError if library is not found
"""
lib, search_paths = None, []
so_extensions = [ ext for ext, _, typ in imp.get_suffixes()
if typ == imp.C_EXTENSION ]
for extension in so_extensions:
for base_path in list(sys.path):
search_paths += [
os.path.abspath(os.path.normpath(
os.path.join( base_path, libname + extension ))),
os.path.abspath(os.path.normpath(
os.path.join( base_path, libname + extension )))
]

for path in search_paths:
if os.path.exists(path):
lib = path
break

if not lib:
raise OSError('Cant find %s.so. searched at:\n %s' % (
libname, '\n'.join(search_paths)))
return ctypes.CDLL(lib)


def _config_file(core):
core_name = ".".join(os.path.split(core)[-1].split(".")[:-1])
return os.path.join(get_config_path(), "core_configs", core_name + ".json")
Expand Down

0 comments on commit b8debc4

Please sign in to comment.