2010-11-23 11:47:52 +00:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
*/
2011-04-24 13:33:23 -04:00
# include "config.h"
2010-11-23 11:47:52 +00:00
# include "visualstudio.h"
# include <fstream>
# include <algorithm>
namespace CreateProjectTool {
//////////////////////////////////////////////////////////////////////////
2014-06-19 18:21:14 -07:00
// Visual Studio Provider (Visual Studio 2008)
2010-11-23 11:47:52 +00:00
//////////////////////////////////////////////////////////////////////////
2019-04-15 18:59:00 +01:00
VisualStudioProvider : : VisualStudioProvider ( StringList & global_warnings , std : : map < std : : string , StringList > & project_warnings , const int version , const MSVCVersion & msvc )
: MSVCProvider ( global_warnings , project_warnings , version , msvc ) {
2020-07-13 06:30:06 +01:00
_archs . push_back ( ARCH_X86 ) ;
_archs . push_back ( ARCH_AMD64 ) ;
2010-11-23 11:47:52 +00:00
}
const char * VisualStudioProvider : : getProjectExtension ( ) {
return " .vcproj " ;
}
const char * VisualStudioProvider : : getPropertiesExtension ( ) {
return " .vsprops " ;
}
void VisualStudioProvider : : createProjectFile ( const std : : string & name , const std : : string & uuid , const BuildSetup & setup , const std : : string & moduleDir ,
const StringList & includeList , const StringList & excludeList ) {
const std : : string projectFile = setup . outputDir + ' / ' + name + getProjectExtension ( ) ;
std : : ofstream project ( projectFile . c_str ( ) ) ;
2020-07-13 12:04:42 +02:00
if ( ! project | | ! project . is_open ( ) ) {
2010-11-23 11:47:52 +00:00
error ( " Could not open \" " + projectFile + " \" for writing " ) ;
2020-07-13 12:04:42 +02:00
return ;
}
2010-11-23 11:47:52 +00:00
project < < " <?xml version= \" 1.0 \" encoding= \" windows-1252 \" ?> \n "
" <VisualStudioProject \n "
" \t ProjectType= \" Visual C++ \" \n "
" \t Version= \" " < < _version < < " .00 \" \n "
" \t Name= \" " < < name < < " \" \n "
" \t ProjectGUID= \" { " < < uuid < < " } \" \n "
" \t RootNamespace= \" " < < name < < " \" \n "
" \t Keyword= \" Win32Proj \" \n " ;
2014-06-19 18:21:14 -07:00
project < < " \t TargetFrameworkVersion= \" 131072 \" \n " ;
2010-11-23 11:47:52 +00:00
project < < " \t > \n "
2020-07-13 06:30:06 +01:00
" \t <Platforms> \n " ;
for ( std : : list < MSVC_Architecture > : : const_iterator arch = _archs . begin ( ) ; arch ! = _archs . end ( ) ; + + arch ) {
project < < " \t \t <Platform Name= \" " < < getMSVCConfigName ( * arch ) < < " \" /> \n " ;
}
project < < " \t </Platforms> \n "
2010-11-23 11:47:52 +00:00
" \t <Configurations> \n " ;
// Check for project-specific warnings:
std : : map < std : : string , std : : list < std : : string > > : : iterator warningsIterator = _projectWarnings . find ( name ) ;
2013-07-07 11:23:19 -04:00
if ( setup . devTools | | setup . tests | | name = = setup . projectName ) {
2010-11-23 11:47:52 +00:00
std : : string libraries ;
for ( StringList : : const_iterator i = setup . libraries . begin ( ) ; i ! = setup . libraries . end ( ) ; + + i )
libraries + = ' ' + * i + " .lib " ;
// For 'x64' we must disable NASM support. Usually we would need to disable the "nasm" feature for that and
// re-create the library list, BUT since NASM doesn't link any additional libraries, we can just use the
// libraries list created for IA-32. If that changes in the future, we need to adjust this part!
2020-07-13 06:30:06 +01:00
for ( std : : list < MSVC_Architecture > : : const_iterator arch = _archs . begin ( ) ; arch ! = _archs . end ( ) ; + + arch ) {
outputConfiguration ( project , setup , libraries , " Debug " , * arch ) ;
outputConfiguration ( project , setup , libraries , " Analysis " , * arch ) ;
outputConfiguration ( project , setup , libraries , " LLVM " , * arch ) ;
outputConfiguration ( project , setup , libraries , " Release " , * arch ) ;
}
2010-11-23 11:47:52 +00:00
} else {
2012-09-05 07:54:33 -04:00
bool enableLanguageExtensions = find ( _enableLanguageExtensions . begin ( ) , _enableLanguageExtensions . end ( ) , name ) ! = _enableLanguageExtensions . end ( ) ;
bool disableEditAndContinue = find ( _disableEditAndContinue . begin ( ) , _disableEditAndContinue . end ( ) , name ) ! = _disableEditAndContinue . end ( ) ;
2010-11-23 11:47:52 +00:00
std : : string warnings = " " ;
if ( warningsIterator ! = _projectWarnings . end ( ) )
for ( StringList : : const_iterator i = warningsIterator - > second . begin ( ) ; i ! = warningsIterator - > second . end ( ) ; + + i )
warnings + = * i + ' ; ' ;
std : : string toolConfig ;
toolConfig = ( ! warnings . empty ( ) ? " DisableSpecificWarnings= \" " + warnings + " \" " : " " ) ;
2012-09-05 07:54:33 -04:00
toolConfig + = ( disableEditAndContinue ? " DebugInformationFormat= \" 3 \" " : " " ) ;
toolConfig + = ( enableLanguageExtensions ? " DisableLanguageExtensions= \" false \" " : " " ) ;
2010-11-23 11:47:52 +00:00
2020-07-13 06:30:06 +01:00
for ( std : : list < MSVC_Architecture > : : const_iterator arch = _archs . begin ( ) ; arch ! = _archs . end ( ) ; + + arch ) {
const std : : string outputBitness = ( * arch = = ARCH_X86 ? " " : " 64 " ) ;
outputConfiguration ( setup , project , toolConfig , " Debug " , getMSVCConfigName ( * arch ) , outputBitness ) ;
outputConfiguration ( setup , project , toolConfig , " Analysis " , getMSVCConfigName ( * arch ) , outputBitness ) ;
outputConfiguration ( setup , project , toolConfig , " LLVM " , getMSVCConfigName ( * arch ) , outputBitness ) ;
outputConfiguration ( setup , project , toolConfig , " Release " , getMSVCConfigName ( * arch ) , outputBitness ) ;
}
2010-11-23 11:47:52 +00:00
}
project < < " \t </Configurations> \n "
" \t <Files> \n " ;
std : : string modulePath ;
if ( ! moduleDir . compare ( 0 , setup . srcDir . size ( ) , setup . srcDir ) ) {
modulePath = moduleDir . substr ( setup . srcDir . size ( ) ) ;
if ( ! modulePath . empty ( ) & & modulePath . at ( 0 ) = = ' / ' )
modulePath . erase ( 0 , 1 ) ;
}
if ( modulePath . size ( ) )
addFilesToProject ( moduleDir , project , includeList , excludeList , setup . filePrefix + ' / ' + modulePath ) ;
else
addFilesToProject ( moduleDir , project , includeList , excludeList , setup . filePrefix ) ;
2013-07-07 11:23:19 -04:00
// Output auto-generated test runner
if ( setup . tests ) {
project < < " \t \t <File RelativePath= \" test_runner.cpp \" /> \n " ;
}
2010-11-23 11:47:52 +00:00
project < < " \t </Files> \n "
" </VisualStudioProject> \n " ;
}
2020-05-08 13:17:36 -07:00
void VisualStudioProvider : : outputConfiguration ( std : : ostream & project , const BuildSetup & setup , const std : : string & libraries , const std : : string & config , const MSVC_Architecture arch ) {
project < < " \t \t <Configuration Name= \" " < < config < < " | " < < getMSVCConfigName ( arch ) < < " \" ConfigurationType= \" 1 \" InheritedPropertySheets= \" . \\ " < < setup . projectDescription < < " _ " < < config < < getMSVCArchName ( arch ) < < " .vsprops \" > \n "
2012-05-11 23:11:17 +10:00
" \t \t \t <Tool \t Name= \" VCCLCompilerTool \" DisableLanguageExtensions= \" false \" DebugInformationFormat= \" 3 \" /> \n "
2011-09-06 16:01:10 -04:00
" \t \t \t <Tool \t Name= \" VCLinkerTool \" OutputFile= \" $(OutDir)/ " < < setup . projectName < < " .exe \" \n "
2011-04-28 17:44:17 +02:00
" \t \t \t \t AdditionalDependencies= \" " < < libraries < < " \" \n "
" \t \t \t /> \n " ;
2020-05-08 13:17:36 -07:00
outputBuildEvents ( project , setup , arch ) ;
2011-04-28 17:44:17 +02:00
project < < " \t \t </Configuration> \n " ;
}
2011-09-06 16:01:10 -04:00
void VisualStudioProvider : : outputConfiguration ( const BuildSetup & setup , std : : ostream & project , const std : : string & toolConfig , const std : : string & config , const std : : string & platform , const std : : string & props ) {
project < < " \t \t <Configuration Name= \" " < < config < < " | " < < platform < < " \" ConfigurationType= \" 4 \" InheritedPropertySheets= \" . \\ " < < setup . projectDescription < < " _ " < < config < < props < < " .vsprops \" > \n "
2011-04-28 17:44:17 +02:00
" \t \t \t <Tool Name= \" VCCLCompilerTool \" " < < toolConfig < < " /> \n "
" \t \t </Configuration> \n " ;
}
2020-05-08 13:17:36 -07:00
void VisualStudioProvider : : outputBuildEvents ( std : : ostream & project , const BuildSetup & setup , const MSVC_Architecture arch ) {
2013-07-07 11:23:19 -04:00
if ( ! setup . devTools & & ! setup . tests & & setup . runBuildEvents ) {
2011-04-28 17:44:17 +02:00
project < < " \t \t \t <Tool \t Name= \" VCPreBuildEventTool \" \n "
" \t \t \t \t CommandLine= \" " < < getPreBuildEvent ( ) < < " \" \n "
" \t \t \t /> \n "
" \t \t \t <Tool \t Name= \" VCPostBuildEventTool \" \n "
2020-05-08 13:17:36 -07:00
" \t \t \t \t CommandLine= \" " < < getPostBuildEvent ( arch , setup ) < < " \" \n "
2011-04-28 17:44:17 +02:00
" \t \t \t /> \n " ;
}
2013-07-07 11:23:19 -04:00
// Generate runner file before build for tests
if ( setup . tests ) {
project < < " \t \t \t <Tool \t Name= \" VCPreBuildEventTool \" \n "
" \t \t \t \t CommandLine= \" " < < getTestPreBuildEvent ( setup ) < < " \" \n "
" \t \t \t /> \n " ;
project < < " \t \t \t <Tool \t Name= \" VCPostBuildEventTool \" \n "
" \t \t \t \t CommandLine= \" $(TargetPath) \" IgnoreExitCode= \" true \" \n "
" \t \t \t /> \n " ;
}
2011-04-28 17:44:17 +02:00
}
2011-09-06 16:01:10 -04:00
void VisualStudioProvider : : writeReferences ( const BuildSetup & setup , std : : ofstream & output ) {
2010-11-23 11:47:52 +00:00
output < < " \t ProjectSection(ProjectDependencies) = postProject \n " ;
for ( UUIDMap : : const_iterator i = _uuidMap . begin ( ) ; i ! = _uuidMap . end ( ) ; + + i ) {
2011-09-06 16:01:10 -04:00
if ( i - > first = = setup . projectName )
2010-11-23 11:47:52 +00:00
continue ;
output < < " \t \t { " < < i - > second < < " } = { " < < i - > second < < " } \n " ;
}
output < < " \t EndProjectSection \n " ;
}
2020-05-08 13:17:36 -07:00
void VisualStudioProvider : : outputGlobalPropFile ( const BuildSetup & setup , std : : ofstream & properties , MSVC_Architecture arch , const StringList & defines , const std : : string & prefix , bool runBuildEvents ) {
2010-11-23 11:47:52 +00:00
std : : string warnings ;
for ( StringList : : const_iterator i = _globalWarnings . begin ( ) ; i ! = _globalWarnings . end ( ) ; + + i )
warnings + = * i + ' ; ' ;
std : : string definesList ;
for ( StringList : : const_iterator i = defines . begin ( ) ; i ! = defines . end ( ) ; + + i ) {
if ( i ! = defines . begin ( ) )
definesList + = ' ; ' ;
definesList + = * i ;
}
2011-04-24 12:34:57 -04:00
// Add define to include revision header
if ( runBuildEvents )
2011-04-24 13:33:23 -04:00
definesList + = REVISION_DEFINE " ; " ;
2011-04-24 12:34:57 -04:00
2010-11-23 11:47:52 +00:00
properties < < " <?xml version= \" 1.0 \" encoding= \" Windows-1252 \" ?> \n "
" <VisualStudioPropertySheet \n "
" \t ProjectType= \" Visual C++ \" \n "
" \t Version= \" 8.00 \" \n "
2011-09-06 16:01:10 -04:00
" \t Name= \" " < < setup . projectDescription < < " _Global \" \n "
2020-05-08 13:17:36 -07:00
" \t OutputDirectory= \" $(ConfigurationName) " < < getMSVCArchName ( arch ) < < " \" \n "
" \t IntermediateDirectory= \" $(ConfigurationName) " < < getMSVCArchName ( arch ) < < " /$(ProjectName) \" \n "
2010-11-23 11:47:52 +00:00
" \t > \n "
" \t <Tool \n "
" \t \t Name= \" VCCLCompilerTool \" \n "
2011-09-06 16:01:10 -04:00
" \t \t DisableLanguageExtensions= \" " < < ( setup . devTools ? " false " : " true " ) < < " \" \n "
2010-11-23 11:47:52 +00:00
" \t \t DisableSpecificWarnings= \" " < < warnings < < " \" \n "
2018-12-19 05:56:36 +00:00
" \t \t AdditionalIncludeDirectories= \" . \\ ; " < < prefix < < " ; " < < prefix < < " \\ engines;$( " < < LIBS_DEFINE < < " ) \\ include;$( " < < LIBS_DEFINE < < " ) \\ include \\ SDL; " < < ( setup . tests ? prefix + " \\ test \\ cxxtest; " : " " ) < < " \" \n "
2010-11-23 11:47:52 +00:00
" \t \t PreprocessorDefinitions= \" " < < definesList < < " \" \n "
2015-09-28 19:23:58 -04:00
" \t \t ExceptionHandling= \" " < < ( ( setup . devTools | | setup . tests | | _version = = 14 ) ? " 1 " : " 0 " ) < < " \" \n " ;
2011-04-24 13:33:23 -04:00
# if NEEDS_RTTI
properties < < " \t \t RuntimeTypeInfo= \" true \" \n " ;
# else
properties < < " \t \t RuntimeTypeInfo= \" false \" \n " ;
# endif
2011-05-06 19:39:12 +10:00
properties < < " \t \t WarningLevel= \" 4 \" \n "
2010-11-23 11:47:52 +00:00
" \t \t WarnAsError= \" false \" \n "
" \t \t CompileAs= \" 0 \" \n "
" \t \t /> \n "
" \t <Tool \n "
" \t \t Name= \" VCLibrarianTool \" \n "
" \t \t IgnoreDefaultLibraryNames= \" \" \n "
" \t /> \n "
" \t <Tool \n "
" \t \t Name= \" VCLinkerTool \" \n "
" \t \t IgnoreDefaultLibraryNames= \" \" \n "
2011-09-06 16:01:10 -04:00
" \t \t SubSystem= \" 1 \" \n " ;
2013-07-07 11:23:19 -04:00
if ( ! setup . devTools & & ! setup . tests )
2011-09-06 16:01:10 -04:00
properties < < " \t \t EntryPointSymbol= \" WinMainCRTStartup \" \n " ;
2020-05-08 13:17:36 -07:00
properties < < " \t \t AdditionalLibraryDirectories= \" $( " < < LIBS_DEFINE < < " ) \\ lib \\ " < < getMSVCArchName ( arch ) < < " \" \n "
2010-11-23 11:47:52 +00:00
" \t /> \n "
" \t <Tool \n "
" \t \t Name= \" VCResourceCompilerTool \" \n "
2018-12-19 05:56:36 +00:00
" \t \t AdditionalIncludeDirectories= \" . \\ ; " < < prefix < < " \" \n "
2018-12-19 04:13:49 +00:00
" \t \t PreprocessorDefinitions= \" " < < definesList < < " \" \n "
2010-11-23 11:47:52 +00:00
" \t /> \n "
" </VisualStudioPropertySheet> \n " ;
properties . flush ( ) ;
}
2020-05-08 13:17:36 -07:00
void VisualStudioProvider : : createBuildProp ( const BuildSetup & setup , bool isRelease , MSVC_Architecture arch , const std : : string & configuration ) {
2010-11-23 11:47:52 +00:00
2020-05-08 13:17:36 -07:00
std : : ofstream properties ( ( setup . outputDir + ' / ' + setup . projectDescription + " _ " + configuration + getMSVCConfigName ( arch ) + getPropertiesExtension ( ) ) . c_str ( ) ) ;
2020-07-13 12:04:42 +02:00
if ( ! properties | | ! properties . is_open ( ) ) {
2020-05-08 13:17:36 -07:00
error ( " Could not open \" " + setup . outputDir + ' / ' + setup . projectDescription + " _ " + configuration + getMSVCConfigName ( arch ) + getPropertiesExtension ( ) + " \" for writing " ) ;
2020-07-13 12:04:42 +02:00
return ;
}
2010-11-23 11:47:52 +00:00
properties < < " <?xml version= \" 1.0 \" encoding= \" Windows-1252 \" ?> \n "
" <VisualStudioPropertySheet \n "
" \t ProjectType= \" Visual C++ \" \n "
" \t Version= \" 8.00 \" \n "
2020-05-08 13:17:36 -07:00
" \t Name= \" " < < setup . projectDescription < < " _ " < < configuration < < getMSVCConfigName ( arch ) < < " \" \n "
" \t InheritedPropertySheets= \" . \\ " < < setup . projectDescription < < " _Global " < < getMSVCConfigName ( arch ) < < " .vsprops \" \n "
2010-11-23 11:47:52 +00:00
" \t > \n "
" \t <Tool \n "
" \t \t Name= \" VCCLCompilerTool \" \n " ;
if ( isRelease ) {
properties < < " \t \t EnableIntrinsicFunctions= \" true \" \n "
" \t \t WholeProgramOptimization= \" true \" \n "
2013-08-16 07:20:51 +01:00
" \t \t PreprocessorDefinitions= \" WIN32;RELEASE_BUILD \" \n "
2010-11-23 11:47:52 +00:00
" \t \t StringPooling= \" true \" \n "
" \t \t BufferSecurityCheck= \" false \" \n "
" \t \t DebugInformationFormat= \" 0 \" \n "
2011-06-06 13:11:47 -04:00
" \t \t RuntimeLibrary= \" 0 \" \n "
2013-09-05 23:48:33 -04:00
" \t \t AdditionalOption= \" " < < ( configuration = = " Analysis " ? " /analyze " : " " ) < < " \" \n "
2010-11-23 11:47:52 +00:00
" \t /> \n "
" \t <Tool \n "
" \t \t Name= \" VCLinkerTool \" \n "
" \t \t LinkIncremental= \" 1 \" \n "
WIN32: Add a default application manifest
This fixes an OpenGL renderer issue for builds with MSYS2/Mingw64 or MSYS2/Mingw32
The issue pertains to MSYS2 adding a default manifest file (default-manifest.o) to the executable
The bug is for PC systems with GPU drivers that were not properly supported for Windows 10
systems, like Intel HD Graphics series 1st and 2nd generations. In those systems, launching a
game in ScummVM (built with MSYS2/Mingw) with the OpenGL renderer would cause the game
screen to be a white blank image, and various warnings would be output to the console, eg.
"WARNING: GL ERROR: GL_INVALID_ENUM on glTexSubImage2D(0x0DE1, 0, 0, area.top, src.w, area.height(), _glFormat, _glType, src.gere.cpp:167)!"
This was due to MSYS2/Mingw builds trying to load the (poorly supported) GPU driver while advertising support for Windows 10 in their
embedded default Manifest file. Hence, the GPU driver DLL (eg ig4icd64.dll) would be unloaded, causing the bug.
More information is available in the following links:
https://github.com/pal1000/save-legacy-intel-graphics
https://github.com/LWJGL/lwjgl/issues/119
https://github.com/msys2/MSYS2-packages/issues/454
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69880
Credits to sluicebox for the VS GenerateManifest flag
2019-08-04 07:18:50 -04:00
" \t \t GenerateManifest= \" false \" \n "
2010-11-23 11:47:52 +00:00
" \t \t IgnoreDefaultLibraryNames= \" \" \n "
" \t \t SetChecksum= \" true \" \n " ;
} else {
properties < < " \t \t Optimization= \" 0 \" \n "
2013-08-16 07:20:51 +01:00
" \t \t PreprocessorDefinitions= \" WIN32 \" \n "
2010-11-23 11:47:52 +00:00
" \t \t MinimalRebuild= \" true \" \n "
" \t \t BasicRuntimeChecks= \" 3 \" \n "
" \t \t RuntimeLibrary= \" 1 \" \n "
" \t \t EnableFunctionLevelLinking= \" true \" \n "
" \t \t WarnAsError= \" false \" \n "
2020-07-13 04:00:35 +01:00
" \t \t DebugInformationFormat= \" " < < ( arch = = ARCH_X86 ? " 3 " : " 4 " ) < < " \" \n " // For x64 format "4" (Edit and continue) is not supported, thus we default to "3"
2013-09-05 23:48:33 -04:00
" \t \t AdditionalOption= \" " < < ( configuration = = " Analysis " ? " /analyze " : " " ) < < " \" \n "
2010-11-23 11:47:52 +00:00
" \t /> \n "
" \t <Tool \n "
" \t \t Name= \" VCLinkerTool \" \n "
" \t \t LinkIncremental= \" 2 \" \n "
WIN32: Add a default application manifest
This fixes an OpenGL renderer issue for builds with MSYS2/Mingw64 or MSYS2/Mingw32
The issue pertains to MSYS2 adding a default manifest file (default-manifest.o) to the executable
The bug is for PC systems with GPU drivers that were not properly supported for Windows 10
systems, like Intel HD Graphics series 1st and 2nd generations. In those systems, launching a
game in ScummVM (built with MSYS2/Mingw) with the OpenGL renderer would cause the game
screen to be a white blank image, and various warnings would be output to the console, eg.
"WARNING: GL ERROR: GL_INVALID_ENUM on glTexSubImage2D(0x0DE1, 0, 0, area.top, src.w, area.height(), _glFormat, _glType, src.gere.cpp:167)!"
This was due to MSYS2/Mingw builds trying to load the (poorly supported) GPU driver while advertising support for Windows 10 in their
embedded default Manifest file. Hence, the GPU driver DLL (eg ig4icd64.dll) would be unloaded, causing the bug.
More information is available in the following links:
https://github.com/pal1000/save-legacy-intel-graphics
https://github.com/LWJGL/lwjgl/issues/119
https://github.com/msys2/MSYS2-packages/issues/454
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69880
Credits to sluicebox for the VS GenerateManifest flag
2019-08-04 07:18:50 -04:00
" \t \t GenerateManifest= \" false \" \n "
2010-11-23 11:47:52 +00:00
" \t \t GenerateDebugInformation= \" true \" \n "
" \t \t IgnoreDefaultLibraryNames= \" libcmt.lib \" \n " ;
}
properties < < " \t /> \n "
" </VisualStudioPropertySheet> \n " ;
properties . flush ( ) ;
properties . close ( ) ;
}
void VisualStudioProvider : : writeFileListToProject ( const FileNode & dir , std : : ofstream & projectFile , const int indentation ,
const StringList & duplicate , const std : : string & objPrefix , const std : : string & filePrefix ) {
const std : : string indentString = getIndent ( indentation + 2 ) ;
if ( indentation )
projectFile < < getIndent ( indentation + 1 ) < < " <Filter \t Name= \" " < < dir . name < < " \" > \n " ;
for ( FileNode : : NodeList : : const_iterator i = dir . children . begin ( ) ; i ! = dir . children . end ( ) ; + + i ) {
const FileNode * node = * i ;
if ( ! node - > children . empty ( ) ) {
writeFileListToProject ( * node , projectFile , indentation + 1 , duplicate , objPrefix + node - > name + ' _ ' , filePrefix + node - > name + ' / ' ) ;
} else {
if ( producesObjectFile ( node - > name ) ) {
std : : string name , ext ;
splitFilename ( node - > name , name , ext ) ;
2016-12-17 15:12:52 -05:00
name + = " .o " ;
std : : transform ( name . begin ( ) , name . end ( ) , name . begin ( ) , tolower ) ;
const bool isDuplicate = ( std : : find ( duplicate . begin ( ) , duplicate . end ( ) , name ) ! = duplicate . end ( ) ) ;
2020-07-13 06:30:06 +01:00
std : : string filePath = convertPathToWin ( filePrefix + node - > name ) ;
2010-11-23 11:47:52 +00:00
if ( ext = = " asm " ) {
std : : string objFileName = " $(IntDir) \\ " ;
if ( isDuplicate )
objFileName + = objPrefix ;
objFileName + = " $(InputName).obj " ;
const std : : string toolLine = indentString + " \t \t <Tool Name= \" VCCustomBuildTool \" CommandLine= \" nasm.exe -f win32 -g -o " " + objFileName + " " "$(InputPath)"
 \" Outputs= \" " + objFileName + " \" /> \n " ;
// NASM is not supported for x64, thus we do not need to add additional entries here :-).
2020-07-13 06:30:06 +01:00
writeFileToProject ( projectFile , filePath , ARCH_X86 , indentString , toolLine ) ;
2010-11-23 11:47:52 +00:00
} else {
if ( isDuplicate ) {
const std : : string toolLine = indentString + " \t \t <Tool Name= \" VCCLCompilerTool \" ObjectFile= \" $(IntDir) \\ " + objPrefix + " $(InputName).obj \" XMLDocumentationFileName= \" $(IntDir) \\ " + objPrefix + " $(InputName).xdc \" /> \n " ;
2020-07-13 06:30:06 +01:00
for ( std : : list < MSVC_Architecture > : : const_iterator arch = _archs . begin ( ) ; arch ! = _archs . end ( ) ; + + arch ) {
writeFileToProject ( projectFile , filePath , * arch , indentString , toolLine ) ;
}
2010-11-23 11:47:52 +00:00
} else {
projectFile < < indentString < < " <File RelativePath= \" " < < convertPathToWin ( filePrefix + node - > name ) < < " \" /> \n " ;
}
}
} else {
projectFile < < indentString < < " <File RelativePath= \" " < < convertPathToWin ( filePrefix + node - > name ) < < " \" /> \n " ;
}
}
}
if ( indentation )
projectFile < < getIndent ( indentation + 1 ) < < " </Filter> \n " ;
}
2020-07-13 06:30:06 +01:00
void VisualStudioProvider : : writeFileToProject ( std : : ofstream & projectFile , const std : : string & filePath , MSVC_Architecture arch ,
const std : : string & indentString , const std : : string & toolLine ) {
projectFile < < indentString < < " <File RelativePath= \" " < < filePath < < " \" > \n "
< < indentString < < " \t <FileConfiguration Name= \" Debug| " < < getMSVCConfigName ( arch ) < < " \" > \n "
< < toolLine
< < indentString < < " \t </FileConfiguration> \n "
< < indentString < < " \t <FileConfiguration Name= \" Analysis| " < < getMSVCConfigName ( arch ) < < " \" > \n "
< < toolLine
< < indentString < < " \t </FileConfiguration> \n "
< < indentString < < " \t <FileConfiguration Name= \" LLVM| " < < getMSVCConfigName ( arch ) < < " \" > \n "
< < toolLine
< < indentString < < " \t </FileConfiguration> \n "
< < indentString < < " \t <FileConfiguration Name= \" Release| " < < getMSVCConfigName ( arch ) < < " \" > \n "
< < toolLine
< < indentString < < " \t </FileConfiguration> \n "
< < indentString < < " </File> \n " ;
}
2010-11-23 11:47:52 +00:00
} // End of CreateProjectTool namespace