Commit 4510e294 authored by Luis Anton Rebollo's avatar Luis Anton Rebollo

Merge pull request #698 from eightyeight/fix-vs-link-time

Append ' DLL' to DLL name to fix linker times
parents 0ca67272 ec78e4d5
......@@ -32,29 +32,49 @@ extern "C"
int (*torque_winmain)( HINSTANCE hInstance, HINSTANCE h, LPSTR lpszCmdLine, int nShow) = NULL;
};
bool getDllName(std::wstring& dllName)
bool getDllName(std::wstring& dllName, const std::wstring suffix)
{
wchar_t filenameBuf[MAX_PATH];
DWORD length = GetModuleFileNameW( NULL, filenameBuf, MAX_PATH );
if(length == 0) return false;
dllName = std::wstring(filenameBuf);
size_t dotPos = dllName.find_last_of(L".");
if(dotPos == std::wstring::npos) return false;
if(dotPos == std::wstring::npos)
{
dllName.clear();
return false;
}
dllName.erase(dotPos);
dllName += L".dll";
dllName += suffix + L".dll";
return true;
}
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow)
{
// Try to find the game DLL, which may have one of several file names.
HMODULE hGame = NULL;
std::wstring dllName = std::wstring();
if(!getDllName(dllName))
// The file name is the same as this executable's name, plus a suffix.
const std::wstring dllSuffices[] = {L"", L" DLL"};
const unsigned int numSuffices = sizeof(dllSuffices) / sizeof(std::wstring);
for (unsigned int i = 0; i < numSuffices; i++)
{
// Attempt to glue the suffix onto the current filename.
if(!getDllName(dllName, dllSuffices[i]))
continue;
// Load the DLL at that address.
hGame = LoadLibraryW(dllName.c_str());
if (hGame)
break;
}
if(!dllName.length())
{
MessageBoxW(NULL, L"Unable to find game dll", L"Error", MB_OK|MB_ICONWARNING);
return -1;
}
HMODULE hGame = LoadLibraryW(dllName.c_str());
if (!hGame)
{
wchar_t error[4096];
......
......@@ -50,15 +50,15 @@
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">{$projectOffset}../../{$gameFolder}/</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">{$projectOffset}../Link/VC2010.$(Configuration).$(PlatformName)/$(ProjectName)/</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">{$projOutName}_DEBUG</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">{$projOutName}_DEBUG DLL</TargetName>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Optimized Debug|Win32'">{$projectOffset}../../{$gameFolder}/</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Optimized Debug|Win32'">{$projectOffset}../Link/VC2010.$(Configuration).$(PlatformName)/$(ProjectName)/</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Optimized Debug|Win32'">false</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Optimized Debug|Win32'">{$projOutName}_OPTIMIZEDDEBUG</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Optimized Debug|Win32'">{$projOutName}_OPTIMIZEDDEBUG DLL</TargetName>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">{$projectOffset}../../{$gameFolder}/</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">{$projectOffset}../Link/VC2010.$(Configuration).$(PlatformName)/$(ProjectName)/</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">{$projOutName}</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">{$projOutName} DLL</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Midl>
......@@ -96,7 +96,7 @@
</ResourceCompile>
<Link>
<AdditionalDependencies>{foreach item=def from=$projLibsDebug}{$def};{/foreach}%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir){$projOutName}_DEBUG.dll</OutputFile>
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>{foreach item=def from=$projLibDirs}{$def};{/foreach}{$projectOffset}../Link/VC2010.$(Configuration).$(PlatformName);$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>LIBC;LIBCD;{foreach item=def from=$projLibsIgnore}{$def};{/foreach}%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
......@@ -148,7 +148,7 @@
</ResourceCompile>
<Link>
<AdditionalDependencies>{foreach item=def from=$projLibsDebug}{$def};{/foreach}%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir){$projOutName}_OPTIMIZEDDEBUG.dll</OutputFile>
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>{foreach item=def from=$projLibDirs}{$def};{/foreach}{$projectOffset}../Link/VC2010.$(Configuration).$(PlatformName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>LIBC;LIBCD;{foreach item=def from=$projLibsIgnore}{$def};{/foreach}%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
......@@ -200,7 +200,7 @@
</ResourceCompile>
<Link>
<AdditionalDependencies>{foreach item=def from=$projLibs}{$def};{/foreach}%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir){$projOutName}.dll</OutputFile>
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>{foreach item=def from=$projLibDirs}{$def};{/foreach}{$projectOffset}../Link/VC2010.$(Configuration).$(PlatformName);$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<IgnoreSpecificDefaultLibraries>LIBC;LIBCD;{foreach item=def from=$projLibsIgnore}{$def};{/foreach}%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
......
......@@ -81,9 +81,9 @@
AdditionalDependencies="{foreach item=def from=$projLibsDebug}{$def} {/foreach}"
{if $uniformOutputFile eq 1}
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName}.dll"
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName} DLL.dll"
{else}
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName}_DEBUG.dll"
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName}_DEBUG DLL.dll"
{/if}
LinkIncremental="2"
......@@ -191,9 +191,9 @@
AdditionalDependencies="{foreach item=def from=$projLibsDebug}{$def} {/foreach}"
{if $uniformOutputFile eq 1}
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName}.dll"
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName} DLL.dll"
{else}
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName}_OPTIMIZEDDEBUG.dll"
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName}_OPTIMIZEDDEBUG DLL.dll"
{/if}
LinkIncremental="1"
......@@ -299,7 +299,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="{foreach item=def from=$projLibs}{$def} {/foreach}"
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName}.dll"
OutputFile="{$projectOffset}../../{$gameFolder}/{$projOutName} DLL.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="{foreach item=def from=$projLibDirs}{$def};{/foreach}{$projectOffset}../Link/VC2k8.$(ConfigurationName).$(PlatformName);"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment