From a6062dea2442c59bb0969f5e305860adfd5e4537 Mon Sep 17 00:00:00 2001 From: Eliza Velasquez <4576666+elizagamedev@users.noreply.github.com> Date: Thu, 27 Sep 2018 07:10:32 +0000 Subject: [PATCH] Initial Conan work --- CMakeLists.txt | 343 +++++++++++------------------------- binding-mri/binding-mri.cpp | 1 + binding-mri/binding-util.h | 1 + cmake/PrepUtils.cmake | 38 ---- conanfile.py | 63 +++++++ src/graphics.cpp | 2 + src/main.cpp | 5 + src/sharedstate.cpp | 2 + 8 files changed, 178 insertions(+), 277 deletions(-) delete mode 100644 cmake/PrepUtils.cmake create mode 100644 conanfile.py diff --git a/CMakeLists.txt b/CMakeLists.txt index d875826..e17b062 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,100 +1,44 @@ cmake_minimum_required(VERSION 2.8.11) -Project(mkxp) +Project(oneshot) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() ## Setup options ## -option(SHARED_FLUID "Dynamically link fluidsynth at build time" OFF) -option(WORKDIR_CURRENT "Keep current directory on startup" OFF) -option(FORCE32 "Force 32bit compile on 64bit OS" OFF) -set(BINDING "MRI" CACHE STRING "The Binding Type (MRI, MRUBY, NULL)") -set(EXTERNAL_LIB_PATH "" CACHE PATH "External precompiled lib prefix") +option(STEAM "Build for Steam" OFF) ## Misc setup ## -include(cmake/PrepUtils.cmake) - set(CMAKE_INCLUDE_CURRENT_DIR ON) -IF("${CMAKE_SYSTEM}" MATCHES "Linux") - SET(LINUX ON) -ENDIF() +# IF("${CMAKE_SYSTEM}" MATCHES "Linux") +# SET(LINUX ON) +# ENDIF() -IF(WORKDIR_CURRENT) - list(APPEND DEFINES - WORKDIR_CURRENT - ) -ENDIF() +# set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6) -IF(FORCE32) - if(APPLE) - SET(CMAKE_OSX_ARCHITECTURES "i386") - else() - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - endif() -ENDIF() +# IF(LINUX) +# if(CMAKE_SIZEOF_VOID_P MATCHES "8" AND NOT(FORCE32) ) +# set(CMAKE_EXECUTABLE_SUFFIX ".bin.x86_64") +# set(BIN_RPATH "\$ORIGIN/lib64") +# set(LIB_PATH "lib64") +# else() +# set(CMAKE_EXECUTABLE_SUFFIX ".bin.x86") +# set(BIN_RPATH "\$ORIGIN/lib") +# set(LIB_PATH "lib") +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64") +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64") +# endif() +# elseif(APPLE) +# SET(BIN_RPATH "@executable_path/../Frameworks") +# set(LIB_PATH "lib") +# endif() -set(CMAKE_OSX_DEPLOYMENT_TARGET 10.6) - -IF(LINUX) - if(CMAKE_SIZEOF_VOID_P MATCHES "8" AND NOT(FORCE32) ) - set(CMAKE_EXECUTABLE_SUFFIX ".bin.x86_64") - set(BIN_RPATH "\$ORIGIN/lib64") - set(LIB_PATH "lib64") - else() - set(CMAKE_EXECUTABLE_SUFFIX ".bin.x86") - set(BIN_RPATH "\$ORIGIN/lib") - set(LIB_PATH "lib") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64") - endif() -elseif(APPLE) - SET(BIN_RPATH "@executable_path/../Frameworks") - set(LIB_PATH "lib") -endif() - -set(CMAKE_SKIP_BUILD_RPATH TRUE) -set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -set(CMAKE_INSTALL_RPATH ${BIN_RPATH}) -set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) - -## Locate core libs ## - -find_package(PkgConfig REQUIRED) - -if (EXTERNAL_LIB_PATH) - set(CMAKE_PREFIX_PATH ${EXTERNAL_LIB_PATH}) - - if(EXISTS "${EXTERNAL_LIB_PATH}/${LIB_PATH}/pkgconfig/") - SET(ENV{PKG_CONFIG_PATH} "${EXTERNAL_LIB_PATH}/${LIB_PATH}/pkgconfig/") - endif() - if(APPLE) - set(PLATFORM_SHARED_LIBS - libSDL2.dylib libSDL2_image-2.0.0.dylib libSDL2_ttf-2.0.0.dylib libSDL_sound-1.0.1.dylib - libfreetype.6.dylib libsigc-2.0.0.dylib - CACHE STRING "List of shared libraries that need to be copied into the OS X bundle") - foreach(lib ${PLATFORM_SHARED_LIBS}) - if(EXISTS ${EXTERNAL_LIB_PATH}/lib/${lib}) - list(APPEND PLATFORM_COPY_LIBS - ${EXTERNAL_LIB_PATH}/lib/${lib} - ) - endif() - endforeach() - endif() -endif() - -pkg_check_modules(SIGCXX REQUIRED sigc++-2.0) -pkg_check_modules(PIXMAN REQUIRED pixman-1) -pkg_check_modules(PHYSFS REQUIRED physfs>=2.1) -pkg_check_modules(VORBISFILE REQUIRED vorbisfile) -pkg_check_modules(SDL2 REQUIRED sdl2) -pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf) -pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image) -pkg_check_modules(SDL_SOUND REQUIRED SDL_sound) - -find_package(Boost 1.49 COMPONENTS program_options REQUIRED) -find_package(OpenAL REQUIRED) -find_package(ZLIB REQUIRED) +# set(CMAKE_SKIP_BUILD_RPATH TRUE) +# set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) +# set(CMAKE_INSTALL_RPATH ${BIN_RPATH}) +# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) ## Setup main source ## @@ -151,12 +95,14 @@ set(MAIN_HEADERS src/alstream.h src/audiostream.h src/rgssad.h - src/windowvx.h - src/tilemapvx.h - src/tileatlasvx.h - src/sharedmidistate.h - src/fluid-fun.h src/sdl-util.h + src/oneshot.h + src/pipe.h + chromasdk/RzChromaSDKDefines.h + chromasdk/RzChromaSDKTypes.h + chromasdk/RzErrors.h + chromasdk/ChromaApi.h + src/i18n.h ) set(MAIN_SOURCE @@ -195,16 +141,32 @@ set(MAIN_SOURCE src/alstream.cpp src/audiostream.cpp src/rgssad.cpp - src/bundledfont.cpp src/vorbissource.cpp - src/windowvx.cpp - src/tilemapvx.cpp - src/tileatlasvx.cpp - src/autotilesvx.cpp - src/midisource.cpp - src/fluid-fun.cpp + src/oneshot.cpp + src/screen.cpp + src/i18n.cpp ) +if(WIN32) + list(APPEND MAIN_SOURCE assets/resources.rc) + list(APPEND DEFINES UNICODE) + list(APPEND PLATFORM_LIBRARIES Secur32) +endif() + +if (STEAM) + list(APPEND MAIN_HEADERS + src/steam.h + steamshim/steamshim_child.h + ) + list(APPEND MAIN_SOURCE + src/steam.cpp + steamshim/steamshim_child.c + ) + list(APPEND DEFINES + STEAM + ) +endif() + source_group("MKXP Source" FILES ${MAIN_SOURCE} ${MAIN_HEADERS}) ## Setup embedded source ## @@ -224,18 +186,18 @@ set(EMBEDDED_INPUT shader/simpleAlpha.frag shader/simpleAlphaUni.frag shader/flashMap.frag + shader/obscured.frag shader/minimal.vert shader/simple.vert shader/simpleColor.vert shader/sprite.vert shader/tilemap.vert - shader/tilemapvx.vert shader/blur.frag shader/blurH.vert shader/blurV.vert shader/simpleMatrix.vert - assets/liberation.ttf assets/icon.png + assets/gamecontrollerdb.txt ) if (RGSS2) @@ -244,10 +206,10 @@ if (RGSS2) ) endif() -if (SHARED_FLUID) - pkg_check_modules(FLUID REQUIRED fluidsynth) +if (MSVC) list(APPEND DEFINES - SHARED_FLUID + _CRT_SECURE_NO_WARNINGS + NOMINMAX ) endif() @@ -286,113 +248,48 @@ source_group("Embedded Source" FILES ${EMBEDDED_INPUT} ${EMBEDDED_SOURCE}) ## Setup binding source ## -if (BINDING STREQUAL "MRI") - set(MRIVERSION "2.1" CACHE STRING "Version of MRI to link with") - pkg_check_modules(MRI REQUIRED ruby-${MRIVERSION}) - list(APPEND DEFINES - BINDING_MRI - ) - set(BINDING_HEADERS - binding-mri/binding-util.h - binding-mri/binding-types.h - binding-mri/serializable-binding.h - binding-mri/disposable-binding.h - binding-mri/sceneelement-binding.h - binding-mri/viewportelement-binding.h - binding-mri/flashable-binding.h - ) - set(BINDING_SOURCE - binding-mri/binding-mri.cpp - binding-mri/binding-util.cpp - binding-mri/table-binding.cpp - binding-mri/etc-binding.cpp - binding-mri/bitmap-binding.cpp - binding-mri/font-binding.cpp - binding-mri/graphics-binding.cpp - binding-mri/input-binding.cpp - binding-mri/sprite-binding.cpp - binding-mri/viewport-binding.cpp - binding-mri/plane-binding.cpp - binding-mri/window-binding.cpp - binding-mri/tilemap-binding.cpp - binding-mri/audio-binding.cpp - binding-mri/module_rpg.cpp - binding-mri/filesystem-binding.cpp - binding-mri/windowvx-binding.cpp - binding-mri/tilemapvx-binding.cpp - ) -elseif(BINDING STREQUAL "MRUBY") - message(FATAL_ERROR "Mruby support in CMake needs to be finished") - list(APPEND DEFINES - BINDING_MRUBY - ) - set(BINDING_HEADERS - binding-mruby/binding-util.h - binding-mruby/disposable-binding.h - binding-mruby/flashable-binding.h - binding-mruby/binding-types.h - binding-mruby/sceneelement-binding.h - binding-mruby/viewportelement-binding.h - binding-mruby/serializable-binding.h - binding-mruby/mrb-ext/file.h - binding-mruby/mrb-ext/rwmem.h - binding-mruby/mrb-ext/marshal.h - ) - set(BINDING_SOURCE - binding-mruby/binding-mruby.cpp - binding-mruby/binding-util.cpp - binding-mruby/window-binding.cpp - binding-mruby/bitmap-binding.cpp - binding-mruby/sprite-binding.cpp - binding-mruby/font-binding.cpp - binding-mruby/viewport-binding.cpp - binding-mruby/plane-binding.cpp - binding-mruby/audio-binding.cpp - binding-mruby/tilemap-binding.cpp - binding-mruby/etc-binding.cpp - binding-mruby/graphics-binding.cpp - binding-mruby/input-binding.cpp - binding-mruby/table-binding.cpp - binding-mruby/module_rpg.c - binding-mruby/mrb-ext/file.cpp - binding-mruby/mrb-ext/marshal.cpp - binding-mruby/mrb-ext/rwmem.cpp - binding-mruby/mrb-ext/kernel.cpp - binding-mruby/mrb-ext/time.cpp - ) -elseif(BINDING STREQUAL "NULL") - set(BINDING_SOURCE - binding-null/binding-null.cpp - ) -else() - message(FATAL_ERROR "Must choose a valid binding type. MRI, MRUBY, or NULL") -endif() +list(APPEND DEFINES + BINDING_MRI +) +set(BINDING_HEADERS + binding-mri/binding-util.h + binding-mri/binding-types.h + binding-mri/serializable-binding.h + binding-mri/disposable-binding.h + binding-mri/sceneelement-binding.h + binding-mri/viewportelement-binding.h + binding-mri/flashable-binding.h +) +set(BINDING_SOURCE + binding-mri/binding-mri.cpp + binding-mri/binding-util.cpp + binding-mri/table-binding.cpp + binding-mri/etc-binding.cpp + binding-mri/bitmap-binding.cpp + binding-mri/font-binding.cpp + binding-mri/graphics-binding.cpp + binding-mri/input-binding.cpp + binding-mri/sprite-binding.cpp + binding-mri/viewport-binding.cpp + binding-mri/plane-binding.cpp + binding-mri/window-binding.cpp + binding-mri/tilemap-binding.cpp + binding-mri/audio-binding.cpp + binding-mri/module_rpg.cpp + binding-mri/filesystem-binding.cpp + binding-mri/oneshot-binding.cpp + binding-mri/steam-binding.cpp + binding-mri/wallpaper-binding.cpp + binding-mri/journal-binding.cpp + binding-mri/chroma-binding.cpp + binding-mri/niko-binding.cpp +) source_group("Binding Source" FILES ${BINDING_SOURCE} ${BINDING_HEADERS}) ## Setup main executable ## -if(APPLE) - find_library(CARBON_LIBRARY Carbon) - find_library(IOKIT_LIBRARY IOKit) - mark_as_advanced(CARBON_LIBRARY IOKIT_LIBRARY) - list(APPEND PLATFORM_LIBRARIES - ${CARBON_LIBRARY} - ${IOKIT_LIBRARY} - "-liconv" - ) -endif() - -link_directories( - ${SIGCXX_LIBRARY_DIRS} - ${PIXMAN_LIBRARY_DIRS} - ${PHYSFS_LIBRARY_DIRS} - ${SDL2_LIBRARY_DIRS} # Blindly assume other SDL bits are in same directory - ${Boost_LIBRARY_DIR} - ${MRI_LIBDIR} -) - -add_executable(${PROJECT_NAME} MACOSX_BUNDLE +add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32 ${MAIN_HEADERS} ${MAIN_SOURCE} ${BINDING_HEADERS} @@ -400,38 +297,6 @@ add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${EMBEDDED_SOURCE} ) -target_compile_definitions(${PROJECT_NAME} PRIVATE - ${DEFINES} -) -target_include_directories(${PROJECT_NAME} PRIVATE - src - ${SIGCXX_INCLUDE_DIRS} - ${PIXMAN_INCLUDE_DIRS} - ${PHYSFS_INCLUDE_DIRS} - ${SDL2_INCLUDE_DIRS} # Blindly assume other SDL bits are in same directory - ${Boost_INCLUDE_DIR} - ${MRI_INCLUDE_DIRS} - ${VORBISFILE_INCLUDE_DIRS} - ${FLUID_INCLUDE_DIRS} - ${OPENAL_INCLUDE_DIR} -) - -target_link_libraries(${PROJECT_NAME} - ${SIGCXX_LIBRARIES} - ${SDL2_LIBRARIES} - ${SDL2_IMAGE_LIBRARIES} - ${SDL2_TTF_LIBRARIES} - ${SDL_SOUND_LIBRARIES} - ${PHYSFS_LIBRARIES} - ${PIXMAN_LIBRARIES} - ${Boost_LIBRARIES} - ${MRI_LIBRARIES} - ${VORBISFILE_LIBRARIES} - ${FLUID_LIBRARIES} - ${OPENAL_LIBRARY} - ${ZLIB_LIBRARY} - - ${PLATFORM_LIBRARIES} -) - -PostBuildMacBundle(${PROJECT_NAME} "" "${PLATFORM_COPY_LIBS}") +target_compile_definitions(${PROJECT_NAME} PRIVATE ${DEFINES}) +target_include_directories(${PROJECT_NAME} PRIVATE src) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS} ${PLATFORM_LIBRARIES}) diff --git a/binding-mri/binding-mri.cpp b/binding-mri/binding-mri.cpp index d50e7e3..1dc8047 100644 --- a/binding-mri/binding-mri.cpp +++ b/binding-mri/binding-mri.cpp @@ -33,6 +33,7 @@ #include #include +#undef inline #include #include diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h index 83589f7..68aacd3 100644 --- a/binding-mri/binding-util.h +++ b/binding-mri/binding-util.h @@ -23,6 +23,7 @@ #define BINDING_UTIL_H #include +#undef inline #include "exception.h" diff --git a/cmake/PrepUtils.cmake b/cmake/PrepUtils.cmake deleted file mode 100644 index 35bd9f6..0000000 --- a/cmake/PrepUtils.cmake +++ /dev/null @@ -1,38 +0,0 @@ -if(APPLE) - function(PostBuildMacBundle target framework_list lib_list) - INCLUDE(BundleUtilities) - GET_TARGET_PROPERTY(_BIN_NAME ${target} LOCATION) - GET_DOTAPP_DIR(${_BIN_NAME} _BUNDLE_DIR) - - set(_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${target}_prep.cmake") - file(WRITE ${_SCRIPT_FILE} - "# Generated Script file\n" - "include(BundleUtilities)\n" - "get_bundle_and_executable(\"\${BUNDLE_APP}\" bundle executable valid)\n" - "if(valid)\n" - " set(framework_dest \"\${bundle}/Contents/Frameworks\")\n" - " foreach(framework_path ${framework_list})\n" - " get_filename_component(framework_name \${framework_path} NAME_WE)\n" - " file(MAKE_DIRECTORY \"\${framework_dest}/\${framework_name}.framework/Versions/A/\")\n" - " copy_resolved_framework_into_bundle(\${framework_path}/Versions/A/\${framework_name} \${framework_dest}/\${framework_name}.framework/Versions/A/\${framework_name})\n" - " endforeach()\n" - " foreach(lib ${lib_list})\n" - " get_filename_component(lib_file \${lib} NAME)\n" - " copy_resolved_item_into_bundle(\${lib} \${framework_dest}/\${lib_file})\n" - " endforeach()\n" - "else()\n" - " message(ERROR \"App Not found? \${BUNDLE_APP}\")\n" - "endif()\n" - "#fixup_bundle(\"\${BUNDLE_APP}\" \"\" \"\${DEP_LIB_DIR}\")\n" - ) - - ADD_CUSTOM_COMMAND(TARGET ${target} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -DBUNDLE_APP="${_BUNDLE_DIR}" -P "${_SCRIPT_FILE}" - ) - endfunction() -else() - function(PostBuildMacBundle target framework_list lib_list) - # noop - endfunction() -endif() \ No newline at end of file diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..f2fb976 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,63 @@ +from conans import ConanFile, CMake, tools +import os.path + + +class MkxpConan(ConanFile): + name = "mkxp" + version = "0.0.0" + license = "GPLv2" + url = "https://github.com/elizagamedev/mkxp-oneshot" + description = "OneShot game runtime" + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + exports_sources = "*" + requires = ( + "boost/1.68.0@conan/stable", + "openal/1.18.2@bincrafters/stable", + "physfs/3.0.1@eliza/stable", + "pixman/0.34.0@eliza/stable", + "ruby-mkxp/2.5.1@eliza/stable", + "sdl2/2.0.8@bincrafters/stable", + "sdl2_image/2.0.3@bincrafters/stable", + "sdl2_ttf/2.0.14@eliza/stable", + "sdl_sound-mkxp/1.0.1@eliza/stable", + "sigc++/2.10.0@eliza/stable", + ) + default_options = ( + "boost:without_test=True", + "cygwin_installer:packages=xxd", + ) + + def build_requirements(self): + if tools.os_info.is_windows: + self.build_requires("cygwin_installer/2.9.0@bincrafters/stable") + + def build_configure(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def build(self): + if tools.os_info.is_windows: + cygwin_bin = self.deps_env_info["cygwin_installer"].CYGWIN_BIN + with tools.environment_append({"PATH": [cygwin_bin], + "CONAN_BASH_PATH": os.path.join(cygwin_bin, "bash.exe")}): + self.build_configure() + else: + self.build_configure() + + def package(self): + self.copy("*", dst="bin", src="bin") + + def imports(self): + self.do_copy_deps(self.copy) + + def deploy(self): + self.copy("*") + self.do_copy_deps(self.copy_deps) + + def do_copy_deps(self, copy): + deps = set(self.deps_cpp_info.deps) + deps.discard("cygwin_installer") + for dep in deps: + copy("*.dll", dst="bin", src="bin", root_package=dep, keep_path=False) diff --git a/src/graphics.cpp b/src/graphics.cpp index 7ca53c6..d59a784 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -44,7 +44,9 @@ #include #include +#ifndef _MSC_VER #include +#endif #include #include diff --git a/src/main.cpp b/src/main.cpp index f5c86d0..416ce7e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,7 +26,12 @@ #include #include +#ifdef _MSC_VER +#include +#define _chdir chdir +#else #include +#endif #include #include #include diff --git a/src/sharedstate.cpp b/src/sharedstate.cpp index dbfbe30..331516b 100644 --- a/src/sharedstate.cpp +++ b/src/sharedstate.cpp @@ -41,7 +41,9 @@ #include "binding.h" #include "exception.h" +#ifndef _MSC_VER #include +#endif #include #include