aboutsummaryrefslogtreecommitdiff
path: root/devtools/create_project/create_project.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2016-07-26 19:48:14 -0400
committerPaul Gilbert2016-07-26 19:48:14 -0400
commit504cf6ecb688a3f1c65a857bffd527d8b0e6ba63 (patch)
tree0c0d96d4061c11850c851f0fc981c75a58c20515 /devtools/create_project/create_project.cpp
parentd8c28d15ae553d047b7e571f98727fa79ee143f3 (diff)
parente19922d181e775791f9105b8be7ff410770ede51 (diff)
downloadscummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.tar.gz
scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.tar.bz2
scummvm-rg350-504cf6ecb688a3f1c65a857bffd527d8b0e6ba63.zip
Merge branch 'master' into xeen
Diffstat (limited to 'devtools/create_project/create_project.cpp')
-rw-r--r--devtools/create_project/create_project.cpp188
1 files changed, 128 insertions, 60 deletions
diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp
index 0aba511491..7e2cad0901 100644
--- a/devtools/create_project/create_project.cpp
+++ b/devtools/create_project/create_project.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "create_project.h"
+#include "cmake.h"
#include "codeblocks.h"
#include "msvc.h"
#include "visualstudio.h"
@@ -53,7 +54,7 @@
#define USE_WIN32_API
#endif
-#ifdef USE_WIN32_API
+#if (defined(_WIN32) || defined(WIN32))
#include <windows.h>
#else
#include <sstream>
@@ -83,10 +84,18 @@ std::string unifyPath(const std::string &path);
* @param exe Name of the executable.
*/
void displayHelp(const char *exe);
+
+/**
+ * Build a list of options to enable or disable GCC warnings
+ *
+ * @param globalWarnings Resulting list of warnings
+ */
+void addGCCWarnings(StringList &globalWarnings);
} // End of anonymous namespace
enum ProjectType {
kProjectNone,
+ kProjectCMake,
kProjectCodeBlocks,
kProjectMSVC,
kProjectXcode
@@ -125,7 +134,6 @@ int main(int argc, char *argv[]) {
ProjectType projectType = kProjectNone;
int msvcVersion = 12;
- bool useSDL2 = false;
// Parse command line arguments
using std::cout;
@@ -142,6 +150,14 @@ int main(int argc, char *argv[]) {
return 0;
+ } else if (!std::strcmp(argv[i], "--cmake")) {
+ if (projectType != kProjectNone) {
+ std::cerr << "ERROR: You cannot pass more than one project type!\n";
+ return -1;
+ }
+
+ projectType = kProjectCMake;
+
} else if (!std::strcmp(argv[i], "--codeblocks")) {
if (projectType != kProjectNone) {
std::cerr << "ERROR: You cannot pass more than one project type!\n";
@@ -269,7 +285,7 @@ int main(int argc, char *argv[]) {
} else if (!std::strcmp(argv[i], "--tests")) {
setup.tests = true;
} else if (!std::strcmp(argv[i], "--sdl2")) {
- useSDL2 = true;
+ setup.useSDL2 = true;
} else {
std::cerr << "ERROR: Unknown parameter \"" << argv[i] << "\"\n";
return -1;
@@ -335,19 +351,51 @@ int main(int argc, char *argv[]) {
StringList featureDefines = getFeatureDefines(setup.features);
setup.defines.splice(setup.defines.begin(), featureDefines);
- // Windows only has support for the SDL backend, so we hardcode it here (along with winmm)
- if (projectType != kProjectXcode) {
+ if (projectType == kProjectXcode) {
+ setup.defines.push_back("POSIX");
+ // Define both MACOSX, and IPHONE, but only one of them will be associated to the
+ // correct target by the Xcode project provider.
+ // This define will help catching up target dependend files, like "browser_osx.mm"
+ // The suffix ("_osx", or "_ios") will be used by the project provider to filter out
+ // the files, according to the target.
+ setup.defines.push_back("MACOSX");
+ setup.defines.push_back("IPHONE");
+ } else if (projectType == kProjectMSVC || projectType == kProjectCodeBlocks) {
+ // Windows only has support for the SDL backend, so we hardcode it here (along with winmm)
setup.defines.push_back("WIN32");
} else {
+ // As a last resort, select the backend files to build based on the platform used to build create_project.
+ // This is broken when cross compiling.
+#if defined(_WIN32) || defined(WIN32)
+ setup.defines.push_back("WIN32");
+#else
setup.defines.push_back("POSIX");
- setup.defines.push_back("MACOSX"); // This will break iOS, but allows OS X to catch up on browser_osx.
+#endif
}
+
+ bool updatesEnabled = false;
+ for (FeatureList::const_iterator i = setup.features.begin(); i != setup.features.end(); ++i) {
+ if (i->enable && !strcmp(i->name, "updates"))
+ updatesEnabled = true;
+ }
+ if (updatesEnabled) {
+ setup.defines.push_back("USE_SPARKLE");
+ if (projectType != kProjectXcode)
+ setup.libraries.push_back("winsparkle");
+ else
+ setup.libraries.push_back("sparkle");
+ }
+
setup.defines.push_back("SDL_BACKEND");
- if (!useSDL2) {
- cout << "\nLinking to SDL 1.2\n\n";
+ if (!setup.useSDL2) {
+ cout << "\nBuilding against SDL 1.2\n\n";
setup.libraries.push_back("sdl");
} else {
- cout << "\nLinking to SDL 2.0\n\n";
+ cout << "\nBuilding against SDL 2.0\n\n";
+ // TODO: This also defines USE_SDL2 in the preprocessor, we don't do
+ // this in our configure/make based build system. Adapt create_project
+ // to replicate this behavior.
+ setup.defines.push_back("USE_SDL2");
setup.libraries.push_back("sdl2");
}
setup.libraries.push_back("winmm");
@@ -374,49 +422,25 @@ int main(int argc, char *argv[]) {
std::cerr << "ERROR: No project type has been specified!\n";
return -1;
+ case kProjectCMake:
+ if (setup.devTools || setup.tests) {
+ std::cerr << "ERROR: Building tools or tests is not supported for the CMake project type!\n";
+ return -1;
+ }
+
+ addGCCWarnings(globalWarnings);
+
+ provider = new CreateProjectTool::CMakeProvider(globalWarnings, projectWarnings);
+
+ break;
+
case kProjectCodeBlocks:
if (setup.devTools || setup.tests) {
std::cerr << "ERROR: Building tools or tests is not supported for the CodeBlocks project type!\n";
return -1;
}
- ////////////////////////////////////////////////////////////////////////////
- // Code::Blocks is using GCC behind the scenes, so we need to pass a list
- // of options to enable or disable warnings
- ////////////////////////////////////////////////////////////////////////////
- //
- // -Wall
- // enable all warnings
- //
- // -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder
- // disable annoying and not-so-useful warnings
- //
- // -Wpointer-arith -Wcast-qual -Wcast-align
- // -Wshadow -Wimplicit -Wnon-virtual-dtor -Wwrite-strings
- // enable even more warnings...
- //
- // -fno-rtti -fno-exceptions -fcheck-new
- // disable RTTI and exceptions, and enable checking of pointers returned
- // by "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-exceptions");
- globalWarnings.push_back("-fcheck-new");
+ addGCCWarnings(globalWarnings);
provider = new CreateProjectTool::CodeBlocksProvider(globalWarnings, projectWarnings);
@@ -630,6 +654,7 @@ void displayHelp(const char *exe) {
" Additionally there are the following switches for changing various settings:\n"
"\n"
"Project specific settings:\n"
+ " --cmake build CMake project files\n"
" --codeblocks build Code::Blocks project files\n"
" --msvc build Visual Studio project files\n"
" --xcode build XCode project files\n"
@@ -684,6 +709,41 @@ void displayHelp(const char *exe) {
cout.setf(std::ios_base::right, std::ios_base::adjustfield);
}
+void addGCCWarnings(StringList &globalWarnings) {
+ ////////////////////////////////////////////////////////////////////////////
+ //
+ // -Wall
+ // enable all warnings
+ //
+ // -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder
+ // disable annoying and not-so-useful warnings
+ //
+ // -Wpointer-arith -Wcast-qual -Wcast-align
+ // -Wshadow -Wimplicit -Wnon-virtual-dtor -Wwrite-strings
+ // enable even more warnings...
+ //
+ // -fno-exceptions -fcheck-new
+ // disable exceptions, and enable checking of pointers returned by "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("-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-exceptions");
+ globalWarnings.push_back("-fcheck-new");
+}
+
/**
* Parse the configure.engine file of a given engine directory and return a
* list of all defined engines.
@@ -929,16 +989,17 @@ TokenList tokenize(const std::string &input, char separator) {
namespace {
const Feature s_features[] = {
// Libraries
- { "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 win_utf8_io_static", true, "FLAC support" },
- { "png", "USE_PNG", "libpng", true, "libpng support" },
- { "faad", "USE_FAAD", "libfaad", false, "AAC support" },
- { "mpeg2", "USE_MPEG2", "libmpeg2", false, "MPEG-2 support" },
- { "theora", "USE_THEORADEC", "libtheora_static", true, "Theora decoding support" },
- {"freetype", "USE_FREETYPE2", "freetype", true, "FreeType support" },
- { "jpeg", "USE_JPEG", "jpeg-static", true, "libjpeg 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 win_utf8_io_static", true, "FLAC support" },
+ { "png", "USE_PNG", "libpng16", true, "libpng support" },
+ { "faad", "USE_FAAD", "libfaad", false, "AAC support" },
+ { "mpeg2", "USE_MPEG2", "libmpeg2", false, "MPEG-2 support" },
+ { "theora", "USE_THEORADEC", "libtheora_static", true, "Theora decoding support" },
+ { "freetype", "USE_FREETYPE2", "freetype", true, "FreeType support" },
+ { "jpeg", "USE_JPEG", "jpeg-static", true, "libjpeg support" },
+ {"fluidsynth", "USE_FLUIDSYNTH", "libfluidsynth", true, "FluidSynth support" },
// Feature flags
{ "bink", "USE_BINK", "", true, "Bink video support" },
@@ -947,12 +1008,14 @@ const Feature s_features[] = {
{ "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" },
+ { "opengl", "USE_OPENGL", "", true, "OpenGL support" },
+ { "opengles", "USE_GLES", "", true, "forced OpenGL ES mode" },
{ "taskbar", "USE_TASKBAR", "", true, "Taskbar integration support" },
{ "translation", "USE_TRANSLATION", "", true, "Translation support" },
{ "vkeybd", "ENABLE_VKEYBD", "", false, "Virtual keyboard support"},
{ "keymapper", "ENABLE_KEYMAPPER", "", false, "Keymapper support"},
{ "eventrecorder", "ENABLE_EVENTRECORDER", "", false, "Event recorder support"},
+ { "updates", "USE_UPDATES", "", false, "Updates 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...
};
@@ -1050,6 +1113,12 @@ void splitFilename(const std::string &fileName, std::string &name, std::string &
ext = (dot == std::string::npos) ? std::string() : fileName.substr(dot + 1);
}
+std::string basename(const std::string &fileName) {
+ const std::string::size_type slash = fileName.find_last_of('/');
+ if (slash == std::string::npos) return fileName;
+ return fileName.substr(slash + 1);
+}
+
bool producesObjectFile(const std::string &fileName) {
std::string n, ext;
splitFilename(fileName, n, ext);
@@ -1143,7 +1212,7 @@ bool compareNodes(const FileNode *l, const FileNode *r) {
FileList listDirectory(const std::string &dir) {
FileList result;
-#ifdef USE_WIN32_API
+#if defined(_WIN32) || defined(WIN32)
WIN32_FIND_DATA fileInformation;
HANDLE fileHandle = FindFirstFile((dir + "/*").c_str(), &fileInformation);
@@ -1334,8 +1403,7 @@ void ProjectProvider::createProject(BuildSetup &setup) {
createModuleList(setup.srcDir + "/image", setup.defines, setup.testDirs, in, ex);
// Resource files
- in.push_back(setup.srcDir + "/icons/" + setup.projectName + ".ico");
- in.push_back(setup.srcDir + "/dists/" + setup.projectName + ".rc");
+ addResourceFiles(setup, in, ex);
// Various text files
in.push_back(setup.srcDir + "/AUTHORS");