Skip to content

Commit

Permalink
refactor: 重构整个ControlUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Nov 9, 2023
1 parent a377f07 commit 0f893c1
Show file tree
Hide file tree
Showing 25 changed files with 854 additions and 629 deletions.
15 changes: 3 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -434,16 +434,7 @@ FodyWeavers.xsd
.idea/
*.sln.iml

enc_temp_folder/*

# Nuke
.nuke/temp/*

# test install dir
install

# chore
.DS_Store

source/MaaRpc/generated/*.h
source/MaaRpc/generated/*.cc
source/MaaRpc/generated/*.timestamp
.nuke/temp/*
enc_temp_folder/*
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.24)
project(MAA)
project(MaaFw)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")

Expand All @@ -9,12 +9,16 @@ set(CMAKE_MAP_IMPORTED_CONFIG_DebWithRelDeps "DebWithRelDeps;Release;")
set(Boost_NO_WARN_NEW_VERSIONS 1)

option(USE_MAADEPS "use third-party libraries built by MaaDeps" ON)

option(WITH_ADB_CONTROLLER "build with adb controller" ON)
option(WITH_THRIFT_CONTROLLER "build with thrift controller" ON)
option(WITH_DBG_CONTROLLER "build with debugging controller" ON)
option(WITH_GRPC "build with protobuf and grpc" ON)

option(BUILD_GRPC_CLI "build grpc CLI exec" ON)

option(BUILD_SAMPLE "build a demo" OFF)

option(BUILD_PIPELINE_TESTING "build pipeline testing" OFF)
option(BUILD_GRPC_TESTING "build grpc testing" OFF)

Expand Down
2 changes: 2 additions & 0 deletions cmake/grpc-gen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ macro(GENERATE_GRPC_LIB LIB_NAME IN_DIR OUT_DIR GEN_SRCS)
set(${LIB_NAME}_INCLUDE_DIRS ${OUT_DIR})
set(${GEN_SRCS} ${SRCS})

set_target_properties(${LIB_NAME} PROPERTIES FOLDER "Generated")

source_group("generated" FILES ${SRCS})
source_group("proto" FILES ${PROTOS})
endmacro()
6 changes: 4 additions & 2 deletions cmake/thrift-gen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ macro(GENERATE_THRIFT_LIB LIB_NAME FILENAME OUTPUTDIR SOURCES)
if(CMD_RESULT)
message(FATAL_ERROR "Error generating ${FILENAME} with generator ${GENERATOR}")
endif()
file(GLOB_RECURSE GENERATED_SOURCES ${OUTPUTDIR}/*.cpp)
add_library(${LIB_NAME} SHARED ${GENERATED_SOURCES})
file(GLOB_RECURSE GENERATED_SOURCES ${OUTPUTDIR}/*.cpp ${OUTPUTDIR}/*.h ${OUTPUTDIR}/*.hpp)
add_library(${LIB_NAME} STATIC ${GENERATED_SOURCES} ${FILENAME})
set_target_properties(${LIB_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(${LIB_NAME} thrift::thrift)
set(${LIB_NAME}_INCLUDE_DIRS
${OUTPUTDIR}
PARENT_SCOPE)
set(${SOURCES} ${GENERATED_SOURCES})

set_target_properties(${LIB_NAME} PROPERTIES FOLDER "Generated")

source_group("generated" FILES ${GENERATED_SOURCES})
source_group("thrift" FILES ${FILENAME})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace cpp ThriftControlUnit
namespace cpp ThriftController

struct Point {
1: i32 x,
Expand Down Expand Up @@ -31,15 +31,18 @@ struct Size {
}

struct CustomImage {
1: Size size,
2: i32 type,
3: binary data,
1: binary png_data,
}

service ThriftControlUnit {
bool set_option(1: string key, 2: string value),

service ThriftController {
bool connect(),

string get_uuid(),
Size get_resolution(),

bool start_app(1: string entry),
bool stop_app(1: string entry),

bool click(1: ClickParam param),
bool swipe(1: SwipeParam param),

Expand All @@ -49,11 +52,5 @@ service ThriftControlUnit {

bool press_key(1: PressKeyParam param),

bool start_game(1: string activity),
bool stop_game(1: string activity),

Size get_resolution(),

string get_uuid(),
CustomImage screencap(),
}
9 changes: 9 additions & 0 deletions include/MaaFramework/MaaDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ enum MaaDbgControllerTypeEnum
MaaDbgControllerType_ReplayRecording = 2,
};

typedef int32_t MaaThriftControllerType;
enum MaaThriftControllerTypeEnum
{
MaaThriftController_Invalid = 0,

MaaThriftControllerType_Socket = 1,
MaaThriftControllerType_UnixDomainSocket = 2,
};

typedef void* MaaTransparentArg;
typedef MaaTransparentArg MaaCallbackTransparentArg;

Expand Down
Loading

0 comments on commit 0f893c1

Please sign in to comment.