From a3f8ab5da18ff0d48fb26a6bdcead50384ef1931 Mon Sep 17 00:00:00 2001 From: loki Date: Fri, 3 Jan 2020 20:25:21 +0100 Subject: [PATCH] Get it to compile for windows in debug mode --- CMakeLists.txt | 11 +++++---- sunshine/nvhttp.cpp | 5 ++-- sunshine/platform/windows.cpp | 43 +++++++++++++++++++++++++++++++++++ toolchain-mingw64.cmake | 19 ++++++++++++++++ 4 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 sunshine/platform/windows.cpp create mode 100644 toolchain-mingw64.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e8f27e50..bca991e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) find_package(Threads REQUIRED) find_package(OpenSSL REQUIRED) -find_package(FFMpeg REQUIRED) +find_package(FFmpeg REQUIRED) find_package(Boost COMPONENTS filesystem REQUIRED) add_subdirectory(Simple-Web-Server) @@ -35,7 +35,8 @@ else() ${X11_LIBRARIES} evdev pulse - pulse-simple) + pulse-simple + ) set(PLATFORM_INCLUDE_DIRS ${X11_INCLUDE_DIR} @@ -89,8 +90,10 @@ include_directories( list(APPEND SUNSHINE_COMPILE_OPTIONS -fPIC -Wall -Wno-missing-braces -Wno-maybe-uninitialized -Wno-sign-compare) string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE) if("x${BUILD_TYPE}" STREQUAL "xDEBUG") - #list(APPEND SUNSHINE_COMPILE_OPTIONS -O0 -pedantic -ggdb3) - list(APPEND SUNSHINE_COMPILE_OPTIONS -O0) + list(APPEND SUNSHINE_COMPILE_OPTIONS -O0 -pedantic -ggdb3) + if(WIN32) + set_source_files_properties(sunshine/nvhttp.cpp PROPERTIES COMPILE_FLAGS -O2) + endif() else() add_definitions(-DNDEBUG) list(APPEND SUNSHINE_COMPILE_OPTIONS -O3) diff --git a/sunshine/nvhttp.cpp b/sunshine/nvhttp.cpp index 9017ce02..8bd7d333 100644 --- a/sunshine/nvhttp.cpp +++ b/sunshine/nvhttp.cpp @@ -76,6 +76,8 @@ struct pair_session_t { // uniqueID, session std::unordered_map map_id_sess; std::unordered_map map_id_client; +std::string local_ip; +net::net_e origin_pin_allowed; using args_t = SimpleWeb::CaseInsensitiveMultimap; using resp_https_t = std::shared_ptr::Response>; @@ -88,9 +90,6 @@ enum class op_e { REMOVE }; -std::string local_ip; -net::net_e origin_pin_allowed; - void save_devices() { pt::ptree root; diff --git a/sunshine/platform/windows.cpp b/sunshine/platform/windows.cpp new file mode 100644 index 00000000..609bf7a5 --- /dev/null +++ b/sunshine/platform/windows.cpp @@ -0,0 +1,43 @@ +#include "common.h" + +namespace platf { +using namespace std::literals; +std::string get_local_ip() { return "192.168.0.119"s; } + +std::unique_ptr microphone() { return nullptr; } +std::unique_ptr display() { return nullptr; } + +input_t input() { + return nullptr; +} + +void move_mouse(input_t &input, int deltaX, int deltaY) {} +void button_mouse(input_t &input, int button, bool release) {} +void scroll(input_t &input, int distance) {} +void keyboard(input_t &input, uint16_t modcode, bool release) {} + +namespace gp { +void dpad_y(input_t &input, int button_state) {} // up pressed == -1, down pressed == 1, else 0 +void dpad_x(input_t &input, int button_state) {} // left pressed == -1, right pressed == 1, else 0 +void start(input_t &input, int button_down) {} +void back(input_t &input, int button_down) {} +void left_stick(input_t &input, int button_down) {} +void right_stick(input_t &input, int button_down) {} +void left_button(input_t &input, int button_down) {} +void right_button(input_t &input, int button_down) {} +void home(input_t &input, int button_down) {} +void a(input_t &input, int button_down) {} +void b(input_t &input, int button_down) {} +void x(input_t &input, int button_down) {} +void y(input_t &input, int button_down) {} +void left_trigger(input_t &input, std::uint8_t abs_z) {} +void right_trigger(input_t &input, std::uint8_t abs_z) {} +void left_stick_x(input_t &input, std::int16_t x) {} +void left_stick_y(input_t &input, std::int16_t y) {} +void right_stick_x(input_t &input, std::int16_t x) {} +void right_stick_y(input_t &input, std::int16_t y) {} +void sync(input_t &input) {} +} + +void freeInput(void*) {} +} diff --git a/toolchain-mingw64.cmake b/toolchain-mingw64.cmake new file mode 100644 index 00000000..a090f58f --- /dev/null +++ b/toolchain-mingw64.cmake @@ -0,0 +1,19 @@ +# the name of the target operating system +SET(CMAKE_SYSTEM_NAME Windows) + +# which compilers to use for C and C++ +SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) +SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) +SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + +# here is the target environment located +SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) +#SET(CMAKE_SYSROOT ${CMAKE_FIND_ROOT_PATH}) +#SET(CMAKE_EXE_LINKER_FLAGS "-static ${CMAKE_EXE_LINKER_FLAGS}") + +# adjust the default behaviour of the FIND_XXX() commands: +# search headers and libraries in the target environment, search +# programs in the host environment +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)