diff options
author | Matthew Hoops | 2011-05-11 00:30:02 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-05-11 00:30:28 -0400 |
commit | a1d41da096c0bcf502a85919cb1cb1ee471719c5 (patch) | |
tree | 8c51419daa486f1d4833757db4715dadab6c3497 /devtools/create_project | |
parent | accb0c2a5d0c9e7b353cda4b74f511a498ed8073 (diff) | |
parent | 33c3e19cea2a08fbf26ecbe940763e8ee1c37d28 (diff) | |
download | scummvm-rg350-a1d41da096c0bcf502a85919cb1cb1ee471719c5.tar.gz scummvm-rg350-a1d41da096c0bcf502a85919cb1cb1ee471719c5.tar.bz2 scummvm-rg350-a1d41da096c0bcf502a85919cb1cb1ee471719c5.zip |
Merge remote branch 'upstream/master' into t7g-ios
Conflicts:
audio/decoders/qdm2.h
common/util.cpp
engines/groovie/music.cpp
engines/groovie/resource.h
video/qt_decoder.cpp
video/qt_decoder.h
Diffstat (limited to 'devtools/create_project')
19 files changed, 758 insertions, 360 deletions
diff --git a/devtools/create_project/codeblocks.cpp b/devtools/create_project/codeblocks.cpp index d803fb0a37..8ca139e515 100644 --- a/devtools/create_project/codeblocks.cpp +++ b/devtools/create_project/codeblocks.cpp @@ -23,6 +23,7 @@ * */ +#include "config.h" #include "codeblocks.h" #include <fstream> @@ -34,20 +35,20 @@ CodeBlocksProvider::CodeBlocksProvider(StringList &global_warnings, std::map<std } void CodeBlocksProvider::createWorkspace(const BuildSetup &setup) { - std::ofstream workspace((setup.outputDir + '/' + "scummvm.workspace").c_str()); + std::ofstream workspace((setup.outputDir + '/' + PROJECT_NAME + ".workspace").c_str()); if (!workspace) - error("Could not open \"" + setup.outputDir + '/' + "scummvm.workspace\" for writing"); + error("Could not open \"" + setup.outputDir + '/' + PROJECT_NAME + ".workspace\" for writing"); workspace << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\n" "<CodeBlocks_workspace_file>\n"; - workspace << "\t<Workspace title=\"ScummVM\">\n"; + workspace << "\t<Workspace title=\"" << PROJECT_DESCRIPTION << "\">\n"; writeReferences(workspace); // Note we assume that the UUID map only includes UUIDs for enabled engines! for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == "scummvm") + if (i->first == PROJECT_NAME) continue; workspace << "\t\t<Project filename=\"" << i->first << ".cbp\" />\n"; @@ -59,7 +60,7 @@ void CodeBlocksProvider::createWorkspace(const BuildSetup &setup) { // HACK We need to pre-process library names // since the MSVC and mingw precompiled -// librarie have different names :( +// libraries have different names :( std::string processLibraryName(std::string name) { // Remove "_static" in lib name size_t pos = name.find("_static"); @@ -90,16 +91,16 @@ void CodeBlocksProvider::createProjectFile(const std::string &name, const std::s "\t\t<Option compiler=\"gcc\" />\n" "\t\t<Build>\n"; - if (name == "scummvm") { + if (name == PROJECT_NAME) { std::string libraries; for (StringList::const_iterator i = setup.libraries.begin(); i != setup.libraries.end(); ++i) libraries += processLibraryName(*i) + ".a;"; project << "\t\t\t<Target title=\"default\">\n" - "\t\t\t\t<Option output=\"scummvm\\scummvm\" prefix_auto=\"1\" extension_auto=\"1\" />\n" - "\t\t\t\t<Option object_output=\"scummvm\" />\n" - "\t\t\t\t<Option external_deps=\"" << libraries /* + list of engines scummvm\engines\name\name.a */ << "\" />\n" + "\t\t\t\t<Option output=\"" << PROJECT_NAME << "\\" << PROJECT_NAME << "\" prefix_auto=\"1\" extension_auto=\"1\" />\n" + "\t\t\t\t<Option object_output=\"" << PROJECT_NAME << "\" />\n" + "\t\t\t\t<Option external_deps=\"" << libraries /* + list of engines engines\name\name.a */ << "\" />\n" "\t\t\t\t<Option type=\"1\" />\n" "\t\t\t\t<Option compiler=\"gcc\" />\n" "\t\t\t\t<Option parameters=\"-d 8 --debugflags=parser\" />\n" @@ -112,8 +113,8 @@ void CodeBlocksProvider::createProjectFile(const std::string &name, const std::s writeWarnings(name, project); writeDefines(setup.defines, project); - project << "\t\t\t\t\t<Add directory=\"$(SCUMMVM_LIBS)include\" />\n" - "\t\t\t\t\t<Add directory=\"$(SCUMMVM_LIBS)include\\SDL\" />\n" + project << "\t\t\t\t\t<Add directory=\"$(" << LIBS_DEFINE << ")include\" />\n" + "\t\t\t\t\t<Add directory=\"$(" << LIBS_DEFINE << ")include\\SDL\" />\n" "\t\t\t\t\t<Add directory=\"..\\..\\engines\" />\n" "\t\t\t\t\t<Add directory=\"..\\..\\common\" />\n" "\t\t\t\t\t<Add directory=\"..\\..\" />\n" @@ -127,21 +128,21 @@ void CodeBlocksProvider::createProjectFile(const std::string &name, const std::s project << "\t\t\t\t\t<Add library=\"" << processLibraryName(*i) << "\" />\n"; for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == "scummvm") + if (i->first == PROJECT_NAME) continue; - project << "\t\t\t\t\t<Add library=\"scummvm\\engines\\" << i->first << "\\lib" << i->first << ".a\" />\n"; + project << "\t\t\t\t\t<Add library=\"" << PROJECT_NAME << "\\engines\\" << i->first << "\\lib" << i->first << ".a\" />\n"; } - project << "\t\t\t\t\t<Add directory=\"$(SCUMMVM_LIBS)lib\\mingw\" />\n" - "\t\t\t\t\t<Add directory=\"$(SCUMMVM_LIBS)lib\" />\n" + project << "\t\t\t\t\t<Add directory=\"$(" << LIBS_DEFINE << ")lib\\mingw\" />\n" + "\t\t\t\t\t<Add directory=\"$(" << LIBS_DEFINE << ")lib\" />\n" "\t\t\t\t</Linker>\n"; ////////////////////////////////////////////////////////////////////////// // Resource compiler project << "\t\t\t\t<ResourceCompiler>\n" "\t\t\t\t\t<Add directory=\"..\\..\\dists\" />\n" - "\t\t\t\t\t<Add directory=\"..\\..\\..\\scummvm\" />\n" + "\t\t\t\t\t<Add directory=\"..\\..\\..\\" << PROJECT_NAME << "\" />\n" "\t\t\t\t</ResourceCompiler>\n" "\t\t\t</Target>\n" "\t\t</Build>\n"; @@ -150,9 +151,9 @@ void CodeBlocksProvider::createProjectFile(const std::string &name, const std::s } else { project << "\t\t\t<Target title=\"default\">\n" - "\t\t\t\t<Option output=\"scummvm\\engines\\" << name << "\\lib" << name << "\" prefix_auto=\"1\" extension_auto=\"1\" />\n" + "\t\t\t\t<Option output=\"" << PROJECT_NAME << "\\engines\\" << name << "\\lib" << name << "\" prefix_auto=\"1\" extension_auto=\"1\" />\n" "\t\t\t\t<Option working_dir=\"\" />\n" - "\t\t\t\t<Option object_output=\"scummvm\" />\n" + "\t\t\t\t<Option object_output=\"" << PROJECT_NAME << "\" />\n" "\t\t\t\t<Option type=\"2\" />\n" "\t\t\t\t<Option compiler=\"gcc\" />\n" "\t\t\t\t<Option createDefFile=\"1\" />\n" @@ -163,11 +164,11 @@ void CodeBlocksProvider::createProjectFile(const std::string &name, const std::s project << "\t\t\t\t\t<Add option=\"-g\" />\n" "\t\t\t\t\t<Add directory=\"..\\..\\engines\" />\n" - "\t\t\t\t\t<Add directory=\"..\\..\\..\\scummvm\" />\n"; + "\t\t\t\t\t<Add directory=\"..\\..\\..\\" << PROJECT_NAME << "\" />\n"; // Sword2.5 engine needs theora and vorbis includes if (name == "sword25") - project << "\t\t\t\t\t<Add directory=\"$(SCUMMVM_LIBS)include\" />\n"; + project << "\t\t\t\t\t<Add directory=\"$(" << LIBS_DEFINE << ")include\" />\n"; project << "\t\t\t\t</Compiler>\n" "\t\t\t</Target>\n" @@ -233,7 +234,7 @@ void CodeBlocksProvider::writeFileListToProject(const FileNode &dir, std::ofstre "\t\t</Unit>\n"; } else if (ext == "asm") { projectFile << "\t\t<Unit filename=\"" << convertPathToWin(filePrefix + node->name) << "\">\n" - "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"$(SCUMMVM_LIBS)bin/nasm.exe -f win32 -g $file -o $object\" />" + "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"$(" << LIBS_DEFINE << ")bin/nasm.exe -f win32 -g $file -o $object\" />" "\t\t</Unit>\n"; } else { projectFile << "\t\t<Unit filename=\"" << convertPathToWin(filePrefix + node->name) << "\" />\n"; @@ -243,10 +244,10 @@ void CodeBlocksProvider::writeFileListToProject(const FileNode &dir, std::ofstre } void CodeBlocksProvider::writeReferences(std::ofstream &output) { - output << "\t\t<Project filename=\"scummvm.cbp\" active=\"1\">\n"; + output << "\t\t<Project filename=\"" << PROJECT_NAME << ".cbp\" active=\"1\">\n"; for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == "scummvm") + if (i->first == " << PROJECT_NAME << ") continue; output << "\t\t\t<Depends filename=\"" << i->first << ".cbp\" />\n"; diff --git a/devtools/create_project/codeblocks/create_project.cbp b/devtools/create_project/codeblocks/create_project.cbp index 9078ddcd51..25b12d8cc2 100644 --- a/devtools/create_project/codeblocks/create_project.cbp +++ b/devtools/create_project/codeblocks/create_project.cbp @@ -36,6 +36,7 @@ <Add option="-Wall" /> <Add option="-fexceptions" /> </Compiler> + <Unit filename="..\config.h" /> <Unit filename="..\codeblocks.cpp" /> <Unit filename="..\codeblocks.h" /> <Unit filename="..\create_project.cpp" /> diff --git a/devtools/create_project/config.h b/devtools/create_project/config.h new file mode 100644 index 0000000000..1609e9e99a --- /dev/null +++ b/devtools/create_project/config.h @@ -0,0 +1,38 @@ +/* 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. + * + * $URL$ + * $Id$ + * + */ + +#ifndef TOOLS_CREATE_PROJECT_CONFIG_H +#define TOOLS_CREATE_PROJECT_CONFIG_H + +#define PROJECT_DESCRIPTION "ScummVM" // Used in console output and build configuration +#define PROJECT_NAME "scummvm" // Used for folders, icons, resources and project/solution name +#define LIBS_DEFINE "SCUMMVM_LIBS" // Name of the include environment variable +#define REVISION_DEFINE "SCUMMVM_INTERNAL_REVISION" + +#define HAS_VIDEO_FOLDER 1 +//#define ADDITIONAL_LIBRARY "" +#define NEEDS_RTTI 0 + +#endif // TOOLS_CREATE_PROJECT_CONFIG_H diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index b896e85131..de82dd1698 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -29,6 +29,7 @@ #undef main #endif // main +#include "config.h" #include "create_project.h" #include "codeblocks.h" @@ -150,7 +151,7 @@ int main(int argc, char *argv[]) { using std::cout; for (int i = 2; i < argc; ++i) { if (!std::strcmp(argv[i], "--list-engines")) { - cout << " The following enables are available in the ScummVM source distribution\n" + cout << " The following enables are available in the " PROJECT_DESCRIPTION " source distribution\n" " located at \"" << srcDir << "\":\n"; cout << " state | name | description\n\n"; @@ -244,6 +245,9 @@ int main(int argc, char *argv[]) { } else if (!std::strcmp(argv[i], "--build-events")) { setup.runBuildEvents = true; + } else if (!std::strcmp(argv[i], "--installer")) { + setup.runBuildEvents = true; + setup.createInstaller = true; } else { std::cerr << "ERROR: Unknown parameter \"" << argv[i] << "\"\n"; return -1; @@ -289,20 +293,17 @@ int main(int argc, char *argv[]) { setup.libraries.push_back("sdl"); setup.libraries.push_back("winmm"); -// Initialize global & project-specific warnings -#define SET_GLOBAL_WARNINGS(...) \ - { \ - std::string global[PP_NARG(__VA_ARGS__)] = { __VA_ARGS__ }; \ - globalWarnings.assign(global, global + (sizeof(global) / sizeof(global[0]))); \ - } - -#define SET_WARNINGS(name, ...) \ - { \ - std::string project[PP_NARG(__VA_ARGS__)] = { __VA_ARGS__ }; \ - projectWarnings[name].assign(project, project + (sizeof(project) / sizeof(project[0]))); \ - } + // Add additional project-specific library +#ifdef ADDITIONAL_LIBRARY + setup.libraries.push_back(ADDITIONAL_LIBRARY); +#endif // List of global warnings and map of project-specific warnings + // FIXME: As shown below these two structures have different behavior for + // Code::Blocks and MSVC. In Code::Blocks this is used to enable *and* + // disable certain warnings (and some other not warning related flags + // actually...). While in MSVC this is solely for disabling warnings. + // That is really not nice. We should consider a nicer way of doing this. StringList globalWarnings; std::map<std::string, StringList> projectWarnings; @@ -336,9 +337,23 @@ int main(int argc, char *argv[]) { // //////////////////////////////////////////////////////////////////////////// - SET_GLOBAL_WARNINGS("-Wall", "-Wno-long-long", "-Wno-multichar", "-Wno-unknown-pragmas", "-Wno-reorder", - "-Wpointer-arith", "-Wcast-qual", "-Wcast-align", "-Wshadow", "-Wimplicit", - "-Wnon-virtual-dtor", "-Wwrite-strings", "-fno-rtti", "-fno-exceptions", "-fcheck-new"); + globalWarnings.push_back("-Wall"); + globalWarnings.push_back("-Wno-long-long"); + globalWarnings.push_back("-Wno-multichar"); + globalWarnings.push_back("-Wno-unknown-pragmas"); + globalWarnings.push_back("-Wno-reorder"); + globalWarnings.push_back("-Wpointer-arith"); + globalWarnings.push_back("-Wcast-qual"); + globalWarnings.push_back("-Wcast-align"); + globalWarnings.push_back("-Wshadow"); + globalWarnings.push_back("-Wimplicit"); + globalWarnings.push_back("-Wnon-virtual-dtor"); + globalWarnings.push_back("-Wwrite-strings"); + // The following are not warnings at all... We should consider adding them to + // a different list of parameters. + globalWarnings.push_back("-fno-rtti"); + globalWarnings.push_back("-fno-exceptions"); + globalWarnings.push_back("-fcheck-new"); provider = new CreateProjectTool::CodeBlocksProvider(globalWarnings, projectWarnings); @@ -415,12 +430,35 @@ int main(int argc, char *argv[]) { // //////////////////////////////////////////////////////////////////////////// - SET_GLOBAL_WARNINGS("4068", "4100", "4103", "4127", "4244", "4250", "4310", "4351", "4512", "4702", "4706", "4800", "4996", "6204", "6211", "6385", "6386"); - SET_WARNINGS("agi", "4510", "4610"); - SET_WARNINGS("agos", "4511"); - SET_WARNINGS("lure", "4189", "4355"); - SET_WARNINGS("kyra", "4355"); - SET_WARNINGS("m4", "4355"); + globalWarnings.push_back("4068"); + globalWarnings.push_back("4100"); + globalWarnings.push_back("4103"); + globalWarnings.push_back("4127"); + globalWarnings.push_back("4244"); + globalWarnings.push_back("4250"); + globalWarnings.push_back("4310"); + globalWarnings.push_back("4351"); + globalWarnings.push_back("4512"); + globalWarnings.push_back("4702"); + globalWarnings.push_back("4706"); + globalWarnings.push_back("4800"); + globalWarnings.push_back("4996"); + globalWarnings.push_back("6204"); + globalWarnings.push_back("6211"); + globalWarnings.push_back("6385"); + globalWarnings.push_back("6386"); + + projectWarnings["agi"].push_back("4510"); + projectWarnings["agi"].push_back("4610"); + + projectWarnings["agos"].push_back("4511"); + + projectWarnings["lure"].push_back("4189"); + projectWarnings["lure"].push_back("4355"); + + projectWarnings["kyra"].push_back("4355"); + + projectWarnings["m4"].push_back("4355"); if (msvcVersion == 8 || msvcVersion == 9) provider = new CreateProjectTool::VisualStudioProvider(globalWarnings, projectWarnings, msvcVersion); @@ -456,7 +494,7 @@ void displayHelp(const char *exe) { cout << "Usage:\n" << exe << " path\\to\\source [optional options]\n" << "\n" - << " Creates project files for the ScummVM source located at \"path\\to\\source\".\n" + << " Creates project files for the " PROJECT_DESCRIPTION " source located at \"path\\to\\source\".\n" " The project files will be created in the directory where tool is run from and\n" " will include \"path\\to\\source\" for relative file paths, thus be sure that you\n" " pass a relative file path like \"..\\..\\trunk\".\n" @@ -481,15 +519,17 @@ void displayHelp(const char *exe) { " The default is \"9\", thus \"Visual Studio 2008\"\n" " --build-events Run custom build events as part of the build\n" " (default: false)\n" + " --installer Create NSIS installer after the build (implies --build-events)\n" + " (default: false)\n" "\n" - "ScummVM engine settings:\n" + "Engines settings:\n" " --list-engines list all available engines and their default state\n" " --enable-engine enable building of the engine with the name \"engine\"\n" " --disable-engine disable building of the engine with the name \"engine\"\n" " --enable-all-engines enable building of all engines\n" " --disable-all-engines disable building of all engines\n" "\n" - "ScummVM optional feature settings:\n" + "Optional features settings:\n" " --enable-name enable inclusion of the feature \"name\"\n" " --disable-name disable inclusion of the feature \"name\"\n" "\n" @@ -686,25 +726,26 @@ TokenList tokenize(const std::string &input) { namespace { const Feature s_features[] = { // Libraries - { "libz", "USE_ZLIB", "zlib", true, "zlib (compression) support" }, - { "mad", "USE_MAD", "libmad", true, "libmad (MP3) support" }, + { "libz", "USE_ZLIB", "zlib", true, "zlib (compression) support" }, + { "mad", "USE_MAD", "libmad", true, "libmad (MP3) support" }, { "vorbis", "USE_VORBIS", "libvorbisfile_static libvorbis_static libogg_static", true, "Ogg Vorbis support" }, - { "flac", "USE_FLAC", "libFLAC_static", true, "FLAC support" }, - { "png", "USE_PNG", "libpng", true, "libpng support" }, - { "theora", "USE_THEORADEC", "libtheora_static", true, "Theora decoding support" }, - { "mpeg2", "USE_MPEG2", "libmpeg2", false, "mpeg2 codec for cutscenes" }, - - // ScummVM feature flags - { "scalers", "USE_SCALERS", "", true, "Scalers" }, - { "hqscalers", "USE_HQ_SCALERS", "", true, "HQ scalers" }, - { "16bit", "USE_RGB_COLOR", "", true, "16bit color support" }, - { "mt32emu", "USE_MT32EMU", "", true, "integrated MT-32 emulator" }, - { "nasm", "USE_NASM", "", true, "IA-32 assembly support" }, // This feature is special in the regard, that it needs additional handling. + { "flac", "USE_FLAC", "libFLAC_static", true, "FLAC support" }, + { "png", "USE_PNG", "libpng", true, "libpng support" }, + { "theora", "USE_THEORADEC", "libtheora_static", true, "Theora decoding support" }, + { "mpeg2", "USE_MPEG2", "libmpeg2", false, "mpeg2 codec for cutscenes" }, + + // Feature flags + { "scalers", "USE_SCALERS", "", true, "Scalers" }, + { "hqscalers", "USE_HQ_SCALERS", "", true, "HQ scalers" }, + { "16bit", "USE_RGB_COLOR", "", true, "16bit color support" }, + { "mt32emu", "USE_MT32EMU", "", true, "integrated MT-32 emulator" }, + { "nasm", "USE_NASM", "", true, "IA-32 assembly support" }, // This feature is special in the regard, that it needs additional handling. { "opengl", "USE_OPENGL", "opengl32", true, "OpenGL support" }, - { "indeo3", "USE_INDEO3", "", true, "Indeo3 codec support"}, - { "translation", "USE_TRANSLATION", "", true, "Translation support" }, - { "langdetect", "USE_DETECTLANG", "", true, "System language detection support" } // This feature actually depends on "translation", there - // is just no current way of properly detecting this... + { "indeo3", "USE_INDEO3", "", true, "Indeo3 codec support"}, + { "translation", "USE_TRANSLATION", "", true, "Translation support" }, + { "vkeybd", "ENABLE_VKEYBD", "", false, "Virtual keyboard support"}, + { "langdetect", "USE_DETECTLANG", "", true, "System language detection support" } // This feature actually depends on "translation", there + // is just no current way of properly detecting this... }; } // End of anonymous namespace @@ -791,9 +832,10 @@ bool producesObjectFile(const std::string &fileName) { * Checks whether the give file in the specified directory is present in the given * file list. * - * This function does as special match against the file list. It will not take file - * extensions into consideration, when the extension of a file in the specified - * directory is one of "h", "cpp", "c" or "asm". + * This function does as special match against the file list. Object files (.o) are + * excluded by default and it will not take file extensions into consideration, + * when the extension of a file in the specified directory is one of "h", "cpp", + * "c" or "asm". * * @param dir Parent directory of the file. * @param fileName File name to match. @@ -823,7 +865,9 @@ bool isInList(const std::string &dir, const std::string &fileName, const StringL } const std::string lastPathComponent = getLastPathComponent(*i); - if (!producesObjectFile(fileName) && extensionName != "h") { + if (extensionName == "o") { + return false; + } else if (!producesObjectFile(fileName) && extensionName != "h") { if (fileName == lastPathComponent) return true; } else { @@ -977,7 +1021,7 @@ void ProjectProvider::createProject(const BuildSetup &setup) { _uuidMap = createUUIDMap(setup); // We also need to add the UUID of the main project file. - const std::string svmUUID = _uuidMap["scummvm"] = createUUID(); + const std::string svmUUID = _uuidMap[PROJECT_NAME] = createUUID(); // Create Solution/Workspace file createWorkspace(setup); @@ -986,7 +1030,7 @@ void ProjectProvider::createProject(const BuildSetup &setup) { // Create engine project files for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == "scummvm") + if (i->first == PROJECT_NAME) continue; in.clear(); ex.clear(); @@ -996,10 +1040,10 @@ void ProjectProvider::createProject(const BuildSetup &setup) { createProjectFile(i->first, i->second, setup, moduleDir, in, ex); } - // Last but not least create the main ScummVM project file. + // Last but not least create the main project file. in.clear(); ex.clear(); - // File list for the ScummVM project file + // File list for the Project file createModuleList(setup.srcDir + "/backends", setup.defines, in, ex); createModuleList(setup.srcDir + "/backends/platform/sdl", setup.defines, in, ex); createModuleList(setup.srcDir + "/base", setup.defines, in, ex); @@ -1009,11 +1053,13 @@ void ProjectProvider::createProject(const BuildSetup &setup) { createModuleList(setup.srcDir + "/gui", setup.defines, in, ex); createModuleList(setup.srcDir + "/audio", setup.defines, in, ex); createModuleList(setup.srcDir + "/audio/softsynth/mt32", setup.defines, in, ex); +#if HAS_VIDEO_FOLDER createModuleList(setup.srcDir + "/video", setup.defines, in, ex); +#endif // Resource files - in.push_back(setup.srcDir + "/icons/scummvm.ico"); - in.push_back(setup.srcDir + "/dists/scummvm.rc"); + in.push_back(setup.srcDir + "/icons/" + PROJECT_NAME + ".ico"); + in.push_back(setup.srcDir + "/dists/" + PROJECT_NAME + ".rc"); // Various text files in.push_back(setup.srcDir + "/AUTHORS"); @@ -1024,8 +1070,8 @@ void ProjectProvider::createProject(const BuildSetup &setup) { in.push_back(setup.srcDir + "/README"); in.push_back(setup.srcDir + "/TODO"); - // Create the scummvm project file. - createProjectFile("scummvm", svmUUID, setup, setup.srcDir, in, ex); + // Create the main project file. + createProjectFile(PROJECT_NAME, svmUUID, setup, setup.srcDir, in, ex); // Create other misc. build files createOtherBuildFiles(setup); @@ -1179,10 +1225,20 @@ void ProjectProvider::createModuleList(const std::string &moduleDir, const Strin tokens = tokenize(line); i = tokens.begin(); } else { - if (shouldInclude.top()) - includeList.push_back(moduleDir + "/" + unifyPath(*i)); - else - excludeList.push_back(moduleDir + "/" + unifyPath(*i)); + const std::string filename = moduleDir + "/" + unifyPath(*i); + + if (shouldInclude.top()) { + // In case we should include a file, we need to make + // sure it is not in the exclude list already. If it + // is we just drop it from the exclude list. + excludeList.remove(filename); + + includeList.push_back(filename); + } else if (std::find(includeList.begin(), includeList.end(), filename) == includeList.end()) { + // We only add the file to the exclude list in case it + // has not yet been added to the include list. + excludeList.push_back(filename); + } ++i; } } diff --git a/devtools/create_project/create_project.h b/devtools/create_project/create_project.h index 8c4b8c7d23..e4ccd7313a 100644 --- a/devtools/create_project/create_project.h +++ b/devtools/create_project/create_project.h @@ -32,34 +32,6 @@ #include <cassert> -// The PP_NARG macro returns the number of arguments that have been passed to it. -#define PP_NARG(...) \ - PP_NARG_(__VA_ARGS__,PP_RSEQ_N()) -#define PP_NARG_(...) \ - PP_ARG_N(__VA_ARGS__) -#define PP_ARG_N( \ - _1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \ - _11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \ - _21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \ - _31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \ - _41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \ - _51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \ - _61,_62,_63,N,...) N -#define PP_RSEQ_N() \ - 63,62,61,60, \ - 59,58,57,56,55,54,53,52,51,50, \ - 49,48,47,46,45,44,43,42,41,40, \ - 39,38,37,36,35,34,33,32,31,30, \ - 29,28,27,26,25,24,23,22,21,20, \ - 19,18,17,16,15,14,13,12,11,10, \ - 9,8,7,6,5,4,3,2,1,0 - -#define SET_VALUES(list, ...) \ - { \ - std::string values[PP_NARG(__VA_ARGS__)] = { __VA_ARGS__ }; \ - list.assign(values, values + (sizeof(values) / sizeof(values[0]))); \ - } - typedef std::list<std::string> StringList; /** @@ -105,13 +77,13 @@ struct EngineDesc { typedef std::list<EngineDesc> EngineDescList; /** - * This function parses the ScummVM configure file and creates a list + * This function parses the project configure file and creates a list * of available engines. * * It will also automatically setup the default build state (enabled * or disabled) to the state specified in the "configure" file. * - * @param srcDir Path to the root of the ScummVM source. + * @param srcDir Path to the root of the project source. * @return List of available engines. */ EngineDescList parseConfigure(const std::string &srcDir); @@ -206,11 +178,11 @@ bool setFeatureBuildState(const std::string &name, FeatureList &features, bool e * Structure to describe a build setup. * * This includes various information about which engines to - * enable, which features should be built into ScummVM. - * It also contains the path to the ScummVM souce root. + * enable, which features should be built into the main executable. + * It also contains the path to the project source root. */ struct BuildSetup { - std::string srcDir; ///< Path to the ScummVM sources. + std::string srcDir; ///< Path to the sources. std::string filePrefix; ///< Prefix for the relative path arguments in the project files. std::string outputDir; ///< Path where to put the MSVC project files. @@ -220,10 +192,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; + bool runBuildEvents; ///< Run build events as part of the build (generate revision number and copy engine/theme data & needed files to the build folder + bool createInstaller; ///< Create NSIS installer after the build BuildSetup() { - runBuildEvents = false; + runBuildEvents = false; + createInstaller = false; } }; diff --git a/devtools/create_project/msbuild.cpp b/devtools/create_project/msbuild.cpp index 73511218b4..f9a2e936f0 100644 --- a/devtools/create_project/msbuild.cpp +++ b/devtools/create_project/msbuild.cpp @@ -23,10 +23,10 @@ * */ +#include "config.h" #include "msbuild.h" #include <fstream> - #include <algorithm> namespace CreateProjectTool { @@ -52,22 +52,29 @@ int MSBuildProvider::getVisualStudioVersion() { return 2010; } -#define OUTPUT_CONFIGURATION_MSBUILD(config, platform) \ - (project << "\t\t<ProjectConfiguration Include=\"" << config << "|" << platform << "\">\n" \ - "\t\t\t<Configuration>" << config << "</Configuration>\n" \ - "\t\t\t<Platform>" << platform << "</Platform>\n" \ - "\t\t</ProjectConfiguration>\n") +namespace { + +inline void outputConfiguration(std::ostream &project, const std::string &config, const std::string &platform) { + project << "\t\t<ProjectConfiguration Include=\"" << config << "|" << platform << "\">\n" + "\t\t\t<Configuration>" << config << "</Configuration>\n" + "\t\t\t<Platform>" << platform << "</Platform>\n" + "\t\t</ProjectConfiguration>\n"; +} + +inline void outputConfigurationType(std::ostream &project, const std::string &name, const std::string &config) { + project << "\t<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='" << config << "'\" Label=\"Configuration\">\n" + "\t\t<ConfigurationType>" << (name == PROJECT_NAME ? "Application" : "StaticLibrary") << "</ConfigurationType>\n" + "\t</PropertyGroup>\n"; +} -#define OUTPUT_CONFIGURATION_TYPE_MSBUILD(config) \ - (project << "\t<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='" << config << "'\" Label=\"Configuration\">\n" \ - "\t\t<ConfigurationType>" << (name == "scummvm" ? "Application" : "StaticLibrary") << "</ConfigurationType>\n" \ - "\t</PropertyGroup>\n") +inline void outputProperties(std::ostream &project, const std::string &config, const std::string &properties) { + project << "\t<ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='" << config << "'\" Label=\"PropertySheets\">\n" + "\t\t<Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n" + "\t\t<Import Project=\"" << properties << "\" />\n" + "\t</ImportGroup>\n"; +} -#define OUTPUT_PROPERTIES_MSBUILD(config, properties) \ - (project << "\t<ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='" << config << "'\" Label=\"PropertySheets\">\n" \ - "\t\t<Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n" \ - "\t\t<Import Project=\"" << properties << "\" />\n" \ - "\t</ImportGroup>\n") +} // End of anonymous namespace void MSBuildProvider::createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, const StringList &includeList, const StringList &excludeList) { @@ -80,12 +87,12 @@ void MSBuildProvider::createProjectFile(const std::string &name, const std::stri "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n" "\t<ItemGroup Label=\"ProjectConfigurations\">\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"); + outputConfiguration(project, "Debug", "Win32"); + outputConfiguration(project, "Debug", "x64"); + outputConfiguration(project, "Analysis", "Win32"); + outputConfiguration(project, "Analysis", "x64"); + outputConfiguration(project, "Release", "Win32"); + outputConfiguration(project, "Release", "x64"); project << "\t</ItemGroup>\n"; @@ -99,23 +106,23 @@ void MSBuildProvider::createProjectFile(const std::string &name, const std::stri // Shared configuration project << "\t<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\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"); + outputConfigurationType(project, name, "Release|Win32"); + outputConfigurationType(project, name, "Analysis|Win32"); + outputConfigurationType(project, name, "Debug|Win32"); + outputConfigurationType(project, name, "Release|x64"); + outputConfigurationType(project, name, "Analysis|x64"); + outputConfigurationType(project, name, "Debug|x64"); project << "\t<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n" "\t<ImportGroup Label=\"ExtensionSettings\">\n" "\t</ImportGroup>\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"); + outputProperties(project, "Release|Win32", PROJECT_DESCRIPTION "_Release.props"); + outputProperties(project, "Analysis|Win32", PROJECT_DESCRIPTION "_Analysis.props"); + outputProperties(project, "Debug|Win32", PROJECT_DESCRIPTION "_Debug.props"); + outputProperties(project, "Release|x64", PROJECT_DESCRIPTION "_Release64.props"); + outputProperties(project, "Analysis|x64", PROJECT_DESCRIPTION "_Analysis64.props"); + outputProperties(project, "Debug|x64", PROJECT_DESCRIPTION "_Debug64.props"); project << "\t<PropertyGroup Label=\"UserMacros\" />\n"; @@ -140,8 +147,8 @@ void MSBuildProvider::createProjectFile(const std::string &name, const std::stri else addFilesToProject(moduleDir, project, includeList, excludeList, setup.filePrefix); - // Output references for scummvm project - if (name == "scummvm") + // Output references for the main project + if (name == PROJECT_NAME) writeReferences(project); project << "\t<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n" @@ -153,21 +160,6 @@ void MSBuildProvider::createProjectFile(const std::string &name, const std::stri createFiltersFile(setup, name); } -#define OUTPUT_FILTER_MSBUILD(files, action) \ - if (!files.empty()) { \ - filters << "\t<ItemGroup>\n"; \ - for (std::list<FileEntry>::const_iterator entry = files.begin(); entry != files.end(); ++entry) { \ - if ((*entry).filter != "") { \ - filters << "\t\t<" action " Include=\"" << (*entry).path << "\">\n" \ - "\t\t\t<Filter>" << (*entry).filter << "</Filter>\n" \ - "\t\t</" action ">\n"; \ - } else { \ - filters << "\t\t<" action " Include=\"" << (*entry).path << "\" />\n"; \ - } \ - } \ - filters << "\t</ItemGroup>\n"; \ - } - void MSBuildProvider::createFiltersFile(const BuildSetup &setup, const std::string &name) { // No filters => no need to create a filter file if (_filters.empty()) @@ -199,20 +191,36 @@ void MSBuildProvider::createFiltersFile(const BuildSetup &setup, const std::stri filters << "\t</ItemGroup>\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") + outputFilter(filters, _compileFiles, "ClCompile"); + outputFilter(filters, _includeFiles, "ClInclude"); + outputFilter(filters, _otherFiles, "None"); + outputFilter(filters, _resourceFiles, "ResourceCompile"); + outputFilter(filters, _asmFiles, "CustomBuild"); filters << "</Project>"; } +void MSBuildProvider::outputFilter(std::ostream &filters, const FileEntries &files, const std::string &action) { + if (!files.empty()) { + filters << "\t<ItemGroup>\n"; + for (FileEntries::const_iterator entry = files.begin(), end = files.end(); entry != end; ++entry) { + if ((*entry).filter != "") { + filters << "\t\t<" << action << " Include=\"" << (*entry).path << "\">\n" + "\t\t\t<Filter>" << (*entry).filter << "</Filter>\n" + "\t\t</" << action << ">\n"; + } else { + filters << "\t\t<" << action << " Include=\"" << (*entry).path << "\" />\n"; + } + } + filters << "\t</ItemGroup>\n"; + } +} + void MSBuildProvider::writeReferences(std::ofstream &output) { output << "\t<ItemGroup>\n"; for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == "scummvm") + if (i->first == PROJECT_NAME) continue; output << "\t<ProjectReference Include=\"" << i->first << ".vcxproj\">\n" @@ -230,7 +238,7 @@ void MSBuildProvider::outputProjectSettings(std::ofstream &project, const std::s std::map<std::string, StringList>::iterator warningsIterator = _projectWarnings.find(name); // Nothing to add here, move along! - if (name != "scummvm" && name != "sword25" && name != "tinsel" && warningsIterator == _projectWarnings.end()) + if (name != PROJECT_NAME && name != "sword25" && name != "tinsel" && name != "grim" && warningsIterator == _projectWarnings.end()) return; std::string warnings = ""; @@ -242,7 +250,7 @@ void MSBuildProvider::outputProjectSettings(std::ofstream &project, const std::s "\t\t<ClCompile>\n"; // Compile configuration - if (name == "scummvm" || name == "sword25") { + if (name == PROJECT_NAME || name == "sword25" || name == "grim") { project << "\t\t\t<DisableLanguageExtensions>false</DisableLanguageExtensions>\n"; } else { if (name == "tinsel" && !isRelease) @@ -254,31 +262,28 @@ void MSBuildProvider::outputProjectSettings(std::ofstream &project, const std::s project << "\t\t</ClCompile>\n"; - // Link configuration for scummvm project - if (name == "scummvm") { + // Link configuration for main project + if (name == PROJECT_NAME) { std::string libraries; for (StringList::const_iterator i = setup.libraries.begin(); i != setup.libraries.end(); ++i) libraries += *i + ".lib;"; project << "\t\t<Link>\n" - "\t\t\t<OutputFile>$(OutDir)scummvm.exe</OutputFile>\n" + "\t\t\t<OutputFile>$(OutDir)" << PROJECT_NAME << ".exe</OutputFile>\n" "\t\t\t<AdditionalDependencies>" << libraries << "%(AdditionalDependencies)</AdditionalDependencies>\n" "\t\t</Link>\n"; if (setup.runBuildEvents) { - // Only generate revision number in debug builds - if (!isRelease) { - project << "\t\t<PreBuildEvent>\n" - "\t\t\t<Message>Generate internal_version.h</Message>\n" - "\t\t\t<Command>" << getPreBuildEvent() << "</Command>\n" - "\t\t</PreBuildEvent>\n"; - } + project << "\t\t<PreBuildEvent>\n" + "\t\t\t<Message>Generate revision</Message>\n" + "\t\t\t<Command>" << getPreBuildEvent() << "</Command>\n" + "\t\t</PreBuildEvent>\n"; // Copy data files to the build folder project << "\t\t<PostBuildEvent>\n" "\t\t\t<Message>Copy data files to the build folder</Message>\n" - "\t\t\t<Command>" << getPostBuildEvent(isWin32) << "</Command>\n" + "\t\t\t<Command>" << getPostBuildEvent(isWin32, setup.createInstaller) << "</Command>\n" "\t\t</PostBuildEvent>\n"; } } @@ -286,7 +291,7 @@ void MSBuildProvider::outputProjectSettings(std::ofstream &project, const std::s project << "\t</ItemDefinitionGroup>\n"; } -void MSBuildProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix) { +void MSBuildProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix, bool runBuildEvents) { std::string warnings; for (StringList::const_iterator i = _globalWarnings.begin(); i != _globalWarnings.end(); ++i) @@ -296,14 +301,18 @@ void MSBuildProvider::outputGlobalPropFile(std::ofstream &properties, int bits, for (StringList::const_iterator i = defines.begin(); i != defines.end(); ++i) definesList += *i + ';'; + // Add define to include revision header + if (runBuildEvents) + definesList += REVISION_DEFINE ";"; + properties << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n" "\t<PropertyGroup>\n" - "\t\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\n" - "\t\t<_PropertySheetDisplayName>ScummVM_Global</_PropertySheetDisplayName>\n" - "\t\t<ExecutablePath>$(SCUMMVM_LIBS)\\bin;$(ExecutablePath)</ExecutablePath>\n" - "\t\t<LibraryPath>$(SCUMMVM_LIBS)\\lib\\" << (bits == 32 ? "x86" : "x64") << ";$(LibraryPath)</LibraryPath>\n" - "\t\t<IncludePath>$(SCUMMVM_LIBS)\\include;$(IncludePath)</IncludePath>\n" + "\t\t<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\n" + "\t\t<_PropertySheetDisplayName>" << PROJECT_DESCRIPTION << "_Global</_PropertySheetDisplayName>\n" + "\t\t<ExecutablePath>$(" << LIBS_DEFINE << ")\\bin;$(ExecutablePath)</ExecutablePath>\n" + "\t\t<LibraryPath>$(" << LIBS_DEFINE << ")\\lib\\" << (bits == 32 ? "x86" : "x64") << ";$(LibraryPath)</LibraryPath>\n" + "\t\t<IncludePath>$(" << LIBS_DEFINE << ")\\include;$(IncludePath)</IncludePath>\n" "\t\t<OutDir>$(Configuration)" << bits << "\\</OutDir>\n" "\t\t<IntDir>$(Configuration)" << bits << "/$(ProjectName)\\</IntDir>\n" "\t</PropertyGroup>\n" @@ -311,11 +320,17 @@ void MSBuildProvider::outputGlobalPropFile(std::ofstream &properties, int bits, "\t\t<ClCompile>\n" "\t\t\t<DisableLanguageExtensions>true</DisableLanguageExtensions>\n" "\t\t\t<DisableSpecificWarnings>" << warnings << ";%(DisableSpecificWarnings)</DisableSpecificWarnings>\n" - "\t\t\t<AdditionalIncludeDirectories>$(SCUMMVM_LIBS)\\include;" << prefix << ";" << prefix << "\\engines;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" + "\t\t\t<AdditionalIncludeDirectories>$(" << LIBS_DEFINE << ")\\include;" << prefix << ";" << prefix << "\\engines;$(TargetDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" "\t\t\t<PreprocessorDefinitions>" << definesList << "%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" - "\t\t\t<ExceptionHandling></ExceptionHandling>\n" - "\t\t\t<RuntimeTypeInfo>false</RuntimeTypeInfo>\n" - "\t\t\t<WarningLevel>Level4</WarningLevel>\n" + "\t\t\t<ExceptionHandling></ExceptionHandling>\n"; + +#if NEEDS_RTTI + properties << "\t\t\t<RuntimeTypeInfo>true</RuntimeTypeInfo>\n"; +#else + properties << "\t\t\t<RuntimeTypeInfo>false</RuntimeTypeInfo>\n"; +#endif + + properties << "\t\t\t<WarningLevel>Level4</WarningLevel>\n" "\t\t\t<TreatWarningAsError>false</TreatWarningAsError>\n" "\t\t\t<CompileAs>Default</CompileAs>\n" "\t\t</ClCompile>\n" @@ -325,7 +340,6 @@ void MSBuildProvider::outputGlobalPropFile(std::ofstream &properties, int bits, "\t\t\t<EntryPointSymbol>WinMainCRTStartup</EntryPointSymbol>\n" "\t\t</Link>\n" "\t\t<ResourceCompile>\n" - "\t\t\t<PreprocessorDefinitions>HAS_INCLUDE_SET;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n" "\t\t\t<AdditionalIncludeDirectories>" << prefix << ";%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n" "\t\t</ResourceCompile>\n" "\t</ItemDefinitionGroup>\n" @@ -338,18 +352,18 @@ void MSBuildProvider::createBuildProp(const BuildSetup &setup, bool isRelease, b 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()); + std::ofstream properties((setup.outputDir + '/' + PROJECT_DESCRIPTION "_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension()).c_str()); if (!properties) - error("Could not open \"" + setup.outputDir + '/' + "ScummVM_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension() + "\" for writing"); + error("Could not open \"" + setup.outputDir + '/' + PROJECT_DESCRIPTION "_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension() + "\" for writing"); properties << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n" "\t<ImportGroup Label=\"PropertySheets\">\n" - "\t\t<Import Project=\"ScummVM_Global" << (isWin32 ? "" : "64") << ".props\" />\n" + "\t\t<Import Project=\"" << PROJECT_DESCRIPTION << "_Global" << (isWin32 ? "" : "64") << ".props\" />\n" "\t</ImportGroup>\n" "\t<PropertyGroup>\n" - "\t\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\n" - "\t\t<_PropertySheetDisplayName>ScummVM_" << outputType << outputBitness << "</_PropertySheetDisplayName>\n" + "\t\t<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>\n" + "\t\t<_PropertySheetDisplayName>" << PROJECT_DESCRIPTION << "_" << outputType << outputBitness << "</_PropertySheetDisplayName>\n" "\t\t<LinkIncremental>" << (isRelease ? "false" : "true") << "</LinkIncremental>\n" "\t</PropertyGroup>\n" "\t<ItemDefinitionGroup>\n" @@ -391,19 +405,6 @@ void MSBuildProvider::createBuildProp(const BuildSetup &setup, bool isRelease, b properties.close(); } -#define OUTPUT_NASM_COMMAND_MSBUILD(config) \ - projectFile << "\t\t\t<Command Condition=\"'$(Configuration)|$(Platform)'=='" << config << "|Win32'\">nasm.exe -f win32 -g -o \"$(IntDir)" << (isDuplicate ? (*entry).prefix : "") << "%(Filename).obj\" \"%(FullPath)\"</Command>\n" \ - "\t\t\t<Outputs Condition=\"'$(Configuration)|$(Platform)'=='" << config << "|Win32'\">$(IntDir)" << (isDuplicate ? (*entry).prefix : "") << "%(Filename).obj;%(Outputs)</Outputs>\n"; - -#define OUPUT_FILES_MSBUILD(files, action) \ - if (!files.empty()) { \ - projectFile << "\t<ItemGroup>\n"; \ - for (std::list<FileEntry>::const_iterator entry = files.begin(); entry != files.end(); ++entry) { \ - projectFile << "\t\t<" action " Include=\"" << (*entry).path << "\" />\n"; \ - } \ - projectFile << "\t</ItemGroup>\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)); @@ -412,6 +413,14 @@ bool hasEnding(std::string const &fullString, std::string const &ending) { } } +namespace { + +inline void outputNasmCommand(std::ostream &projectFile, const std::string &config, const std::string &prefix) { + projectFile << "\t\t\t<Command Condition=\"'$(Configuration)|$(Platform)'=='" << config << "|Win32'\">nasm.exe -f win32 -g -o \"$(IntDir)" << prefix << "%(Filename).obj\" \"%(FullPath)\"</Command>\n" + "\t\t\t<Outputs Condition=\"'$(Configuration)|$(Platform)'=='" << config << "|Win32'\">$(IntDir)" << prefix << "%(Filename).obj;%(Outputs)</Outputs>\n"; +} + +} // End of anonymous namespace void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream &projectFile, const int, const StringList &duplicate, const std::string &objPrefix, const std::string &filePrefix) { @@ -439,9 +448,6 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream projectFile << "\t\t<ClCompile Include=\"" << (*entry).path << "\">\n" "\t\t\t<ObjectFileName>$(IntDir)" << (*entry).prefix << "%(Filename).obj</ObjectFileName>\n"; - if (hasEnding((*entry).path, "base\\version.cpp")) - projectFile << "\t\t\t<PreprocessorDefinitions Condition=\"'$(Configuration)'=='Debug'\">SCUMMVM_REVISION#" $(SCUMMVM_REVISION_STRING)";%(PreprocessorDefinitions)</PreprocessorDefinitions>\n"; - projectFile << "\t\t</ClCompile>\n"; } else { projectFile << "\t\t<ClCompile Include=\"" << (*entry).path << "\" />\n"; @@ -451,9 +457,9 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream } // Output include, other and resource files - OUPUT_FILES_MSBUILD(_includeFiles, "ClInclude") - OUPUT_FILES_MSBUILD(_otherFiles, "None") - OUPUT_FILES_MSBUILD(_resourceFiles, "ResourceCompile") + outputFiles(projectFile, _includeFiles, "ClInclude"); + outputFiles(projectFile, _otherFiles, "None"); + outputFiles(projectFile, _resourceFiles, "ResourceCompile"); // Output asm files if (!_asmFiles.empty()) { @@ -465,9 +471,9 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream projectFile << "\t\t<CustomBuild Include=\"" << (*entry).path << "\">\n" "\t\t\t<FileType>Document</FileType>\n"; - OUTPUT_NASM_COMMAND_MSBUILD("Debug") - OUTPUT_NASM_COMMAND_MSBUILD("Analysis") - OUTPUT_NASM_COMMAND_MSBUILD("Release") + outputNasmCommand(projectFile, "Debug", (isDuplicate ? (*entry).prefix : "")); + outputNasmCommand(projectFile, "Analysis", (isDuplicate ? (*entry).prefix : "")); + outputNasmCommand(projectFile, "Release", (isDuplicate ? (*entry).prefix : "")); projectFile << "\t\t</CustomBuild>\n"; } @@ -475,6 +481,16 @@ void MSBuildProvider::writeFileListToProject(const FileNode &dir, std::ofstream } } +void MSBuildProvider::outputFiles(std::ostream &projectFile, const FileEntries &files, const std::string &action) { + if (!files.empty()) { + projectFile << "\t<ItemGroup>\n"; + for (FileEntries::const_iterator entry = files.begin(), end = files.end(); entry != end; ++entry) { + projectFile << "\t\t<" << action << " Include=\"" << (*entry).path << "\" />\n"; + } + projectFile << "\t</ItemGroup>\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; diff --git a/devtools/create_project/msbuild.h b/devtools/create_project/msbuild.h index fa5311734b..98bb65e19b 100644 --- a/devtools/create_project/msbuild.h +++ b/devtools/create_project/msbuild.h @@ -45,7 +45,7 @@ protected: void writeReferences(std::ofstream &output); - void outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix); + void outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix, bool runBuildEvents); void createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32, bool enableAnalysis); @@ -75,6 +75,9 @@ private: 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); + + void outputFilter(std::ostream &filters, const FileEntries &files, const std::string &action); + void outputFiles(std::ostream &projectFile, const FileEntries &files, const std::string &action); }; } // End of CreateProjectTool namespace diff --git a/devtools/create_project/msvc.cpp b/devtools/create_project/msvc.cpp index e2fff59c46..af3aa4a519 100644 --- a/devtools/create_project/msvc.cpp +++ b/devtools/create_project/msvc.cpp @@ -23,10 +23,10 @@ * */ +#include "config.h" #include "msvc.h" #include <fstream> - #include <algorithm> namespace CreateProjectTool { @@ -39,23 +39,23 @@ MSVCProvider::MSVCProvider(StringList &global_warnings, std::map<std::string, St } void MSVCProvider::createWorkspace(const BuildSetup &setup) { - UUIDMap::const_iterator svmUUID = _uuidMap.find("scummvm"); + UUIDMap::const_iterator svmUUID = _uuidMap.find(PROJECT_NAME); if (svmUUID == _uuidMap.end()) - error("No UUID for \"scummvm\" project created"); + error("No UUID for \"" PROJECT_NAME "\" project created"); const std::string svmProjectUUID = svmUUID->second; assert(!svmProjectUUID.empty()); std::string solutionUUID = createUUID(); - std::ofstream solution((setup.outputDir + '/' + "scummvm.sln").c_str()); + std::ofstream solution((setup.outputDir + '/' + PROJECT_NAME ".sln").c_str()); if (!solution) - error("Could not open \"" + setup.outputDir + '/' + "scummvm.sln\" for writing"); + error("Could not open \"" + setup.outputDir + '/' + PROJECT_NAME ".sln\" for writing"); solution << "Microsoft Visual Studio Solution File, Format Version " << _version + 1 << ".00\n"; solution << "# Visual Studio " << getVisualStudioVersion() << "\n"; - solution << "Project(\"{" << solutionUUID << "}\") = \"scummvm\", \"scummvm" << getProjectExtension() << "\", \"{" << svmProjectUUID << "}\"\n"; + solution << "Project(\"{" << solutionUUID << "}\") = \"" << PROJECT_NAME << "\", \"" << PROJECT_NAME << getProjectExtension() << "\", \"{" << svmProjectUUID << "}\"\n"; // Project dependencies are moved to vcxproj files in Visual Studio 2010 if (_version < 10) @@ -65,7 +65,7 @@ void MSVCProvider::createWorkspace(const BuildSetup &setup) { // Note we assume that the UUID map only includes UUIDs for enabled engines! for (UUIDMap::const_iterator i = _uuidMap.begin(); i != _uuidMap.end(); ++i) { - if (i->first == "scummvm") + if (i->first == PROJECT_NAME) continue; solution << "Project(\"{" << solutionUUID << "}\") = \"" << i->first << "\", \"" << i->first << getProjectExtension() << "\", \"{" << i->second << "}\"\n" @@ -120,16 +120,16 @@ void MSVCProvider::createOtherBuildFiles(const BuildSetup &setup) { } void MSVCProvider::createGlobalProp(const BuildSetup &setup) { - std::ofstream properties((setup.outputDir + '/' + "ScummVM_Global" + getPropertiesExtension()).c_str()); + std::ofstream properties((setup.outputDir + '/' + PROJECT_DESCRIPTION "_Global" + getPropertiesExtension()).c_str()); if (!properties) - error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Global" + getPropertiesExtension() + "\" for writing"); + error("Could not open \"" + setup.outputDir + '/' + PROJECT_DESCRIPTION "_Global" + getPropertiesExtension() + "\" for writing"); - outputGlobalPropFile(properties, 32, setup.defines, convertPathToWin(setup.filePrefix)); + outputGlobalPropFile(properties, 32, setup.defines, convertPathToWin(setup.filePrefix), setup.runBuildEvents); properties.close(); - properties.open((setup.outputDir + '/' + "ScummVM_Global64" + getPropertiesExtension()).c_str()); + properties.open((setup.outputDir + '/' + PROJECT_DESCRIPTION "_Global64" + getPropertiesExtension()).c_str()); if (!properties) - error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Global64" + getPropertiesExtension() + "\" for writing"); + error("Could not open \"" + setup.outputDir + '/' + PROJECT_DESCRIPTION "_Global64" + getPropertiesExtension() + "\" for writing"); // HACK: We must disable the "nasm" feature for x64. To achieve that we must duplicate the feature list and // recreate a define list. @@ -143,7 +143,7 @@ void MSVCProvider::createGlobalProp(const BuildSetup &setup) { x64Defines.push_back("WIN32"); x64Defines.push_back("SDL_BACKEND"); - outputGlobalPropFile(properties, 64, x64Defines, convertPathToWin(setup.filePrefix)); + outputGlobalPropFile(properties, 64, x64Defines, convertPathToWin(setup.filePrefix), setup.runBuildEvents); } std::string MSVCProvider::getPreBuildEvent() const { @@ -152,13 +152,13 @@ std::string MSVCProvider::getPreBuildEvent() const { cmdLine = "@echo off\n" "echo Executing Pre-Build script...\n" "echo.\n" - "@call "$(SolutionDir)../../devtools/create_project/scripts/prebuild.cmd" "$(SolutionDir)/../.."\n" + "@call "$(SolutionDir)../../devtools/create_project/scripts/prebuild.cmd" "$(SolutionDir)/../.." "$(TargetDir)"\n" "EXIT /B0"; return cmdLine; } -std::string MSVCProvider::getPostBuildEvent(bool isWin32) const { +std::string MSVCProvider::getPostBuildEvent(bool isWin32, bool createInstaller) const { std::string cmdLine = ""; cmdLine = "@echo off\n" @@ -168,6 +168,11 @@ std::string MSVCProvider::getPostBuildEvent(bool isWin32) const { cmdLine += (isWin32) ? "x86" : "x64"; + cmdLine += " %SCUMMVM_LIBS% "; + + // Specify if installer needs to be built or not + cmdLine += (createInstaller ? "1" : "0"); + cmdLine += "\n" "EXIT /B0"; diff --git a/devtools/create_project/msvc.h b/devtools/create_project/msvc.h index f41ecc3aba..6c8ac33a76 100644 --- a/devtools/create_project/msvc.h +++ b/devtools/create_project/msvc.h @@ -59,8 +59,9 @@ protected: * @param bits Number of bits the platform supports. * @param defines Defines the platform needs to have set. * @param prefix File prefix, used to add additional include paths. + * @param runBuildEvents true if generating a revision number, false otherwise */ - virtual void outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix) = 0; + virtual void outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix, bool runBuildEvents) = 0; /** * Generates the project properties for debug and release settings. @@ -88,11 +89,14 @@ protected: std::string getPreBuildEvent() const; /** - * Get the command line for copying data files to the build directory + * Get the command line for copying data files to the build directory. * - * @param isWin32 Bitness of property file + * @param isWin32 Bitness of property file. + * @param createInstaller true to NSIS create installer + * + * @return The post build event. */ - std::string getPostBuildEvent(bool isWin32) const; + std::string getPostBuildEvent(bool isWin32, bool createInstaller) const; }; } // End of CreateProjectTool namespace diff --git a/devtools/create_project/msvc10/create_project.vcxproj b/devtools/create_project/msvc10/create_project.vcxproj index 532d6dba29..bf5e415b5d 100644 --- a/devtools/create_project/msvc10/create_project.vcxproj +++ b/devtools/create_project/msvc10/create_project.vcxproj @@ -101,12 +101,14 @@ xcopy /Y $(TargetPath) $(SolutionDir)\..\..\..\dists\codeblocks\</Command> </ItemGroup> <ItemGroup> <ClInclude Include="..\codeblocks.h" /> + <ClInclude Include="..\config.h" /> <ClInclude Include="..\create_project.h" /> <ClInclude Include="..\msbuild.h" /> <ClInclude Include="..\msvc.h" /> <ClInclude Include="..\visualstudio.h" /> </ItemGroup> <ItemGroup> + <None Include="..\scripts\installer.vbs" /> <None Include="..\scripts\postbuild.cmd" /> <None Include="..\scripts\prebuild.cmd" /> <None Include="..\scripts\revision.vbs" /> diff --git a/devtools/create_project/msvc10/create_project.vcxproj.filters b/devtools/create_project/msvc10/create_project.vcxproj.filters index 7922e1e6f7..b5e870824e 100644 --- a/devtools/create_project/msvc10/create_project.vcxproj.filters +++ b/devtools/create_project/msvc10/create_project.vcxproj.filters @@ -27,6 +27,9 @@ <ClInclude Include="..\visualstudio.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\config.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ClCompile Include="..\codeblocks.cpp"> @@ -55,5 +58,8 @@ <None Include="..\scripts\postbuild.cmd"> <Filter>scripts</Filter> </None> + <None Include="..\scripts\installer.vbs"> + <Filter>scripts</Filter> + </None> </ItemGroup> </Project>
\ No newline at end of file diff --git a/devtools/create_project/msvc8/create_project.vcproj b/devtools/create_project/msvc8/create_project.vcproj index bc3b2437ac..639b23d6e7 100644 --- a/devtools/create_project/msvc8/create_project.vcproj +++ b/devtools/create_project/msvc8/create_project.vcproj @@ -199,6 +199,10 @@ > </File> <File + RelativePath="..\config.h" + > + </File> + <File RelativePath="..\msvc.h" > </File> @@ -228,6 +232,10 @@ RelativePath="..\scripts\revision.vbs" > </File> + <File + RelativePath="..\scripts\installer.vbs" + > + </File> </Filter> </Files> <Globals> diff --git a/devtools/create_project/msvc9/create_project.vcproj b/devtools/create_project/msvc9/create_project.vcproj index c89b88a1c9..f56cbd711c 100644 --- a/devtools/create_project/msvc9/create_project.vcproj +++ b/devtools/create_project/msvc9/create_project.vcproj @@ -200,6 +200,10 @@ > </File> <File + RelativePath="..\config.h" + > + </File> + <File RelativePath="..\msvc.h" > </File> @@ -229,6 +233,10 @@ RelativePath="..\scripts\revision.vbs" > </File> + <File + RelativePath="..\scripts\installer.vbs" + > + </File> </Filter> </Files> <Globals> diff --git a/devtools/create_project/scripts/installer.vbs b/devtools/create_project/scripts/installer.vbs new file mode 100644 index 0000000000..6bcd794bef --- /dev/null +++ b/devtools/create_project/scripts/installer.vbs @@ -0,0 +1,196 @@ +' +' 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, version 2 +' of the License. +' +' 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. +' +'/ + +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +' This script calls the makensis tool to generate a NSIS Windows installer for ScummVM +' +' It tries to read the NSIS installation folder from the registry and then calls the +' command line script compiler to create the installer. +' +' This is called from the postbuild.cmd batch file +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + +'================================================================ +' TODO: Reduce duplication with revision.vbs script +' (ReadRegistryKey and ParseCommandLine are identical) +'================================================================ + +Option Explicit + +Dim FSO : Set FSO = CreateObject("Scripting.FileSystemObject") +Dim WshShell : Set WshShell = CreateObject("WScript.Shell") + +' Folders +Dim rootFolder : rootFolder = "" +Dim targetFolder : targetFolder = "" +Dim arch : arch = "" + +' Parse our command line arguments +If ParseCommandLine() Then + CreateInstaller() +End If + +'//////////////////////////////////////////////////////////////// +'// Installer creation +'//////////////////////////////////////////////////////////////// +Sub CreateInstaller() + ' Get nsis installation folder + Dim nsisPath : nsisPath = GetNSISPath() + If (nsisPath = "") Then + Exit Sub + End If + + ' Preprocess architecture + Select Case arch + Case "x86" + arch = "win32" + + Case "x64" + arch = "win64" + End Select + + ' Build command line + Dim commandLine : commandLine = """" & nsisPath & "\makensis.exe"" /V2" & _ + " /Dtop_srcdir=""" & rootFolder & """" & _ + " /Dbuild_dir=""" & targetFolder & """" & _ + " /Dtext_dir=""" & targetFolder & """" & _ + " /DARCH=""" & arch & """" & _ + " """ & rootFolder & "\dists\nsis\scummvm.nsi""" + + Dim oExec: Set oExec = WshShell.Exec(commandline) + If Err.Number <> 0 Then + Wscript.StdErr.WriteLine "Error running makensis.exe!" + Exit Sub + End If + + ' Wait till the application is finished ... + Dim ostdOut : Set oStdOut = oExec.StdOut + Do While oExec.Status = 0 + If Not ostdOut.AtEndOfStream Then + Wscript.StdErr.WriteLine ostdOut.ReadAll + End If + + WScript.Sleep 100 + Loop + + If oExec.ExitCode <> 0 Then + Wscript.StdErr.WriteLine "Error while creating installer!" + Exit Sub + End If +End Sub + +Function GetNSISPath() + ' Get the directory where NSIS (should) reside(s) + Dim sNSIS + + ' First, try with 32-bit architecture + sNSIS = ReadRegistryKey("HKLM", "SOFTWARE\NSIS", "", 32) + + If sNSIS = "" Or IsNull(sNSIS) Then + ' No 32-bit version of TortoiseSVN installed, try 64-bit version (doesn't hurt on 32-bit machines, it returns nothing or is ignored) + sNSIS = ReadRegistryKey("HKLM", "SOFTWARE\NSIS", "", 64) + End If + + ' Check if Tortoise is present + If sNSIS = "" Then + Wscript.StdErr.WriteLine "NSIS not installed!" + Exit Function + End If + + GetNSISPath = sNSIS +End Function + +'//////////////////////////////////////////////////////////////// +'// Utilities +'//////////////////////////////////////////////////////////////// +Function ParseCommandLine() + ParseCommandLine = True + + If Wscript.Arguments.Count <> 3 Then + Wscript.StdErr.WriteLine "[Error] Invalid number of arguments (was: " & Wscript.Arguments.Count & ", expected: 3)" + + ParseCommandLine = False + Exit Function + End If + + ' Get our arguments + rootFolder = Wscript.Arguments.Item(0) + targetFolder = Wscript.Arguments.Item(1) + arch = Wscript.Arguments.Item(2) + + ' Check that the folders are valid + If Not FSO.FolderExists(rootFolder) Then + Wscript.StdErr.WriteLine "[Error] Invalid root folder (" & rootFolder & ")" + + ParseCommandLine = False + Exit Function + End If + + If Not FSO.FolderExists(targetFolder) Then + Wscript.StdErr.WriteLine "[Error] Invalid target folder (" & targetFolder & ")" + + ParseCommandLine = False + Exit Function + End If + + ' Set absolute paths + rootFolder = FSO.GetAbsolutePathName(rootFolder) + targetFolder = FSO.GetAbsolutePathName(targetFolder) +End Function + +Function ReadRegistryKey(shive, subkey, valuename, architecture) + Dim hiveKey, objCtx, objLocator, objServices, objReg, Inparams, Outparams + + ' First, get the Registry Provider for the requested architecture + Set objCtx = CreateObject("WbemScripting.SWbemNamedValueSet") + objCtx.Add "__ProviderArchitecture", architecture ' Must be 64 of 32 + Set objLocator = CreateObject("Wbemscripting.SWbemLocator") + Set objServices = objLocator.ConnectServer("","root\default","","",,,,objCtx) + Set objReg = objServices.Get("StdRegProv") + + ' Check the hive and give it the right value + Select Case shive + Case "HKCR", "HKEY_CLASSES_ROOT" + hiveKey = &h80000000 + Case "HKCU", "HKEY_CURRENT_USER" + hiveKey = &H80000001 + Case "HKLM", "HKEY_LOCAL_MACHINE" + hiveKey = &h80000002 + Case "HKU", "HKEY_USERS" + hiveKey = &h80000003 + Case "HKCC", "HKEY_CURRENT_CONFIG" + hiveKey = &h80000005 + Case "HKDD", "HKEY_DYN_DATA" ' Only valid for Windows 95/98 + hiveKey = &h80000006 + Case Else + MsgBox "Hive not valid (ReadRegistryKey)" + End Select + + Set Inparams = objReg.Methods_("GetStringValue").Inparameters + Inparams.Hdefkey = hiveKey + Inparams.Ssubkeyname = subkey + Inparams.Svaluename = valuename + Set Outparams = objReg.ExecMethod_("GetStringValue", Inparams,,objCtx) + + ReadRegistryKey = Outparams.SValue +End Function diff --git a/devtools/create_project/scripts/postbuild.cmd b/devtools/create_project/scripts/postbuild.cmd index 5c2bd8a1ad..e78861463a 100644 --- a/devtools/create_project/scripts/postbuild.cmd +++ b/devtools/create_project/scripts/postbuild.cmd @@ -1,35 +1,55 @@ -REM @echo off
+@echo off
REM ---------------------------------------------------------------
REM -- Post-Build Script
REM ---------------------------------------------------------------
REM
REM Copy engine data, themes, translation and required dlls to the
-REM output folder.
+REM output folder and optionally create an installer
REM
REM Expected parameters
REM Root folder
REM Output folder
REM Architecture
+REM Libs folder
+REM Installer ("1" to build, "0" to skip)
-if "%~1"=="" goto error_input
+if "%~1"=="" goto error_root
if "%~2"=="" goto error_output
if "%~3"=="" goto error_arch
+if "%~4"=="" goto error_libs
+if "%~5"=="" goto error_installer
echo Copying data files
echo.
-REM Copy files
-xcopy /F /Y "%~1/dists/engine-data/*.dat" %~2 > NUL 2>&1
-xcopy /F /Y "%~1/dists/engine-data/*.tbl" %~2 > NUL 2>&1
-xcopy /F /Y "%~1/dists/engine-data/*.cpt" %~2 > NUL 2>&1
-xcopy /F /Y "%~1/dists/engine-data/README" %~2 > NUL 2>&1
-xcopy /F /Y "%~1/gui/themes/*.zip" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/AUTHORS" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/COPYING.GPL" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/COPYING" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/COPYING.LGPL" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/COPYRIGHT" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/NEWS" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/README" %~2 > NUL 2>&1
+
+xcopy /F /Y "%~1/dists/engine-data/*.dat" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/dists/engine-data/*.tbl" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/dists/engine-data/*.cpt" %~2 > NUL 2>&1
+xcopy /F /Y "%~1/gui/themes/*.zip" %~2 > NUL 2>&1
xcopy /F /Y "%~1/gui/themes/translations.dat" %~2 > NUL 2>&1
-xcopy /F /Y "%SCUMMVM_LIBS%/lib/%~3/SDL.dll" %~2 > NUL 2>&1
+xcopy /F /Y "%~4/lib/%~3/SDL.dll" %~2 > NUL 2>&1
+xcopy /F /Y "%~4/README-SDL" %~2 > NUL 2>&1
+
+xcopy /F /Y "%~1/backends/vkeybd/packs/vkeybd_default.zip" %~2 > NUL 2>&1
+
+if "%~5"=="0" goto done
+
+echo Running installer script
+echo.
+@call cscript "%~1/devtools/create_project/scripts/installer.vbs" %~1 %~2 %~3 1>NUL
+if not %errorlevel% == 0 goto error_script
goto done
-:error_output
+:error_root
echo Invalid root folder (%~1)!
goto done
@@ -41,5 +61,17 @@ goto done echo Invalid arch parameter (was: %~3, allowed: x86, x64)!
goto done
+:error_libs
+echo Invalid libs folder (%~4)!
+goto done
+
+:error_installer
+echo Invalid installer parameter. Should be "0" or "1" (was %~5)!
+goto done
+
+:error_script:
+echo An error occured while running the installer script!
+goto done
+
:done
exit /B0
diff --git a/devtools/create_project/scripts/prebuild.cmd b/devtools/create_project/scripts/prebuild.cmd index b824f0d5a0..dd4d12a851 100644 --- a/devtools/create_project/scripts/prebuild.cmd +++ b/devtools/create_project/scripts/prebuild.cmd @@ -4,22 +4,28 @@ REM --------------------------------------------------------------- REM -- Pre-Build Script
REM ---------------------------------------------------------------
REM
-REM Generate file with proper revision number
+REM Generate file with revision number
REM
REM Expected parameters
-REM Root folder
+REM Root folder (the source root folder)
+REM Target folder (the build output folder, will be used to copy internal_revision.h)
-if "%~1"=="" goto error_input
+if "%~1"=="" goto error_root
+if "%~2"=="" goto error_target
REM Run the revision script
-@call cscript "%~1/devtools/create_project/scripts/revision.vbs" %~1 1>NUL
+@call cscript "%~1/devtools/create_project/scripts/revision.vbs" %~1 %~2 1>NUL
if not %errorlevel% == 0 goto error_script
goto done
-:error_output
+:error_root
echo Invalid root folder (%~1)!
goto done
+:error_target
+echo Invalid target folder (%~2)!
+goto done
+
:error_script:
echo An error occured while running the revision script!
diff --git a/devtools/create_project/scripts/revision.vbs b/devtools/create_project/scripts/revision.vbs index 851185371b..3e1212521c 100644 --- a/devtools/create_project/scripts/revision.vbs +++ b/devtools/create_project/scripts/revision.vbs @@ -23,6 +23,21 @@ ' '/ +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +' This script tries to determine a revision number based on the current working tree +' by trying revision control tools in the following order: +' - git (with hg-git detection) +' - mercurial +' - TortoiseSVN +' - SVN +' +' It then writes a new header file to be included during build, with the revision +' information, the current branch, the revision control system (when not git) and +' a flag when the tree is dirty. +' +' This is called from the prebuild.cmd batch file +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' + Option Explicit ' Working copy check priority: @@ -35,6 +50,7 @@ Dim WshShell : Set WshShell = CreateObject("WScript.Shell") ' Folders Dim rootFolder : rootFolder = "" +Dim targetFolder : targetFolder = "" ' Info variables Dim tool : tool = "" @@ -81,27 +97,33 @@ Sub DetermineRevision() End If End If End If - - Wscript.StdErr.WriteLine "Found revision " & revision & " on branch " & branch & vbCrLf - + + Dim outputInfo : outputInfo = "Found revision " & revision & " on branch " & branch + ' Setup our revision string - Dim revisionString : revisionString = "r" & revision + Dim revisionString : revisionString = revision If (modified) Then - revisionString = revisionString & " M" + revisionString = revisionString & "-dirty" + outputInfo = outputInfo & " (dirty)" End If ' If we are not on trunk, add the branch name to the revision string - If (branch <> "trunk" And branch <> "") Then - revisionString = revisionString & " (" & branch & ")" + If (branch <> "trunk" And branch <> "master" And branch <> "") Then + revisionString = revisionString & "(" & branch & ")" End If - ' Add the DVCS name at the end - revisionString = revisionString & " - " & tool + ' Add the DVCS name at the end (when not git) + If (tool <> "git") Then + revisionString = revisionString & "-" & tool + outputInfo = outputInfo & " using " & tool + End If + + Wscript.StdErr.WriteLine outputInfo & vbCrLf - ' Setup an environment variable with the revision string - Dim Env: Set Env = WshShell.Environment("User") - Env.item("SCUMMVM_REVISION_STRING") = revisionString + ' Output revision header file + FSO.CopyFile rootFolder & "\\base\\internal_revision.h.in", targetFolder & "\\internal_revision.h" + FindReplaceInFile targetFolder & "\\internal_revision.h", "@REVISION@", revisionString End Sub Function DetermineTortoiseSVNVersion() @@ -210,10 +232,11 @@ Function DetermineGitVersion() Err.Clear On Error Resume Next DetermineGitVersion = False + Dim line Wscript.StdErr.Write " Git... " tool = "git" - ' First check if we have both a .git & .svn folders (in case hg-git has been set up to have the git folder at the working copy level) + ' First check if we have both a .git & .hg folders (in case hg-git has been set up to have the git folder at the working copy level) If FSO.FolderExists(rootFolder & "/.git") And FSO.FolderExists(rootFolder & "/.hg") Then Wscript.StdErr.WriteLine "Mercurial clone with git repository in tree!" Exit Function @@ -247,10 +270,10 @@ Function DetermineGitVersion() End If ' Get the version hash - Dim hash: hash = oExec.StdOut.ReadLine() + Dim hash : hash = oExec.StdOut.ReadLine() ' Make sure index is in sync with disk - Set oExec = WshShell.Exec(gitPath & "update-index --refresh") + Set oExec = WshShell.Exec(gitPath & "update-index --refresh --unmerged") If Err.Number = 0 Then ' Wait till the application is finished ... Do While oExec.Status = 0 @@ -258,7 +281,7 @@ Function DetermineGitVersion() Loop End If - Set oExec = WshShell.Exec(gitPath & "diff-index --exit-code --quiet HEAD " & rootFolder) + Set oExec = WshShell.Exec(gitPath & "diff-index --quiet HEAD " & rootFolder) If oExec.ExitCode <> 0 Then Wscript.StdErr.WriteLine "Error parsing git revision!" Exit Function @@ -276,36 +299,26 @@ Function DetermineGitVersion() ' Get branch name Set oExec = WshShell.Exec(gitPath & "symbolic-ref HEAD") If Err.Number = 0 Then - Dim line: line = oExec.StdOut.ReadLine() + line = oExec.StdOut.ReadLine() line = Mid(line, InStrRev(line, "/") + 1) If line <> "master" Then branch = line End If End If - ' Check for svn clones - Set oExec = WshShell.Exec(gitPath & "log --pretty=format:%s --grep=" & Chr(34) & "^(svn r[0-9]*)" & Chr(34) & " -1 " & rootFolder) - if Err.Number = 0 Then - revision = Mid(oExec.StdOut.ReadLine(), 7) - revision = Mid(revision, 1, InStr(revision, ")") - 1) - tool = "svn-git" - End If - - ' No revision? Maybe it is a custom git-svn clone - If revision = "" Then - Err.Clear - Set oExec = WshShell.Exec(gitPath & "log --pretty=format:%b --grep=" & Chr(34) & "git-svn-id:.*@[0-9]*" & Chr(34) & " -1 " & rootFolder) - If Err.Number = 0 Then - revision = oExec.StdOut.ReadLine() - revision = Mid(revision, InStr(revision, "@") + 1) - revision = Mid(revision, 1, InStr(revision, " ") - 1) - tool = "svn-git" + ' Get revision description + Set oExec = WshShell.Exec(gitPath & "describe --match desc/*") + If Err.Number = 0 Then + line = oExec.StdOut.ReadLine() + line = Mid(line, InStr(line, "-") + 1) + If line <> "" Then + revision = line End If End If - ' Fallback to abbreviated revision number + ' Fallback to abbreviated revision number if needed If revision = "" Then - revision = Mid(hash, 1, 8) + revision = Mid(hash, 1, 7) End If DetermineGitVersion = True @@ -385,8 +398,8 @@ End Function Function ParseCommandLine() ParseCommandLine = True - If Wscript.Arguments.Count <> 1 Then - Wscript.StdErr.WriteLine "[Error] Invalid number of arguments (was: " & Wscript.Arguments.Count & ", expected: 1)" + If Wscript.Arguments.Count <> 2 Then + Wscript.StdErr.WriteLine "[Error] Invalid number of arguments (was: " & Wscript.Arguments.Count & ", expected: 2)" ParseCommandLine = False Exit Function @@ -394,6 +407,7 @@ Function ParseCommandLine() ' Get our arguments rootFolder = Wscript.Arguments.Item(0) + targetFolder = Wscript.Arguments.Item(1) ' Check that the folders are valid If Not FSO.FolderExists(rootFolder) Then @@ -403,8 +417,16 @@ Function ParseCommandLine() Exit Function End If - ' Set absolute path + If Not FSO.FolderExists(targetFolder) Then + Wscript.StdErr.WriteLine "[Error] Invalid target folder (" & targetFolder & ")" + + ParseCommandLine = False + Exit Function + End If + + ' Set absolute paths rootFolder = FSO.GetAbsolutePathName(rootFolder) + targetFolder = FSO.GetAbsolutePathName(targetFolder) End Function Function ReadRegistryKey(shive, subkey, valuename, architecture) @@ -443,3 +465,14 @@ Function ReadRegistryKey(shive, subkey, valuename, architecture) ReadRegistryKey = Outparams.SValue End Function + +Sub FindReplaceInFile(filename, to_find, replacement) + Dim file, data + Set file = FSO.OpenTextFile(filename, 1, 0, 0) + data = file.ReadAll + file.Close + data = Replace(data, to_find, replacement) + Set file = FSO.CreateTextFile(filename, -1, 0) + file.Write data + file.Close +End Sub diff --git a/devtools/create_project/visualstudio.cpp b/devtools/create_project/visualstudio.cpp index 2b7c8908cb..8642f071ff 100644 --- a/devtools/create_project/visualstudio.cpp +++ b/devtools/create_project/visualstudio.cpp @@ -23,10 +23,10 @@ * */ +#include "config.h" #include "visualstudio.h" #include <fstream> - #include <algorithm> namespace CreateProjectTool { @@ -54,39 +54,7 @@ int VisualStudioProvider::getVisualStudioVersion() { if (_version == 8) return 2005; - error("Unsupported version passed to createScummVMSolution"); -} - -#define OUTPUT_CONFIGURATION_SCUMMVM(config, platform, props) { \ - project << "\t\t<Configuration Name=\"" << config << "|" << platform << "\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_" << config << props << ".vsprops\">\n" \ - "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" \ - "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" \ - "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" \ - "\t\t\t/>\n" \ - "\t\t</Configuration>\n"; \ -} - -#define OUTPUT_CONFIGURATION_SCUMMVM_DEBUG(config, platform, props, isWin32) { \ - project << "\t\t<Configuration Name=\"" << config << "|" << platform << "\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\ScummVM_" << config << props << ".vsprops\">\n" \ - "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" \ - "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/scummvm.exe\"\n" \ - "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" \ - "\t\t\t/>\n"; \ - if (setup.runBuildEvents) { \ - project << "\t\t\t<Tool\tName=\"VCPreBuildEventTool\"\n" \ - "\t\t\t\tCommandLine=\"" << getPreBuildEvent() << "\"\n" \ - "\t\t\t/>\n" \ - "\t\t\t<Tool\tName=\"VCPostBuildEventTool\"\n" \ - "\t\t\t\tCommandLine=\"" << getPostBuildEvent(isWin32) << "\"\n" \ - "\t\t\t/>\n"; \ - } \ - project << "\t\t</Configuration>\n"; \ -} - -#define OUTPUT_CONFIGURATION(config, platform, props) { \ - project << "\t\t<Configuration Name=\"" << config << "|" << platform << "\" ConfigurationType=\"4\" InheritedPropertySheets=\".\\ScummVM_" << config << props << ".vsprops\">\n" \ - "\t\t\t<Tool Name=\"VCCLCompilerTool\" "<< toolConfig << "/>\n" \ - "\t\t</Configuration>\n"; \ + error("Unsupported version passed to getVisualStudioVersion"); } void VisualStudioProvider::createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, @@ -118,24 +86,24 @@ void VisualStudioProvider::createProjectFile(const std::string &name, const std: // Check for project-specific warnings: std::map< std::string, std::list<std::string> >::iterator warningsIterator = _projectWarnings.find(name); - if (name == "scummvm") { + if (name == PROJECT_NAME) { 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", ""); + outputConfiguration(project, setup, libraries, "Debug", "Win32", "", true); + outputConfiguration(project, setup, libraries, "Analysis", "Win32", "", true); + outputConfiguration(project, setup, libraries, "Release", "Win32", "", true); // 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"); + outputConfiguration(project, setup, libraries, "Debug", "x64", "64", false); + outputConfiguration(project, setup, libraries, "Analysis", "x64", "64", false); + outputConfiguration(project, setup, libraries, "Release", "x64", "64", false); } else { std::string warnings = ""; @@ -147,14 +115,15 @@ void VisualStudioProvider::createProjectFile(const std::string &name, const std: toolConfig = (!warnings.empty() ? "DisableSpecificWarnings=\"" + warnings + "\"" : ""); toolConfig += (name == "tinsel" ? "DebugInformationFormat=\"3\" " : ""); toolConfig += (name == "sword25" ? "DisableLanguageExtensions=\"false\" " : ""); + toolConfig += (name == "grim" ? "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"); + outputConfiguration(project, toolConfig, "Debug", "Win32", ""); + outputConfiguration(project, toolConfig, "Analysis", "Win32", ""); + outputConfiguration(project, toolConfig, "Release", "Win32", ""); + outputConfiguration(project, toolConfig, "Debug", "x64", "64"); + outputConfiguration(project, toolConfig, "Analysis", "x64", "64"); + outputConfiguration(project, toolConfig, "Release", "x64", "64"); } project << "\t</Configurations>\n" @@ -176,11 +145,38 @@ void VisualStudioProvider::createProjectFile(const std::string &name, const std: "</VisualStudioProject>\n"; } +void VisualStudioProvider::outputConfiguration(std::ostream &project, const BuildSetup &setup, const std::string &libraries, const std::string &config, const std::string &platform, const std::string &props, const bool isWin32) { + project << "\t\t<Configuration Name=\"" << config << "|" << platform << "\" ConfigurationType=\"1\" InheritedPropertySheets=\".\\" << PROJECT_DESCRIPTION << "_" << config << props << ".vsprops\">\n" + "\t\t\t<Tool\tName=\"VCCLCompilerTool\" DisableLanguageExtensions=\"false\" />\n" + "\t\t\t<Tool\tName=\"VCLinkerTool\" OutputFile=\"$(OutDir)/" << PROJECT_NAME << ".exe\"\n" + "\t\t\t\tAdditionalDependencies=\"" << libraries << "\"\n" + "\t\t\t/>\n"; + outputBuildEvents(project, setup, isWin32); + project << "\t\t</Configuration>\n"; +} + +void VisualStudioProvider::outputConfiguration(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=\".\\" << PROJECT_DESCRIPTION << "_" << config << props << ".vsprops\">\n" + "\t\t\t<Tool Name=\"VCCLCompilerTool\" "<< toolConfig << "/>\n" + "\t\t</Configuration>\n"; +} + +void VisualStudioProvider::outputBuildEvents(std::ostream &project, const BuildSetup &setup, const bool isWin32) { + if (setup.runBuildEvents) { + project << "\t\t\t<Tool\tName=\"VCPreBuildEventTool\"\n" + "\t\t\t\tCommandLine=\"" << getPreBuildEvent() << "\"\n" + "\t\t\t/>\n" + "\t\t\t<Tool\tName=\"VCPostBuildEventTool\"\n" + "\t\t\t\tCommandLine=\"" << getPostBuildEvent(isWin32, setup.createInstaller) << "\"\n" + "\t\t\t/>\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") + if (i->first == PROJECT_NAME) continue; output << "\t\t{" << i->second << "} = {" << i->second << "}\n"; @@ -189,7 +185,7 @@ void VisualStudioProvider::writeReferences(std::ofstream &output) { output << "\tEndProjectSection\n"; } -void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix) { +void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix, bool runBuildEvents) { std::string warnings; for (StringList::const_iterator i = _globalWarnings.begin(); i != _globalWarnings.end(); ++i) warnings += *i + ';'; @@ -201,11 +197,15 @@ void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int b definesList += *i; } + // Add define to include revision header + if (runBuildEvents) + definesList += REVISION_DEFINE ";"; + properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" "<VisualStudioPropertySheet\n" "\tProjectType=\"Visual C++\"\n" "\tVersion=\"8.00\"\n" - "\tName=\"ScummVM_Global\"\n" + "\tName=\"" << PROJECT_DESCRIPTION << "_Global\"\n" "\tOutputDirectory=\"$(ConfigurationName)" << bits << "\"\n" "\tIntermediateDirectory=\"$(ConfigurationName)" << bits << "/$(ProjectName)\"\n" "\t>\n" @@ -213,11 +213,17 @@ void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int b "\t\tName=\"VCCLCompilerTool\"\n" "\t\tDisableLanguageExtensions=\"true\"\n" "\t\tDisableSpecificWarnings=\"" << warnings << "\"\n" - "\t\tAdditionalIncludeDirectories=\"" << prefix << ";" << prefix << "\\engines;$(SCUMMVM_LIBS)\\include\"\n" + "\t\tAdditionalIncludeDirectories=\"" << prefix << ";" << prefix << "\\engines;$(" << LIBS_DEFINE << ")\\include;$(TargetDir)\"\n" "\t\tPreprocessorDefinitions=\"" << definesList << "\"\n" - "\t\tExceptionHandling=\"0\"\n" - "\t\tRuntimeTypeInfo=\"false\"\n" - "\t\tWarningLevel=\"4\"\n" + "\t\tExceptionHandling=\"0\"\n"; + +#if NEEDS_RTTI + properties << "\t\tRuntimeTypeInfo=\"true\"\n"; +#else + properties << "\t\tRuntimeTypeInfo=\"false\"\n"; +#endif + + properties << "\t\tWarningLevel=\"4\"\n" "\t\tWarnAsError=\"false\"\n" "\t\tCompileAs=\"0\"\n" "\t\t/>\n" @@ -230,11 +236,10 @@ void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int b "\t\tIgnoreDefaultLibraryNames=\"\"\n" "\t\tSubSystem=\"1\"\n" "\t\tEntryPointSymbol=\"WinMainCRTStartup\"\n" - "\t\tAdditionalLibraryDirectories=\"$(SCUMMVM_LIBS)\\lib\\" << ((bits == 32) ? "x86" : "x64") << "\"\n" + "\t\tAdditionalLibraryDirectories=\"$(" << LIBS_DEFINE << ")\\lib\\" << ((bits == 32) ? "x86" : "x64") << "\"\n" "\t/>\n" "\t<Tool\n" "\t\tName=\"VCResourceCompilerTool\"\n" - "\t\tPreprocessorDefinitions=\"HAS_INCLUDE_SET\"\n" "\t\tAdditionalIncludeDirectories=\"" << prefix << "\"\n" "\t/>\n" "</VisualStudioPropertySheet>\n"; @@ -246,16 +251,16 @@ void VisualStudioProvider::createBuildProp(const BuildSetup &setup, bool isRelea 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()); + std::ofstream properties((setup.outputDir + '/' + PROJECT_DESCRIPTION "_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension()).c_str()); if (!properties) - error("Could not open \"" + setup.outputDir + '/' + "ScummVM_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension() + "\" for writing"); + error("Could not open \"" + setup.outputDir + '/' + PROJECT_DESCRIPTION "_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension() + "\" for writing"); properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n" "<VisualStudioPropertySheet\n" "\tProjectType=\"Visual C++\"\n" "\tVersion=\"8.00\"\n" - "\tName=\"ScummVM_" << outputType << outputBitness << "\"\n" - "\tInheritedPropertySheets=\".\\ScummVM_Global" << (isWin32 ? "" : "64") << ".vsprops\"\n" + "\tName=\"" << PROJECT_DESCRIPTION << "_" << outputType << outputBitness << "\"\n" + "\tInheritedPropertySheets=\".\\" << PROJECT_DESCRIPTION << "_Global" << (isWin32 ? "" : "64") << ".vsprops\"\n" "\t>\n" "\t<Tool\n" "\t\tName=\"VCCLCompilerTool\"\n"; @@ -282,7 +287,7 @@ void VisualStudioProvider::createBuildProp(const BuildSetup &setup, bool isRelea "\t\tRuntimeLibrary=\"1\"\n" "\t\tEnableFunctionLevelLinking=\"true\"\n" "\t\tWarnAsError=\"false\"\n" - "\t\tDebugInformationFormat=\"" << (isWin32 ? "4" : "3") << "\"\n" // For x64 format "4" (Edit and continue) is not supported, thus we default to "3" + "\t\tDebugInformationFormat=\"" << (isWin32 ? "4" : "3") << "\"\n" // For x64 format "4" (Edit and continue) is not supported, thus we default to "3" "\t\tAdditionalOption=\"" << (enableAnalysis ? "/analyze" : "") << "\"\n" "\t/>\n" "\t<Tool\n" diff --git a/devtools/create_project/visualstudio.h b/devtools/create_project/visualstudio.h index 0cf572429b..0e4b441e63 100644 --- a/devtools/create_project/visualstudio.h +++ b/devtools/create_project/visualstudio.h @@ -43,13 +43,17 @@ protected: void writeReferences(std::ofstream &output); - void outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix); + void outputGlobalPropFile(std::ofstream &properties, int bits, const StringList &defines, const std::string &prefix, bool runBuildEvents); void createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32, bool enableAnalysis); const char *getProjectExtension(); const char *getPropertiesExtension(); int getVisualStudioVersion(); + + void outputConfiguration(std::ostream &project, const BuildSetup &setup, const std::string &libraries, const std::string &config, const std::string &platform, const std::string &props, const bool isWin32); + void outputConfiguration(std::ostream &project, const std::string &toolConfig, const std::string &config, const std::string &platform, const std::string &props); + void outputBuildEvents(std::ostream &project, const BuildSetup &setup, const bool isWin32); }; } // End of CreateProjectTool namespace |