Skip to content

Commit

Permalink
Fix Windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
dapetcu21 committed Jun 10, 2019
1 parent 718bec8 commit 1c54d05
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 33 deletions.
4 changes: 2 additions & 2 deletions bridge/fmod_generated_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ static int unsignedLongLongGetHigh(lua_State *L) {

static int longLongToString(lua_State *L) {
char s[22];
sprintf(s, "%lld", FMODBridge_check_long_long(L, 1));
sprintf_s(s, 22, "%lld", FMODBridge_check_long_long(L, 1));
lua_pushstring(L, s);
return 1;
}

static int unsignedLongLongToString(lua_State *L) {
char s[22];
sprintf(s, "%llu", FMODBridge_check_unsigned_long_long(L, 1));
sprintf_s(s, 22, "%llu", FMODBridge_check_unsigned_long_long(L, 1));
lua_pushstring(L, s);
return 1;
}
Expand Down
10 changes: 2 additions & 8 deletions bridge/src/fmod_dynamic_loading.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,11 @@ bool FMODBridge_linkLibraries() {

#ifdef _WIN32
#define LIBPREFIX ""
#if defined(__x86_64__) || defined(_M_X64)
#define LIBPOSTFIX "64"
#else
#define LIBPOSTFIX ""
#endif
#define libOpen(var, path) \
var = LoadLibraryA(path); \
if (!var) { LOGW("LoadLibrary(\"%s\") failed with error code %lu", path, GetLastError()); }
#else
#define LIBPREFIX "lib"
#define LIBPOSTFIX ""
#define libOpen(var, path) \
var = dlopen(path, RTLD_NOW | RTLD_GLOBAL); \
if (!var) { LOGW("%s", dlerror()); }
Expand All @@ -372,11 +366,11 @@ bool FMODBridge_linkLibraries() {
exePath = (char*)malloc(maxPathLen + 1);

strcpy(exePath, libPath);
strncat(exePath, SEP LIBPREFIX "fmod" LIBPOSTFIX "." LIBEXT, maxPathLen);
strncat(exePath, SEP LIBPREFIX "fmod." LIBEXT, maxPathLen);
libOpen(FMODBridge_dlHandleLL, exePath);

strcpy(exePath, libPath);
strncat(exePath, SEP LIBPREFIX "fmodstudio" LIBPOSTFIX "." LIBEXT, maxPathLen);
strncat(exePath, SEP LIBPREFIX "fmodstudio." LIBEXT, maxPathLen);
libOpen(FMODBridge_dlHandleST, exePath);

if (mustFreeLibPath) { free((void*)libPath); }
Expand Down
4 changes: 2 additions & 2 deletions bridge/src/fmod_generated.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,14 @@ static int unsignedLongLongGetHigh(lua_State *L) {

static int longLongToString(lua_State *L) {
char s[22];
sprintf(s, "%lld", FMODBridge_check_long_long(L, 1));
sprintf_s(s, 22, "%lld", FMODBridge_check_long_long(L, 1));
lua_pushstring(L, s);
return 1;
}

static int unsignedLongLongToString(lua_State *L) {
char s[22];
sprintf(s, "%llu", FMODBridge_check_unsigned_long_long(L, 1));
sprintf_s(s, 22, "%llu", FMODBridge_check_unsigned_long_long(L, 1));
lua_pushstring(L, s);
return 1;
}
Expand Down
8 changes: 6 additions & 2 deletions bridge/src/fmod_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#include <unistd.h>
#endif

#ifdef _WIN32
#include <shlwapi.h>
#endif

FMOD_STUDIO_SYSTEM* FMODBridge_system = NULL;
FMOD_SYSTEM* FMODBridge_lowLevelSystem = NULL;
bool FMODBridge_isPaused = false;
Expand Down Expand Up @@ -222,8 +226,8 @@ int FMODBridge_getBundleRoot(lua_State* L) {
#if defined(_WIN32)
HMODULE hModule = GetModuleHandle(NULL);
char path[MAX_PATH];
GetModuleFileName(hModule, path, MAX_PATH);
PathRemoveFileSpec(path);
GetModuleFileNameA(hModule, path, MAX_PATH);
PathRemoveFileSpecA(path);
lua_pushstring(L, path);
return 1;
#elif defined(__linux__) && !defined(__ANDROID__)
Expand Down
16 changes: 7 additions & 9 deletions bridge/vs_proj/fmodbridge.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,19 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\fmod_bridge.hpp" />
<ClInclude Include="..\src\fmod_helpers.hpp" />
<ClInclude Include="..\src\fmod_bridge.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\fmod_classes.cpp" />
<ClCompile Include="..\src\fmod_dynamic_loading.cpp" />
<ClCompile Include="..\src\fmod_enums.cpp" />
<ClCompile Include="..\src\fmod_init.cpp" />
<ClCompile Include="..\src\fmod_dynamic_loading.c" />
<ClCompile Include="..\src\fmod_generated.c" />
<ClCompile Include="..\src\fmod_init.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{8F48FAAA-908A-4B6B-AA11-7A9A3246F98C}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>fmodbridge</RootNamespace>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand All @@ -45,7 +43,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand All @@ -58,7 +56,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down
14 changes: 4 additions & 10 deletions bridge/vs_proj/fmodbridge.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,18 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\fmod_bridge.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\fmod_helpers.hpp">
<ClInclude Include="..\src\fmod_bridge.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\fmod_classes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\fmod_enums.cpp">
<ClCompile Include="..\src\fmod_dynamic_loading.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\fmod_init.cpp">
<ClCompile Include="..\src\fmod_generated.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\fmod_dynamic_loading.cpp">
<ClCompile Include="..\src\fmod_init.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down
8 changes: 8 additions & 0 deletions fmod/ext.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ platforms:
x86_64-ios:
context:
frameworks: ["AVFoundation"]

x86_64-win32:
context:
libs: ["shlwapi.lib"]

x86-win32:
context:
libs: ["shlwapi.lib"]

0 comments on commit 1c54d05

Please sign in to comment.