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

Add gRPC as third party #212

Open
wants to merge 3 commits into
base: master
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
build/
tools/coding_style/backup
tools/third_party/

.vscode/
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[submodule "source/third_party/safestringlib"]
path = source/third_party/safestringlib
url = https://github.com/intel/safestringlib
[submodule "source/third_party/protobuf"]
path = source/third_party/protobuf
url = https://github.com/protocolbuffers/protobuf.git
[submodule "source/third_party/googletest"]
path = source/third_party/googletest
url = https://github.com/google/googletest
[submodule "source/third_party/libfort"]
path = source/third_party/libfort
url = https://github.com/seleznevae/libfort.git
[submodule "source/third_party/grpc"]
path = source/third_party/grpc
url = https://github.com/grpc/grpc.git
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(octf-version.cmake)
project(octf VERSION ${OCTF_VERSION} LANGUAGES C CXX)

set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/third_party;${CMAKE_PREFIX_PATH}")

include(octf-paths.cmake)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ To build OCTF, the following tools are needed:
* CMake 3.9 or above

> **NOTE:** You can use setup dependencies script to install above tools.
>
>
~~~{.sh}
sudo ./setup_dependencies.sh
~~~
Expand Down Expand Up @@ -165,6 +165,7 @@ OCTF uses:
- Google Protocol Buffers
- SeCoe Safe String Library
- Google Test
- gRPC
- cmake
- libfort

Expand Down
16 changes: 16 additions & 0 deletions doc/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,19 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******
gRPC
******
Copyright 2014 gRPC authors.

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.
77 changes: 36 additions & 41 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
set(srcDir ${CMAKE_CURRENT_SOURCE_DIR}/octf)
set(buildDir ${CMAKE_CURRENT_BINARY_DIR}/octf)

add_library(octf SHARED ""
$<TARGET_OBJECTS:protooctf>
$<TARGET_OBJECTS:safestringlib>
)
set(OCTF_PROTO_DIR ${CMAKE_CURRENT_BINARY_DIR}/octf/proto)
add_subdirectory(third_party)
add_subdirectory(octf)

find_package(Protobuf 3.0 REQUIRED)

add_subdirectory(octf/proto)
set(PROTOBUF_IMPORT_DIRS "${PROTOBUF_IMPORT_DIRS}" "${CMAKE_CURRENT_SOURCE_DIR}/octf/proto")
find_package(Protobuf CONFIG REQUIRED)

add_library(octf SHARED ""
$<TARGET_OBJECTS:protooctf>
$<TARGET_OBJECTS:safestringlib>
)
set_target_properties(octf PROPERTIES LINKER_LANGUAGE CXX)
target_compile_options(octf PRIVATE -Wall -Wextra)

set(OCTF_PROTO_DIR ${CMAKE_CURRENT_BINARY_DIR}/octf/proto)

target_include_directories(octf
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
Expand All @@ -25,26 +22,25 @@ target_include_directories(octf
$<INSTALL_INTERFACE:${OCTF_INCLUDE_DIR}/octf/proto>
$<INSTALL_INTERFACE:${OCTF_INCLUDE_DIR}/octf>
)
target_include_directories(octf
SYSTEM PRIVATE ${PROTOBUF_INCLUDE_DIR}
)

# Specify libraries to link
target_link_libraries(octf PUBLIC pthread)
target_link_libraries(octf PRIVATE ${PROTOBUF_LIBRARY})
target_link_libraries(octf PUBLIC protobuf::libprotobuf)
target_link_libraries(octf PRIVATE fort)

add_subdirectory(octf)

# Add version definitions
target_compile_definitions(octf
PUBLIC
OCTF_VERSION=${OCTF_VERSION}
OCTF_VERSION_LABEL=${OCTF_VERSION_LABEL}
PUBLIC
OCTF_VERSION=${OCTF_VERSION}
OCTF_VERSION_LABEL=${OCTF_VERSION_LABEL}
)

# Define static version of octf library and copy all properties from shared one
add_library(octf-static STATIC EXCLUDE_FROM_ALL ""
$<TARGET_OBJECTS:protooctf>
$<TARGET_OBJECTS:safestringlib>
$<TARGET_OBJECTS:protooctf>
$<TARGET_OBJECTS:safestringlib>
)

get_target_property(OCTF_SRCS octf SOURCES)
Expand All @@ -65,39 +61,40 @@ set_target_properties(octf-static PROPERTIES INCLUDE_DIRECTORIES "${OCTF_INC}")
set_target_properties(octf-static PROPERTIES COMPILE_OPTIONS "${OCTF_OPTS}")
set_target_properties(octf-static PROPERTIES COMPILE_DEFINITIONS "${OCTF_DEFS}")


file(GLOB_RECURSE protoFiles
${srcDir}/proto/*.proto)
${srcDir}/proto/*.proto)
file(GLOB_RECURSE publicHeaders
${srcDir}/*.h)
${srcDir}/*.h)

# Replace all .proto extensions to pb.h, this is needed in order to
# get a list of pb.h files before they are generated
string(REPLACE "\.proto" "\.pb.h" protoHeaders "${protoFiles}")

# Modify path from source to build
STRING(REGEX REPLACE
"${srcDir}([^;]*\.pb\.h)"
"${buildDir}\\1"
protoHeaders
"${protoHeaders}")
set(publicHeaders ${publicHeaders} ${protoHeaders})

# Remove headers not added to sdk (from internal directories)
FOREACH(item ${publicHeaders})
IF(${item} MATCHES ".*internal\/.*")
LIST(REMOVE_ITEM publicHeaders ${item})
ENDIF(${item} MATCHES ".*internal\/.*")
IF(${item} MATCHES ".*internal\/.*")
LIST(REMOVE_ITEM publicHeaders ${item})
ENDIF(${item} MATCHES ".*internal\/.*")
ENDFOREACH(item)

# Generate and copy octf.h header file, do this in pre-link phase
add_custom_command(
TARGET octf
PRE_LINK
COMMAND ${srcDir}/generateCommonHeader.sh "\"${publicHeaders}\"" ${buildDir}
TARGET octf
PRE_LINK
COMMAND ${srcDir}/generateCommonHeader.sh "\"${publicHeaders}\"" ${buildDir}
)
add_custom_command(
TARGET octf-static
PRE_LINK
COMMAND ${srcDir}/generateCommonHeader.sh "\"${publicHeaders}\"" ${buildDir}
TARGET octf-static
PRE_LINK
COMMAND ${srcDir}/generateCommonHeader.sh "\"${publicHeaders}\"" ${buildDir}
)

# Install install-manifest with list of installed files, to allow uninstalling
Expand All @@ -115,22 +112,20 @@ install(FILES ${OCTF_MANIFEST_PREINSTALL}
# because we must use GNUUtils to obtain the proper path to install-manifest
add_custom_target(octf-uninstall
COMMAND test -f ${OCTF_MANIFEST_POSTINSTALL} &&
xargs rm -vf < ${OCTF_MANIFEST_POSTINSTALL} ||
echo "-- No OCTF install manifest found: ${OCTF_MANIFEST_POSTINSTALL} Nothing to uninstall!"
xargs rm -vf < ${OCTF_MANIFEST_POSTINSTALL} ||
echo "-- No OCTF install manifest found: ${OCTF_MANIFEST_POSTINSTALL} Nothing to uninstall!"
)


# Install octf.so library and add octf target to export group 'octf-targets'
install(TARGETS octf DESTINATION ${OCTF_LIBRARY_DIR} EXPORT octf-targets COMPONENT octf-install)

if (${CMAKE_INSTALL_PREFIX} STREQUAL "/")
install(
CODE "execute_process(COMMAND ldconfig)"
COMPONENT octf-post-install
)
if(${CMAKE_INSTALL_PREFIX} STREQUAL "/")
install(
CODE "execute_process(COMMAND ldconfig)"
COMPONENT octf-post-install
)
endif()


# Install headers and proto files
install(DIRECTORY octf ${CMAKE_CURRENT_BINARY_DIR}/octf
DESTINATION ${OCTF_INCLUDE_DIR}
Expand Down
21 changes: 9 additions & 12 deletions source/examples/auto_cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
add_executable(auto-cli "")
target_link_libraries(auto-cli octf ${PROTOBUF_LIBRARY})

target_include_directories(auto-cli
SYSTEM PRIVATE ${PROTOBUF_INCLUDE_DIR}
)

# Generate protocol buffer headers and sources
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER InterfaceHelloWorld.proto)

target_link_libraries(auto-cli octf protobuf::libprotobuf)
target_include_directories(auto-cli PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(auto-cli PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

target_sources(auto-cli
PRIVATE
target_sources(auto-cli PRIVATE
${CMAKE_CURRENT_LIST_DIR}/main.cpp
${CMAKE_CURRENT_LIST_DIR}/InterfaceHelloWorldImpl.cpp
${PROTO_SRC}
${CMAKE_CURRENT_LIST_DIR}/InterfaceHelloWorld.proto
)

protobuf_generate(TARGET auto-cli
LANGUAGE CPP
IMPORT_DIRS ${OCTF_PROTOBUF_IMPORT_DIRS} ${CMAKE_CURRENT_LIST_DIR}
GENERATE_EXTENSIONS .pb.h .pb.cc
)
7 changes: 1 addition & 6 deletions source/examples/plugin/client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
add_executable(testPluginClient "")
target_include_directories(testPluginClient PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(testPluginClient PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/proto)
target_include_directories(testPluginClient PRIVATE ${PROTOBUF_INCLUDE_DIR})
target_link_libraries(testPluginClient octf protoexamples)
target_sources(testPluginClient
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/TestPluginShadow.h
${CMAKE_CURRENT_LIST_DIR}/TestPluginShadow.cpp
${CMAKE_CURRENT_LIST_DIR}/main.cpp
)
target_link_libraries(testPluginClient octf)
target_link_libraries(testPluginClient protoexamples)
target_link_libraries(testPluginClient ${PROTOBUF_LIBRARIES})
19 changes: 9 additions & 10 deletions source/examples/plugin/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
set(protoListExamples
InterfaceTest.proto
test.proto
)

protobuf_generate_cpp(PROTO_SRC PROTO_HEADER ${protoListExamples})
add_library(protoexamples STATIC ${PROTO_HEADER} ${PROTO_SRC} ${protoListExamples})
add_dependencies(protoexamples protooctf)
add_library(protoexamples STATIC
${CMAKE_CURRENT_LIST_DIR}/InterfaceTest.proto
${CMAKE_CURRENT_LIST_DIR}/test.proto
)
protobuf_generate(TARGET protoexamples
IMPORT_DIRS ${OCTF_PROTOBUF_IMPORT_DIRS} ${CMAKE_CURRENT_LIST_DIR}
)
target_include_directories(protoexamples
PUBLIC
${PROTOBUF_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${OCTF_PROTO_DIR}
)
)
target_link_libraries(protoexamples PUBLIC protobuf::libprotobuf)

4 changes: 0 additions & 4 deletions source/examples/plugin/server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
add_executable(testPlugin "")
target_link_libraries(testPlugin octf protoexamples)
target_link_libraries(testPlugin ${PROTOBUF_LIBRARIES})
target_include_directories(testPlugin PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(testPlugin PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/proto)
target_include_directories(testPlugin PRIVATE ${PROTOBUF_INCLUDE_DIR} ${OCTF_PROTO_DIR})
target_sources(testPlugin
PRIVATE
${CMAKE_CURRENT_LIST_DIR}/InterfaceTestImpl.h
Expand Down
1 change: 1 addition & 0 deletions source/octf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
add_subdirectory(proto)
add_subdirectory(cli)
add_subdirectory(communication)
add_subdirectory(interface)
Expand Down
3 changes: 1 addition & 2 deletions source/octf/cli/internal/CLIUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ void printKeys(stringstream &ss,
}

void printOutputMessage(MessageShRef message) {
google::protobuf::util::Status status;
google::protobuf::util::JsonPrintOptions opts;
string strOutput;

Expand All @@ -156,7 +155,7 @@ void printOutputMessage(MessageShRef message) {
// this field in output, enable this
opts.always_print_primitive_fields = true;

status = google::protobuf::util::MessageToJsonString(*message, &strOutput,
auto status = google::protobuf::util::MessageToJsonString(*message, &strOutput,
opts);
if (!status.ok()) {
throw ProtoBufferException(status.ToString());
Expand Down
9 changes: 6 additions & 3 deletions source/octf/interface/InterfaceTraceParsingImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ void InterfaceTraceParsingImpl::BuildExtensions(

// Define variables for
std::string jsonTrace;
google::protobuf::util::JsonOptions jsonOptions;
google::protobuf::util::JsonPrintOptions jsonOptions;
jsonOptions.always_print_primitive_fields = true;
jsonOptions.add_whitespace = false;
table::Table tab;
Expand Down Expand Up @@ -523,8 +523,11 @@ void InterfaceTraceParsingImpl::BuildExtensions(
} break;
case proto::OutputFormat::JSON: {
jsonTrace.clear();
google::protobuf::util::MessageToJsonString(msg, &jsonTrace,
jsonOptions);
auto status = google::protobuf::util::MessageToJsonString(
msg, &jsonTrace, jsonOptions);
if (!status.ok()) {
throw Exception("Failed to convert message to JSON");
}
cout << jsonTrace << std::endl;
} break;
default: {
Expand Down
43 changes: 19 additions & 24 deletions source/octf/proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
set(protoList
configuration.proto
defs.proto
InterfaceCLI.proto
InterfaceIdentification.proto
InterfaceTraceParsing.proto
InterfaceService.proto
InterfaceTraceCreating.proto
InterfaceTraceManagement.proto
InterfaceConfiguration.proto
opts.proto
packets.proto
trace.proto
parsedTrace.proto
traceDefinitions.proto
statistics.proto
extensions.proto
add_library(protooctf OBJECT
${CMAKE_CURRENT_LIST_DIR}/configuration.proto
${CMAKE_CURRENT_LIST_DIR}/defs.proto
${CMAKE_CURRENT_LIST_DIR}/InterfaceCLI.proto
${CMAKE_CURRENT_LIST_DIR}/InterfaceIdentification.proto
${CMAKE_CURRENT_LIST_DIR}/InterfaceTraceParsing.proto
${CMAKE_CURRENT_LIST_DIR}/InterfaceService.proto
${CMAKE_CURRENT_LIST_DIR}/InterfaceTraceCreating.proto
${CMAKE_CURRENT_LIST_DIR}/InterfaceTraceManagement.proto
${CMAKE_CURRENT_LIST_DIR}/InterfaceConfiguration.proto
${CMAKE_CURRENT_LIST_DIR}/opts.proto
${CMAKE_CURRENT_LIST_DIR}/packets.proto
${CMAKE_CURRENT_LIST_DIR}/trace.proto
${CMAKE_CURRENT_LIST_DIR}/parsedTrace.proto
${CMAKE_CURRENT_LIST_DIR}/traceDefinitions.proto
${CMAKE_CURRENT_LIST_DIR}/statistics.proto
${CMAKE_CURRENT_LIST_DIR}/extensions.proto
)
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER ${protoList})
add_library(protooctf OBJECT ${PROTO_HEADER} ${PROTO_SRC})
target_include_directories(protooctf
PUBLIC
${PROTOBUF_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}
)
target_link_libraries(protooctf PUBLIC protobuf::libprotobuf)
target_compile_options(protooctf PRIVATE -Wno-unused-parameter PUBLIC -fPIC)

# Set import dirs for protobuf and store them in 'global' variable OCTF_PROTOBUF_IMPORT_DIRS
# which can be used by projects utilizing octf's build system
set(PROTOBUF_IMPORT_DIRS ${PROTOBUF_IMPORT_DIRS} "${CMAKE_CURRENT_SOURCE_DIR}")
set(OCTF_PROTOBUF_IMPORT_DIRS ${PROTOBUF_IMPORT_DIRS} CACHE INTERNAL "OCTF_PROTOBUF_IMPORT_DIRS")

protobuf_generate(TARGET protooctf)
Loading