From 8d01019f6767ad419de3d63c6c0efa9c331c1e7d Mon Sep 17 00:00:00 2001 From: Yuvaramachandran Gurusamy Date: Wed, 4 Jun 2025 02:04:23 +0530 Subject: [PATCH 1/3] RDKEMW-4914: Prepare a build script for HdmiCec to build independently. Signed-off-by: Yuvaramachandran Gurusamy --- cov_build.sh | 97 +++++++++++++++++++++++++++ stubs/safec_lib.h | 165 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 262 insertions(+) create mode 100755 cov_build.sh create mode 100644 stubs/safec_lib.h diff --git a/cov_build.sh b/cov_build.sh new file mode 100755 index 00000000..412ffaa9 --- /dev/null +++ b/cov_build.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +WORKDIR=`pwd` +export ROOT=/usr +export INSTALL_DIR=${ROOT}/local +mkdir -p $INSTALL_DIR + +export CC=gcc +export CXX=g++ +export AR=ar +export LD=ld +export NM=nm +export RANLIB=ranlib +export STRIP=strip + +apt-get update && apt-get install -y libsoup-3.0 libcjson-dev + +cd $ROOT +rm -rf rdk-halif-hdmi_cec +git clone https://github.com/rdkcentral/rdk-halif-hdmi_cec.git +export CEC_HALIF_PATH=$ROOT/rdk-halif-hdmi_cec +mkdir -p $INSTALL_DIR/include/ccec/drivers/ +cp $CEC_HALIF_PATH/include/hdmi_cec_driver.h $INSTALL_DIR/include/ccec/drivers/ + +cd $ROOT +rm -rf telemetry +git clone https://github.com/rdkcentral/telemetry.git +export TELEMETRY_PATH=$ROOT/telemetry + +echo "##### Building HdmiCec module" +cd $WORKDIR + +# default PATHs - use `man readlink` for more info +# the path to combined build +export RDK_PROJECT_ROOT_PATH=${RDK_PROJECT_ROOT_PATH-`readlink -m ../../..`} + +# path to build script (this script) +export RDK_SCRIPTS_PATH=${RDK_SCRIPTS_PATH-`readlink -m $0 | xargs dirname`} + +# path to components sources and target +export RDK_SOURCE_PATH=${RDK_SOURCE_PATH-$RDK_SCRIPTS_PATH} + +# default component name +export RDK_COMPONENT_NAME=${RDK_COMPONENT_NAME-`basename $RDK_SOURCE_PATH`} +cd ${RDK_SOURCE_PATH} + +# functional modules +function configure() +{ + pd=`pwd` + cd $RDK_SCRIPTS_PATH + aclocal -I cfg + libtoolize --automake + autoheader + automake --foreign --add-missing + rm -f configure + autoconf + ./configure --with-libtool-sysroot=/ --disable-static --host=$HOST --disable-silent-rules --prefix=${RDK_FSROOT_PATH}/usr/ +} + +function clean() +{ + pd=`pwd` + CLEAN_BUILD=1 + dnames="$RDK_SCRIPTS_PATH" + for dName in $dnames + do + cd $dName + if [ -f Makefile ]; then + make distclean + fi + rm -f configure + rm -rf aclocal.m4 autom4te.cache config.log config.status libtool + rm -rf install + find . -iname "Makefile.in" -exec rm -f {} \; + ls cfg/* | grep -v "Makefile.am" | xargs rm -f + cd $pd + done + true #use this function to provide instructions to clean workspace +} + +function build() +{ + cd ${RDK_SCRIPTS_PATH} + + make VERBOSE=1 AM_CXXFLAGS="-I${WORKDIR}/stubs -I${WORKDIR}/osal/include -I${WORKDIR}/ccec/include -I${TELEMETRY_PATH}/include" +} + +function rebuild() +{ + clean + configure + build + clean +} + +rebuild diff --git a/stubs/safec_lib.h b/stubs/safec_lib.h new file mode 100644 index 00000000..49924ae4 --- /dev/null +++ b/stubs/safec_lib.h @@ -0,0 +1,165 @@ +/* + * If not stated otherwise in this file or this component's LICENSE file the + * following copyright and licenses apply: + * + * Copyright 2020 RDK Management + * + * 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. +*/ + +#define SAFEC_DUMMY_API 1 +#ifndef SAFEC_DUMMY_API +#include "safe_str_lib.h" +#include "safe_mem_lib.h" + +/* Macro is defined for non clobbering of the safec secure string API strcpy_s & memcpy_s function*/ +/* strcpy_s overwrites the old value and nulls the dest when encounters an error*/ +#ifndef STRCPY_S_NOCLOBBER + #define STRCPY_S_NOCLOBBER(dst,dmax,src) ((src != NULL) ? (strlen(src) < dmax ? strcpy_s(dst,dmax,src) : ESNOSPC):ESNULLP) +#endif +#define MEMCPY_S_NOCLOBBER(dst,dmax,src,len) ((src != NULL) ? (len <= dmax ? memcpy_s(dst,dmax,src,len) : ESNOSPC):ESNULLP) +#endif + +#define STRCPY_S(dest,size,source) \ + { \ + errno_t rc=-1; \ + rc=strcpy_s(dest, size, source); \ + if(rc!=EOK) \ + { \ + RDK_SAFECLIB_ERR(rc); \ + }\ +} +#define MEMCPY_S(dest,dsize,source,ssize) \ + { \ + errno_t safec_rc=-1; \ + safec_rc=memcpy_s(dest, dsize, source, ssize); \ + if(safec_rc!=EOK) \ + { \ + RDK_SAFECLIB_ERR(safec_rc); \ + }\ +} + +/* + * SAFECLIB Error Handling Logging APIs + */ +#define RDK_SAFECLIB_ERR(rc) printf("safeclib error at rc - %d %s %s:%d", rc, __FILE__, __FUNCTION__, __LINE__) + +#define ERR_CHK(rc) \ + if(rc !=EOK) { \ + RDK_SAFECLIB_ERR(rc); \ + } + +#ifdef SAFEC_DUMMY_API +#include +#include +#include +typedef int errno_t; +#define EOK 0 +#define ESNULLP 400 /* null ptr */ +#define ESLEMAX 403 /* length exceeds RSIZE_MAX */ +#define ESNOSPC 406 /* not enough space for s2 */ + +#define strcpy_s(dst,max,src) (src != NULL)?((max > strlen(src))?EOK:ESLEMAX):ESNULLP; \ + if((src != NULL) && (max > strlen(src))) strcpy(dst,src); + +#define strncpy_s(dst,max,src,len) (src != NULL)?((len <= max)?EOK:ESLEMAX):ESNULLP; \ + if((src != NULL) && (len <= max)) strncpy(dst,src,len); + +#define memset_s(dst,max_1,c,max) EOK; \ + memset(dst,c,max); + +#define strcat_s(dst,max,src) (src != NULL)?((max > strlen(src))?EOK:ESLEMAX):ESNULLP; \ + if((src != NULL) && (max > strlen(src))) strcat(dst,src); + +#define strncat_s(dst,max,src,len) (src != NULL)?((len <= max)?EOK:ESLEMAX):ESNULLP; \ + if((src != NULL) && (len <= max)) strncat(dst,src,len); + +#define memcpy_s(dst,max,src,len) EOK; \ + memcpy(dst,src,len); + +#ifndef STRCPY_S_NOCLOBBER + #define STRCPY_S_NOCLOBBER(dst,max,src) (src != NULL)?((max > strlen(src))?EOK:ESLEMAX):ESNULLP; \ + if((src != NULL) && (strlen(src) < max)) strcpy(dst, src); +#endif + +#define MEMCPY_S_NOCLOBBER(dst,max,src,len) (src != NULL) ? ((len <= max)?EOK:ESLEMAX):ESNULLP; \ + if((src != NULL) && (len <= max)) memcpy(dst, src, len); + +#define strtok_s(dest, dmax, delim, ptr) strtok_r(dest, delim, ptr) + +#define sprintf_s( dst, max, fmt, ... ) (parseFormat(dst, max, fmt, ##__VA_ARGS__) == 0) ? -ESNULLP : sprintf( dst, fmt, ##__VA_ARGS__) + +#define STRCPY_S(dest,size,source) \ + { \ + errno_t rc=-1; \ + rc=strcpy_s(dest, size, source); \ + if(rc!=EOK) \ + { \ + RDK_SAFECLIB_ERR(rc); \ + }\ +} +#define MEMCPY_S(dest,dsize,source,ssize) \ + { \ + errno_t safec_rc=-1; \ + safec_rc=memcpy_s(dest, dsize, source, ssize); \ + if(safec_rc!=EOK) \ + { \ + RDK_SAFECLIB_ERR(safec_rc); \ + }\ +} + +static inline int parseFormat(const char *dst, int max, const char *fmt, ...) +{ + va_list argp; + int len = 0; + + if((fmt == NULL) || (dst == NULL) || (max == 0)) + { + return 0; + } + + va_start(argp, fmt); + + len = vsnprintf((char *)dst, (size_t)max, fmt, argp); + + va_end(argp); + + return (max > len) ? 1 : 0; +} + +static inline int strcmp_s(const char *dst, int dmax, const char *src, int *r) { + if((src == NULL) || (dst == NULL) || (dmax == 0)) + return ESNULLP; + + *r = strcmp(dst, src); + return EOK; +} + +static inline int strcasecmp_s(const char *dst, int dmax, const char *src, int *r) { + if((src == NULL) || (dst == NULL) || (dmax == 0)) + return ESNULLP; + + *r = strcasecmp(dst, src); + return EOK; +} + +static inline int memcmp_s(const void *dst, int dmax, const void *src, int len, int *r) { + if((src == NULL) || (dst == NULL) || (dmax == 0)) + return ESNULLP; + if(len > dmax) + return ESNOSPC; + + *r = memcmp(dst, src,len); + return EOK; +} +#endif From 3e6becfac9df8f3a0dc5ef5d187e91308e05f09c Mon Sep 17 00:00:00 2001 From: Yuvaramachandran Gurusamy Date: Wed, 4 Jun 2025 02:10:33 +0530 Subject: [PATCH 2/3] RDKEMW-4914: Integrate native_full_build.yml workflow Signed-off-by: Yuvaramachandran Gurusamy --- .github/workflows/native_full_build.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/native_full_build.yml diff --git a/.github/workflows/native_full_build.yml b/.github/workflows/native_full_build.yml new file mode 100644 index 00000000..f35995e4 --- /dev/null +++ b/.github/workflows/native_full_build.yml @@ -0,0 +1,22 @@ +name: Build Component in Native Environment + +on: + push: + branches: [ main, 'sprint/**', 'release/**', develop ] + pull_request: + branches: [ main, 'sprint/**', 'release/**', topic/*, feature/RDK*, develop ] + +jobs: + build-entservices-on-pr: + name: Build HdmiCec Component in github rdkcentral + runs-on: ubuntu-latest + container: + image: ghcr.io/rdkcentral/docker-rdk-ci:latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: native build + run: | + sh -x cov_build.sh From 809829b8b8315b7cf7eb5c5bc145d6d16b99d976 Mon Sep 17 00:00:00 2001 From: Yuvaramachandran Gurusamy Date: Wed, 4 Jun 2025 02:14:33 +0530 Subject: [PATCH 3/3] RDKEMW-4914: Fix cov_build.sh script syntax issue Signed-off-by: Yuvaramachandran Gurusamy --- .github/workflows/native_full_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/native_full_build.yml b/.github/workflows/native_full_build.yml index f35995e4..6419f530 100644 --- a/.github/workflows/native_full_build.yml +++ b/.github/workflows/native_full_build.yml @@ -19,4 +19,4 @@ jobs: - name: native build run: | - sh -x cov_build.sh + ./cov_build.sh