Skip to content

Commit 1a2b503

Browse files
committed
FMOD - fix packaging issue and update to 2.0.22
1 parent 12071b1 commit 1a2b503

File tree

15 files changed

+76
-88
lines changed

15 files changed

+76
-88
lines changed

UnityPy/export/AudioClipConverter.py

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
import ctypes
44
import os
55
import platform
6-
import sys
7-
from importlib.resources import path
8-
from typing import TYPE_CHECKING, Dict
6+
from typing import TYPE_CHECKING, Dict, Union
97

108
from UnityPy.streams import EndianBinaryWriter
119

@@ -22,65 +20,53 @@
2220
pyfmodex = None
2321

2422

23+
def get_fmod_path(
24+
system: Union["Windows", "Linux", "Darwin"], arch: ["x64", "x86", "arm"]
25+
) -> str:
26+
if system == "Darwin":
27+
# universal dylib
28+
return "lib/FMOD/Darwin/libfmod.dylib"
29+
30+
if system == "Windows":
31+
return f"lib/FMOD/Windows/{arch}/fmod.dll"
32+
33+
if system == "Linux":
34+
if arch == "x64":
35+
arch = "x86_64"
36+
return f"lib/FMOD/Linux/{arch}/libfmod.so"
37+
38+
raise NotImplementedError(f"Unsupported system: {system}")
39+
40+
2541
def import_pyfmodex():
2642
global pyfmodex
2743
if pyfmodex is not None:
2844
return
2945

3046
# determine system - Windows, Darwin, Linux, Android
3147
system = platform.system()
32-
if system == "Linux" and "ANDROID_BOOTLOGO" in os.environ:
33-
system = "Android"
34-
# determine architecture
35-
machine = platform.machine()
3648
arch = platform.architecture()[0]
49+
machine = platform.machine()
3750

38-
if system in ["Windows", "Darwin"]:
39-
if arch == "32bit":
40-
arch = "x86"
41-
elif arch == "64bit":
42-
arch = "x64"
43-
elif system == "Linux":
44-
# Raspberry Pi and Linux on arm projects
45-
if "arm" in machine:
46-
if arch == "32bit":
47-
arch = "armhf" if machine.endswith("l") else "arm"
48-
elif arch == "64bit":
49-
# Raise an exception for now; Once it gets supported by FMOD we can just modify the code here
50-
pyfmodex = False
51-
raise NotImplementedError(
52-
"ARM64 not supported by FMOD.\nUse a 32bit python version."
53-
)
54-
elif arch == "32bit":
55-
arch = "x86"
56-
elif arch == "64bit":
57-
arch = "x86_64"
58-
else:
59-
pyfmodex = False
60-
raise NotImplementedError(
61-
"Couldn't find a correct FMOD library for your system ({system} - {arch})."
62-
)
51+
if "arm" in machine or "aarch64" in machine:
52+
arch = "arm"
53+
elif arch == "32bit":
54+
arch = "x86"
55+
elif arch == "64bit":
56+
arch = "x64"
57+
58+
fmod_rel_path = get_fmod_path(system, arch)
59+
fmod_path = os.path.join(
60+
os.path.dirname(os.path.dirname(os.path.realpath(__file__))), fmod_rel_path
61+
)
62+
os.environ["PYFMODEX_DLL_PATH"] = fmod_path
6363

6464
# build path and load library
6565
# prepare the environment for pyfmodex
66-
if system == "Windows":
67-
libname = "fmod.dll"
68-
else:
69-
ext = "dylib" if system == "Darwin" else "so"
70-
libname = f"libfmod.{ext}"
66+
if system != "Windows":
7167
# hotfix ctypes for pyfmodex for non windows systems
7268
ctypes.windll = None
7369

74-
lib_path = os.path.join(
75-
os.path.dirname(os.path.dirname(os.path.realpath(__file__))),
76-
"lib",
77-
"FMOD",
78-
system,
79-
arch,
80-
libname
81-
)
82-
os.environ["PYFMODEX_DLL_PATH"] = lib_path
83-
8470
import pyfmodex
8571

8672

2.32 MB
Binary file not shown.

UnityPy/lib/FMOD/Darwin/x64/4.x64

-3.11 MB
Binary file not shown.

UnityPy/lib/FMOD/Darwin/x64/4.x86

-1.79 MB
Binary file not shown.
-2.57 MB
Binary file not shown.
4 KB
Binary file not shown.

UnityPy/lib/FMOD/Linux/armhf/__init__.py

Whitespace-only changes.
-1.15 MB
Binary file not shown.
0 Bytes
Binary file not shown.
-32 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)