-
Notifications
You must be signed in to change notification settings - Fork 28
Cmake and Meson Integration #9
base: main
Are you sure you want to change the base?
Changes from 40 commits
308a283
bea448a
f62b377
57d8cb4
373423e
b923059
59ba959
8572fb7
a7c4c2b
d93d6c6
d8dd3df
998d824
c5ca0fe
45e2935
baf1c8e
779a573
39e30dd
70af781
82d2b7e
66dc4d9
dcd5fd5
281ac9f
fe7f43d
fe80eaf
0aad3fa
5574067
5a236e4
f3980d0
3448ecb
87a6b0a
ab7e953
e5cea2d
21c50e3
508895c
ac273c6
003c6f5
038902e
83e6a3b
3bd97c4
90a397f
a2d6122
5709e6e
2ed7274
b7831ea
3c47aa3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,3 +32,7 @@ _testmain.go | |
| *.test | ||
| *.prof | ||
| *.xml | ||
|
|
||
| subprojects/rbus* | ||
| subprojects/rtMessage | ||
| subprojects/cJSON* | ||
| 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) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
| void getValues_rbus(const char *paramName[], const unsigned int paramCount, int index, money_trace_spans *timeSpan, param_t ***paramArr, int *retValCount, WDMP_STATUS *retStatus); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same comment as above. Think about prefixing the functions with something like |
||
| int rbus_GetValueFromDB( char* paramName, char** paramValue); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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']) | ||
|
|
@@ -15,32 +16,82 @@ if not meson.is_subproject() | |
| werror = true | ||
| endif | ||
|
|
||
| script = join_paths(meson.source_root(), 'workaround.sh') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems wrong. meson 0.55.0 added a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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']) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| 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'] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The former is already handled by |
||
| 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 | ||
|
|
||
| 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}) | ||
|
|
There was a problem hiding this comment.
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
paramNameshould be aconstif 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.There was a problem hiding this comment.
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.