Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Python argparse option to supply additional DLL search paths for Windows #1415

Merged
merged 2 commits into from
Sep 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions openage/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ def main(argv=None):
help=("upon throwing an exception a debug break is "
"triggered. this will crash openage if no "
"debugger is present"))
if sys.platform == 'win32':
global_cli.add_argument(
"--add-dll-search-path", action='append', dest='dll_paths',
help="(Windows only) provide additional DLL search path")

devmodes = global_cli.add_mutually_exclusive_group()
devmodes.add_argument("--devmode", action="store_true",
help="force-enable development mode")
Expand Down
12 changes: 11 additions & 1 deletion openage/game/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Holds the game entry point for openage.
"""

import sys
from ..convert.tool.subtool.acquire_sourcedir import wanna_convert
from ..log import err, info

Expand All @@ -30,6 +31,12 @@ def main(args, error):
"""
del error # unused

win_dll_path_handles = []
if sys.platform == 'win32' and args.dll_paths is not None:
import os
for addtional_path in args.dll_paths:
win_dll_path_handles.append(os.add_dll_directory(addtional_path))

# we have to import stuff inside the function
# as it depends on generated/compiled code
from .main_cpp import run_game
Expand All @@ -40,6 +47,10 @@ def main(args, error):
from ..cvar.location import get_config_path
from ..util.fslike.union import Union

if sys.platform == 'win32':
for handle in win_dll_path_handles:
handle.close()

# initialize libopenage
cpp_interface_setup(args)

Expand Down Expand Up @@ -87,7 +98,6 @@ def main(args, error):
info("Generated nyan assets are not yet compatible to the engine.")
info("Please revert to release v0.4.1 if you want to test the previous working gamestate.")
info("Exiting...")
import sys
sys.exit()

# start the game, continue in main_cpp.pyx!
Expand Down