Skip to content

Commit

Permalink
feat: basic impl cli
Browse files Browse the repository at this point in the history
  • Loading branch information
neko-para committed Aug 29, 2024
1 parent 88318e0 commit a48ca93
Show file tree
Hide file tree
Showing 17 changed files with 658 additions and 52 deletions.
13 changes: 12 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"MIMode": "lldb"
},
{
"name": "Pi sample",
"name": "MaaPICli",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/Debug/sample_pi",
Expand All @@ -28,6 +28,17 @@
"externalConsole": false,
"MIMode": "lldb"
},
{
"name": "MaaPICli - Win",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceFolder}/build/bin/Debug/MaaPICli.exe",
"args": ["."],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/sample",
"environment": [],
"console": "externalTerminal"
},
{
"type": "lldb",
"request": "launch",
Expand Down
3 changes: 2 additions & 1 deletion include/MaaPI/MaaPIAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ extern "C"
MAA_PI_API MaaController* MaaPIRuntimeGetController(MaaPIRuntime* rt);
MAA_PI_API MaaResource* MaaPIRuntimeGetResource(MaaPIRuntime* rt);
MAA_PI_API MaaTasker* MaaPIRuntimeGetTasker(MaaPIRuntime* rt);
MAA_PI_API MaaBool MaaPIRuntimeSetup(MaaPIRuntime* rt, MaaPIData* data, MaaPIConfig* cfg, MaaNotificationCallback cb, void* cb_arg);
MAA_PI_API MaaBool MaaPIRuntimeBind(MaaPIRuntime* rt, MaaPIData* data, MaaPIConfig* cfg);
MAA_PI_API MaaBool MaaPIRuntimeSetup(MaaPIRuntime* rt, MaaNotificationCallback cb, void* cb_arg);

MAA_PI_API MaaPIClient* MaaPIClientCreate(const char* locale, MaaPIClientHandler handler, void* handler_arg);
MAA_PI_API void MaaPIClientDestroy(MaaPIClient* client);
Expand Down
2 changes: 2 additions & 0 deletions sample/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
config.json
pi_config.json
maa_option.json
1 change: 0 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ endif()
add_subdirectory(LibraryHolder)
add_subdirectory(MaaFramework)
add_subdirectory(MaaToolkit)
add_subdirectory(MaaProjectInterface)
add_subdirectory(MaaPI)

add_subdirectory(binding)
13 changes: 11 additions & 2 deletions source/MaaPI/API/MaaPi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,22 @@ MaaTasker* MaaPIRuntimeGetTasker(MaaPIRuntime* rt)
return rt->get_tasker();
}

MaaBool MaaPIRuntimeSetup(MaaPIRuntime* rt, MaaPIData* data, MaaPIConfig* cfg, MaaNotificationCallback cb, void* cb_arg)
MaaBool MaaPIRuntimeBind(MaaPIRuntime* rt, MaaPIData* data, MaaPIConfig* cfg)
{
if (!rt || !data || !cfg) {
return false;
}

return rt->setup(data, cfg, cb, cb_arg);
return rt->bind(data, cfg);
}

MaaBool MaaPIRuntimeSetup(MaaPIRuntime* rt, MaaNotificationCallback cb, void* cb_arg)
{
if (!rt) {
return false;
}

return rt->setup(cb, cb_arg);
}

MaaPIClient* MaaPIClientCreate(const char* locale, MaaPIClientHandler handler, void* handler_arg)
Expand Down
6 changes: 4 additions & 2 deletions source/MaaPI/CLI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
add_executable(MaaPICli main.cpp)
target_link_libraries(MaaPICli MaaPI HeaderOnlyLibraries)
add_executable(MaaPICli main.cpp interactor.cpp)
target_link_libraries(MaaPICli MaaPI MaaUtils HeaderOnlyLibraries)

target_include_directories(MaaPICli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${MAA_PRIVATE_INC} ${MAA_PUBLIC_INC})
Loading

0 comments on commit a48ca93

Please sign in to comment.