diff --git a/CMakeLists.txt b/CMakeLists.txt index 1569a45d5..d4911732c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeModules) -#this block wil fix install prefixes to install everything in a subdirectory +#this block will fix install prefixes to install everything in a subdirectory #of cmake_binary_dir if we are on windows/android to make packaging more easy if(NOT CMAKE_TOOLCHAIN_FILE) if(WIN32) @@ -59,7 +59,7 @@ if(UNIX AND NOT ANDROID) endif() endif() -if(ANDROID OR PSP) +if(ANDROID OR PSP OR IOS) #to allow finding of pathes/headers/libs within the source tree #even if only search for target platform libs set(CMAKE_FIND_ROOT_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_FIND_ROOT_PATH}) @@ -87,7 +87,7 @@ endif() if(WIN32 OR ANDROID OR UNIX) WAGIC_OPTION(backend_sdl "build for sdl" (WIN32 OR ANDROID OR EMSCRIPTEN)) endif() -if(NOT backend_sdl AND UNIX AND NOT ANDROID) +if(NOT backend_sdl AND UNIX AND NOT ANDROID AND NOT IOS) WAGIC_OPTION(backend_qt_console "build qt-console version with testsuit" ON) WAGIC_OPTION(backend_qt_widget "build qt-widget version" OFF) endif() @@ -97,9 +97,9 @@ WAGIC_OPTION(BUILD_ZLIB "build zlib from source" WIN32 OR APPLE OR EMSCRIP WAGIC_OPTION(BUILD_JPEG "build jpeg from source" (WIN32 OR APPLE OR PSP OR ANDROID OR EMSCRIPTEN)) WAGIC_OPTION(BUILD_PNG "build png from source" (WIN32 OR APPLE OR PSP OR ANDROID OR EMSCRIPTEN)) WAGIC_OPTION(BUILD_UNZIP "build unzip from source" ON) -WAGIC_OPTION(BUILD_TINYXML "build tinyxml from source" (WIN32 OR APPLE OR PSP OR ANDROID OR EMSCRIPTEN)) +WAGIC_OPTION(BUILD_TINYXML "build tinyxml from source" (WIN32 OR APPLE OR PSP OR ANDROID OR EMSCRIPTEN OR IOS)) WAGIC_OPTION(BUILD_ZIPFS "build zipfs from source" ON) -WAGIC_OPTION(BUILD_SDL2 "build SDL2 from source" (backend_sdl AND (UNIX OR WIN32 OR ANDROID) AND (NOT EMSCRIPTEN))) +WAGIC_OPTION(BUILD_SDL2 "build SDL2 from source" (backend_sdl AND (UNIX OR WIN32 OR ANDROID) AND (NOT EMSCRIPTEN AND NOT IOS))) #project options if(ANDROID) @@ -206,3 +206,34 @@ endif() if(EMSCRIPTEN) set(CMAKE_EXECUTABLE_SUFFIX ".html") endif() + +if(IOS) + list_add_prefix(JGE_SOURCES " JGE/") + list_add_prefix(MTG_generic_src " projects/mtg/") + list_add_prefix(JGE_INCLUDE_DIRS " -IJGE/") + list_add_prefix(MTG_INCLUDE_DIRS " -Iprojects/mtg/") + list_add_prefix(TINYXML_SRC " thirdparty/tinyxml/") + list_add_prefix(UNZIP_SRC " thirdparty/unzip/") + list_add_prefix(ZIPFS_SRC " thirdparty/zipFS/") + + file(WRITE makefile.ios + "ARCHS= armv7 armv7s \n" + "include ${THEOS_PATH}/makefiles/common.mk\n" + "TARGET= iphone:clang:latest:8.0 \n" + "APPLICATION_NAME = " ${PROJECT_NAME} "\n" + ${PROJECT_NAME} "_FILES =" ${ZIPFS_SRC} ${UNZIP_SRC} ${TINYXML_SRC} ${JGE_SOURCES} ${MTG_generic_src} " thirdparty/Boost/lib/pthread/once.cpp thirdparty/Boost/lib/pthread/thread.cpp\n" + ${PROJECT_NAME} "_LDFLAGS = -lz\n" + ${PROJECT_NAME} "_FRAMEWORKS = UIKit CoreGraphics OpenGLES Foundation CFNetwork MobileCoreServices AVFoundation OpenAL AudioToolbox QuartzCore SystemConfiguration\n" + "include ${THEOS_PATH}/makefiles/application.mk\n" + "ADDITIONAL_CFLAGS = " ${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} " -I" ${ZIPFS_INCLUDE_DIR} " -I" ${UNZIP_INCLUDE_DIR} " -I" ${HGE_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} " -I" ${ZLIB_INCLUDE_DIRS} ${BOOST_INCLUDE_DIRS} " " + "-DIOS -D__arm__ -DTIXML_USE_STL -DVERSION=\"$(GIT_VERSION)\" " + "-Wno-parentheses-equality -Wno-delete-non-virtual-dtor " + "-Wno-tautological-undefined-compare -Wno-undefined-bool-conversion " + "-Wno-visibility -Wno-deprecated-declarations -Wno-non-literal-null-conversion " + "-Wno-format -Wno-distributed-object-modifiers -Wno-missing-braces -Wno-uninitialized " + "-Wno-unused-const-variable -Wno-unused-function -Wno-unknown-warning-option -Wno-unused-local-typedef " + "-x objective-c++ \n" + + "_THEOS_TARGET_ONLY_OBJCFLAGS :=\"\"\n" + ) +endif() diff --git a/CMakeModules/FindOrBuild.cmake b/CMakeModules/FindOrBuild.cmake index 98e59b956..1b59810e5 100644 --- a/CMakeModules/FindOrBuild.cmake +++ b/CMakeModules/FindOrBuild.cmake @@ -57,7 +57,7 @@ macro(FindOrBuildUNZIP) endmacro() macro(FindOrBuildBoost) - if(PSP OR UNIX OR WIN32) + if(PSP OR UNIX OR WIN32 OR IOS) #the psp build does not need more than a few headers #todo: remove from the repository set(BOOST_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/thirdparty/Boost) diff --git a/CMakeModules/ios-theos.toolchain.cmake b/CMakeModules/ios-theos.toolchain.cmake new file mode 100644 index 000000000..0c84625fe --- /dev/null +++ b/CMakeModules/ios-theos.toolchain.cmake @@ -0,0 +1,48 @@ +include(CMakeForceCompiler) + +# this one is important +SET(CMAKE_SYSTEM_NAME "Generic") +#this one not so much +SET(CMAKE_SYSTEM_VERSION 1) + +set (CMAKE_SYSTEM_NAME Generic) + +# Just point to anything that exists. +# We don't need CMake to generate proper build files. +set(CMAKE_C_COMPILER ${CMAKE_CURRENT_SOURCE_DIR}) +set(CMAKE_CXX_COMPILER ${CMAKE_CURRENT_SOURCE_DIR}) + +# Skip the platform compiler checks +set (CMAKE_CXX_COMPILER_WORKS TRUE) +set (CMAKE_C_COMPILER_WORKS TRUE) + +#how libraries look +SET(CMAKE_FIND_LIBRARY_PREFIXES "lib") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") + +SET(CMAKE_SYSTEM_INCLUDE_PATH + ${THEOS_PATH}/include + ${CMAKE_INSTALL_PREFIX}/include + ${CMAKE_SYSTEM_INCLUDE_PATH}) + +# where is the target environment +SET(CMAKE_SYSTEM_LIBRARY_PATH + ${THEOS_PATH}/lib + ${CMAKE_INSTALL_PREFIX}/lib + ${CMAKE_SYSTEM_LIBRARY_PATH}) + + +SET(CMAKE_FIND_ROOT_PATH + ${CMAKE_SOURCE_DIR} + ${THEOS_PATH} + ${THEOS_PATH}/lib + ${THEOS_PATH}/include + ) + +# search for programs in the build host directories +# for libraries and headers in the target directories and then in the host +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY FIRST) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE FIRST) + +set(IOS 1) diff --git a/JGE/CMakeLists.txt b/JGE/CMakeLists.txt index fc39eec3a..b3ab98cd1 100644 --- a/JGE/CMakeLists.txt +++ b/JGE/CMakeLists.txt @@ -17,7 +17,6 @@ set(JGE_generic_src src/JParticleSystem.cpp src/JResourceManager.cpp src/JSpline.cpp - src/JNetwork.cpp src/JSprite.cpp src/Vector2D.cpp) @@ -45,11 +44,13 @@ set(JGE_console_src #the sources we need on linux set(JGE_linux_src + src/JNetwork.cpp src/pc/JSocket.cpp src/pc/JSfx.cpp) set(JGE_android_src - src/JSocket.cpp + src/JNetwork.cpp + src/JSocket.cpp src/android/JSfx.cpp) #the sources we need if we compile for psp @@ -57,7 +58,8 @@ set(JGE_android_src #the other main functions reside in projects/mtg to reduce cross-library dependencies. #there may be a way to get all main-functions into the same project set(JGE_psp_src - src/JSocket.cpp + src/JNetwork.cpp + src/JSocket.cpp src/JGfx.cpp src/JSfx.cpp src/JAudio.cpp @@ -66,6 +68,14 @@ set(JGE_psp_src src/main.cpp src/vram.cpp) +set(JGE_ios_src + src/iOS/wagicAppDelegate.m + src/iOS/ES2Renderer.m + src/iOS/EAGLView.m + src/iOS/EAGLViewController.m + src/iOS/JSfx.cpp) + + set(JGE_INCLUDE_DIRS include include/hge) set(EXTRA_INCLUDE_DIR ../projects/mtg/extra) @@ -135,6 +145,13 @@ if(backend_psp) endif() endif() +if(IOS) + set(JGE_SOURCES ${JGE_generic_src} ${JGE_ios_src} ${JGE_hge_src} src/pc/JGfx.cpp) + set(JGE_SOURCES ${JGE_SOURCES} PARENT_SCOPE) + set(JGE_INCLUDE_DIRS ${JGE_INCLUDE_DIRS} src/iOS PARENT_SCOPE) + set(JGE_LINK_LIBRARIES ${TINYXML_LIBRARIES} ${ZIPFS_LIBRARY} ${UNZIP_LIRARY}) +endif() + add_library(jge STATIC ${JGE_SOURCES}) include_directories(${JGE_INTERNAL_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS}) target_link_libraries(jge ${JGE_LINK_LIBRARIES}) diff --git a/JGE/include/JTypes.h b/JGE/include/JTypes.h index 7aedb500f..5c022c612 100644 --- a/JGE/include/JTypes.h +++ b/JGE/include/JTypes.h @@ -27,7 +27,11 @@ #else //#define __STDC_LIMIT_MACROS +#ifdef IOS +#include +#else #include +#endif //#include //the MSC version might only define _MSC_STDINT_H_ //and that might cause redefinition of standard types diff --git a/platforms/win/configure.cmake b/platforms/win/configure.cmake index 0588f1e53..28cf8131f 100644 --- a/platforms/win/configure.cmake +++ b/platforms/win/configure.cmake @@ -1,2 +1,3 @@ add_definitions(-DWIN32) -add_definitions(-D_DEBUG -D_CRT_SECURE_NO_WARNINGS) +add_definitions(-D_CRT_SECURE_NO_WARNINGS) +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") diff --git a/projects/mtg/CMakeLists.txt b/projects/mtg/CMakeLists.txt index ca5366caa..491fae3e3 100644 --- a/projects/mtg/CMakeLists.txt +++ b/projects/mtg/CMakeLists.txt @@ -109,9 +109,10 @@ set(MTG_generic_src src/WFont.cpp src/WGui.cpp src/WResourceManager.cpp - src/NetworkPlayer.cpp ) +set(MTG_network_src src/NetworkPlayer.cpp) + #the sources we need if we compile a graphical qt version #TODO: add declarative version since this only works with QWidget right now set(MTG_qt_graphic_src @@ -132,6 +133,24 @@ set(MTG_sdl_src set(MTG_android_sdl_src src/SDLmain.cpp) +set(MTG_iOS_src + iOS/UI/WagicDownloadProgressViewController.m + iOS/asi-http-request/ASIAuthenticationDialog.m + iOS/asi-http-request/ASIDataCompressor.m + iOS/asi-http-request/ASIDataDecompressor.m + iOS/asi-http-request/ASIDownloadCache.m + iOS/asi-http-request/ASIFormDataRequest.m + iOS/asi-http-request/ASIHTTPRequest.m + iOS/asi-http-request/ASIInputStream.m + iOS/asi-http-request/ASINetworkQueue.m + iOS/SoundManager/SoundManager.m + iOS/SoundManager/MyOpenALSupport.c + iOS/Reachability/Reachability/Reachability.m + iOS/ZipArchive/ZipArchive.mm) + + +set(MTG_iOS_INCLUDE_DIRS iOS/UI iOS/Reachability/Reachability iOS/asi-http-request iOS/ZipArchive iOS/SoundManager) + set(MTG_INCLUDE_DIRS include include/qt) set(JGE_INCLUDE_DIRS ../../JGE/include ../../JGE/include/hge) set(JGE_LIBRARY jge) @@ -147,7 +166,7 @@ if(backend_qt_console) if(UNIX AND NOT ANDROID) include_directories(${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} ${ZIPFS_INCLUDE_DIR} ${Qt5Core_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${UNZIP_INCLUDE_DIR} ${HGE_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default) - add_executable(wagic ${MTG_generic_src} ${MTG_qt_console_src}) + add_executable(wagic ${MTG_generic_src} ${MTG_qt_console_src} ${MTG_network_src}) target_link_libraries(wagic ${JGE_LIBRARY} ${Qt5Core_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${TINYXML_LIBRARIES} ${HGE_LIBRARY} ${ZLIB_LIBRARIES}) else() @@ -157,7 +176,7 @@ elseif(backend_qt_widget) if(UNIX AND NOT ANDROID) include_directories(${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} ${ZIPFS_INCLUDE_DIR} ${Qt5Core_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${UNZIP_INCLUDE_DIR} ${HGE_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} ${QT_MKSPECS_DIR}/default) - add_executable(wagic ${MTG_generic_src} ${MTG_qt_graphic_src}) + add_executable(wagic ${MTG_generic_src} ${MTG_qt_graphic_src} ${MTG_network_src}) target_link_libraries(wagic ${JGE_LIBRARY} ${Qt5Core_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES} ${HGE_LIBRARY} ${ZLIB_LIBRARIES})# ${X11_LIBRARIES}) else() @@ -166,16 +185,16 @@ elseif(backend_qt_widget) elseif(backend_sdl) if((UNIX OR EMSCRIPTEN) AND NOT ANDROID) include_directories(${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${UNZIP_INCLUDE_DIR} ${HGE_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS}) - add_executable(wagic ${MTG_generic_src} ${MTG_sdl_src} src/TestSuiteAI.cpp src/AIPlayerBakaB.cpp) + add_executable(wagic ${MTG_generic_src} ${MTG_sdl_src} ${MTG_network_src} src/TestSuiteAI.cpp src/AIPlayerBakaB.cpp) target_link_libraries(wagic ${JGE_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES} ${HGE_LIBRARY} ${ZLIB_LIBRARIES}) elseif(ANDROID) include_directories(${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${BOOST_INCLUDE_DIRS} ${UNZIP_INCLUDE_DIR} ${HGE_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR}) #we should try to get rid of this hack - add_library(wagic SHARED ${MTG_generic_src} ${MTG_android_sdl_src} src/TestSuiteAI.cpp) + add_library(wagic SHARED ${MTG_generic_src} ${MTG_network_src} ${MTG_android_sdl_src} src/TestSuiteAI.cpp) target_link_libraries(wagic ${JGE_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES} ${HGE_LIBRARY} ${ZLIB_LIBRARIES}) elseif(WIN32) include_directories(${EXTRA_INCLUDE_DIR} ${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} ${SDL2_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} ${UNZIP_INCLUDE_DIR} ${HGE_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS}) + ${Boost_INCLUDE_DIRS} ${UNZIP_INCLUDE_DIR} ${HGE_INCLUDE_DIR} ${TINYXML_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS}) add_executable(wagic ${MTG_generic_src} ${MTG_sdl_src} src/TestSuiteAI.cpp src/AIPlayerBakaB.cpp) link_directories(${Boost_LIBRARY_DIR} ${SDL2_LIBRARY_DIR}) target_link_libraries(wagic ${JGE_LIBRARY} ${SDL2_LIBRARY} ${OPENGL_LIBRARIES} ${TINYXML_LIBRARIES} ${BOOST_date_time} ${HGE_LIBRARY} ${ZLIB_LIBRARIES}) @@ -185,7 +204,7 @@ elseif(backend_psp) #${PSPSDK_PATH}/include include_directories(${MTG_INCLUDE_DIRS} ${JGE_INCLUDE_DIRS} ${TINYXML_INCLUDE_DIR} ${ZIPFS_INCLUDE_DIR} ${UNZIP_INCLUDE_DIR} ${BOOST_INCLUDE_DIRS} ${GIF_INCLUDE_DIR} ${HGETOOLS_INCLUDE_DIRS}) - add_executable(wagic ${MTG_generic_src}) + add_executable(wagic ${MTG_generic_src} ${MTG_network_src}) target_link_libraries(wagic ${JGE_LIBRARY} ${PSPSDK_LIB} ${HGETOOLS_LIBRARY} ${FREETYPE_LIB} ${JPEG_LIBRARY} ${GIF_LIBRARIES} ${PNG_LIBRARIES} z m ${MIKMOD_LIBRARY} ${TINYXML_LIBRARIES} stdc++ ${PSPSDK_REQUIRED_LIB}) @@ -207,3 +226,8 @@ elseif(backend_psp) message(FATAL_ERROR "use the cross-compile toolchain to build as the psp target") endif() endif() +if(IOS) + set(MTG_generic_src ${MTG_generic_src} ${MTG_iOS_src} PARENT_SCOPE) + set(MTG_INCLUDE_DIRS ${MTG_INCLUDE_DIRS} ${MTG_iOS_INCLUDE_DIRS} PARENT_SCOPE) + +endif() diff --git a/projects/mtg/include/WDataSrc.h b/projects/mtg/include/WDataSrc.h index 7279f78c7..2b8aceba0 100644 --- a/projects/mtg/include/WDataSrc.h +++ b/projects/mtg/include/WDataSrc.h @@ -315,7 +315,7 @@ public: int loadMatches(WSrcCards* src, bool all = false) { - return loadMatches(src, all); + return active->loadMatches(src, all); } int addRandomCards(MTGDeck * i, int howmany = 1) diff --git a/thirdparty/tinyxml/CMakeLists.txt b/thirdparty/tinyxml/CMakeLists.txt index d32912a5e..fdcaadacf 100644 --- a/thirdparty/tinyxml/CMakeLists.txt +++ b/thirdparty/tinyxml/CMakeLists.txt @@ -3,7 +3,9 @@ set(SOURCES tinyxmlerror.cpp tinyxmlparser.cpp tinyxml.cpp) - + +set(TINYXML_SRC ${SOURCES} PARENT_SCOPE) + add_definitions(-DTIXML_USE_STL) -add_library(tinyxml ${SOURCES}) \ No newline at end of file +add_library(tinyxml ${SOURCES}) diff --git a/thirdparty/unzip/CMakeLists.txt b/thirdparty/unzip/CMakeLists.txt index b6d3a7e23..067c987b0 100644 --- a/thirdparty/unzip/CMakeLists.txt +++ b/thirdparty/unzip/CMakeLists.txt @@ -2,9 +2,10 @@ SET(SOURCE ioapi.c - miniunz.c + zip.c unzip.c) +SET(UNZIP_SRC ${SOURCE} PARENT_SCOPE) include_directories(${ZLIB_INCLUDE_DIRS} ${EXTRA_INCLUDES}) add_library(unzip ${SOURCE}) diff --git a/thirdparty/zipFS/CMakeLists.txt b/thirdparty/zipFS/CMakeLists.txt index b38ea1ca5..73f9f9ff8 100644 --- a/thirdparty/zipFS/CMakeLists.txt +++ b/thirdparty/zipFS/CMakeLists.txt @@ -5,8 +5,10 @@ set(SOURCES zstream.cpp ziphdr.cpp) +set(ZIPFS_SRC ${SOURCES} PARENT_SCOPE) + #FindOrBuildZLIB() include_directories(${CMAKE_SOURCE_DIR}/JGE/include ${EXTRA_INCLUDES} ${ZLIB_INCLUDE_DIRS}) add_library(zipFS ${SOURCES}) -#target_link_libraries(zipFS ${ZLIB_LIBRARIES}) \ No newline at end of file +#target_link_libraries(zipFS ${ZLIB_LIBRARIES}) diff --git a/tools/travis-script.sh b/tools/travis-script.sh index 19f421dea..7bbdfedb9 100755 --- a/tools/travis-script.sh +++ b/tools/travis-script.sh @@ -83,7 +83,7 @@ fi # Let's launch de iOS cross-compilation if [ "$BUILD_TYPE" = "iOS" ]; then - cd projects/mtg/iOS - make -j 4 package - cd ../../.. + cmake -DCMAKE_TOOLCHAIN_FILE=CMakeModules/ios-theos.toolchain.cmake -DTHEOS_PATH=theos . + cp projects/mtg/iOS/control . + make -j4 -f makefile.ios package fi