refactor(agent): reorganize emulator command handling for gRPC support
- Removed direct inclusion of `emulator_commands.h` in non-gRPC contexts to streamline dependencies. - Updated CMake configuration to conditionally include emulator command sources only when gRPC is enabled, enhancing modularity. - Ensured consistent handling of emulator commands across different components. Benefits: - Improved code organization and maintainability by clarifying the inclusion of gRPC-related features. - Enhanced flexibility in managing command handlers based on compilation flags.
This commit is contained in:
@@ -41,7 +41,6 @@ set(YAZE_AGENT_SOURCES
|
||||
cli/handlers/game/dialogue_commands.cc
|
||||
cli/handlers/game/music_commands.cc
|
||||
cli/handlers/graphics/palette_commands.cc
|
||||
cli/handlers/tools/emulator_commands.cc
|
||||
cli/handlers/game/message_commands.cc
|
||||
cli/handlers/graphics/sprite_commands.cc
|
||||
# ROM commands
|
||||
@@ -56,6 +55,7 @@ if(YAZE_WITH_GRPC)
|
||||
list(APPEND YAZE_AGENT_SOURCES
|
||||
cli/service/agent/agent_control_server.cc
|
||||
cli/service/agent/emulator_service_impl.cc
|
||||
cli/handlers/tools/emulator_commands.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "cli/handlers/game/dungeon_commands.h"
|
||||
#include "cli/handlers/game/overworld_commands.h"
|
||||
#include "cli/handlers/tools/gui_commands.h"
|
||||
#include "cli/handlers/tools/emulator_commands.h"
|
||||
|
||||
ABSL_DECLARE_FLAG(bool, quiet);
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
#include "cli/handlers/tools/resource_commands.h"
|
||||
#include "cli/handlers/tools/gui_commands.h"
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
#include "cli/handlers/tools/emulator_commands.h"
|
||||
#endif
|
||||
#include "cli/handlers/game/dungeon_commands.h"
|
||||
#include "cli/handlers/game/overworld_commands.h"
|
||||
#include "cli/handlers/game/message_commands.h"
|
||||
@@ -95,6 +97,7 @@ std::vector<std::unique_ptr<resources::CommandHandler>> CreateAgentCommandHandle
|
||||
handlers.push_back(std::make_unique<GuiScreenshotCommandHandler>());
|
||||
|
||||
// Emulator & debugger commands
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
handlers.push_back(std::make_unique<EmulatorStepCommandHandler>());
|
||||
handlers.push_back(std::make_unique<EmulatorRunCommandHandler>());
|
||||
handlers.push_back(std::make_unique<EmulatorPauseCommandHandler>());
|
||||
@@ -107,6 +110,7 @@ std::vector<std::unique_ptr<resources::CommandHandler>> CreateAgentCommandHandle
|
||||
handlers.push_back(std::make_unique<EmulatorWriteMemoryCommandHandler>());
|
||||
handlers.push_back(std::make_unique<EmulatorGetRegistersCommandHandler>());
|
||||
handlers.push_back(std::make_unique<EmulatorGetMetricsCommandHandler>());
|
||||
#endif
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@
|
||||
#include "cli/handlers/game/music_commands.h"
|
||||
#include "cli/handlers/game/overworld_commands.h"
|
||||
#include "cli/handlers/graphics/sprite_commands.h"
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
#include "cli/handlers/tools/emulator_commands.h"
|
||||
#endif
|
||||
#include "cli/handlers/tools/gui_commands.h"
|
||||
#include "cli/handlers/tools/resource_commands.h"
|
||||
#include "cli/service/resources/command_context.h"
|
||||
@@ -168,6 +170,7 @@ std::unique_ptr<resources::CommandHandler> CreateHandler(ToolCallType type) {
|
||||
return std::make_unique<SpritePaletteCommandHandler>();
|
||||
|
||||
// Emulator & Debugger commands
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
case ToolCallType::kEmulatorStep:
|
||||
return std::make_unique<EmulatorStepCommandHandler>();
|
||||
case ToolCallType::kEmulatorRun:
|
||||
@@ -192,6 +195,7 @@ std::unique_ptr<resources::CommandHandler> CreateHandler(ToolCallType type) {
|
||||
return std::make_unique<EmulatorGetRegistersCommandHandler>();
|
||||
case ToolCallType::kEmulatorGetMetrics:
|
||||
return std::make_unique<EmulatorGetMetricsCommandHandler>();
|
||||
#endif
|
||||
|
||||
default:
|
||||
return nullptr;
|
||||
|
||||
Reference in New Issue
Block a user