From b3a5a82b5cb28dca637528b488527168592d0d65 Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Sun, 27 Sep 2015 15:30:21 -0400 Subject: [PATCH] Bring us closer to working with MinGW again. The biggest obstacle right now deals with FFMPEG. I insist on being able to utilize the git clone/submodule (5_1_0) section. I'm just struggling with the commands. As part of this commit, some linux files are restored in the compilation chain. This is for consistency with the old Makefile approach. Assistance will be needed at this point to complete MinGW support. --- CMake/SetupFfmpeg.cmake | 60 ++++++++++ StepmaniaCore.cmake | 111 ++++++------------ src/CMakeData-arch.cmake | 20 ++++ .../InputHandler/InputHandler_Win32_Pump.cpp | 4 +- src/archutils/Win32/arch_setup.h | 2 + src/config.in.hpp | 18 +++ 6 files changed, 139 insertions(+), 76 deletions(-) create mode 100644 CMake/SetupFfmpeg.cmake diff --git a/CMake/SetupFfmpeg.cmake b/CMake/SetupFfmpeg.cmake new file mode 100644 index 0000000000..26fb0b3e68 --- /dev/null +++ b/CMake/SetupFfmpeg.cmake @@ -0,0 +1,60 @@ +set(SM_FFMPEG_VERSION "2.1.3") +set(SM_FFMPEG_SRC_LIST "${SM_EXTERN_DIR}" "/ffmpeg-linux-" "${SM_FFMPEG_VERSION}") +sm_join("${SM_FFMPEG_SRC_LIST}" "" SM_FFMPEG_SRC_DIR) +set(SM_FFMPEG_ROOT "${CMAKE_BINARY_DIR}/ffmpeg-prefix/src/ffmpeg-build") +set(SM_FFMPEG_CONFIGURE_EXE "${SM_FFMPEG_SRC_DIR}/configure") +if (MINGW) + # Borrow from http://stackoverflow.com/q/11845823 + # string(SUBSTRING ${SM_FFMPEG_CONFIGURE_EXE} 0 1 FIRST_LETTER) + # string(TOLOWER ${FIRST_LETTER} FIRST_LETTER_LOW) + # string(REPLACE "${FIRST_LETTER}:" "/${FIRST_LETTER_LOW}" # SM_FFMPEG_CONFIGURE_EXE ${SM_FFMPEG_CONFIGURE_EXE}) + # string(REGEX REPLACE "\\\\" "/" SM_FFMPEG_CONFIGURE_EXE "${SM_FFMPEG_CONFIGURE_EXE}") + set(SM_FFMPEG_CONFIGURE_EXE "extern/ffmpeg-linux-${SM_FFMPEG_VERSION}/configure") +endif() +list(APPEND FFMPEG_CONFIGURE + "${SM_FFMPEG_CONFIGURE_EXE}" + "--disable-programs" + "--disable-doc" + "--disable-avdevice" + "--disable-swresample" + "--disable-postproc" + "--disable-avfilter" + "--disable-shared" + "--enable-static" +) +if(WITH_GPL_LIBS) + list(APPEND FFMPEG_CONFIGURE + "--enable-gpl" + ) +endif() + +if (WITH_CRYSTALHD_DISABLED) + list(APPEND FFMPEG_CONFIGURE "--disable-crystalhd") +endif() + +if (NOT WITH_EXTERNAL_WARNINGS) + list(APPEND FFMPEG_CONFIGURE + "--extra-cflags=-w" + ) +endif() + +if (IS_DIRECTORY "${SM_FFMPEG_SRC_DIR}") + externalproject_add("ffmpeg" + SOURCE_DIR "${SM_FFMPEG_SRC_DIR}" + CONFIGURE_COMMAND ${FFMPEG_CONFIGURE} + BUILD_COMMAND "make" + UPDATE_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) +else() + # --shlibdir=$our_installdir/stepmania-$VERSION + externalproject_add("ffmpeg" + DOWNLOAD_COMMAND git clone "--branch" "n${SM_FFMPEG_VERSION}" "--depth" "1" "git://source.ffmpeg.org/ffmpeg.git" "${SM_FFMPEG_SRC_DIR}" + CONFIGURE_COMMAND "${FFMPEG_CONFIGURE}" + BUILD_COMMAND "make" + UPDATE_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" + ) +endif() diff --git a/StepmaniaCore.cmake b/StepmaniaCore.cmake index e4b4562e9f..231ad3e1a7 100644 --- a/StepmaniaCore.cmake +++ b/StepmaniaCore.cmake @@ -115,6 +115,12 @@ check_symbol_exists(size_t stdlib.h HAVE_SIZE_T_STDLIB) check_symbol_exists(size_t stdio.h HAVE_SIZE_T_STDIO) check_symbol_exists(posix_fadvise fcntl.h HAVE_POSIX_FADVISE) +if (MINGW) + set(NEED_WINDOWS_LOADING_WINDOW TRUE) + check_symbol_exists(PBS_MARQUEE commctrl.h HAVE_PBS_MARQUEE) + check_symbol_exists(PBM_SETMARQUEE commctrl.h HAVE_PBM_SETMARQUEE) +endif() + # Checks to make it easier to work with 32-bit/64-bit builds if required. include(CheckTypeSize) check_type_size(int16_t SIZEOF_INT16_T) @@ -215,30 +221,42 @@ endif() find_package(nasm) find_package(yasm) +find_package(Threads) +if (${Threads_FOUND}) + set(HAS_PTHREAD TRUE) +else() + set(HAS_PTHREAD FALSE) +endif() + if(WIN32) set(SYSTEM_PCRE_FOUND FALSE) find_package(DirectX REQUIRED) - # FFMPEG...it can be evil. - find_library(LIB_SWSCALE NAMES "swscale" - PATHS "${SM_EXTERN_DIR}/ffmpeg/lib" NO_DEFAULT_PATH - ) - get_filename_component(LIB_SWSCALE ${LIB_SWSCALE} NAME) + if (MINGW) + include("${SM_CMAKE_DIR}/SetupFfmpeg.cmake") + set(HAS_FFMPEG TRUE) + else() + # FFMPEG...it can be evil. + find_library(LIB_SWSCALE NAMES "swscale" + PATHS "${SM_EXTERN_DIR}/ffmpeg/lib" NO_DEFAULT_PATH + ) + get_filename_component(LIB_SWSCALE ${LIB_SWSCALE} NAME) - find_library(LIB_AVCODEC NAMES "avcodec" - PATHS "${SM_EXTERN_DIR}/ffmpeg/lib" NO_DEFAULT_PATH - ) - get_filename_component(LIB_AVCODEC ${LIB_AVCODEC} NAME) + find_library(LIB_AVCODEC NAMES "avcodec" + PATHS "${SM_EXTERN_DIR}/ffmpeg/lib" NO_DEFAULT_PATH + ) + get_filename_component(LIB_AVCODEC ${LIB_AVCODEC} NAME) - find_library(LIB_AVFORMAT NAMES "avformat" - PATHS "${SM_EXTERN_DIR}/ffmpeg/lib" NO_DEFAULT_PATH - ) - get_filename_component(LIB_AVFORMAT ${LIB_AVFORMAT} NAME) + find_library(LIB_AVFORMAT NAMES "avformat" + PATHS "${SM_EXTERN_DIR}/ffmpeg/lib" NO_DEFAULT_PATH + ) + get_filename_component(LIB_AVFORMAT ${LIB_AVFORMAT} NAME) - find_library(LIB_AVUTIL NAMES "avutil" - PATHS "${SM_EXTERN_DIR}/ffmpeg/lib" NO_DEFAULT_PATH - ) - get_filename_component(LIB_AVUTIL ${LIB_AVUTIL} NAME) + find_library(LIB_AVUTIL NAMES "avutil" + PATHS "${SM_EXTERN_DIR}/ffmpeg/lib" NO_DEFAULT_PATH + ) + get_filename_component(LIB_AVUTIL ${LIB_AVUTIL} NAME) + endif() elseif(MACOSX) set(SYSTEM_PCRE_FOUND FALSE) set(WITH_CRASH_HANDLER TRUE) @@ -363,13 +381,6 @@ elseif(LINUX) message(STATUS "-- At least one sound library was found. Do not worry if any were not found at this stage.") endif() - find_package(Threads) - if (${Threads_FOUND}) - set(HAS_PTHREAD TRUE) - else() - set(HAS_PTHREAD FALSE) - endif() - if (WITH_FFMPEG AND NOT YASM_FOUND AND NOT NASM_FOUND) message("Neither NASM nor YASM were found. Please install at least one of them if you wish for ffmpeg support.") set(WITH_FFMPEG OFF) @@ -388,57 +399,7 @@ elseif(LINUX) set(HAS_FFMPEG TRUE) endif() else() - set(SM_FFMPEG_VERSION "2.1.3") - set(SM_FFMPEG_SRC_LIST "${SM_EXTERN_DIR}" "/ffmpeg-linux-" "${SM_FFMPEG_VERSION}") - sm_join("${SM_FFMPEG_SRC_LIST}" "" SM_FFMPEG_SRC_DIR) - set(SM_FFMPEG_ROOT "${CMAKE_BINARY_DIR}/ffmpeg-prefix/src/ffmpeg-build") - list(APPEND FFMPEG_CONFIGURE - "${SM_FFMPEG_SRC_DIR}/configure" - "--disable-programs" - "--disable-doc" - "--disable-avdevice" - "--disable-swresample" - "--disable-postproc" - "--disable-avfilter" - "--disable-shared" - "--enable-static" - ) - if(WITH_GPL_LIBS) - list(APPEND FFMPEG_CONFIGURE - "--enable-gpl" - ) - endif() - - if (WITH_CRYSTALHD_DISABLED) - list(APPEND FFMPEG_CONFIGURE "--disable-crystalhd") - endif() - - if (NOT WITH_EXTERNAL_WARNINGS) - list(APPEND FFMPEG_CONFIGURE - "--extra-cflags=-w" - ) - endif() - - if (IS_DIRECTORY "${SM_FFMPEG_SRC_DIR}") - externalproject_add("ffmpeg" - SOURCE_DIR "${SM_FFMPEG_SRC_DIR}" - CONFIGURE_COMMAND ${FFMPEG_CONFIGURE} - BUILD_COMMAND "make" - UPDATE_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) - else() - # --shlibdir=$our_installdir/stepmania-$VERSION - externalproject_add("ffmpeg" - DOWNLOAD_COMMAND git clone "--branch" "n${SM_FFMPEG_VERSION}" "--depth" "1" "git://source.ffmpeg.org/ffmpeg.git" "${SM_FFMPEG_SRC_DIR}" - CONFIGURE_COMMAND "${FFMPEG_CONFIGURE}" - BUILD_COMMAND "make" - UPDATE_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) - endif() + include("${SM_CMAKE_DIR}/SetupFfmpeg.cmake") set(HAS_FFMPEG TRUE) endif() else() diff --git a/src/CMakeData-arch.cmake b/src/CMakeData-arch.cmake index 67593a3eee..5ff70e99c8 100644 --- a/src/CMakeData-arch.cmake +++ b/src/CMakeData-arch.cmake @@ -274,6 +274,16 @@ if(NOT APPLE) list(APPEND SMDATA_ARCH_LIGHTS_HPP "arch/Lights/LightsDriver_Export.h" ) + + if(NOT MSVC) + list(APPEND SMDATA_ARCH_LIGHTS_SRC + "arch/Lights/LightsDriver_SextetStream.cpp" + ) + list(APPEND SMDATA_ARCH_LIGHTS_SRC + "arch/Lights/LightsDriver_SextetStream.h" + ) + endif() + if(WIN32) list(APPEND SMDATA_ARCH_LIGHTS_SRC "arch/Lights/LightsDriver_Win32Parallel.cpp" @@ -341,6 +351,14 @@ if(WIN32) "arch/InputHandler/InputHandler_Win32_Para.h" "arch/InputHandler/InputHandler_Win32_Pump.h" ) + if (NOT MSVC) + list(APPEND SMDATA_ARCH_INPUT_SRC + "arch/InputHandler/InputHandler_SextetStream.cpp" + ) + list(APPEND SMDATA_ARCH_INPUT_HPP + "arch/InputHandler/InputHandler_SextetStream.h" + ) + endif() elseif(APPLE) list(APPEND SMDATA_ARCH_INPUT_SRC "arch/InputHandler/InputHandler_MacOSX_HID.cpp" @@ -355,12 +373,14 @@ else() # Unix/Linux "arch/InputHandler/InputHandler_Linux_Joystick.cpp" "arch/InputHandler/InputHandler_Linux_Event.cpp" "arch/InputHandler/InputHandler_Linux_PIUIO.cpp" + "arch/InputHandler/InputHandler_SextetStream.cpp" ) list(APPEND SMDATA_ARCH_INPUT_SRC "arch/InputHandler/LinuxInputManager.h" "arch/InputHandler/InputHandler_Linux_Joystick.h" "arch/InputHandler/InputHandler_Linux_Event.h" "arch/InputHandler/InputHandler_Linux_PIUIO.h" + "arch/InputHandler/InputHandler_SextetStream.h" ) if(WITH_TTY) list(APPEND SMDATA_ARCH_INPUT_SRC diff --git a/src/arch/InputHandler/InputHandler_Win32_Pump.cpp b/src/arch/InputHandler/InputHandler_Win32_Pump.cpp index 57fa2379ea..b8fed6a93c 100644 --- a/src/arch/InputHandler/InputHandler_Win32_Pump.cpp +++ b/src/arch/InputHandler/InputHandler_Win32_Pump.cpp @@ -22,7 +22,9 @@ InputHandler_Win32_Pump::InputHandler_Win32_Pump() m_pDevice = new USBDevice[NUM_PUMPS]; int iNumFound = 0; - for( int p = 0; p < ARRAYSIZE(pump_usb_pids); ++p ) + // TODO: Use C++1x semantics to loop through the pids. + // Hardcoding for now to keep this moving. + for( int p = 0; p < 2; ++p ) { const int pump_usb_pid = pump_usb_pids[p]; for( int i = 0; i < NUM_PUMPS; ++i ) diff --git a/src/archutils/Win32/arch_setup.h b/src/archutils/Win32/arch_setup.h index 3724a58e31..ec5c3932f1 100644 --- a/src/archutils/Win32/arch_setup.h +++ b/src/archutils/Win32/arch_setup.h @@ -89,8 +89,10 @@ struct tm *my_localtime_r( const time_t *timep, struct tm *result ); #define localtime_r my_localtime_r struct tm *my_gmtime_r( const time_t *timep, struct tm *result ); #define gmtime_r my_gmtime_r +#if defined(_MSC_VER) void my_usleep( unsigned long usec ); #define usleep my_usleep +#endif // Missing stdint types: #if !defined(__MINGW32__) // MinGW headers define these for us diff --git a/src/config.in.hpp b/src/config.in.hpp index 4f81b40790..9fcc5b4954 100644 --- a/src/config.in.hpp +++ b/src/config.in.hpp @@ -126,6 +126,24 @@ typedef long ssize_t; /* Defined to 1 if compiling with OGG support. */ #cmakedefine HAS_OGG 1 +/* Defined to 1 if building on a windows system, and thus uses the windows loading window. */ +#cmakedefine NEED_WINDOWS_LOADING_WINDOW 1 + +/* Defined to 1 if the PBS_MARQUEE symbol was found. */ +#cmakedefine HAVE_PBS_MARQUEE 1 + +/* Defined to 1 if the PBM_SETMARQUEE symbol was found. */ +#cmakedefine HAVE_PBM_SETMARQUEE 1 + +#if defined(NEED_WINDOWS_LOADING_WINDOW) +#if !defined(HAVE_PBS_MARQUEE) +#define PBS_MARQUEE 0x08 +#endif +#if !defined(HAVE_PBM_SETMARQUEE) +#define PBM_SETMARQUEE (WM_USER+10) +#endif +#endif + #if defined(__GNUC__) /** @brief Define a macro to tell the compiler that a function has printf() * semantics, to aid warning output. */