CREATE_PROJECT: Add support for Visual Studio 2012 project creation

This commit is contained in:
Littleboy 2012-07-11 01:08:22 -04:00
parent 4e0f6d346f
commit d86c0a44f8
6 changed files with 122 additions and 10 deletions

View File

@ -65,7 +65,7 @@ create_lure (dreammaster)
create_project (LordHoto, Littleboy)
--------------
Creates project files for Visual Studio 2005, 2008, 2010, Xcode and
Creates project files for Visual Studio 2005, 2008, 2010, 2012, Xcode and
Code::Blocks out of the configure / Makefile based build system.
It also offers a way to enable or disable certain engines and the use
of external libraries similar to configure. Run the tool without

View File

@ -221,7 +221,7 @@ int main(int argc, char *argv[]) {
msvcVersion = atoi(argv[++i]);
if (msvcVersion != 8 && msvcVersion != 9 && msvcVersion != 10) {
if (msvcVersion != 8 && msvcVersion != 9 && msvcVersion != 10 && msvcVersion != 11) {
std::cerr << "ERROR: Unsupported version: \"" << msvcVersion << "\" passed to \"--msvc-version\"!\n";
return -1;
}
@ -643,6 +643,7 @@ void displayHelp(const char *exe) {
" 8 stands for \"Visual Studio 2005\"\n"
" 9 stands for \"Visual Studio 2008\"\n"
" 10 stands for \"Visual Studio 2010\"\n"
" 11 stands for \"Visual Studio 2012\"\n"
" The default is \"9\", thus \"Visual Studio 2008\"\n"
" --build-events Run custom build events as part of the build\n"
" (default: false)\n"

View File

@ -46,7 +46,13 @@ const char *MSBuildProvider::getPropertiesExtension() {
}
int MSBuildProvider::getVisualStudioVersion() {
return 2010;
if (_version == 10)
return 2010;
if (_version == 11)
return 2012;
error("Unsupported version passed to getVisualStudioVersion");
}
namespace {
@ -58,9 +64,10 @@ inline void outputConfiguration(std::ostream &project, const std::string &config
"\t\t</ProjectConfiguration>\n";
}
inline void outputConfigurationType(const BuildSetup &setup, std::ostream &project, const std::string &name, const std::string &config) {
inline void outputConfigurationType(const BuildSetup &setup, std::ostream &project, const std::string &name, const std::string &config, int version) {
project << "\t<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='" << config << "'\" Label=\"Configuration\">\n"
"\t\t<ConfigurationType>" << ((name == setup.projectName || setup.devTools) ? "Application" : "StaticLibrary") << "</ConfigurationType>\n"
"\t\t<PlatformToolset>v" << version << "0</PlatformToolset>"
"\t</PropertyGroup>\n";
}
@ -98,17 +105,18 @@ void MSBuildProvider::createProjectFile(const std::string &name, const std::stri
"\t\t<ProjectGuid>{" << uuid << "}</ProjectGuid>\n"
"\t\t<RootNamespace>" << name << "</RootNamespace>\n"
"\t\t<Keyword>Win32Proj</Keyword>\n"
"\t\t<VCTargetsPath Condition=\"'$(VCTargetsPath11)' != '' and '$(VSVersion)' == '' and $(VisualStudioVersion) == ''\">$(VCTargetsPath11)</VCTargetsPath>\n"
"\t</PropertyGroup>\n";
// Shared configuration
project << "\t<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n";
outputConfigurationType(setup, project, name, "Release|Win32");
outputConfigurationType(setup, project, name, "Analysis|Win32");
outputConfigurationType(setup, project, name, "Debug|Win32");
outputConfigurationType(setup, project, name, "Release|x64");
outputConfigurationType(setup, project, name, "Analysis|x64");
outputConfigurationType(setup, project, name, "Debug|x64");
outputConfigurationType(setup, project, name, "Release|Win32", _version);
outputConfigurationType(setup, project, name, "Analysis|Win32", _version);
outputConfigurationType(setup, project, name, "Debug|Win32", _version);
outputConfigurationType(setup, project, name, "Release|x64", _version);
outputConfigurationType(setup, project, name, "Analysis|x64", _version);
outputConfigurationType(setup, project, name, "Debug|x64", _version);
project << "\t<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n"
"\t<ImportGroup Label=\"ExtensionSettings\">\n"

View File

@ -63,6 +63,7 @@
</Link>
<PostBuildEvent>
<Command>@echo off
xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\msvc11\"
xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\msvc10\"
xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\msvc9\"
xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\msvc8\"
@ -89,6 +90,7 @@ xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\iphone\"</Command>
</Link>
<PostBuildEvent>
<Command>@echo off
xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\msvc11\"
xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\msvc10\"
xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\msvc9\"
xcopy /Y "$(TargetPath)" "$(SolutionDir)\..\..\..\dists\msvc8\"

View File

@ -0,0 +1,95 @@
@echo off
echo.
echo Automatic creation of the MSVC11 project files
echo.
if "%~1"=="/stable" goto stable
if "%~1"=="/STABLE" goto stable
if "%~1"=="/all" goto all
if "%~1"=="/ALL" goto all
if "%~1"=="/tools" goto tools
if "%~1"=="/TOOLS" goto tools
if "%~1"=="/clean" goto clean_check
if "%~1"=="/CLEAN" goto clean_check
if "%~1"=="/help" goto command_help
if "%~1"=="/HELP" goto command_help
if "%~1"=="/?" goto command_help
if "%~1"=="" goto check_tool
echo Invalid command parameter: %~1
echo.
:command_help
echo Valid command parameters are:
echo stable Generated stable engines project files
echo all Generate all engines project files
echo tools Generate project files for the devtools
echo clean Clean generated project files
echo help Show help message
goto done
:check_tool
if not exist create_project.exe goto no_tool
:question
echo.
set batchanswer=S
set /p batchanswer="Enable stable engines only, or all engines? (S/a)"
if "%batchanswer%"=="s" goto stable
if "%batchanswer%"=="S" goto stable
if "%batchanswer%"=="a" goto all
if "%batchanswer%"=="A" goto all
goto question
:no_tool
echo create_project.exe not found in the current folder.
echo You need to build it first and copy it in this
echo folder
goto done
:all
echo.
echo Creating project files with all engines enabled (stable and unstable)
echo.
create_project ..\.. --enable-all-engines --msvc --msvc-version 11 --build-events
goto done
:stable
echo.
echo Creating normal project files, with only the stable engines enabled
echo.
create_project ..\.. --msvc --msvc-version 11
goto done
:tools
echo.
echo Creating tools project files
echo.
create_project ..\.. --tools --msvc --msvc-version 11
goto done
:clean_check
echo.
set cleananswer=N
set /p cleananswer="This will remove all project files. Are you sure you want to continue? (N/y)"
if "%cleananswer%"=="n" goto done
if "%cleananswer%"=="N" goto done
if "%cleananswer%"=="y" goto clean
if "%cleananswer%"=="Y" goto clean
goto clean_check
:clean
echo.
echo Removing all project files
del /Q *.vcxproj* > NUL 2>&1
del /Q *.props > NUL 2>&1
del /Q *.sln* > NUL 2>&1
del /Q scummvm* > NUL 2>&1
del /Q devtools* > NUL 2>&1
goto done
:done
echo.
pause

6
dists/msvc11/readme.txt Normal file
View File

@ -0,0 +1,6 @@
The Visual Studio project files can now be created automatically from the GCC
files using the create_project tool inside the /devtools/create_project folder.
To create the default project files, build create_project.exe, copy it inside
this folder and run the create_msvc11.bat file for a default build. You can run
create_project.exe with no parameters to check the possible command-line options