Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding code and files to be able to embed TDI shell with one command #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_CXX_FLAGS}")


add_subdirectory(src)
if(STANDALONE)
add_subdirectory(cli)
endif()

#Building tdi doxygen
find_package(Doxygen)
Expand Down
34 changes: 34 additions & 0 deletions cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
cmake_minimum_required(VERSION 3.12)
project(libtdi_cli VERSION 0.1 LANGUAGES C)

find_package(Python3 COMPONENTS Interpreter Development)

set(TDI_CLI_SRCS
tdi_cli.c
)

set(TDI_CLI_EXAMPLES_SRCS
cli_example.c
)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third-party/target-syslibs/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third-party/target-utils/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third-party/target-utils/third-party/klish)

set(CMAKE_SHARED_LIBRARY_PREFIX "")

add_library(tdi_cli_o OBJECT ${TDI_CLI_SRCS})
target_include_directories(tdi_cli_o PRIVATE ${Python3_INCLUDE_DIRS})
target_link_libraries(tdi_cli_o PUBLIC target_sys tdi clish python3.11)

add_library(bfshell_plugin_tdi SHARED $<TARGET_OBJECTS:tdi_cli_o>)
target_link_libraries(bfshell_plugin_tdi PUBLIC target_sys tdi clish python3.11)

add_executable(tdi_cli_example ${TDI_CLI_EXAMPLES_SRCS})
target_link_libraries(tdi_cli_example bfshell_plugin_tdi)

install(TARGETS tdi_cli_example DESTINATION bin)
install(FILES xml/startup.xml xml/tdi.xml DESTINATION share/cli/xml)
36 changes: 36 additions & 0 deletions cli/cli_example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright(c) 2024 Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>

#include "tdi_cli.h"

int main() {
char loc[] = "/root";
char * p4_names[] = {
"Program 1",
"Program 2",
};

tdi_shell_start(loc,
p4_names);
sleep(200);
}

Loading
Loading