Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
308a283
Adding rbus dependency
guruchandru Oct 22, 2021
bea448a
New changes to incorporate main rbus code
guruchandru Oct 25, 2021
f62b377
This should more or less get rtMessage building.
schmidtw Oct 26, 2021
57d8cb4
Work around the need to have the wrapper code in the wrapdb.
schmidtw Oct 26, 2021
373423e
Graft enough meson build scripts onto the rbus libraries so we can bu…
schmidtw Oct 26, 2021
b923059
Merge pull request #1 from schmidtw/main
guruchandru Oct 26, 2021
59ba959
cJSON build issue fix
guruchandru Oct 26, 2021
8572fb7
Script and executable change
guruchandru Oct 26, 2021
a7c4c2b
Test changes
guruchandru Oct 26, 2021
d93d6c6
Work around the old version of meson in RDK Yocto today (0.53).
schmidtw Oct 26, 2021
d8dd3df
Merge remote-tracking branch 'upstream/main'
guruchandru Oct 27, 2021
998d824
Fix for rbus related yocto dependency
guruchandru Oct 27, 2021
c5ca0fe
Cmake change for cpeabs
guruchandru Oct 28, 2021
45e2935
Code changes for utility lib
guruchandru Oct 28, 2021
baf1c8e
Debug logs
guruchandru Nov 2, 2021
779a573
Refactored code
guruchandru Nov 2, 2021
39e30dd
Review comment changes with debug logs
guruchandru Nov 9, 2021
70af781
Cflag changes
guruchandru Nov 9, 2021
82d2b7e
Guardrail Security Fix
guruchandru Nov 9, 2021
66dc4d9
Removed debug logs
guruchandru Nov 9, 2021
dcd5fd5
Rbus Code changes and Review comment changes
guruchandru Nov 10, 2021
281ac9f
Updated README.md file
guruchandru Nov 10, 2021
fe7f43d
Merge pull request #1 from guruchandru/master
shilpa24balaji Nov 10, 2021
fe80eaf
Adding cimplog fix for extender support
debasya Nov 11, 2021
0aad3fa
Merge pull request #2 from debasya/cpeab_cimpfix
shilpa24balaji Nov 11, 2021
5574067
Check CR systemready using rbus
sadhyama Nov 11, 2021
5a236e4
To use file creat functions instead of system commands
sadhyama Nov 15, 2021
f3980d0
Merge pull request #3 from sadhyama/sys_ready
shilpa24balaji Nov 17, 2021
3448ecb
Move connected client notification business logic from webconfig to w…
Sreedevi29 Nov 23, 2021
87a6b0a
Merge pull request #4 from Sreedevi29/meshCujo
shilpa24balaji Nov 24, 2021
ab7e953
Adding utils and database functionalities
debasya Dec 10, 2021
e5cea2d
Update impl.c
debasya Dec 10, 2021
21c50e3
Merge pull request #7 from debasya/cpeabs_extender
sadhyama Dec 13, 2021
508895c
Cmake and meson integration
guruchandru Dec 16, 2021
ac273c6
Sky Specific mac address change
retheesh-sasidharan Dec 17, 2021
003c6f5
Merge pull request #8 from retheesh-sasidharan/patch-1
sadhyama Dec 20, 2021
038902e
wrapdb integration
guruchandru Dec 17, 2021
83e6a3b
Refactoring Folders
guruchandru Dec 22, 2021
3bd97c4
Pod refactoring and jansson local build config changes
guruchandru Dec 22, 2021
90a397f
Added Steps to build in README.md
guruchandru Dec 22, 2021
a2d6122
Fix for REUSE Compliance Check Failure
guruchandru Dec 22, 2021
5709e6e
Refactored Macros, platform independent header files
guruchandru Dec 30, 2021
2ed7274
Merge remote-tracking branch 'upstream/cmake' into pr_reqd
debasya Jan 4, 2022
b7831ea
Adding mods according to review
debasya Jan 4, 2022
3c47aa3
Merge pull request #2 from debasya/pr_reqd
guruchandru Jan 4, 2022
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ _testmain.go
*.test
*.prof
*.xml

subprojects/rbus*
subprojects/rtMessage
subprojects/cJSON*
167 changes: 167 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# SPDX-FileCopyrightText: 2021 Comcast Cable Communications Management, LLC
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 2.8.7)

project(cpeabs)

include(ExternalProject)
include(CTest)

add_definitions(-std=c99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -g -Werror -Wall -D_GNU_SOURCE=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c99 -g -Werror -Wall -D_GNU_SOURCE=1")

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
endif()

set(INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/_install)
set(PREFIX_DIR ${CMAKE_CURRENT_BINARY_DIR}/_prefix)
set(INCLUDE_DIR ${INSTALL_DIR}/include)
set(LIBRARY_DIR ${INSTALL_DIR}/lib)
set(LIBRARY_DIR64 ${INSTALL_DIR}/lib64)
set(COMMON_LIBRARY_DIR ${INSTALL_DIR}/lib/${CMAKE_LIBRARY_ARCHITECTURE})
set(TEST_RESULTS_DIR ${CMAKE_CURRENT_BINARY_DIR}/test_results)
file(MAKE_DIRECTORY ${TEST_RESULTS_DIR})

include_directories(${INCLUDE_DIR}
${INCLUDE_DIR}/cjson
${INCLUDE_DIR}/msgpack
${INCLUDE_DIR}/rbus
${INCLUDE_DIR}/rbus-core
${INCLUDE_DIR}/rtmessage
${INCLUDE_DIR}/wdmp-c
${INCLUDE_DIR}/cimplog
)

include_directories(
${PROJECT_SOURCE_DIR}/include/cpeabs/
)

if (PLATFORM STREQUAL "DEVICE_GATEWAY")
include_directories(
${PROJECT_SOURCE_DIR}/src/rdkb/include/
)
elseif (PLATFORM STREQUAL "DEVICE_EXTENDER")
include_directories(
${PROJECT_SOURCE_DIR}/src/pods/include/
)
endif ()

if (NOT BUILD_YOCTO)

# msgpack-c external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(msgpack
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/msgpack
GIT_REPOSITORY https://github.com/msgpack/msgpack-c.git
GIT_TAG "7a98138f27f27290e680bf8fbf1f8d1b089bf138"
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-DMSGPACK_ENABLE_CXX=OFF
-DMSGPACK_BUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF
)
add_library(libmsgpack STATIC SHARED IMPORTED)
add_dependencies(libmsgpack msgpack)

# cimplog external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(cimplog
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/cimplog
GIT_REPOSITORY https://github.com/Comcast/cimplog.git
GIT_TAG "1.0.2"
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
)
add_library(libcimplog STATIC SHARED IMPORTED)
add_dependencies(libcimplog cimplog)

# cJSON external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(cJSON
PREFIX ${PREFIX_DIR}/cJSON
GIT_REPOSITORY https://github.com/DaveGamble/cJSON.git
GIT_TAG "aafb64a1c549b7b927e339df6d35b1d5059dc235"
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
)
add_library(libcJSON STATIC IMPORTED)
add_dependencies(libcJSON cJSON)

# wdmp-c external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(wdmp-c
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/wdmp-c
GIT_REPOSITORY https://github.com/Comcast/wdmp-c.git
GIT_TAG "796dddbcfa7686ec63536d950775e79b52ee5c3f"
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-DBUILD_TESTING=OFF
)
add_library(libwdmp-c STATIC SHARED IMPORTED)
add_dependencies(libwdmp-c wdmp-c)

# rtMessage external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(rtMessage
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/rtMessage
GIT_REPOSITORY https://github.com/rdkcmf/rdk-rtmessage.git
GIT_TAG rdk-next
CMAKE_ARGS += -DBUILD_RTMESSAGE_LIB=ON
-DBUILD_RTMESSAGE_SAMPLE_APP=ON
-DBUILD_FOR_DESKTOP=ON
-DBUILD_DATAPROVIDER_LIB=ON
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
)
add_library(librtMessage STATIC SHARED IMPORTED)
add_dependencies(librtMessage rtMessage)

# rbus-core external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(rbus-core
DEPENDS rtMessage
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/rbus-core
GIT_REPOSITORY https://github.com/rdkcmf/rbuscore.git
GIT_TAG rdk-next
CMAKE_ARGS += DBUILD_FOR_DESKTOP=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-DBUILD_TESTING=OFF
)
add_library(librbus-core STATIC SHARED IMPORTED)
add_dependencies(librbus-core rbus-core)

# rbus external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(rbus
DEPENDS rtMessage rbus-core
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/rbus
GIT_REPOSITORY https://github.com/rdkcmf/rbus.git
GIT_TAG rdk-next
CMAKE_ARGS += -DBUILD_FOR_DESKTOP=ON -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} -DBUILD_TESTING=OFF
)

add_library(librbus STATIC SHARED IMPORTED)
add_dependencies(librbus rbus)

if (PLATFORM STREQUAL "DEVICE_EXTENDER")

# jansson external dependency
#-------------------------------------------------------------------------------
ExternalProject_Add(jansson
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/_prefix/rbus
GIT_REPOSITORY https://github.com/akheron/jansson.git
GIT_TAG master
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
)

add_library(libjansson STATIC SHARED IMPORTED)
add_dependencies(libjansson jansson)
endif ()

endif ()

link_directories ( ${LIBRARY_DIR} ${COMMON_LIBRARY_DIR} ${LIBRARY_DIR64} )

add_subdirectory(src)

if (BUILD_TESTING)
add_subdirectory(tests)
endif (BUILD_TESTING)
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,26 @@ An abstraction layer for consumer preference equipment systems.

# Building and Testing Instructions

Use the below commands to build using meson
```
./workaround.sh
meson build
cd build
ninja all test coverage
firefox meson-logs/coveragereport/index.html

```
Use the below commands to build using cmake
```
Use CFLAG -DPLATFORM=DEVICE_GATEWAY to build for RDKB platform
Use CFLAG -DPLATFORM=DEVICE_EXTENDER to build for POD platform

mkdir build
cd build
cmake ..
make
make test
```

The `workaround.sh` script makes it so we don't need to add the rbus stuff to the
upstream wrapdb.
21 changes: 20 additions & 1 deletion include/cpeabs/cpeabs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@
#ifndef __CPEABS_H__
#define __CPEABS_H__

#include <stddef.h>
#include <stdint.h>
#include <wdmp-c.h>

/*----------------------------------------------------------------------------*/
/* Macros */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Data Structures */
/*----------------------------------------------------------------------------*/
/* none */
/*----------------------------------------------------------------------------*/
/* External Functions */
/*----------------------------------------------------------------------------*/

char * getParamValue(char *paramName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a header that describes what the function does, what the values are and what the returned values are. Also call out any expectation about who should own memory.

The paramName should be a const if at all possible.

Think about prefixing the functions with something like cpeabs_ so it is clear that these APIs are all related when they are used elsewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the descriptive header for getParamValue() to the header file so that users of the header file can see it easily and without needing to dig into the c source code. Same for the functions below.

void getValues_rbus(const char *paramName[], const unsigned int paramCount, int index, money_trace_spans *timeSpan, param_t ***paramArr, int *retValCount, WDMP_STATUS *retStatus);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comment as above. const against integers is less valuable as those are passed by value. A *** is really challenging to define and use. If possible try to define more concrete structures instead.

Think about prefixing the functions with something like cpeabs_ so it is clear that these APIs are all related when they are used elsewhere.

int rbus_GetValueFromDB( char* paramName, char** paramValue);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comments as above. (Add comments). Shorten the parameter names to something like name and value because parameter doesn't really add value.

Think about prefixing the functions with something like cpeabs_ so it is clear that these APIs are all related when they are used elsewhere.

int rbus_StoreValueIntoDB(char *paramName, char *value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same comments as above. (Add comments). Shorten the parameter names to something like name and value because param doesn't really add value.

Think about prefixing the functions with something like cpeabs_ so it is clear that these APIs are all related when they are used elsewhere.

int rbus_waitUntilSystemReady();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function in particular needs good documentation since it is not clear if it is a blocking call, thread safe or something I can/should repeatedly call.

The same comments as above. (Add comments). Shorten the parameter names to something like name and value because parameter doesn't really add value.

Think about prefixing the functions with something like cpeabs_ so it is clear that these APIs are all related when they are used elsewhere.

void cpeabs_free(void *ptr);
#endif

59 changes: 55 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

project('cpeabs', 'c',
version: '0.0.0',
meson_version: '>=0.53',
license: ['Apache-2.0'],
default_options: ['c_std=c99',
'b_coverage=true'])
Expand All @@ -15,32 +16,82 @@ if not meson.is_subproject()
werror = true
endif

script = join_paths(meson.source_root(), 'workaround.sh')
Copy link

@eli-schwartz eli-schwartz Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. meson 0.55.0 added a patch_directory option to handle locally wrapped dependencies, so you do not need to autogenerate tarball intermediaries here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eli-schwartz The yocto build we're using (and can't change for a while) is using meson 0.53. We've not been able to iron out a set of LD based issues for the cross compiler calls with meson, which is why CMake got added. I've not been able to get back to trying to find a better solution for this, but good suggestion.

@guruchandru I'd rather not add the workaround code to the meson file since that couples us with a hack that hopefully we can remove sooner than later.

Copy link

@eli-schwartz eli-schwartz Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, at least re: my comment below you cannot rely on the [provide] section either, so you can just add the fallback: ['foo_project', 'foo_dep'] styled references to each one, and you still do not need if/else logic. :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as these wraps go... jansson could probably go into the wrapdb, the other ones look like they may be specialized enough that that is not worth it so the alternative would be somehow getting meson.build files into those repos...


r = run_command('/bin/sh', script)
if r.returncode() != 0
message('script failed')
endif

output = r.stdout().strip()
errortxt = r.stderr().strip()

prefix = get_option('prefix')

################################################################################
# Dependencies
################################################################################

if meson.version().version_compare('>=0.54.0')
libcjson_dep = dependency('libcjson', version: '>=1.7.14', fallback: ['cjson'])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need this if/else, since most of them are doing the exact same thing.

And use of the [provide] section means that new enough versions of meson automatically fall back with zero configuration, so it's not necessary to add special handling in meson.build.

libcimplog_dep = dependency('libcimplog')
libwdmp_dep = dependency('libwdmp')
librtMessage_dep = dependency('librtMessage')
librbuscore_dep = dependency('librbuscore')
librbus_dep = dependency('librbus')
libjansson_dep = dependency('libjansson')
else
warning('You are running an older version of meson.')
warning('In order for dependency management to be supported you need a newer version of meson (0.54+)')
# For older versions of meson, you need to have the upstream dependencies installed
# in the correct locations.
libcjson_dep = dependency('libcjson')
libcimplog_dep = dependency('libcimplog')
libwdmp_dep = dependency('libwdmp')
librtMessage_dep = dependency('librtMessage')
librbuscore_dep = dependency('librbuscore')
librbus_dep = dependency('librbus')
libjansson_dep = dependency('libjansson')
endif

all_dep = [libcjson_dep, librtMessage_dep, librbuscore_dep, librbus_dep, libcimplog_dep, libwdmp_dep, libjansson_dep]

################################################################################
# Common variable definitions
################################################################################

inc_base = 'include/'+meson.project_name()
inc_base = ['include/'+meson.project_name()]

################################################################################
# Generate the version header file
################################################################################

subdir('include/'+meson.project_name())

install_headers([headers, ver_h], subdir: meson.project_name())
install_headers(['include/'+meson.project_name()+'/cpeabs.h', ver_h], subdir: meson.project_name())

################################################################################
# Define the libraries
################################################################################

inc = include_directories(inc_base)
inc = include_directories([inc_base])

src_args = ['-lcjson', '-lpthread']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The former is already handled by libcjson_dep, the latter should not be handled by manual -l flags, see https://mesonbuild.com/FAQ.html#what-is-the-correct-way-to-use-threads-such-as-pthreads

sources = ['src/common.c']

libcpeabs = library(meson.project_name(),
sources,
include_directories: inc,
install: true)
dependencies: all_dep,
install: true,
link_args: src_args)

executable(meson.project_name(),
sources,
include_directories: inc,
dependencies: all_dep,
install: true,
link_args: src_args)

################################################################################
# Define the tests
Expand Down
37 changes: 37 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-FileCopyrightText: 2021 Comcast Cable Communications Management, LLC
# SPDX-License-Identifier: Apache-2.0

set(PROJ_CPEABS cpeabs)

if (BUILD_YOCTO)
add_definitions(-DBUILD_YOCTO)
endif (BUILD_YOCTO)

if (PLATFORM STREQUAL "DEVICE_GATEWAY")
add_definitions(-DDEVICE_GATEWAY)
elseif (PLATFORM STREQUAL "DEVICE_EXTENDER")
add_definitions(-DDEVICE_EXTENDER)
endif ()

if (PLATFORM STREQUAL "DEVICE_GATEWAY")
set(SOURCES rdkb/impl.c common.c)
set(HEADERS ${PROJECT_SOURCE_DIR}/include/cpeabs/cpeabs.h ${PROJECT_SOURCE_DIR}/src/rdkb/include/cpeabs_rdkb.h)
elseif (PLATFORM STREQUAL "DEVICE_EXTENDER")
set(SOURCES pods/impl.c pods/cpeabs_ovsdb_utils.c common.c)
set(HEADERS ${PROJECT_SOURCE_DIR}/include/cpeabs/cpeabs.h ${PROJECT_SOURCE_DIR}/src/pods/include/cpeabs_ovsdb_utils.h ${PROJECT_SOURCE_DIR}/src/pods/include/cpeabs_pod.h)
add_definitions(-DPS_FILE_PATH=${PS_FILE_PATH})
else ()
set(SOURCES pc/impl.c common.c)
endif ()

#Support cpeabs lib for backward compatibility
add_library(${PROJ_CPEABS} STATIC ${HEADERS} ${SOURCES})
add_library(${PROJ_CPEABS}.shared SHARED ${HEADERS} ${SOURCES})
set_target_properties(${PROJ_CPEABS}.shared PROPERTIES OUTPUT_NAME ${PROJ_CPEABS})
set_property(TARGET ${PROJ_CPEABS} PROPERTY C_STANDARD 99)
set_property(TARGET ${PROJ_CPEABS}.shared PROPERTY C_STANDARD 99)

install (TARGETS ${PROJ_CPEABS} DESTINATION lib${LIB_SUFFIX})
install (TARGETS ${PROJ_CPEABS}.shared DESTINATION lib${LIB_SUFFIX})
install (FILES ${HEADERS} DESTINATION include/${PROJ_CPEABS})

Loading