From 3cb5c64477845e5306d75f394692b2e57267ffb8 Mon Sep 17 00:00:00 2001 From: Julien Templier Date: Tue, 23 Nov 2010 11:22:31 +0000 Subject: TOOLS: Move MSBuild and Visual Studio project providers to separate files - Add option --build-events to run custom pre/post build events as part of the build (defaults to false and VS2010 only ATM) - Only run build events as part of VS2010 build with all engines enabled (ie. dev build) svn-id: r54424 --- dists/msvc10/create_msvc10.bat | 2 +- tools/create_project/create_project.cpp | 8 + tools/create_project/create_project.h | 8 +- tools/create_project/msvc.cpp | 821 --------------------- tools/create_project/msvc.h | 69 -- tools/create_project/msvc10/create_project.vcxproj | 4 + .../msvc10/create_project.vcxproj.filters | 12 + tools/create_project/msvc8/create_project.vcproj | 16 + tools/create_project/msvc9/create_project.vcproj | 16 + 9 files changed, 64 insertions(+), 892 deletions(-) diff --git a/dists/msvc10/create_msvc10.bat b/dists/msvc10/create_msvc10.bat index 1d3e146d52..f915d5d366 100644 --- a/dists/msvc10/create_msvc10.bat +++ b/dists/msvc10/create_msvc10.bat @@ -50,7 +50,7 @@ goto done echo. echo Creating project files with all engines enabled (stable and unstable) echo. -create_project ..\.. --enable-all-engines --msvc --msvc-version 10 +create_project ..\.. --enable-all-engines --msvc --msvc-version 10 --build-events goto done :stable diff --git a/tools/create_project/create_project.cpp b/tools/create_project/create_project.cpp index 8f8aafa3e1..904452cf84 100644 --- a/tools/create_project/create_project.cpp +++ b/tools/create_project/create_project.cpp @@ -25,7 +25,10 @@ #include "create_project.h" #include "codeblocks.h" + #include "msvc.h" +#include "visualstudio.h" +#include "msbuild.h" #include #include @@ -228,6 +231,9 @@ int main(int argc, char *argv[]) { setup.outputDir = unifyPath(argv[++i]); if (setup.outputDir.at(setup.outputDir.size() - 1) == '/') setup.outputDir.erase(setup.outputDir.size() - 1); + + } else if (!std::strcmp(argv[i], "--build-events")) { + setup.runBuildEvents = true; } else { std::cerr << "ERROR: Unknown parameter \"" << argv[i] << "\"\n"; return -1; @@ -462,6 +468,8 @@ void displayHelp(const char *exe) { " 9 stands for \"Visual Studio 2008\"\n" " 10 stands for \"Visual Studio 2010\"\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" "\n" "ScummVM engine settings:\n" " --list-engines list all available engines and their default state\n" diff --git a/tools/create_project/create_project.h b/tools/create_project/create_project.h index 0024e9386e..8c4b8c7d23 100644 --- a/tools/create_project/create_project.h +++ b/tools/create_project/create_project.h @@ -203,7 +203,7 @@ StringList getFeatureLibraries(const FeatureList &features); bool setFeatureBuildState(const std::string &name, FeatureList &features, bool enable); /** - * Structure to describe a MSVC build setup. + * Structure to describe a build setup. * * This includes various information about which engines to * enable, which features should be built into ScummVM. @@ -219,6 +219,12 @@ struct BuildSetup { StringList defines; ///< List of all defines for the build. StringList libraries; ///< List of all external libraries required for the build. + + bool runBuildEvents; + + BuildSetup() { + runBuildEvents = false; + } }; /** diff --git a/tools/create_project/msvc.cpp b/tools/create_project/msvc.cpp index 3d537b989d..fa1e405557 100644 --- a/tools/create_project/msvc.cpp +++ b/tools/create_project/msvc.cpp @@ -170,825 +170,4 @@ std::string MSVCProvider::getPostBuildEvent(bool isWin32) const { return cmdLine; } -////////////////////////////////////////////////////////////////////////// -// Visual Studio Provider -////////////////////////////////////////////////////////////////////////// - -VisualStudioProvider::VisualStudioProvider(StringList &global_warnings, std::map &project_warnings, const int version) - : MSVCProvider(global_warnings, project_warnings, version) { -} - -const char *VisualStudioProvider::getProjectExtension() { - return ".vcproj"; -} - -const char *VisualStudioProvider::getPropertiesExtension() { - return ".vsprops"; -} - -int VisualStudioProvider::getVisualStudioVersion() { - if (_version == 9) - return 2008; - - if (_version == 8) - return 2005; - - error("Unsupported version passed to createScummVMSolution"); -} - -#define OUTPUT_CONFIGURATION_SCUMMVM(config, platform, props) { \ - project << "\t\t\n" \ - "\t\t\t\n" \ - "\t\t\t\n" \ - "\t\t\n"; \ -} - -#define OUTPUT_CONFIGURATION_SCUMMVM_DEBUG(config, platform, props, isWin32) { \ - project << "\t\t\n" \ - "\t\t\t\n" \ - "\t\t\t\n" \ - "\t\t\t\n" \ - "\t\t\t\n" \ - "\t\t\n"; \ -} - -#define OUTPUT_CONFIGURATION(config, platform, props) { \ - project << "\t\t\n" \ - "\t\t\t\n" \ - "\t\t\n"; \ -} - -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()); - if (!project) - error("Could not open \"" + projectFile + "\" for writing"); - - project << "\n" - "= 9) - project << "\tTargetFrameworkVersion=\"131072\"\n"; - - project << "\t>\n" - "\t\n" - "\t\t\n" - "\t\t\n" - "\t\n" - "\t\n"; - - // Check for project-specific warnings: - std::map< std::string, std::list >::iterator warningsIterator = _projectWarnings.find(name); - - if (name == "scummvm") { - std::string libraries; - - for (StringList::const_iterator i = setup.libraries.begin(); i != setup.libraries.end(); ++i) - libraries += ' ' + *i + ".lib"; - - // Win32 - OUTPUT_CONFIGURATION_SCUMMVM_DEBUG("Debug", "Win32", "", true); - OUTPUT_CONFIGURATION_SCUMMVM_DEBUG("Analysis", "Win32", "", true); - OUTPUT_CONFIGURATION_SCUMMVM("Release", "Win32", ""); - - // x64 - // 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! - OUTPUT_CONFIGURATION_SCUMMVM_DEBUG("Debug", "x64", "64", true); - OUTPUT_CONFIGURATION_SCUMMVM_DEBUG("Analysis", "x64", "64", true); - OUTPUT_CONFIGURATION_SCUMMVM("Release", "x64", "64"); - - } else { - 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 + "\"" : ""); - toolConfig += (name == "tinsel" ? "DebugInformationFormat=\"3\" " : ""); - toolConfig += (name == "sword25" ? "DisableLanguageExtensions=\"false\" " : ""); - - // Win32 - OUTPUT_CONFIGURATION("Debug", "Win32", ""); - OUTPUT_CONFIGURATION("Analysis", "Win32", ""); - OUTPUT_CONFIGURATION("Release", "Win32", ""); - OUTPUT_CONFIGURATION("Debug", "x64", "64"); - OUTPUT_CONFIGURATION("Analysis", "x64", "64"); - OUTPUT_CONFIGURATION("Release", "x64", "64"); - } - - project << "\t\n" - "\t\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); - - project << "\t\n" - "\n"; -} - -void VisualStudioProvider::writeReferences(std::ofstream &output) { - output << "\tProjectSection(ProjectDependencies) = postProject\n"; - - for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == "scummvm") - continue; - - output << "\t\t{" << i->second << "} = {" << i->second << "}\n"; - } - - output << "\tEndProjectSection\n"; -} - -void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix) { - 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; - } - - properties << "\n" - "\n" - "\t\n" - "\t\n" - "\t\n" - "\t\n" - "\n"; - - properties.flush(); -} - -void VisualStudioProvider::createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32, bool enableAnalysis) { - const std::string outputType = (enableAnalysis ? "Analysis" : (isRelease ? "Release" : "Debug")); - const std::string outputBitness = (isWin32 ? "32" : "64"); - - std::ofstream properties((setup.outputDir + '/' + "ScummVM_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension()).c_str()); - if (!properties) - error("Could not open \"" + setup.outputDir + '/' + "ScummVM_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension() + "\" for writing"); - - properties << "\n" - "\n" - "\t\n" - "\t\n" - "\t\n" - "\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) << "\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); - const bool isDuplicate = (std::find(duplicate.begin(), duplicate.end(), name + ".o") != duplicate.end()); - - if (ext == "asm") { - std::string objFileName = "$(IntDir)\\"; - if (isDuplicate) - objFileName += objPrefix; - objFileName += "$(InputName).obj"; - - const std::string toolLine = indentString + "\t\t\n"; - - // NASM is not supported for x64, thus we do not need to add additional entries here :-). - projectFile << indentString << "name) << "\">\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\n"; - } else { - if (isDuplicate) { - const std::string toolLine = indentString + "\t\t\n"; - - projectFile << indentString << "name) << "\">\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\t\n" - << toolLine - << indentString << "\t\n" - << indentString << "\n"; - } else { - projectFile << indentString << "name) << "\" />\n"; - } - } - } else { - projectFile << indentString << "name) << "\" />\n"; - } - } - } - - if (indentation) - projectFile << getIndent(indentation + 1) << "\n"; -} - -////////////////////////////////////////////////////////////////////////// -// MSBuild Provider (Visual Studio 2010) -////////////////////////////////////////////////////////////////////////// - -MSBuildProvider::MSBuildProvider(StringList &global_warnings, std::map &project_warnings, const int version) - : MSVCProvider(global_warnings, project_warnings, version) { - -} - -const char *MSBuildProvider::getProjectExtension() { - return ".vcxproj"; -} - -const char *MSBuildProvider::getPropertiesExtension() { - return ".props"; -} - -int MSBuildProvider::getVisualStudioVersion() { - return 2010; -} - -#define OUTPUT_CONFIGURATION_MSBUILD(config, platform) \ - (project << "\t\t\n" \ - "\t\t\t" << config << "\n" \ - "\t\t\t" << platform << "\n" \ - "\t\t\n") - -#define OUTPUT_CONFIGURATION_TYPE_MSBUILD(config) \ - (project << "\t\n" \ - "\t\t" << (name == "scummvm" ? "Application" : "StaticLibrary") << "\n" \ - "\t\n") - -#define OUTPUT_PROPERTIES_MSBUILD(config, properties) \ - (project << "\t\n" \ - "\t\t\n" \ - "\t\t\n" \ - "\t\n") - -void MSBuildProvider::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()); - if (!project) - error("Could not open \"" + projectFile + "\" for writing"); - - project << "\n" - "\n" - "\t\n"; - - OUTPUT_CONFIGURATION_MSBUILD("Debug", "Win32"); - OUTPUT_CONFIGURATION_MSBUILD("Debug", "x64"); - OUTPUT_CONFIGURATION_MSBUILD("Analysis", "Win32"); - OUTPUT_CONFIGURATION_MSBUILD("Analysis", "x64"); - OUTPUT_CONFIGURATION_MSBUILD("Release", "Win32"); - OUTPUT_CONFIGURATION_MSBUILD("Release", "x64"); - - project << "\t\n"; - - // Project name & Guid - project << "\t\n" - "\t\t{" << uuid << "}\n" - "\t\t" << name << "\n" - "\t\tWin32Proj\n" - "\t\n"; - - // Shared configuration - project << "\t\n"; - - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Release|Win32"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Analysis|Win32"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Debug|Win32"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Release|x64"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Analysis|x64"); - OUTPUT_CONFIGURATION_TYPE_MSBUILD("Debug|x64"); - - project << "\t\n" - "\t\n" - "\t\n"; - - OUTPUT_PROPERTIES_MSBUILD("Release|Win32", "ScummVM_Release.props"); - OUTPUT_PROPERTIES_MSBUILD("Analysis|Win32", "ScummVM_Analysis.props"); - OUTPUT_PROPERTIES_MSBUILD("Debug|Win32", "ScummVM_Debug.props"); - OUTPUT_PROPERTIES_MSBUILD("Release|x64", "ScummVM_Release64.props"); - OUTPUT_PROPERTIES_MSBUILD("Analysis|x64", "ScummVM_Analysis64.props"); - OUTPUT_PROPERTIES_MSBUILD("Debug|x64", "ScummVM_Debug64.props"); - - project << "\t\n"; - - // Project-specific settings (analysis uses debug properties) - outputProjectSettings(project, name, setup, false, true, false); - outputProjectSettings(project, name, setup, false, true, true); - outputProjectSettings(project, name, setup, true, true, false); - outputProjectSettings(project, name, setup, false, false, false); - outputProjectSettings(project, name, setup, false, false, true); - outputProjectSettings(project, name, setup, true, false, false); - - // Files - 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); - - // Output references for scummvm project - if (name == "scummvm") - writeReferences(project); - - project << "\t\n" - "\t\n" - "\t\n" - "\n"; - - // Output filter file if necessary - createFiltersFile(setup, name); -} - -#define OUTPUT_FILTER_MSBUILD(files, action) \ - if (!files.empty()) { \ - filters << "\t\n"; \ - for (std::list::const_iterator entry = files.begin(); entry != files.end(); ++entry) { \ - if ((*entry).filter != "") { \ - filters << "\t\t<" action " Include=\"" << (*entry).path << "\">\n" \ - "\t\t\t" << (*entry).filter << "\n" \ - "\t\t\n"; \ - } else { \ - filters << "\t\t<" action " Include=\"" << (*entry).path << "\" />\n"; \ - } \ - } \ - filters << "\t\n"; \ - } - -void MSBuildProvider::createFiltersFile(const BuildSetup &setup, const std::string &name) { - // No filters => no need to create a filter file - if (_filters.empty()) - return; - - // Sort all list alphabetically - _filters.sort(); - _compileFiles.sort(); - _includeFiles.sort(); - _otherFiles.sort(); - _resourceFiles.sort(); - _asmFiles.sort(); - - const std::string filtersFile = setup.outputDir + '/' + name + getProjectExtension() + ".filters"; - std::ofstream filters(filtersFile.c_str()); - if (!filters) - error("Could not open \"" + filtersFile + "\" for writing"); - - filters << "\n" - "\n"; - - // Output the list of filters - filters << "\t\n"; - for (std::list::iterator filter = _filters.begin(); filter != _filters.end(); ++filter) { - filters << "\t\t\n" - "\t\t\t" << createUUID() << "\n" - "\t\t\n"; - } - filters << "\t\n"; - - // Output files - OUTPUT_FILTER_MSBUILD(_compileFiles, "ClCompile") - OUTPUT_FILTER_MSBUILD(_includeFiles, "ClInclude") - OUTPUT_FILTER_MSBUILD(_otherFiles, "None") - OUTPUT_FILTER_MSBUILD(_resourceFiles, "ResourceCompile") - OUTPUT_FILTER_MSBUILD(_asmFiles, "CustomBuild") - - filters << ""; -} - -void MSBuildProvider::writeReferences(std::ofstream &output) { - output << "\t\n"; - - for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == "scummvm") - continue; - - output << "\tfirst << ".vcxproj\">\n" - "\t\t{" << i->second << "}\n" - "\t\n"; - } - - output << "\t\n"; -} - -void MSBuildProvider::outputProjectSettings(std::ofstream &project, const std::string &name, const BuildSetup &setup, bool isRelease, bool isWin32, bool enableAnalysis) { - const std::string configuration = (enableAnalysis ? "Analysis" : (isRelease ? "Release" : "Debug")); - - // Check for project-specific warnings: - std::map::iterator warningsIterator = _projectWarnings.find(name); - - // Nothing to add here, move along! - if (name != "scummvm" && name != "sword25" && name != "tinsel" && warningsIterator == _projectWarnings.end()) - return; - - std::string warnings = ""; - if (warningsIterator != _projectWarnings.end()) - for (StringList::const_iterator i = warningsIterator->second.begin(); i != warningsIterator->second.end(); ++i) - warnings += *i + ';'; - - project << "\t\n" - "\t\t\n"; - - // Compile configuration - if (name == "scummvm" || name == "sword25") { - project << "\t\t\tfalse\n"; - } else { - if (name == "tinsel" && !isRelease) - project << "\t\t\tProgramDatabase\n"; - - if (warningsIterator != _projectWarnings.end()) - project << "\t\t\t" << warnings << ";%(DisableSpecificWarnings)\n"; - } - - project << "\t\t\n"; - - // Link configuration for scummvm project - if (name == "scummvm") { - std::string libraries; - - for (StringList::const_iterator i = setup.libraries.begin(); i != setup.libraries.end(); ++i) - libraries += *i + ".lib;"; - - project << "\t\t\n" - "\t\t\t$(OutDir)scummvm.exe\n" - "\t\t\t" << libraries << "%(AdditionalDependencies)\n" - "\t\t\n"; - - // Only generate revision number in debug builds - if (!isRelease) { - project << "\t\t\n" - "\t\t\tGenerate internal_version.h\n" - "\t\t\t" << getPreBuildEvent() << "\n" - "\t\t\n"; - } - - // Copy data files to the build folder - project << "\t\t\n" - "\t\t\tCopy data files to the build folder\n" - "\t\t\t" << getPostBuildEvent(isWin32) << "\n" - "\t\t\n"; - } - - project << "\t\n"; -} - -void MSBuildProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix) { - - 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) - definesList += *i + ';'; - - properties << "\n" - "\n" - "\t\n" - "\t\t<_ProjectFileVersion>10.0.30319.1\n" - "\t\t<_PropertySheetDisplayName>ScummVM_Global\n" - "\t\t$(SCUMMVM_LIBS)\\bin;$(ExecutablePath)\n" - "\t\t$(SCUMMVM_LIBS)\\lib\\" << (bits == 32 ? "x86" : "x64") << ";$(LibraryPath)\n" - "\t\t$(SCUMMVM_LIBS)\\include;$(IncludePath)\n" - "\t\t$(Configuration)" << bits << "\\\n" - "\t\t$(Configuration)" << bits << "/$(ProjectName)\\\n" - "\t\n" - "\t\n" - "\t\t\n" - "\t\t\ttrue\n" - "\t\t\t" << warnings << ";%(DisableSpecificWarnings)\n" - "\t\t\t$(SCUMMVM_LIBS)\\include;" << prefix << ";" << prefix << "\\engines;%(AdditionalIncludeDirectories)\n" - "\t\t\t" << definesList << "%(PreprocessorDefinitions)\n" - "\t\t\t\n" - "\t\t\tfalse\n" - "\t\t\tLevel4\n" - "\t\t\tfalse\n" - "\t\t\tDefault\n" - "\t\t\n" - "\t\t\n" - "\t\t\t%(IgnoreSpecificDefaultLibraries)\n" - "\t\t\tConsole\n" - "\t\t\tWinMainCRTStartup\n" - "\t\t\n" - "\t\t\n" - "\t\t\tHAS_INCLUDE_SET;%(PreprocessorDefinitions)\n" - "\t\t\t" << prefix << ";%(AdditionalIncludeDirectories)\n" - "\t\t\n" - "\t\n" - "\n"; - - properties.flush(); -} - -void MSBuildProvider::createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32, bool enableAnalysis) { - const std::string outputType = (enableAnalysis ? "Analysis" : (isRelease ? "Release" : "Debug")); - const std::string outputBitness = (isWin32 ? "32" : "64"); - - std::ofstream properties((setup.outputDir + '/' + "ScummVM_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension()).c_str()); - if (!properties) - error("Could not open \"" + setup.outputDir + '/' + "ScummVM_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension() + "\" for writing"); - - properties << "\n" - "\n" - "\t\n" - "\t\t\n" - "\t\n" - "\t\n" - "\t\t<_ProjectFileVersion>10.0.30319.1\n" - "\t\t<_PropertySheetDisplayName>ScummVM_" << outputType << outputBitness << "\n" - "\t\t" << (isRelease ? "false" : "true") << "\n" - "\t\n" - "\t\n" - "\t\t\n"; - - if (isRelease) { - properties << "\t\t\ttrue\n" - "\t\t\ttrue\n" - "\t\t\tWIN32;RELEASE_BUILD;%(PreprocessorDefinitions)\n" - "\t\t\ttrue\n" - "\t\t\tfalse\n" - "\t\t\t\n" - "\t\t\t" << (enableAnalysis ? "true" : "false") << "\n" - "\t\t\n" - "\t\t\n" - "\t\t\t%(IgnoreSpecificDefaultLibraries)\n" - "\t\t\ttrue\n"; - } else { - properties << "\t\t\tDisabled\n" - "\t\t\tWIN32;%(PreprocessorDefinitions)\n" - "\t\t\ttrue\n" - "\t\t\tEnableFastChecks\n" - "\t\t\tMultiThreadedDebug\n" - "\t\t\ttrue\n" - "\t\t\tfalse\n" - "\t\t\t" << (isWin32 ? "EditAndContinue" : "ProgramDatabase") << "\n" // For x64 format Edit and continue is not supported, thus we default to Program Database - "\t\t\t" << (enableAnalysis ? "true" : "false") << "\n" - "\t\t\n" - "\t\t\n" - "\t\t\ttrue\n" - "\t\t\tlibcmt.lib;%(IgnoreSpecificDefaultLibraries)\n"; - } - - properties << "\t\t\n" - "\t\n" - "\n"; - - properties.flush(); - properties.close(); -} - -#define OUTPUT_NASM_COMMAND_MSBUILD(config) \ - projectFile << "\t\t\tnasm.exe -f win32 -g -o \"$(IntDir)" << (isDuplicate ? (*entry).prefix : "") << "%(Filename).obj\" \"%(FullPath)\"\n" \ - "\t\t\t$(IntDir)" << (isDuplicate ? (*entry).prefix : "") << "%(Filename).obj;%(Outputs)\n"; - -#define OUPUT_FILES_MSBUILD(files, action) \ - if (!files.empty()) { \ - projectFile << "\t\n"; \ - for (std::list::const_iterator entry = files.begin(); entry != files.end(); ++entry) { \ - projectFile << "\t\t<" action " Include=\"" << (*entry).path << "\" />\n"; \ - } \ - projectFile << "\t\n"; \ - } - -bool hasEnding(std::string const &fullString, std::string const &ending) { - if (fullString.length() > ending.length()) { - return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending)); - } else { - return false; - } -} - - -void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int, const StringList &duplicate, - const std::string &objPrefix, const std::string &filePrefix) { - // Reset lists - _filters.clear(); - _compileFiles.clear(); - _includeFiles.clear(); - _otherFiles.clear(); - _resourceFiles.clear(); - _asmFiles.clear(); - - // Compute the list of files - _filters.push_back(""); // init filters - computeFileList(dir, duplicate, objPrefix, filePrefix); - _filters.pop_back(); // remove last empty filter - - // Output compile files - if (!_compileFiles.empty()) { - projectFile << "\t\n"; - for (std::list::const_iterator entry = _compileFiles.begin(); entry != _compileFiles.end(); ++entry) { - const bool isDuplicate = (std::find(duplicate.begin(), duplicate.end(), (*entry).name + ".o") != duplicate.end()); - - // Deal with duplicated file names - if (isDuplicate) { - projectFile << "\t\t\n" - "\t\t\t$(IntDir)" << (*entry).prefix << "%(Filename).obj\n"; - - if (hasEnding((*entry).path, "base\\version.cpp")) - projectFile << "\t\t\tSCUMMVM_SVN_REVISION#" $(SCUMMVM_REVISION_STRING)";%(PreprocessorDefinitions)\n"; - - projectFile << "\t\t\n"; - } else { - projectFile << "\t\t\n"; - } - } - projectFile << "\t\n"; - } - - // Output include, other and resource files - OUPUT_FILES_MSBUILD(_includeFiles, "ClInclude") - OUPUT_FILES_MSBUILD(_otherFiles, "None") - OUPUT_FILES_MSBUILD(_resourceFiles, "ResourceCompile") - - // Output asm files - if (!_asmFiles.empty()) { - projectFile << "\t\n"; - for (std::list::const_iterator entry = _asmFiles.begin(); entry != _asmFiles.end(); ++entry) { - - const bool isDuplicate = (std::find(duplicate.begin(), duplicate.end(), (*entry).name + ".o") != duplicate.end()); - - projectFile << "\t\t\n" - "\t\t\tDocument\n"; - - OUTPUT_NASM_COMMAND_MSBUILD("Debug") - OUTPUT_NASM_COMMAND_MSBUILD("Analysis") - OUTPUT_NASM_COMMAND_MSBUILD("Release") - - projectFile << "\t\t\n"; - } - projectFile << "\t\n"; - } -} - -void MSBuildProvider::computeFileList(const FileNode &dir, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) { - for (FileNode::NodeList::const_iterator i = dir.children.begin(); i != dir.children.end(); ++i) { - const FileNode *node = *i; - - if (!node->children.empty()) { - // Update filter - std::string _currentFilter = _filters.back(); - _filters.back().append((_filters.back() == "" ? "" : "\\") + node->name); - - computeFileList(*node, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/'); - - // Reset filter - _filters.push_back(_currentFilter); - } else { - // Filter files by extension - std::string name, ext; - splitFilename(node->name, name, ext); - - FileEntry entry; - entry.name = name; - entry.path = convertPathToWin(filePrefix + node->name); - entry.filter = _filters.back(); - entry.prefix = objPrefix; - - if (ext == "cpp" || ext == "c") - _compileFiles.push_back(entry); - else if (ext == "h") - _includeFiles.push_back(entry); - else if (ext == "rc") - _resourceFiles.push_back(entry); - else if (ext == "asm") - _asmFiles.push_back(entry); - else - _otherFiles.push_back(entry); - } - } -} - } // End of CreateProjectTool namespace diff --git a/tools/create_project/msvc.h b/tools/create_project/msvc.h index d5c90972f4..f41ecc3aba 100644 --- a/tools/create_project/msvc.h +++ b/tools/create_project/msvc.h @@ -95,75 +95,6 @@ protected: std::string getPostBuildEvent(bool isWin32) const; }; -class VisualStudioProvider : public MSVCProvider { -public: - VisualStudioProvider(StringList &global_warnings, std::map &project_warnings, const int version); - -protected: - void createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, - const StringList &includeList, const StringList &excludeList); - - void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, - const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix); - - void writeReferences(std::ofstream &output); - - void outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix); - - void createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32, bool enableAnalysis); - - const char *getProjectExtension(); - const char *getPropertiesExtension(); - int getVisualStudioVersion(); -}; - -class MSBuildProvider : public MSVCProvider { -public: - MSBuildProvider(StringList &global_warnings, std::map &project_warnings, const int version); - -protected: - void createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, - const StringList &includeList, const StringList &excludeList); - - void outputProjectSettings(std::ofstream &project, const std::string &name, const BuildSetup &setup, bool isRelease, bool isWin32, bool enableAnalysis); - - void writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int indentation, - const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix); - - void writeReferences(std::ofstream &output); - - void outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix); - - void createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32, bool enableAnalysis); - - const char *getProjectExtension(); - const char *getPropertiesExtension(); - int getVisualStudioVersion(); - -private: - struct FileEntry { - std::string name; - std::string path; - std::string filter; - std::string prefix; - - bool operator<(const FileEntry& rhs) const { - return path.compare(rhs.path) == -1; // Not exactly right for alphabetical order, but good enough - } - }; - typedef std::list FileEntries; - - std::list _filters; // list of filters (we need to create a GUID for each filter id) - FileEntries _compileFiles; - FileEntries _includeFiles; - FileEntries _otherFiles; - FileEntries _asmFiles; - FileEntries _resourceFiles; - - void computeFileList(const FileNode &dir, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix); - void createFiltersFile(const BuildSetup &setup, const std::string &name); -}; - } // End of CreateProjectTool namespace #endif // TOOLS_CREATE_PROJECT_MSVC_H diff --git a/tools/create_project/msvc10/create_project.vcxproj b/tools/create_project/msvc10/create_project.vcxproj index 305eadcf72..532d6dba29 100644 --- a/tools/create_project/msvc10/create_project.vcxproj +++ b/tools/create_project/msvc10/create_project.vcxproj @@ -95,12 +95,16 @@ xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\codeblocks\ + + + + diff --git a/tools/create_project/msvc10/create_project.vcxproj.filters b/tools/create_project/msvc10/create_project.vcxproj.filters index edf947d6e6..7922e1e6f7 100644 --- a/tools/create_project/msvc10/create_project.vcxproj.filters +++ b/tools/create_project/msvc10/create_project.vcxproj.filters @@ -21,6 +21,12 @@ Header Files + + Header Files + + + Header Files + @@ -32,6 +38,12 @@ Source Files + + Source Files + + + Source Files + diff --git a/tools/create_project/msvc8/create_project.vcproj b/tools/create_project/msvc8/create_project.vcproj index 1e1a68d2ba..bc3b2437ac 100644 --- a/tools/create_project/msvc8/create_project.vcproj +++ b/tools/create_project/msvc8/create_project.vcproj @@ -176,6 +176,14 @@ RelativePath="..\msvc.cpp" > + + + + + + + + + + + + + + + +