DEVTOOLS: Improve SDL2 support in create_project.

This adapts MSBuild and XCode project generators to output project files which
can be used to build the SDL backend with SDL2 easily.
This commit is contained in:
Johannes Schickel 2016-03-24 01:26:05 +01:00
parent 567a6b4712
commit dfaf97dda7
4 changed files with 23 additions and 9 deletions

View File

@ -125,7 +125,6 @@ int main(int argc, char *argv[]) {
ProjectType projectType = kProjectNone;
int msvcVersion = 12;
bool useSDL2 = false;
// Parse command line arguments
using std::cout;
@ -269,7 +268,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;
@ -349,11 +348,15 @@ int main(int argc, char *argv[]) {
setup.defines.push_back("IPHONE");
}
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");

View File

@ -232,12 +232,14 @@ struct BuildSetup {
bool tests; ///< Generate project files for the tests
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
bool useSDL2; ///< Whether to use SDL2 or not.
BuildSetup() {
devTools = false;
tests = false;
runBuildEvents = false;
createInstaller = false;
useSDL2 = false;
}
};

View File

@ -366,7 +366,7 @@ void MSBuildProvider::outputGlobalPropFile(const BuildSetup &setup, std::ofstrea
"\t\t<_PropertySheetDisplayName>" << setup.projectDescription << "_Global</_PropertySheetDisplayName>\n"
"\t\t<ExecutablePath>$(" << LIBS_DEFINE << ")\\bin;$(" << LIBS_DEFINE << ")\\bin\\" << (bits == 32 ? "x86" : "x64") << ";$(ExecutablePath)</ExecutablePath>\n"
"\t\t<LibraryPath>$(" << LIBS_DEFINE << ")\\lib\\" << (bits == 32 ? "x86" : "x64") << ";$(" << LIBS_DEFINE << ")\\lib\\" << (bits == 32 ? "x86" : "x64") << "\\$(Configuration);$(LibraryPath)</LibraryPath>\n"
"\t\t<IncludePath>$(" << LIBS_DEFINE << ")\\include;$(" << LIBS_DEFINE << ")\\include\\SDL;$(IncludePath)</IncludePath>\n"
"\t\t<IncludePath>$(" << LIBS_DEFINE << ")\\include;$(" << LIBS_DEFINE << ")\\include\\" << (setup.useSDL2 ? "SDL2" : "SDL") << ";$(IncludePath)</IncludePath>\n"
"\t\t<OutDir>$(Configuration)" << bits << "\\</OutDir>\n"
"\t\t<IntDir>$(Configuration)" << bits << "\\$(ProjectName)\\</IntDir>\n"
"\t</PropertyGroup>\n"

View File

@ -927,7 +927,11 @@ void XcodeProvider::setupBuildConfiguration(const BuildSetup &setup) {
ADD_SETTING_LIST(scummvmOSX_Debug, "GCC_PREPROCESSOR_DEFINITIONS", scummvmOSX_defines, kSettingsNoQuote | kSettingsAsList, 5);
ADD_SETTING_QUOTE(scummvmOSX_Debug, "GCC_VERSION", "");
ValueList scummvmOSX_HeaderPaths;
scummvmOSX_HeaderPaths.push_back("/opt/local/include/SDL");
if (setup.useSDL2) {
scummvmOSX_HeaderPaths.push_back("/opt/local/include/SDL2");
} else {
scummvmOSX_HeaderPaths.push_back("/opt/local/include/SDL");
}
scummvmOSX_HeaderPaths.push_back("/opt/local/include");
scummvmOSX_HeaderPaths.push_back("/opt/local/include/freetype2");
scummvmOSX_HeaderPaths.push_back("include/");
@ -943,7 +947,6 @@ void XcodeProvider::setupBuildConfiguration(const BuildSetup &setup) {
ADD_SETTING_LIST(scummvmOSX_Debug, "LIBRARY_SEARCH_PATHS", scummvmOSX_LibPaths, kSettingsNoQuote | kSettingsAsList, 5);
ADD_SETTING_QUOTE(scummvmOSX_Debug, "OTHER_CFLAGS", "");
ValueList scummvmOSX_LdFlags;
scummvmOSX_LdFlags.push_back("-lSDLmain");
scummvmOSX_LdFlags.push_back("-logg");
scummvmOSX_LdFlags.push_back("-lpng");
scummvmOSX_LdFlags.push_back("-ljpeg");
@ -953,7 +956,13 @@ void XcodeProvider::setupBuildConfiguration(const BuildSetup &setup) {
scummvmOSX_LdFlags.push_back("-lvorbis");
scummvmOSX_LdFlags.push_back("-lmad");
scummvmOSX_LdFlags.push_back("-lFLAC");
scummvmOSX_LdFlags.push_back("-lSDL");
if (setup.useSDL2) {
scummvmOSX_LdFlags.push_back("-lSDL2main");
scummvmOSX_LdFlags.push_back("-lSDL2");
} else {
scummvmOSX_LdFlags.push_back("-lSDLmain");
scummvmOSX_LdFlags.push_back("-lSDL");
}
scummvmOSX_LdFlags.push_back("-lz");
ADD_SETTING_LIST(scummvmOSX_Debug, "OTHER_LDFLAGS", scummvmOSX_LdFlags, kSettingsAsList, 5);
ADD_SETTING(scummvmOSX_Debug, "PREBINDING", "NO");