Added CMake option to enable/disable scripting support

This commit is contained in:
EverOddish 2018-09-23 18:16:57 -04:00
parent 6b538a49ac
commit fce7afb8dc
5 changed files with 122 additions and 95 deletions

View File

@ -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 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
@ -258,6 +260,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
# ====================================== # ======================================

View File

@ -94,6 +94,7 @@ if (ENABLE_WEB_SERVICE)
target_include_directories(json-headers INTERFACE ./json) target_include_directories(json-headers INTERFACE ./json)
endif() endif()
if (ENABLE_SCRIPTING)
# ZeroMQ # ZeroMQ
# libzmq includes its own clang-format target, which conflicts with the # libzmq includes its own clang-format target, which conflicts with the
# clang-format in Citra if libzmq is added as a subdirectory. An external # clang-format in Citra if libzmq is added as a subdirectory. An external
@ -186,3 +187,4 @@ target_include_directories(libzmq-headers INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/
add_library(cppzmq-headers INTERFACE) add_library(cppzmq-headers INTERFACE)
target_include_directories(cppzmq-headers INTERFACE ./cppzmq) target_include_directories(cppzmq-headers INTERFACE ./cppzmq)
add_dependencies(cppzmq-headers libzmq) add_dependencies(cppzmq-headers libzmq)
endif()

View File

@ -1,4 +1,4 @@
add_library(core STATIC set(core_sources
3ds.h 3ds.h
announce_multiplayer_session.cpp announce_multiplayer_session.cpp
announce_multiplayer_session.h announce_multiplayer_session.h
@ -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,19 @@ add_library(core STATIC
tracer/recorder.cpp tracer/recorder.cpp
tracer/recorder.h tracer/recorder.h
) )
if (ENABLE_SCRIPTING)
list(APPEND core_sources
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()
add_library(core STATIC ${core_sources})
create_target_directory_groups(core) create_target_directory_groups(core)
@ -445,4 +450,6 @@ if (ARCHITECTURE_x86_64)
target_link_libraries(core PRIVATE dynarmic) target_link_libraries(core PRIVATE dynarmic)
endif() endif()
if (ENABLE_SCRIPTING)
target_link_libraries(core PUBLIC libzmq-headers cppzmq-headers libzmq) target_link_libraries(core PUBLIC libzmq-headers cppzmq-headers libzmq)
endif()

View File

@ -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();

View File

@ -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;