@@ -9,6 +9,12 @@ target_path = ARGUMENTS.pop("target_path", "demo/addons/fmod/libs/")
99target_name = ARGUMENTS .pop ("target_name" , "libGodotFmod" )
1010fmod_lib_dir = ARGUMENTS .pop ("fmod_lib_dir" , "../libs/fmod/" )
1111
12+ # Although FMOD's WebAssembly libraries are built with pthreads / shared memory support, Godot doesn't yet like it.
13+ # For web builds, default to single-threaded godot-cpp (unless the user explicitly overrides it).
14+ platform_arg = ARGUMENTS .get ("platform" )
15+ if platform_arg == "web" and "threads" not in ARGUMENTS :
16+ ARGUMENTS ["threads" ] = "no"
17+
1218env = SConscript ("godot-cpp/SConstruct" )
1319
1420# Add those directory manually, so we can skip the godot_cpp directory when including headers in C++ files
@@ -123,12 +129,19 @@ elif env["platform"] == "android":
123129 env .Append (LIBS = [libfmod , libfmodstudio ])
124130
125131elif env ["platform" ] == "web" :
126- libfmodstudio = os .path .join (fmod_lib_dir , 'web/studio/lib/fastcomp/bitcode/' , 'fmodstudio%s.bc' % lfix )
132+ html_lib = os .path .join (fmod_lib_dir , 'api/studio/lib/upstream/w32/' )
133+ html_inc = os .path .join (fmod_lib_dir , 'api/studio/inc/' )
134+
135+ html_core_lib = os .path .join (fmod_lib_dir , 'api/core/lib/upstream/w32/' )
136+ html_core_inc = os .path .join (fmod_lib_dir , 'api/core/inc/' )
137+
138+ libfmodstudio_path = os .path .join (html_lib , 'fmodstudio%s_wasm.a' % lfix )
127139
128- env .Append (CPPPATH = [env ['fmod_lib_dir' ] + 'web/core/inc/' , env ['fmod_lib_dir' ] + 'web/studio/inc/' ])
129- env .Append (LIBPATH = [env ['fmod_lib_dir' ] + 'web/core/lib/fastcomp/bitcode/' , env ['fmod_lib_dir' ] + 'web/studio/lib/fastcomp/bitcode/' ])
130- # Instead of LIBS, directly add to LINKFLAGS for explicit paths
131- env .Append (LINKFLAGS = [libfmodstudio ])
140+ env .Append (CPPPATH = [html_inc , html_core_inc ])
141+ env .Append (LIBPATH = [html_lib ])
142+ # env.Append(LIBS=[libfmodstudio]) # ← REMOVE or comment this out
143+ env .Append (LINKFLAGS = [libfmodstudio_path ])
144+ env .Append (LINKFLAGS = ["-sEXPORTED_RUNTIME_METHODS=ccall,cwrap,setValue,getValue" ])
132145
133146#Output is placed in the addons directory of the demo project directly
134147target = "{}{}/{}.{}.{}" .format (
0 commit comments