mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-07-06 04:52:09 -07:00
Make CLI optional
This commit is contained in:
parent
b591105c3b
commit
94e7735c34
3 changed files with 20 additions and 2 deletions
|
@ -4,14 +4,19 @@ cmake_minimum_required(VERSION 3.2)
|
|||
project(chiaki)
|
||||
|
||||
option(CHIAKI_ENABLE_TESTS "Enable tests for Chiaki" ON)
|
||||
option(CHIAKI_ENABLE_CLI "Enable CLI for Chiaki" OFF)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
add_subdirectory(third-party)
|
||||
|
||||
add_subdirectory(lib)
|
||||
|
||||
if(CHIAKI_ENABLE_CLI)
|
||||
add_subdirectory(cli)
|
||||
endif()
|
||||
|
||||
add_subdirectory(gui)
|
||||
add_subdirectory(cli)
|
||||
|
||||
if(CHIAKI_ENABLE_TESTS)
|
||||
enable_testing()
|
||||
|
|
|
@ -49,7 +49,12 @@ add_executable(chiaki
|
|||
res/resources.qrc)
|
||||
target_include_directories(chiaki PRIVATE include)
|
||||
|
||||
target_link_libraries(chiaki chiaki-lib chiaki-cli-lib)
|
||||
target_link_libraries(chiaki chiaki-lib)
|
||||
if(CHIAKI_ENABLE_CLI)
|
||||
add_definitions(CHIAKI_ENABLE_CLI)
|
||||
target_link_libraries(chiaki chiaki-cli-lib)
|
||||
endif()
|
||||
|
||||
target_link_libraries(chiaki FFMPEG::avcodec)
|
||||
target_link_libraries(chiaki Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Multimedia Qt5::OpenGL Qt5::Svg)
|
||||
if(CHIAKI_GUI_ENABLE_QT_GAMEPAD)
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
#include <host.h>
|
||||
#include <avopenglwidget.h>
|
||||
|
||||
#ifdef CHIAKI_ENABLE_CLI
|
||||
#include <chiaki-cli.h>
|
||||
#endif
|
||||
|
||||
#include <chiaki/session.h>
|
||||
#include <chiaki/regist.h>
|
||||
|
@ -26,6 +28,7 @@
|
|||
|
||||
Q_DECLARE_METATYPE(ChiakiLogLevel)
|
||||
|
||||
#ifdef CHIAKI_ENABLE_CLI
|
||||
struct CLICommand
|
||||
{
|
||||
int (*cmd)(ChiakiLog *log, int argc, char *argv[]);
|
||||
|
@ -34,6 +37,7 @@ struct CLICommand
|
|||
static const QMap<QString, CLICommand> cli_commands = {
|
||||
{ "discover", { chiaki_cli_cmd_discover } }
|
||||
};
|
||||
#endif
|
||||
|
||||
int RunStream(QApplication &app, const StreamSessionConnectInfo &connect_info);
|
||||
int RunMain(QApplication &app, Settings *settings);
|
||||
|
@ -72,7 +76,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
QStringList cmds;
|
||||
cmds.append("stream");
|
||||
#ifdef CHIAKI_ENABLE_CLI
|
||||
cmds.append(cli_commands.keys());
|
||||
#endif
|
||||
|
||||
parser.addPositionalArgument("command", cmds.join(", "));
|
||||
parser.addPositionalArgument("host", "Address to connect to (when using the stream command)");
|
||||
|
@ -118,6 +124,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
return RunStream(app, connect_info);
|
||||
}
|
||||
#ifdef CHIAKI_ENABLE_CLI
|
||||
else if(cli_commands.contains(args[0]))
|
||||
{
|
||||
ChiakiLog log;
|
||||
|
@ -135,6 +142,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
return cmd.cmd(&log, sub_argc, sub_argv.data());
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
parser.showHelp(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue