Skip to content

Commit

Permalink
Add a command line option to provide additional DLL search paths for …
Browse files Browse the repository at this point in the history
…Windows (requires Python 3.8+)
  • Loading branch information
duanqn committed Sep 25, 2021
1 parent f0b282e commit 3c5bdb6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openage/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def main(argv=None):
help=("upon throwing an exception a debug break is "
"triggered. this will crash openage if no "
"debugger is present"))
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
11 changes: 11 additions & 0 deletions openage/game/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def main(args, error):
"""
del error # unused

win_dll_path_handles = []
import sys
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

0 comments on commit 3c5bdb6

Please sign in to comment.