mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Merge pull request #4262 from EverOddish/master
Added CMake option to enable/disable scripting support
This commit is contained in:
		
						commit
						1f9f220a3e
					
				
					 5 changed files with 120 additions and 94 deletions
				
			
		|  | @ -22,6 +22,8 @@ option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) | ||||||
| 
 | 
 | ||||||
| option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) | option(USE_DISCORD_PRESENCE "Enables Discord Rich Presence" OFF) | ||||||
| 
 | 
 | ||||||
|  | option(ENABLE_SCRIPTING "Enables scripting support" ON) | ||||||
|  | 
 | ||||||
| if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit) | if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit) | ||||||
|     message(STATUS "Copying pre-commit hook") |     message(STATUS "Copying pre-commit hook") | ||||||
|     file(COPY hooks/pre-commit |     file(COPY hooks/pre-commit | ||||||
|  | @ -260,6 +262,10 @@ if (CITRA_ENABLE_COMPATIBILITY_REPORTING) | ||||||
|     add_definitions(-DCITRA_ENABLE_COMPATIBILITY_REPORTING) |     add_definitions(-DCITRA_ENABLE_COMPATIBILITY_REPORTING) | ||||||
| endif() | endif() | ||||||
| 
 | 
 | ||||||
|  | if (ENABLE_SCRIPTING) | ||||||
|  |     add_definitions(-DENABLE_SCRIPTING) | ||||||
|  | endif() | ||||||
|  | 
 | ||||||
| # Platform-specific library requirements | # Platform-specific library requirements | ||||||
| # ====================================== | # ====================================== | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										62
									
								
								externals/CMakeLists.txt
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										62
									
								
								externals/CMakeLists.txt
									
										
									
									
										vendored
									
									
								
							|  | @ -94,15 +94,16 @@ if (ENABLE_WEB_SERVICE) | ||||||
|     target_include_directories(json-headers INTERFACE ./json) |     target_include_directories(json-headers INTERFACE ./json) | ||||||
| endif() | endif() | ||||||
| 
 | 
 | ||||||
| # ZeroMQ | if (ENABLE_SCRIPTING) | ||||||
| # libzmq includes its own clang-format target, which conflicts with the |     # ZeroMQ | ||||||
| # clang-format in Citra if libzmq is added as a subdirectory. An external |     # libzmq includes its own clang-format target, which conflicts with the | ||||||
| # project gets around this issue. Unfortunately, a lot of different |     # clang-format in Citra if libzmq is added as a subdirectory. An external | ||||||
| # configuration options are required for each different platform. An |     # project gets around this issue. Unfortunately, a lot of different | ||||||
| # attempt was made to use CMake variables where possible, but some |     # configuration options are required for each different platform. An | ||||||
| # information necessarily had to be repeated. Hopefully there is not |     # attempt was made to use CMake variables where possible, but some | ||||||
| # often a need to change anything. |     # information necessarily had to be repeated. Hopefully there is not | ||||||
| if (MINGW) |     # often a need to change anything. | ||||||
|  |     if (MINGW) | ||||||
|         if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") |         if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows") | ||||||
|             set(LIBZMQ_MAKE mingw32-make) |             set(LIBZMQ_MAKE mingw32-make) | ||||||
|             set(LIBZMQ_COMPILER "") |             set(LIBZMQ_COMPILER "") | ||||||
|  | @ -119,7 +120,7 @@ if (MINGW) | ||||||
|             GIT_REPOSITORY https://github.com/zeromq/libzmq |             GIT_REPOSITORY https://github.com/zeromq/libzmq | ||||||
|             GIT_TAG v4.2.5 |             GIT_TAG v4.2.5 | ||||||
|             INSTALL_COMMAND "") |             INSTALL_COMMAND "") | ||||||
| else() |     else() | ||||||
|         if (MSVC) |         if (MSVC) | ||||||
|             set(LIBZMQ_COMPILER_FLAGS -DCMAKE_C_FLAGS=/GL-;-DCMAKE_CXX_FLAGS=/GL-) |             set(LIBZMQ_COMPILER_FLAGS -DCMAKE_C_FLAGS=/GL-;-DCMAKE_CXX_FLAGS=/GL-) | ||||||
|         else() |         else() | ||||||
|  | @ -132,11 +133,11 @@ else() | ||||||
|             GIT_REPOSITORY https://github.com/zeromq/libzmq |             GIT_REPOSITORY https://github.com/zeromq/libzmq | ||||||
|             GIT_TAG v4.2.5 |             GIT_TAG v4.2.5 | ||||||
|             INSTALL_COMMAND "") |             INSTALL_COMMAND "") | ||||||
| endif() |     endif() | ||||||
| set(LIBZMQ_DIR ${CMAKE_CURRENT_BINARY_DIR}/libzmq-external-prefix/src/libzmq-external-build/lib) |     set(LIBZMQ_DIR ${CMAKE_CURRENT_BINARY_DIR}/libzmq-external-prefix/src/libzmq-external-build/lib) | ||||||
| # On macOS, we need to build a fat static library containing both x86_64 and x86_64h, since macOS |     # On macOS, we need to build a fat static library containing both x86_64 and x86_64h, since macOS | ||||||
| # targets specify two architectures in their link command line ("-arch x86_64 -arch x86_64h"). |     # targets specify two architectures in their link command line ("-arch x86_64 -arch x86_64h"). | ||||||
| if (APPLE) |     if (APPLE) | ||||||
|         ExternalProject_Add(libzmq-external-h |         ExternalProject_Add(libzmq-external-h | ||||||
|             SOURCE_DIR ./libzmq-h |             SOURCE_DIR ./libzmq-h | ||||||
|             CMAKE_ARGS -DCMAKE_MACOSX_RPATH=1;-DCMAKE_OSX_ARCHITECTURES=x86_64h;-DWITH_PERF_TOOL=OFF;-DZMQ_BUILD_TESTS=OFF;-DENABLE_CPACK=OFF;-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} |             CMAKE_ARGS -DCMAKE_MACOSX_RPATH=1;-DCMAKE_OSX_ARCHITECTURES=x86_64h;-DWITH_PERF_TOOL=OFF;-DZMQ_BUILD_TESTS=OFF;-DENABLE_CPACK=OFF;-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||||||
|  | @ -150,15 +151,15 @@ if (APPLE) | ||||||
|         add_library(libzmq-external-imported-h STATIC IMPORTED GLOBAL) |         add_library(libzmq-external-imported-h STATIC IMPORTED GLOBAL) | ||||||
|         add_dependencies(libzmq-external-imported libzmq-external) |         add_dependencies(libzmq-external-imported libzmq-external) | ||||||
|         add_dependencies(libzmq-external-imported-h libzmq-external-h) |         add_dependencies(libzmq-external-imported-h libzmq-external-h) | ||||||
| else() |     else() | ||||||
|         add_library(libzmq STATIC IMPORTED GLOBAL) |         add_library(libzmq STATIC IMPORTED GLOBAL) | ||||||
|         add_dependencies(libzmq libzmq-external) |         add_dependencies(libzmq libzmq-external) | ||||||
| endif() |     endif() | ||||||
| # Set up the imported target properties |     # Set up the imported target properties | ||||||
| if (MSVC) |     if (MSVC) | ||||||
|         set_target_properties(libzmq PROPERTIES IMPORTED_LOCATION ${LIBZMQ_DIR}/${CMAKE_BUILD_TYPE}/libzmq-v141-mt-s-4_2_5${CMAKE_STATIC_LIBRARY_SUFFIX}) |         set_target_properties(libzmq PROPERTIES IMPORTED_LOCATION ${LIBZMQ_DIR}/${CMAKE_BUILD_TYPE}/libzmq-v141-mt-s-4_2_5${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||||||
|         set_target_properties(libzmq PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES iphlpapi${CMAKE_STATIC_LIBRARY_SUFFIX}) |         set_target_properties(libzmq PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES iphlpapi${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||||||
| else() |     else() | ||||||
|         if (APPLE) |         if (APPLE) | ||||||
|             set_target_properties(libzmq-external-imported PROPERTIES IMPORTED_LOCATION ${LIBZMQ_DIR}/libzmq${CMAKE_STATIC_LIBRARY_SUFFIX}) |             set_target_properties(libzmq-external-imported PROPERTIES IMPORTED_LOCATION ${LIBZMQ_DIR}/libzmq${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||||||
|             set_target_properties(libzmq-external-imported-h PROPERTIES IMPORTED_LOCATION ${LIBZMQ_H_DIR}/libzmq${CMAKE_STATIC_LIBRARY_SUFFIX}) |             set_target_properties(libzmq-external-imported-h PROPERTIES IMPORTED_LOCATION ${LIBZMQ_H_DIR}/libzmq${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||||||
|  | @ -168,9 +169,9 @@ else() | ||||||
|                 set_target_properties(libzmq PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "ws2_32${CMAKE_STATIC_LIBRARY_SUFFIX};iphlpapi${CMAKE_STATIC_LIBRARY_SUFFIX}") |                 set_target_properties(libzmq PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "ws2_32${CMAKE_STATIC_LIBRARY_SUFFIX};iphlpapi${CMAKE_STATIC_LIBRARY_SUFFIX}") | ||||||
|             endif() |             endif() | ||||||
|         endif() |         endif() | ||||||
| endif() |     endif() | ||||||
| # On macOS, create the combined target |     # On macOS, create the combined target | ||||||
| if (APPLE) |     if (APPLE) | ||||||
|         set(LIBZMQ_COMBINED_OUTPUT ${LIBZMQ_DIR}/libzmq_combined${CMAKE_STATIC_LIBRARY_SUFFIX}) |         set(LIBZMQ_COMBINED_OUTPUT ${LIBZMQ_DIR}/libzmq_combined${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||||||
|         add_custom_target(libzmq-combined COMMAND lipo -create ${LIBZMQ_DIR}/libzmq${CMAKE_STATIC_LIBRARY_SUFFIX} ${LIBZMQ_H_DIR}/libzmq${CMAKE_STATIC_LIBRARY_SUFFIX} -o ${LIBZMQ_COMBINED_OUTPUT} |         add_custom_target(libzmq-combined COMMAND lipo -create ${LIBZMQ_DIR}/libzmq${CMAKE_STATIC_LIBRARY_SUFFIX} ${LIBZMQ_H_DIR}/libzmq${CMAKE_STATIC_LIBRARY_SUFFIX} -o ${LIBZMQ_COMBINED_OUTPUT} | ||||||
|                                           BYPRODUCTS ${LIBZMQ_COMBINED_OUTPUT}) |                                           BYPRODUCTS ${LIBZMQ_COMBINED_OUTPUT}) | ||||||
|  | @ -178,11 +179,12 @@ if (APPLE) | ||||||
|         add_library(libzmq STATIC IMPORTED GLOBAL) |         add_library(libzmq STATIC IMPORTED GLOBAL) | ||||||
|         set_target_properties(libzmq PROPERTIES IMPORTED_LOCATION ${LIBZMQ_COMBINED_OUTPUT}) |         set_target_properties(libzmq PROPERTIES IMPORTED_LOCATION ${LIBZMQ_COMBINED_OUTPUT}) | ||||||
|         add_dependencies(libzmq libzmq-combined) |         add_dependencies(libzmq libzmq-combined) | ||||||
|  |     endif() | ||||||
|  |     # C interface to ZeroMQ | ||||||
|  |     add_library(libzmq-headers INTERFACE) | ||||||
|  |     target_include_directories(libzmq-headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libzmq/include) | ||||||
|  |     # C++ interface to ZeroMQ | ||||||
|  |     add_library(cppzmq-headers INTERFACE) | ||||||
|  |     target_include_directories(cppzmq-headers INTERFACE ./cppzmq) | ||||||
|  |     add_dependencies(cppzmq-headers libzmq) | ||||||
| endif() | endif() | ||||||
| # C interface to ZeroMQ |  | ||||||
| add_library(libzmq-headers INTERFACE) |  | ||||||
| target_include_directories(libzmq-headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/libzmq/include) |  | ||||||
| # C++ interface to ZeroMQ |  | ||||||
| add_library(cppzmq-headers INTERFACE) |  | ||||||
| target_include_directories(cppzmq-headers INTERFACE ./cppzmq) |  | ||||||
| add_dependencies(cppzmq-headers libzmq) |  | ||||||
|  |  | ||||||
|  | @ -410,14 +410,6 @@ add_library(core STATIC | ||||||
|     movie.h |     movie.h | ||||||
|     perf_stats.cpp |     perf_stats.cpp | ||||||
|     perf_stats.h |     perf_stats.h | ||||||
|     rpc/packet.cpp |  | ||||||
|     rpc/packet.h |  | ||||||
|     rpc/rpc_server.cpp |  | ||||||
|     rpc/rpc_server.h |  | ||||||
|     rpc/server.cpp |  | ||||||
|     rpc/server.h |  | ||||||
|     rpc/zmq_server.cpp |  | ||||||
|     rpc/zmq_server.h |  | ||||||
|     settings.cpp |     settings.cpp | ||||||
|     settings.h |     settings.h | ||||||
|     telemetry_session.cpp |     telemetry_session.cpp | ||||||
|  | @ -426,6 +418,18 @@ add_library(core STATIC | ||||||
|     tracer/recorder.cpp |     tracer/recorder.cpp | ||||||
|     tracer/recorder.h |     tracer/recorder.h | ||||||
| ) | ) | ||||||
|  | if (ENABLE_SCRIPTING) | ||||||
|  |     target_sources(core PRIVATE | ||||||
|  |         rpc/packet.cpp | ||||||
|  |         rpc/packet.h | ||||||
|  |         rpc/rpc_server.cpp | ||||||
|  |         rpc/rpc_server.h | ||||||
|  |         rpc/server.cpp | ||||||
|  |         rpc/server.h | ||||||
|  |         rpc/zmq_server.cpp | ||||||
|  |         rpc/zmq_server.h | ||||||
|  |     ) | ||||||
|  | endif() | ||||||
| 
 | 
 | ||||||
| create_target_directory_groups(core) | create_target_directory_groups(core) | ||||||
| 
 | 
 | ||||||
|  | @ -445,4 +449,6 @@ if (ARCHITECTURE_x86_64) | ||||||
|     target_link_libraries(core PRIVATE dynarmic) |     target_link_libraries(core PRIVATE dynarmic) | ||||||
| endif() | endif() | ||||||
| 
 | 
 | ||||||
| target_link_libraries(core PUBLIC libzmq-headers cppzmq-headers libzmq) | if (ENABLE_SCRIPTING) | ||||||
|  |     target_link_libraries(core PUBLIC libzmq-headers cppzmq-headers libzmq) | ||||||
|  | endif() | ||||||
|  |  | ||||||
|  | @ -25,7 +25,9 @@ | ||||||
| #include "core/loader/loader.h" | #include "core/loader/loader.h" | ||||||
| #include "core/memory_setup.h" | #include "core/memory_setup.h" | ||||||
| #include "core/movie.h" | #include "core/movie.h" | ||||||
|  | #ifdef ENABLE_SCRIPTING | ||||||
| #include "core/rpc/rpc_server.h" | #include "core/rpc/rpc_server.h" | ||||||
|  | #endif | ||||||
| #include "core/settings.h" | #include "core/settings.h" | ||||||
| #include "network/network.h" | #include "network/network.h" | ||||||
| #include "video_core/video_core.h" | #include "video_core/video_core.h" | ||||||
|  | @ -182,7 +184,11 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) { | ||||||
|     dsp_core->EnableStretching(Settings::values.enable_audio_stretching); |     dsp_core->EnableStretching(Settings::values.enable_audio_stretching); | ||||||
| 
 | 
 | ||||||
|     telemetry_session = std::make_unique<Core::TelemetrySession>(); |     telemetry_session = std::make_unique<Core::TelemetrySession>(); | ||||||
|  | 
 | ||||||
|  | #ifdef ENABLE_SCRIPTING | ||||||
|     rpc_server = std::make_unique<RPC::RPCServer>(); |     rpc_server = std::make_unique<RPC::RPCServer>(); | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|     service_manager = std::make_shared<Service::SM::ServiceManager>(); |     service_manager = std::make_shared<Service::SM::ServiceManager>(); | ||||||
|     shared_page_handler = std::make_shared<SharedPage::Handler>(); |     shared_page_handler = std::make_shared<SharedPage::Handler>(); | ||||||
| 
 | 
 | ||||||
|  | @ -234,7 +240,9 @@ void System::Shutdown() { | ||||||
|     Kernel::Shutdown(); |     Kernel::Shutdown(); | ||||||
|     HW::Shutdown(); |     HW::Shutdown(); | ||||||
|     telemetry_session.reset(); |     telemetry_session.reset(); | ||||||
|  | #ifdef ENABLE_SCRIPTING | ||||||
|     rpc_server.reset(); |     rpc_server.reset(); | ||||||
|  | #endif | ||||||
|     service_manager.reset(); |     service_manager.reset(); | ||||||
|     dsp_core.reset(); |     dsp_core.reset(); | ||||||
|     cpu_core.reset(); |     cpu_core.reset(); | ||||||
|  |  | ||||||
|  | @ -21,9 +21,11 @@ namespace AudioCore { | ||||||
| class DspInterface; | class DspInterface; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #ifdef ENABLE_SCRIPTING | ||||||
| namespace RPC { | namespace RPC { | ||||||
| class RPCServer; | class RPCServer; | ||||||
| } | } | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
| namespace Service { | namespace Service { | ||||||
| namespace SM { | namespace SM { | ||||||
|  | @ -220,8 +222,10 @@ private: | ||||||
|     /// Frontend applets
 |     /// Frontend applets
 | ||||||
|     std::shared_ptr<Frontend::SoftwareKeyboard> registered_swkbd; |     std::shared_ptr<Frontend::SoftwareKeyboard> registered_swkbd; | ||||||
| 
 | 
 | ||||||
|  | #ifdef ENABLE_SCRIPTING | ||||||
|     /// RPC Server for scripting support
 |     /// RPC Server for scripting support
 | ||||||
|     std::unique_ptr<RPC::RPCServer> rpc_server; |     std::unique_ptr<RPC::RPCServer> rpc_server; | ||||||
|  | #endif | ||||||
| 
 | 
 | ||||||
|     /// Shared Page
 |     /// Shared Page
 | ||||||
|     std::shared_ptr<SharedPage::Handler> shared_page_handler; |     std::shared_ptr<SharedPage::Handler> shared_page_handler; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue