Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ project(Playergstinterface)

set(CMAKE_CXX_STANDARD 14)

# Option for building pi-cli
option(BUILD_PICLI "Build the pi-cli test project" OFF)

find_package(PkgConfig REQUIRED)
pkg_check_modules(GST REQUIRED gstreamer-plugins-base-1.0)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
Expand Down Expand Up @@ -364,3 +367,8 @@ target_link_libraries(playergstinterface subtec)
target_link_libraries(playergstinterface baseconversion)
target_link_libraries(playergstinterface playerfbinterface)
set(LIBPLAYERGSTINTERFACE_SOURCES ${LIBPLAYERGSTINTERFACE_SOURCES} {LIBPLAYERGSTINTERFACE_MOCK_SOURCES})

# Optionally build pi-cli for l2
if(BUILD_PICLI)
add_subdirectory(test/pi-cli)
endif()
37 changes: 37 additions & 0 deletions test/pi-cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cmake_minimum_required(VERSION 3.10)

# Project name
project(pi-cli VERSION 1.0 LANGUAGES CXX)

set(PI_ROOT "../..")

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

include_directories(${PI_ROOT})

# Add the executable (now includes commandProcessing.cpp)
add_executable(pi-cli
main.cpp
commandProcessing.cpp
)

# Use pkg-config to locate the readline library
find_package(PkgConfig REQUIRED)
pkg_check_modules(READLINE REQUIRED readline)

if (READLINE_FOUND)
include_directories(${READLINE_INCLUDE_DIRS})
link_directories(${READLINE_LIBRARY_DIRS})
target_link_libraries(pi-cli ${READLINE_LIBRARIES})
else()
message(FATAL_ERROR "Readline library not found. Please install it.")
endif()

target_link_libraries(pi-cli playergstinterface)

# Additional warnings and flags for development
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(pi-cli PRIVATE -Wall -Wextra -pedantic)
endif()
93 changes: 93 additions & 0 deletions test/pi-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# pi-cli

`pi-cli` is a simple command-line interface application written in C++. It supports multithreaded command execution and provides a set of sample commands for demonstration purposes.

---

## Supported Commands

Here are the commands supported by `pi-cli`:

- **`exit`**: Exit the program. Ensures that the worker thread is stopped cleanly before exiting.
- **`help`**: Display a list of available commands and their descriptions.
- **`echo [parameters...]`**: Echoes the provided parameters back to the console.

---

## Building the Application

Follow these steps to build `pi-cli` on macOS or Linux:

### Prerequisites

Make sure you have the following installed:
- `CMake` (version 3.10 or higher)
- A C++ compiler with support for C++17 (e.g., `clang` or `g++`)

### Steps to Build

1. Open a terminal.

2. Navigate to the directory containing the `CMakeLists.txt` file:
```bash
cd /path/to/project
```

3. Create a build directory and navigate into it:
```bash
mkdir build
cd build
```

4. Generate the build files using CMake:
```bash
cmake ..
```

5. Build the project:
```bash
make
```

6. The compiled executable will be located in the `bin` directory inside the `build` folder. You can run it as follows:
```bash
./bin/pi-cli
```

---

## Running the Application

Once built, run the `pi-cli` executable. You will see a prompt where you can enter supported commands.

### Example Usage

```bash
$ ./bin/pi-cli
Please enter a command (type 'help' for available commands): help
Available commands:
- exit: Exit the program.
- help: Display this help message.
- echo: Echoes the provided parameters.
```

To exit the program, type:
```bash
exit
```

---

## Notes

- For Linux builds, the `-pthread` flag is automatically applied to ensure multithreading compatibility.
- If you encounter any issues, ensure that your development environment meets the prerequisites.

```bash
# To install CMake on macOS using Homebrew:
brew install cmake
```

---

Enjoy using `pi-cli`!
Loading
Loading