mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 16:20:11 -04:00
dist: Add extraInitFuncs option to FreezeTool
Useful for init_libpnmimagetypes in particular
This commit is contained in:
parent
108b317327
commit
4da2059758
22
direct/src/dist/FreezeTool.py
vendored
22
direct/src/dist/FreezeTool.py
vendored
@ -370,6 +370,8 @@ extern PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
|
||||
|
||||
/* Main program */
|
||||
|
||||
EXTRA_INIT_FUNC_DECLS
|
||||
|
||||
int
|
||||
Py_FrozenMain(int argc, char **argv)
|
||||
{
|
||||
@ -449,6 +451,8 @@ Py_FrozenMain(int argc, char **argv)
|
||||
PySys_SetArgv(argc, argv);
|
||||
#endif
|
||||
|
||||
EXTRA_INIT_FUNC_CALLS
|
||||
|
||||
n = PyImport_ImportFrozenModule("__main__");
|
||||
if (n == 0)
|
||||
Py_FatalError("__main__ not frozen");
|
||||
@ -839,6 +843,12 @@ class Freezer:
|
||||
# modules.
|
||||
self.extras = []
|
||||
|
||||
# This is a list of init functions that must be called after
|
||||
# Py_Initialize(), but before importing __main__. This is a
|
||||
# tuple of (return type, name). They should use C calling
|
||||
# convention.
|
||||
self.extraInitFuncs = []
|
||||
|
||||
# Set this to true if extension modules should be linked in to
|
||||
# the resulting executable.
|
||||
self.linkExtensionModules = False
|
||||
@ -1711,6 +1721,18 @@ class Freezer:
|
||||
|
||||
if compileToExe:
|
||||
code = self.frozenMainCode
|
||||
|
||||
decls = ''
|
||||
calls = ''
|
||||
for func in self.extraInitFuncs:
|
||||
if isinstance(func, str):
|
||||
func = ('void', func)
|
||||
decls += f'extern {func[0]} {func[1]}();\n'
|
||||
calls += f' {func[1]}();\n';
|
||||
|
||||
code = code.replace('EXTRA_INIT_FUNC_DECLS', decls)
|
||||
code = code.replace('EXTRA_INIT_FUNC_CALLS', calls)
|
||||
|
||||
if self.platform.startswith('win'):
|
||||
code += self.frozenDllMainCode
|
||||
initCode = self.mainInitCode % {
|
||||
|
Loading…
x
Reference in New Issue
Block a user