Skip to content

Commit

Permalink
Add a Python argparse option to supply additional DLL search paths fo…
Browse files Browse the repository at this point in the history
…r Windows (#1415)

Add a command line option to provide additional DLL search paths for Windows (requires Python 3.8+)
  • Loading branch information
duanqn authored Sep 25, 2021
1 parent f0b282e commit ff1c69f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit ff1c69f

Please sign in to comment.