Skip to content

Commit 7f61484

Browse files
authored
Merge pull request #5 from feature/cpp-client
feat: CPP SDK (#:386) feat: Adapt C++ SDK to changes in transport layer (#:393) feat: Support for event handling in demo app (#:405)
2 parents 482b760 + 68be032 commit 7f61484

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+7333
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules/
2+
build/

CMakeLists.txt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Copyright 2023 Comcast Cable Communications Management, LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
cmake_minimum_required(VERSION 3.3)
18+
19+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
20+
include(HelperFunctions)
21+
22+
project(FireboltSDK)
23+
project_version("1.0.0")
24+
25+
set(FIREBOLT_TRANSPORT_WAITTIME 1000 CACHE STRING "Maximum time to wait for Transport layer to get response")
26+
set(FIREBOLT_LOGLEVEL "Info" CACHE STRING "Log level to be enabled")
27+
option(FIREBOLT_ENABLE_STATIC_LIB "Create Firebolt library as Static library" OFF)
28+
option(ENABLE_TESTS "Build openrpc native test" OFF)
29+
option(ENABLE_DEMO_APP "Build demo app" OFF)
30+
31+
if (FIREBOLT_ENABLE_STATIC_LIB)
32+
set(FIREBOLT_LIBRARY_TYPE STATIC)
33+
add_compile_definitions(FIREBOLTSDK_STATIC)
34+
else ()
35+
set(FIREBOLT_LIBRARY_TYPE SHARED)
36+
endif ()
37+
38+
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
39+
set(CMAKE_INSTALL_PREFIX "${SYSROOT_PATH}/usr" CACHE INTERNAL "" FORCE)
40+
set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE)
41+
endif()
42+
43+
list(APPEND CMAKE_MODULE_PATH
44+
"${SYSROOT_PATH}/usr/lib/cmake"
45+
"${SYSROOT_PATH}/tools/cmake")
46+
47+
set(FIREBOLT_NAMESPACE ${PROJECT_NAME} CACHE STRING "Namespace of the project")
48+
49+
add_subdirectory(src)
50+
51+
if (ENABLE_DEMO_APP)
52+
add_subdirectory(demo)
53+
endif()
54+
55+
if (ENABLE_TESTS)
56+
add_subdirectory(test)
57+
endif()
58+
59+
message("${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}Config.cmake")
60+
61+
# make sure others can make use cmake settings of Firebolt OpenRPC
62+
configure_file( "${CMAKE_SOURCE_DIR}/cmake/project.cmake.in"
63+
"${CMAKE_BINARY_DIR}/${FIREBOLT_NAMESPACE}Config.cmake"
64+
@ONLY)

build.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
case $1 in
6+
'') ;;
7+
--) shift;;
8+
*) SYSROOT_PATH="$1"; shift;;
9+
esac
10+
[[ ! -z $SYSROOT_PATH ]] || { echo "SYSROOT_PATH not set" >/dev/stderr; exit 1; }
11+
[[ -e $SYSROOT_PATH ]] || { echo "SYSROOT_PATH not exist ($SYSROOT_PATH)" >/dev/stderr; exit 1; }
12+
13+
bdir="build"
14+
idir="install"
15+
rm -rf $bdir $idir
16+
cmake -B $bdir -DSYSROOT_PATH=$SYSROOT_PATH "$@"
17+
cmake --build $bdir
18+
cmake --install $bdir
19+

cmake/HelperFunctions.cmake

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# If not stated otherwise in this file or this component's LICENSE file the
3+
# following copyright and licenses apply:
4+
#
5+
# Copyright 2025 Sky UK
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
macro(project_version)
21+
string(REGEX REPLACE "^v?([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1" _VERSION_MAJOR "${ARGV0}")
22+
string(REGEX REPLACE "^v?([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\2" _VERSION_MINOR "${ARGV0}")
23+
string(REGEX REPLACE "^v?([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\3" _VERSION_PATCH "${ARGV0}")
24+
25+
set(PROJECT_VERSION_MAJOR ${_VERSION_MAJOR})
26+
set(PROJECT_VERSION_MINOR ${_VERSION_MINOR})
27+
set(PROJECT_VERSION_PATCH ${_VERSION_PATCH})
28+
29+
set(PROJECT_VERSION ${_VERSION_MAJOR}.${_VERSION_MINOR}.${_VERSION_PATCH})
30+
set(VERSION ${PROJECT_VERSION})
31+
endmacro()
32+

cmake/project.cmake.in

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2023 Comcast Cable Communications Management, LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
set(FIREBOLT_NAMESPACE "@FIREBOLT_NAMESPACE@" CACHE INTERNAL "" FORCE)
18+
set("${FIREBOLT_NAMESPACE}_FOUND" TRUE CACHE INTERNAL "" FORCE)
19+
20+
list(APPEND CMAKE_MODULE_PATH
21+
"${CMAKE_SOURCE_DIR}/cmake"
22+
"${SYSROOT_PATH}/usr/lib/cmake"
23+
"${SYSROOT_PATH}/usr/lib/cmake/Firebolt"
24+
"${SYSROOT_PATH}/tools/cmake")
25+
26+
if (NOT DEFINED CMAKE_PREFIX_PATH)
27+
set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE)
28+
endif()
29+
30+
if (FIREBOLT_ENABLE_STATIC_LIB)
31+
set(FIREBOLT_LIBRARY_TYPE STATIC)
32+
else ()
33+
set(FIREBOLT_LIBRARY_TYPE SHARED)
34+
endif ()
35+

demo/CMakeLists.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright 2023 Comcast Cable Communications Management, LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# SPDX-License-Identifier: Apache-2.0
16+
17+
cmake_minimum_required(VERSION 3.10.0)
18+
19+
project(FireboltCoreSDKDemo)
20+
21+
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
22+
set(CMAKE_INSTALL_PREFIX "${SYSROOT_PATH}/usr" CACHE INTERNAL "" FORCE)
23+
set(CMAKE_PREFIX_PATH ${SYSROOT_PATH}/usr/lib/cmake CACHE INTERNAL "" FORCE)
24+
endif()
25+
26+
list(APPEND CMAKE_MODULE_PATH
27+
"${SYSROOT_PATH}/usr/lib/cmake"
28+
"${SYSROOT_PATH}/tools/cmake")
29+
30+
message("FIREBOLT_PATH inside cmake " ${FIREBOLT_PATH})
31+
if (FIREBOLT_PATH)
32+
set(CMAKE_FIREBOLT_PATH
33+
"${FIREBOLT_PATH}/usr/lib/cmake/FireboltSDK")
34+
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_FIREBOLT_PATH})
35+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_FIREBOLT_PATH})
36+
else ()
37+
set(FIREBOLT_PATH "${SYSROOT_PATH}" CACHE INTERNAL "" FORCE)
38+
endif ()
39+
40+
if (STUB_FIREBOLT)
41+
endif()
42+
43+
# Do not look for FireboltSDK if been called from the main cmake
44+
if (NOT ENABLE_DEMO_APP)
45+
find_package(FireboltSDK CONFIG REQUIRED)
46+
endif ()
47+
48+
message("Setup ${PROJECT_NAME}")
49+
50+
add_executable(${PROJECT_NAME}
51+
FireboltDemoService.cpp
52+
main.cpp)
53+
54+
target_link_libraries(${PROJECT_NAME}
55+
PRIVATE
56+
FireboltSDK::FireboltSDK
57+
)
58+
59+
target_include_directories(${PROJECT_NAME}
60+
PRIVATE
61+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include/>
62+
)
63+
64+
set_target_properties(${PROJECT_NAME} PROPERTIES
65+
CXX_STANDARD 17
66+
CXX_STANDARD_REQUIRED YES
67+
)
68+
69+
install(
70+
TARGETS ${PROJECT_NAME}
71+
DESTINATION bin
72+
)

0 commit comments

Comments
 (0)