From af3219378347807a8d7d8fb08287b417868abe95 Mon Sep 17 00:00:00 2001 From: "Deepak.M" Date: Tue, 20 Jan 2026 21:02:23 +0000 Subject: [PATCH 1/9] RDKB-62988 [GitHub Coverity] Enable Coverity Scan for cable-modem-agent using Native Build Integration Reason for change: Native build and Github Action Workflow Changes for Enabling Coverity Scan for github cable-modem-agent Test Procedure: verify able-modem-agent dependency and build native build and using Github workflow Risks: Low Priority: P1 Signed-off-by: Deepak.M --- cov_docker_script/README.md | 476 +++++++++++++++++++++ cov_docker_script/build_native.sh | 340 +++++++++++++++ cov_docker_script/common_build_utils.sh | 287 +++++++++++++ cov_docker_script/common_external_build.sh | 92 ++++ cov_docker_script/component_config.json | 168 ++++++++ cov_docker_script/setup_dependencies.sh | 241 +++++++++++ 6 files changed, 1604 insertions(+) create mode 100644 cov_docker_script/README.md create mode 100755 cov_docker_script/build_native.sh create mode 100755 cov_docker_script/common_build_utils.sh create mode 100755 cov_docker_script/common_external_build.sh create mode 100644 cov_docker_script/component_config.json create mode 100755 cov_docker_script/setup_dependencies.sh diff --git a/cov_docker_script/README.md b/cov_docker_script/README.md new file mode 100644 index 0000000..f449390 --- /dev/null +++ b/cov_docker_script/README.md @@ -0,0 +1,476 @@ +# Coverity Build System for RDK-B Components + +**Generic, reusable build system for any RDK-B component.** Just copy the scripts and customize `component_config.json`. + +## Quick Start + +### Complete Build (Recommended) + +```bash +cd /path/to/component/cov_docker_script +./common_external_build.sh +``` + +This runs the complete 2-step pipeline: +1. **Setup Dependencies** - Clones repos, copies headers, builds libraries +2. **Build Component** - Applies patches, builds component, installs libraries + +### Clean Build + +```bash +CLEAN_BUILD=true ./common_external_build.sh +``` + +Removes all previous build artifacts before starting. + +## Scripts Overview + +### 1. common_build_utils.sh + +**Purpose:** Shared utility library with common functions used by all build scripts. + +**Key Functions:** +- `log()`, `ok()`, `warn()`, `err()`, `step()` - Color-coded logging +- `expand_path()` - Expands `$HOME` variables in paths +- `check_dependencies()` - Validates required system tools (git, jq, gcc, make) +- `clone_repo()` - Clones git repositories with depth 1 +- `copy_headers()` - Copies header files from source to destination +- `apply_patch()` - Applies patches using Python3 for safe string replacement +- `build_autotools()`, `build_cmake()`, `build_meson()` - Build functions for different systems +- `execute_commands()` - Runs custom command sequences +- `copy_libraries()` - Finds and copies library files (.so, .a, .la) + +**Usage:** +```bash +# This script is sourced by other scripts, not run directly +source common_build_utils.sh +``` + +**Auto-configured:** +- Validates presence of git, jq, gcc, make +- Sets up color-coded terminal output +- Exports all functions for use in other scripts + +--- + +### 2. setup_dependencies.sh + +**Purpose:** Clones dependency repositories, copies headers, and builds required libraries. + +**What it does:** +1. Reads dependency list from `component_config.json` +2. Clones each repository to `$HOME/build/` +3. Copies headers to `$HOME/usr/include/rdkb/` +4. Builds libraries (if `build` section present) +5. Installs libraries to `$HOME/usr/local/lib/` and `$HOME/usr/lib/` +6. Configures PKG_CONFIG_PATH and LD_LIBRARY_PATH + +**Usage:** +```bash +# Use default config (component_config.json in same directory) +./setup_dependencies.sh + +# Use custom config file +./setup_dependencies.sh /path/to/custom_config.json + +# Clean build (removes $HOME/build and $HOME/usr first) +CLEAN_BUILD=true ./setup_dependencies.sh + +# Custom directories +BUILD_DIR=/tmp/build USR_DIR=/opt/rdkb ./setup_dependencies.sh +``` + +**Environment Variables:** +- `BUILD_DIR` - Where to clone repos (default: `$HOME/build`) +- `USR_DIR` - Install directory (default: `$HOME/usr`) +- `CLEAN_BUILD` - Set to `true` to remove previous artifacts + +**Output:** +- Headers: `$HOME/usr/include/rdkb/` +- Libraries: `$HOME/usr/local/lib/` and `$HOME/usr/lib/` + +--- + +### 3. build_native.sh + +**Purpose:** Builds the native component after dependencies are setup. + +**What it does:** +1. Reads component configuration from `component_config.json` +2. Processes native component headers (copies to destination) +3. Applies source patches (if configured) +4. Configures build environment (PKG_CONFIG_PATH, LD_LIBRARY_PATH, CPPFLAGS, LDFLAGS) +5. Runs autogen.sh or autoreconf (for autotools) +6. Executes configure/cmake with specified options +7. Builds component with make (parallel by default) +8. Copies libraries to configured output path + +**Usage:** +```bash +# Use defaults (assumes setup_dependencies.sh already run) +./build_native.sh + +# Specify custom config and component directory +./build_native.sh /path/to/config.json /path/to/component + +# With environment overrides +HEADER_PATH=/custom/include ./build_native.sh +``` + +**Prerequisites:** +- `setup_dependencies.sh` must have run successfully +- Headers and libraries must be in `$HOME/usr/` + +**Output:** +- Component libraries in path specified by `native_component.lib_output_path` +- Default: `$HOME/usr/local/lib/` + +--- + +### 4. common_external_build.sh + +**Purpose:** Orchestrates complete build pipeline (dependencies + component). + +**What it does:** +1. Validates configuration and paths +2. Runs `setup_dependencies.sh` (Step 1/2) +3. Runs `build_native.sh` (Step 2/2) +4. Displays progress banners and status + +**Usage:** +```bash +# Complete build with defaults +./common_external_build.sh + +# With custom config and component directory +./common_external_build.sh /path/to/config.json /path/to/component + +# Clean build +CLEAN_BUILD=true ./common_external_build.sh +``` + +**This is the recommended entry point for complete builds.** + +**Output:** +- Complete dependency setup +- Built component with all libraries +- Success/failure status for entire pipeline + +--- + +### 5. component_config.json + +**Purpose:** JSON configuration defining all dependencies and build settings. + +**Key Sections:** +- `dependencies.repos[]` - List of dependency repositories +- `native_component` - Component-specific build configuration +- `source_patches[]` - Patches to apply before building + +**Not a script, but required by all build scripts.** + +See **Configuration** section below for detailed format. + +--- + +## Configuration + +All build configuration is in **`component_config.json`**. This file defines: +- Dependencies to clone and build +- Headers to copy +- Patches to apply +- Build settings + +### Key Configuration Sections + +#### Dependencies + +```json +{ + "dependencies": { + "repos": [ + { + "name": "repo-name", + "repo": "https://github.com/org/repo.git", + "branch": "main", + "header_paths": [ + { "source": "include", "destination": "$HOME/usr/include/rdkb" } + ], + "build": { + "type": "autotools|cmake|meson|commands|script", + "configure_flags": "--prefix=$HOME/usr", + "parallel_make": true + } + } + ] + } +} +``` + +**Note:** The `build` section is optional - omit it for header-only dependencies. + +#### Native Component + +```json +{ + "native_component": { + "name": "component-name", + "include_path": "$HOME/usr/include/rdkb/", + "lib_output_path": "$HOME/usr/local/lib/", + "header_sources": [ + { "source": "source/ccsp/include", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/cosa/include", "destination": "$HOME/usr/include/rdkb" } + ], + "source_patches": [ + { + "file": "$HOME/usr/include/rdkb/header.h", + "type": "replace", + "search": "old text", + "replace": "new text" + } + ], + "build": { + "type": "autotools|cmake", + "configure_options": [ + "CPPFLAGS=-I$HOME/usr/include/rdkb", + "LDFLAGS=-L$HOME/usr/lib" + ] + } + } +} +``` + +**Configuration Details:** +- `header_sources[]` - Component headers to copy before building. Source paths are relative to component directory. +- `source_patches[]` - Patches to apply after headers are copied. Use absolute paths with `$HOME` for files in install directories. +- `include_path` - Colon-separated include paths for building +- `lib_output_path` - Where to install built libraries + +## Build Types + +### Autotools +```json +"build": { + "type": "autotools", + "configure_flags": "--prefix=$HOME/usr --enable-feature" +} +``` + +### CMake +```json +"build": { + "type": "cmake", + "build_dir": "build", + "cmake_flags": "-DCMAKE_INSTALL_PREFIX=$HOME/usr" +} +``` + +### Meson +```json +"build": { + "type": "meson", + "meson_flags": "--prefix=$HOME/usr" +} +``` + +### Custom Commands +```json +"build": { + "type": "commands", + "commands": ["meson setup build --prefix=$HOME/usr", "meson compile -C build"] +} +``` + +### Custom Script +```json +"build": { + "type": "script", + "script": "cov_docker_script/build.sh" +} +``` + +## Troubleshooting + +### Build fails with "command not found" +**Install required tools:** +```bash +sudo apt-get install git jq gcc make autoconf automake libtool cmake python3 +``` + +### Dependencies fail to build +- Check `$HOME/build/` for build logs +- Verify `configure_flags` in JSON are correct +- Ensure system packages for build type are installed (cmake, meson, etc.) + +### Headers not found during component build +- Verify `setup_dependencies.sh` completed successfully +- Check `$HOME/usr/include/rdkb/` contains expected headers +- Verify `header_paths` in JSON point to correct source directories + +### Libraries not found +- Check library directories: + - `$HOME/usr/local/lib/` - Primary location + - `$HOME/usr/lib/` - Secondary location +- Verify dependencies built successfully (look for `.so`, `.a` files) +- Check build logs for `make install` errors + +### Patches fail to apply +- **File not found:** Verify file path is relative to component directory +- **Use `../`** for files outside component (e.g., `../usr/include/rdkb/header.h`) +- **Exact match required:** Search string must exactly match file content +- **Python3 required:** Ensure Python3 is installed + +### Clean build needed +```bash +# Remove all previous build artifacts +CLEAN_BUILD=true ./common_external_build.sh +``` + +### Validate configuration +```bash +# Check JSON syntax +jq . component_config.json + +# List all dependencies +jq '.dependencies.repos[].name' component_config.json +``` + +## Directory Structure After Build + +``` +$HOME/ +├── build/ # Cloned repositories (removed after build) +└── usr/ + ├── include/ + │ └── rdkb/ # All dependency headers + ├── lib/ # Secondary library location + └── local/ + └── lib/ # Primary library location (.so, .a files) +``` + +## Environment Variables + +These are automatically configured by the scripts: + +- `BUILD_DIR` - Repository clone location (default: `$HOME/build`) +- `USR_DIR` - Install directory (default: `$HOME/usr`) +- `PKG_CONFIG_PATH` - Configured for dependency detection +- `LD_LIBRARY_PATH` - Configured for runtime linking +- `CPPFLAGS` - Include paths for compilation +- `LDFLAGS` - Library paths for linking +- `CLEAN_BUILD` - Set to `true` to clean before build + +## Required System Tools + +- `bash` (version 4.0+) +- `git` - Repository cloning +- `jq` - JSON parsing +- `gcc`/`g++` - C/C++ compiler +- `make` - Build automation +- `python3` - Patch application + +**Optional (based on dependency types):** +- `autoconf`, `automake`, `libtool` - For autotools builds +- `cmake` - For CMake builds +- `meson`, `ninja` - For Meson builds +- `pkg-config` - For dependency detection + +--- + +## Adopting for Another Component + +**These scripts are 100% generic and component-agnostic.** To use them for a different component: + +### Step 1: Copy the Scripts + +```bash +# Copy all scripts to your component's build directory +cp common_build_utils.sh setup_dependencies.sh build_native.sh common_external_build.sh /path/to/new-component/cov_docker_script/ + +# Make executable +chmod +x /path/to/new-component/cov_docker_script/*.sh +``` + +### Step 2: Create component_config.json + +Create a new `component_config.json` for your component: + +```json +{ + "_comment": "Component Build Configuration", + "_version": "2.0", + + "dependencies": { + "repos": [ + { + "name": "your-dependency", + "repo": "https://github.com/org/your-dependency.git", + "branch": "main", + "header_paths": [ + { "source": "include", "destination": "$HOME/usr/include/rdkb" } + ], + "build": { + "type": "cmake", + "cmake_flags": "-DCMAKE_INSTALL_PREFIX=$HOME/usr" + } + } + ] + }, + + "native_component": { + "name": "your-component-name", + "include_path": "$HOME/usr/include/rdkb/", + "lib_output_path": "$HOME/usr/local/lib/", + "source_patches": [], + "build": { + "type": "autotools", + "configure_options": [ + "CPPFLAGS=-I$HOME/usr/include/rdkb", + "LDFLAGS=-L$HOME/usr/local/lib" + ] + } + } +} +``` + +### Step 3: Run the Build + +```bash +cd /path/to/new-component/cov_docker_script +./common_external_build.sh +``` + +**That's it!** No script modifications needed. The scripts automatically: +- Read component name from JSON +- Find component directory (parent of script directory) +- Clone dependencies listed in JSON +- Copy headers from paths specified in JSON +- Build using build type specified in JSON +- Apply patches listed in JSON + +### What Makes These Scripts Generic? + +✅ **No hardcoded paths** - All paths from JSON or environment variables +✅ **No hardcoded component names** - Component name read from JSON +✅ **No hardcoded dependencies** - All dependencies defined in JSON +✅ **No hardcoded build commands** - Build type and options from JSON +✅ **Flexible build systems** - Supports autotools, cmake, meson, custom commands, custom scripts +✅ **Configurable patches** - All patches defined in JSON + +### Example: Migrating from Utopia to CcspPandM + +```bash +# 1. Copy scripts to CcspPandM +cp utopia/cov_docker_script/*.sh ccsp-p-and-m/cov_docker_script/ + +# 2. Create ccsp-p-and-m/cov_docker_script/component_config.json +# Update: component name, dependencies, build settings + +# 3. Run build +cd ccsp-p-and-m/cov_docker_script +./common_external_build.sh +``` + +**Scripts remain unchanged - only JSON changes!** + +--- diff --git a/cov_docker_script/build_native.sh b/cov_docker_script/build_native.sh new file mode 100755 index 0000000..ce1bd67 --- /dev/null +++ b/cov_docker_script/build_native.sh @@ -0,0 +1,340 @@ +#!/usr/bin/env bash +set -e + +################################################################################ +# Generic Native Component Build Script +# Usage: ./build_native.sh [config_file] [component_dir] +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CONFIG_FILE="${1:-$SCRIPT_DIR/component_config.json}" +COMPONENT_DIR="${2:-$(cd "$SCRIPT_DIR/.." && pwd)}" + +# Source common utilities +source "$SCRIPT_DIR/common_build_utils.sh" + +# Validate environment +if [[ ! -f "$CONFIG_FILE" ]]; then + err "Config file not found: $CONFIG_FILE" + exit 1 +fi + +if [[ ! -d "$COMPONENT_DIR" ]]; then + err "Component directory not found: $COMPONENT_DIR" + exit 1 +fi + +check_dependencies || exit 1 + +# Read component configuration +COMPONENT_NAME=$(jq -r '.native_component.name' "$CONFIG_FILE") +BUILD_TYPE=$(jq -r '.native_component.build.type' "$CONFIG_FILE") +HEADER_PATH=$(expand_path "$(jq -r '.native_component.include_path' "$CONFIG_FILE")") +LIB_PATH=$(expand_path "$(jq -r '.native_component.lib_output_path' "$CONFIG_FILE")") + +# Configure environment +configure_environment() { + print_banner "Building Native Component: $COMPONENT_NAME" + + log "Component: $COMPONENT_NAME" + log "Build type: $BUILD_TYPE" + log "Component directory: $COMPONENT_DIR" + log "Header path: $HEADER_PATH" + log "Library path: $LIB_PATH" + echo "" + + # Setup PKG_CONFIG_PATH and LD_LIBRARY_PATH + export PKG_CONFIG_PATH="$LIB_PATH/pkgconfig:${PKG_CONFIG_PATH:-}" + export LD_LIBRARY_PATH="$LIB_PATH:${LD_LIBRARY_PATH:-}" + + # Add common include and lib paths + export CPPFLAGS="${CPPFLAGS:-} -I$HEADER_PATH" + export CFLAGS="${CFLAGS:-} -I$HEADER_PATH" + export LDFLAGS="${LDFLAGS:-} -L$LIB_PATH" + + log "Environment configured" + log " PKG_CONFIG_PATH=$PKG_CONFIG_PATH" + log " LD_LIBRARY_PATH=$LD_LIBRARY_PATH" + echo "" +} + +# Apply source patches +apply_source_patches() { + local patch_count + patch_count=$(jq -r '.native_component.source_patches // [] | length' "$CONFIG_FILE") + + if [[ "$patch_count" -eq 0 ]]; then + log "No source patches configured" + return 0 + fi + + step "Applying source patches ($patch_count patches)" + + local i=0 + while [[ $i -lt $patch_count ]]; do + local file search replace type content + file=$(jq -r ".native_component.source_patches[$i].file" "$CONFIG_FILE") + type=$(jq -r ".native_component.source_patches[$i].type // \"replace\"" "$CONFIG_FILE") + search=$(jq -r ".native_component.source_patches[$i].search // \"\"" "$CONFIG_FILE") + replace=$(jq -r ".native_component.source_patches[$i].replace // \"\"" "$CONFIG_FILE") + content=$(jq -r ".native_component.source_patches[$i].content // \"\"" "$CONFIG_FILE") + + # Expand $HOME in file path, then resolve relative paths from COMPONENT_DIR + local expanded_file=$(expand_path "$file") + local target_file + if [[ "$expanded_file" = /* ]]; then + # Absolute path - use as is + target_file="$expanded_file" + else + # Relative path - prepend COMPONENT_DIR + target_file="$COMPONENT_DIR/$expanded_file" + fi + + if ! apply_patch "$target_file" "$search" "$replace" "$type" "$content"; then + err "Failed to apply patch $((i+1))/$patch_count" + return 1 + fi + + i=$((i + 1)) + done + + ok "All patches applied successfully" + echo "" + return 0 +} + +# Process native headers +process_native_headers() { + local header_count + header_count=$(jq -r '.native_component.header_sources // [] | length' "$CONFIG_FILE") + + if [[ "$header_count" -eq 0 ]]; then + log "No header sources configured" + return 0 + fi + + step "Processing native component headers ($header_count sources)" + + local i=0 + while [[ $i -lt $header_count ]]; do + local src dst + src=$(jq -r ".native_component.header_sources[$i].source" "$CONFIG_FILE") + dst=$(jq -r ".native_component.header_sources[$i].destination" "$CONFIG_FILE") + + # Expand paths + src="$COMPONENT_DIR/$src" + dst=$(expand_path "$dst") + + copy_headers "$src" "$dst" + i=$((i + 1)) + done + + ok "All headers processed successfully" + echo "" + return 0 +} + +# Build with autotools +build_component_autotools() { + cd "$COMPONENT_DIR" + + # Read configure options as array + local configure_options=() + local opt_count + opt_count=$(jq -r '.native_component.build.configure_options // [] | length' "$CONFIG_FILE") + + local i=0 + while [[ $i -lt $opt_count ]]; do + local option + option=$(jq -r ".native_component.build.configure_options[$i]" "$CONFIG_FILE") + option=$(expand_path "$option") + configure_options+=("$option") + i=$((i + 1)) + done + + # Run autogen if exists + if [[ -f "./autogen.sh" ]]; then + step "Running autogen.sh" + chmod +x ./autogen.sh + # Set NOCONFIGURE to prevent autogen.sh from automatically running configure + if ! NOCONFIGURE=1 ./autogen.sh; then + err "autogen.sh failed" + return 1 + fi + ok "autogen.sh completed" + echo "" + fi + + # Configure + step "Running configure" + + # Export configure options as environment variables + for option in "${configure_options[@]}"; do + export "$option" + done + + if ! ./configure; then + err "Configure failed" + return 1 + fi + ok "Configure completed" + echo "" + + # Make + local make_targets + make_targets=$(jq -r '.native_component.build.make_targets[]? // "all"' "$CONFIG_FILE" | tr '\n' ' ') + + local parallel_make + parallel_make=$(jq -r '.native_component.build.parallel_make // true' "$CONFIG_FILE") + + local make_jobs="" + [[ "$parallel_make" == "true" ]] && make_jobs="-j$(nproc)" + + step "Running make $make_jobs $make_targets" + if ! make $make_jobs $make_targets; then + err "Make failed" + return 1 + fi + ok "Make completed" + echo "" + + return 0 +} + +# Run pre-build commands from native_component.pre_build_commands[] +run_pre_build_commands() { + + log "copying python files generic..." + copy_python_files_generic + + log "Running pre-build commands..." + + if [[ -z "$CONFIG_FILE" ]] || [[ ! -f "$CONFIG_FILE" ]]; then + err "CONFIG_FILE not set or file missing" + return 1 + fi + + if [[ -z "$COMPONENT_DIR" ]] || [[ ! -d "$COMPONENT_DIR" ]]; then + err "COMPONENT_DIR not set or directory missing" + return 1 + fi + + local cmd_count + cmd_count=$(jq '.native_component.pre_build_commands // [] | length' "$CONFIG_FILE") + + if [[ "$cmd_count" -eq 0 ]]; then + log "No pre-build commands to run" + return 0 + fi + + pushd "$COMPONENT_DIR" >/dev/null || { + err "Failed to enter component root: $COMPONENT_DIR" + return 1 + } + + local i description command + for ((i=0; i/dev/null + return 1 + fi + done + + popd >/dev/null + ok "Pre-build commands completed" + return 0 +} + +# Build with CMake +build_component_cmake() { + cd "$COMPONENT_DIR" + + local build_dir cmake_flags make_targets parallel_make + build_dir=$(jq -r '.native_component.build.build_dir // "build"' "$CONFIG_FILE") + cmake_flags=$(jq -r '.native_component.build.cmake_flags // empty' "$CONFIG_FILE") + cmake_flags=$(expand_path "$cmake_flags") + make_targets=$(jq -r '.native_component.build.make_targets[]? // "all"' "$CONFIG_FILE" | tr '\n' ' ') + parallel_make=$(jq -r '.native_component.build.parallel_make // true' "$CONFIG_FILE") + + build_cmake "$COMPONENT_DIR" "$build_dir" "$cmake_flags" "$make_targets" "$parallel_make" || return 1 + + return 0 +} + +# Install libraries +install_libraries() { + step "Installing libraries to $LIB_PATH" + mkdir -p "$LIB_PATH" + + # Find and copy all library files (shared objects, static, libtool archives) + find "$COMPONENT_DIR" \( -name "*.so*" -o -name "*.a" -o -name "*.la*" \) \( -type f -o -type l \) -exec cp -Pv {} "$LIB_PATH/" \; 2>/dev/null || true + + ok "Libraries installed" + echo "" +} + +# Main execution +main() { + configure_environment + + # Process native headers + if ! process_native_headers; then + err "Header processing failed" + exit 1 + fi + + # Apply patches + if ! apply_source_patches; then + err "Patch application failed" + exit 1 + fi + + # Run pre-build commands + if ! run_pre_build_commands; then + err "Pre-build commands failed" + exit 1 + fi + + # Build based on type + case "$BUILD_TYPE" in + autotools) + if ! build_component_autotools; then + err "Autotools build failed" + exit 1 + fi + ;; + + cmake) + if ! build_component_cmake; then + err "CMake build failed" + exit 1 + fi + ;; + + *) + err "Unsupported build type: $BUILD_TYPE" + exit 1 + ;; + esac + + # Install libraries + install_libraries + + print_banner "Native Component Build Completed Successfully" + log "Component: $COMPONENT_NAME" + log "Headers: $HEADER_PATH" + log "Libraries: $LIB_PATH" + echo "" +} + +main diff --git a/cov_docker_script/common_build_utils.sh b/cov_docker_script/common_build_utils.sh new file mode 100755 index 0000000..a38db9e --- /dev/null +++ b/cov_docker_script/common_build_utils.sh @@ -0,0 +1,287 @@ +#!/usr/bin/env bash + +################################################################################ +# Common Build Utilities +# Shared functions for dependency and component builds +################################################################################ + +# Colors +RED="\e[31m"; GREEN="\e[32m"; YELLOW="\e[33m" +BLUE="\e[34m"; CYAN="\e[36m"; BOLD="\e[1m"; NC="\e[0m" + +# Logging functions +log() { echo -e "${CYAN}[INFO]${NC} $1"; } +ok() { echo -e "${GREEN}[OK]${NC} $1"; } +warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } +err() { echo -e "${RED}[ERROR]${NC} $1"; } +step() { echo -e "${BLUE}[STEP]${NC} $1"; } + +# Expand $HOME in paths +expand_path() { + echo "${1//\$HOME/$HOME}" +} + +# Validate required tools +check_dependencies() { + local required_tools=("git" "jq" "gcc" "make") + local missing=() + + for tool in "${required_tools[@]}"; do + if ! command -v "$tool" &> /dev/null; then + missing+=("$tool") + fi + done + + if [ ${#missing[@]} -gt 0 ]; then + err "Missing required tools: ${missing[*]}" + err "Please install them before continuing" + return 1 + fi + return 0 +} + +# Clone a git repository +clone_repo() { + local name="$1" repo="$2" branch="$3" dest="$4" + + if [[ -d "$dest" ]]; then + warn "$name already exists, skipping clone" + return 0 + fi + + log "Cloning $name (branch: $branch)" + if ! git clone --branch "$branch" "$repo" "$dest" --depth 1; then + err "Failed to clone $name" + return 1 + fi + ok "$name cloned successfully" + return 0 +} + +# Copy headers from source to destination +copy_headers() { + local src="$1" dst="$2" + + src=$(expand_path "$src") + dst=$(expand_path "$dst") + + mkdir -p "$dst" + + if [[ -d "$src" ]]; then + log "Copying headers: $src → $dst" + if ! find "$src" -maxdepth 1 -name "*.h" -exec cp {} "$dst/" \; 2>/dev/null; then + warn "No headers found in $src" + fi + else + warn "Header source not found: $src" + fi +} + +# Apply source patches +apply_patch() { + local file="$1" search="$2" replace="$3" type="${4:-replace}" content="$5" + + if [[ "$type" == "create" ]]; then + log "Creating file: $file" + local dir=$(dirname "$file") + mkdir -p "$dir" + echo -e "$content" > "$file" + if [[ $? -ne 0 ]]; then + err "Failed to create file: $file" + return 1 + fi + ok "File created successfully" + return 0 + fi + + if [[ ! -f "$file" ]]; then + err "Patch target not found: $file" + return 1 + fi + + log "Patching: $file ($type)" + + # Use python for safe string replacement with literal matching + if ! python3 -c " +import sys +with open('$file', 'r') as f: + content = f.read() +content = content.replace('''$search''', '''$replace''') +with open('$file', 'w') as f: + f.write(content) +"; then + err "Failed to apply patch to $file" + return 1 + fi + + ok "Patch applied successfully" + return 0 +} + +# Build with autotools +build_autotools() { + local repo_dir="$1" configure_flags="$2" make_targets="$3" parallel_make="${4:-true}" + + pushd "$repo_dir" >/dev/null || return 1 + + # Run autogen or autoreconf if needed + if [[ -f "autogen.sh" ]]; then + step "Running autogen.sh" + chmod +x autogen.sh + # Set NOCONFIGURE to prevent autogen.sh from automatically running configure + if ! NOCONFIGURE=1 ./autogen.sh; then + err "autogen.sh failed" + popd >/dev/null + return 1 + fi + elif [[ -f "configure.ac" ]] || [[ -f "configure.in" ]]; then + step "Running autoreconf" + if ! autoreconf -fi; then + err "autoreconf failed" + popd >/dev/null + return 1 + fi + fi + + # Configure + step "Running configure" + # Ensure PKG_CONFIG_PATH is set for configure + export PKG_CONFIG_PATH="${HOME}/usr/local/lib/pkgconfig:${HOME}/usr/lib/pkgconfig:${PKG_CONFIG_PATH:-}" + if ! eval "./configure $configure_flags"; then + err "Configure failed" + popd >/dev/null + return 1 + fi + + # Make + local make_jobs="" + [[ "$parallel_make" == "true" ]] && make_jobs="-j$(nproc)" + + step "Running make $make_jobs $make_targets" + if ! make $make_jobs $make_targets; then + err "Make failed" + popd >/dev/null + return 1 + fi + + popd >/dev/null + ok "Autotools build completed" + return 0 +} + +# Build with CMake +build_cmake() { + local repo_dir="$1" build_dir="$2" cmake_flags="$3" make_targets="$4" parallel_make="${5:-true}" + + pushd "$repo_dir" >/dev/null || return 1 + mkdir -p "$build_dir" + + step "Running cmake" + if ! eval "cmake -S . -B $build_dir $cmake_flags"; then + err "CMake configuration failed" + popd >/dev/null + return 1 + fi + + local make_jobs="" + [[ "$parallel_make" == "true" ]] && make_jobs="-j$(nproc)" + + step "Building with make $make_jobs $make_targets" + if ! make $make_jobs -C "$build_dir" $make_targets; then + err "Make failed" + popd >/dev/null + return 1 + fi + + popd >/dev/null + ok "CMake build completed" + return 0 +} + +# Build with Meson +build_meson() { + local repo_dir="$1" build_dir="$2" meson_flags="$3" ninja_targets="$4" + + pushd "$repo_dir" >/dev/null || return 1 + + step "Running meson setup" + if ! eval "meson setup $build_dir $meson_flags"; then + err "Meson setup failed" + popd >/dev/null + return 1 + fi + + step "Running ninja -C $build_dir $ninja_targets" + if ! ninja -C "$build_dir" $ninja_targets; then + err "Ninja build failed" + popd >/dev/null + return 1 + fi + + popd >/dev/null + ok "Meson build completed" + return 0 +} + +# Execute custom commands +execute_commands() { + local repo_dir="$1" config_file="$2" index="$3" + + pushd "$repo_dir" >/dev/null || return 1 + + local cmd_count + cmd_count=$(jq ".dependencies.repos[$index].build.commands | length" "$config_file") + + local i=0 + while [[ $i -lt $cmd_count ]]; do + local cmd + cmd=$(jq -r ".dependencies.repos[$index].build.commands[$i]" "$config_file") + step "Executing: $cmd" + if ! eval "$cmd"; then + err "Command failed: $cmd" + popd >/dev/null + return 1 + fi + i=$((i + 1)) + done + + popd >/dev/null + ok "Commands executed successfully" + return 0 +} + +# Copy shared libraries to destination +copy_libraries() { + local src_dir="$1" dst_dir="$2" + + dst_dir=$(expand_path "$dst_dir") + mkdir -p "$dst_dir" + + log "Copying libraries to $dst_dir" + find "$src_dir" \( -name "*.so*" -o -name "*.a" -o -name "*.la*" \) \( -type f -o -type l \) -exec cp -Pv {} "$dst_dir/" \; 2>/dev/null || true +} + +# Print banner +print_banner() { + local title="$1" + echo "" + echo -e "${BLUE}================================================${NC}" + echo -e "${BLUE} $title${NC}" + echo -e "${BLUE}================================================${NC}" + echo "" +} + +# Print section header +print_section() { + local title="$1" + echo "" + echo -e "${BLUE}------------------------------------------------${NC}" + echo -e "${BOLD}${CYAN}▶ $title${NC}" + echo -e "${BLUE}------------------------------------------------${NC}" +} + +# Export this file's functions +export -f log ok warn err step +export -f expand_path check_dependencies clone_repo copy_headers apply_patch +export -f build_autotools build_cmake build_meson execute_commands copy_libraries +export -f print_banner print_section diff --git a/cov_docker_script/common_external_build.sh b/cov_docker_script/common_external_build.sh new file mode 100755 index 0000000..3826f78 --- /dev/null +++ b/cov_docker_script/common_external_build.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash +set -e + +################################################################################ +# Common External Build Script +# Orchestrates the complete build process: dependencies + native component +# Usage: ./common_external_build.sh [config_file] [component_dir] +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CONFIG_FILE="${1:-$SCRIPT_DIR/component_config.json}" +COMPONENT_DIR="${2:-$(cd "$SCRIPT_DIR/.." && pwd)}" + +# Source common utilities +source "$SCRIPT_DIR/common_build_utils.sh" + +# Validate inputs +if [[ ! -f "$CONFIG_FILE" ]]; then + err "Config file not found: $CONFIG_FILE" + exit 1 +fi + +if [[ ! -d "$COMPONENT_DIR" ]]; then + err "Component directory not found: $COMPONENT_DIR" + exit 1 +fi + +# Get component name from config +COMPONENT_NAME=$(jq -r '.native_component.name' "$CONFIG_FILE") + +# Print main banner +echo "" +echo -e "${BOLD}${BLUE}================================================================${NC}" +echo -e "${BOLD}${BLUE} Complete Build Pipeline for: ${COMPONENT_NAME}${NC}" +echo -e "${BOLD}${BLUE}================================================================${NC}" +echo "" +log "Configuration: $CONFIG_FILE" +log "Component directory: $COMPONENT_DIR" +echo "" + +# Step 1: Setup Dependencies +print_banner "Step 1/2: Setting Up Dependencies" +log "Running dependency setup script..." +echo "" + +if ! "$SCRIPT_DIR/setup_dependencies.sh" "$CONFIG_FILE"; then + err "Dependency setup failed" + exit 1 +fi + +echo "" +ok "Dependencies setup completed successfully" +echo "" + +# Step 2: Build Native Component +print_banner "Step 2/2: Building Native Component" +log "Running native component build script..." +echo "" + +if ! "$SCRIPT_DIR/build_native.sh" "$CONFIG_FILE" "$COMPONENT_DIR"; then + err "Native component build failed" + exit 1 +fi + +echo "" +ok "Native component build completed successfully" +echo "" + +# Final summary +echo "" +echo -e "${BOLD}${GREEN}================================================================${NC}" +echo -e "${BOLD}${GREEN} Complete Build Pipeline Completed Successfully!${NC}" +echo -e "${BOLD}${GREEN}================================================================${NC}" +echo "" +log "Component: ${BOLD}$COMPONENT_NAME${NC}" +log "All dependencies built and installed" +log "Native component compiled successfully" +echo "" + +# Display installation paths +HEADER_PATH=$(jq -r '.native_component.include_path' "$CONFIG_FILE") +LIB_PATH=$(jq -r '.native_component.lib_output_path' "$CONFIG_FILE") +HEADER_PATH="${HEADER_PATH//\$HOME/$HOME}" +LIB_PATH="${LIB_PATH//\$HOME/$HOME}" + +echo -e "${CYAN}Installation Locations:${NC}" +log " Headers: $HEADER_PATH" +log " Libraries: $LIB_PATH" +echo "" + +echo -e "${GREEN}✓ Ready for Coverity analysis or deployment${NC}" +echo "" diff --git a/cov_docker_script/component_config.json b/cov_docker_script/component_config.json new file mode 100644 index 0000000..9d8fb23 --- /dev/null +++ b/cov_docker_script/component_config.json @@ -0,0 +1,168 @@ +{ + "_comment": "Component Build Configuration for Coverity/Native Builds", + "_version": "2.0", + "_description": "Defines dependencies and build settings for the native component", + + "dependencies": { + "_comment": "External repositories needed by this component", + "repos": [ + { + "name": "rbus", + "repo": "https://github.com/rdkcentral/rbus.git", + "branch": "v2.7.0", + "header_paths": [ + { "source": "include", "destination": "$HOME/usr/include/rdkb/rbus" }, + { "source": "src/rbus", "destination": "$HOME/usr/include/rdkb/rbus" }, + { "source": "src/core", "destination": "$HOME/usr/include/rdkb/rbus" }, + { "source": "src/rtmessage", "destination": "$HOME/usr/include/rdkb/rtmessage" } + ], + "build": { + "type": "cmake", + "build_dir": "build", + "cmake_flags": "-DCMAKE_INSTALL_PREFIX=$HOME/usr -DCMAKE_PREFIX_PATH=/usr -DBUILD_FOR_DESKTOP=ON -DCMAKE_BUILD_TYPE=Debug" + } + }, + { + "name": "safec", + "repo": "https://github.com/rurban/safeclib.git", + "branch": "master", + "header_paths": [ + { "source": "include", "destination": "$HOME/usr/include/rdkb" } + ] + }, + { + "name": "trower-base64", + "repo": "https://github.com/xmidt-org/trower-base64.git", + "branch": "v1.2.7", + "header_paths": [ + { "source": "include/trower-base64", "destination": "$HOME/usr/include/rdkb" }, + { "source": "include/trower-base64", "destination": "$HOME/usr/include/rdkb/trower-base64" } + ], + "build": { + "type": "commands", + "commands": [ + "meson setup build --prefix=$HOME/usr", + "meson compile -C build" + ] + } + }, + { + "name": "Utopia", + "repo": "https://github.com/rdkcentral/utopia.git", + "branch": "feature/cov_native_build", + "header_paths": [ + { "source": "source/include/sysevent", "destination": "$HOME/usr/include/rdkb/sysevent" }, + { "source": "source/include/syscfg", "destination": "$HOME/usr/include/rdkb/syscfg" }, + { "source": "source/include", "destination": "$HOME/usr/include/rdkb/utctx" }, + { "source": "source/include", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/utapi/lib", "destination": "$HOME/usr/include/rdkb/utapi" }, + { "source": "source/include/ulog", "destination": "$HOME/usr/include/rdkb/ulog" }, + { "source": "source/util/utils", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/sysevent/lib", "destination": "$HOME/usr/include/rdkb/sysevent" }, + { "source": "source/util/print_uptime", "destination": "$HOME/usr/include/rdkb" } + ], + "build": { + "type": "script", + "script": "cov_docker_script/common_external_build.sh" + } + }, + { + "name": "Utopia-headers", + "repo": "https://github.com/rdkcentral/utopia.git", + "branch": "main", + "header_paths": [ + { "source": "source/include/sysevent", "destination": "$HOME/usr/include/rdkb/sysevent" }, + { "source": "source/include/syscfg", "destination": "$HOME/usr/include/rdkb/syscfg" }, + { "source": "source/include/utctx", "destination": "$HOME/usr/include/rdkb/utctx" }, + { "source": "source/include", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/utapi/lib", "destination": "$HOME/usr/include/rdkb/utapi" }, + { "source": "source/include/ulog", "destination": "$HOME/usr/include/rdkb/ulog" }, + { "source": "source/util/utils", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/sysevent/lib", "destination": "$HOME/usr/include/rdkb/sysevent" }, + { "source": "source/util/print_uptime", "destination": "$HOME/usr/include/rdkb" } + ] + }, + { + "name": "rdkb-halif-vlan", + "repo": "https://github.com/rdkcentral/rdkb-halif-cm.git", + "branch": "main", + "header_paths": [ + { "source": "include", "destination": "$HOME/usr/include" } + ] + }, + { + "name": "rdkb-halif-dhcp", + "repo": "https://github.com/rdkcentral/rdkb-halif-vlan.git", + "branch": "main", + "header_paths": [ + { "source": "include", "destination": "$HOME/usr/include" } + ] + }, + { + "name": "rdkb-halif-wifi", + "repo": "https://github.com/rdkcentral/rdkb-halif-wifi.git", + "branch": "develop", + "header_paths": [ + { "source": "include", "destination": "$HOME/usr/include" } + ] + }, + { + "name": "rdkb-halif-cm", + "repo": "https://github.com/rdkcentral/rdkb-halif-cm.git", + "branch": "main", + "header_paths": [ + { "source": "include", "destination": "$HOME/usr/include" } + ] + }, + { + "name": "hal-cm-generic", + "repo": "https://code.rdkcentral.com/r/rdkb/components/opensource/ccsp/hal" , + "branch": "rdk-next", + "repo_dir": "hal-cm-generic/source/cm", + "include_path": "$HOME/usr/include/rdkb/", + "lib_output_path": "$HOME/usr/local/lib", + "build": { + "type": "commands", + "commands": [ + "echo \"${PWD}\"", + "cd source/cm", + "autoreconf -i", + "./configure", + "make CFLAGS=\"-Os -pipe -g -feliminate-unused-debug-types -I${HOME}/usr/include/rdkb -I${HOME}/build/rdkb-halif-cm/include\" LDFLAGS=\"-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed\"" + ] + } + } + ] + }, + + "native_component": { + "_comment": "Configuration for the main component being built", + "name": "cable-modem-agent", + "include_path": "$HOME/usr/include/rdkb", + "lib_output_path": "$HOME/usr/local/lib", + "pre_build_commands": [ + { + "description": "Generate dm_pack_datamodel.c from XML", + "command": "python3 $HOME/usr/include/rdkb/dm_pack_code_gen.py config-arm/TR181-CM.XML source/CMAgentSsp/dm_pack_datamodel.c" + } + ], + "header_sources": [ + { "source": "config.h", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/CMAgentSsp", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/Custom", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/TR-181/include", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/TR-181/middle_layer_src", "destination": "$HOME/usr/include/rdkb" }, + { "source": "source/test/CcspCMAgentDmlTest", "destination": "$HOME/usr/include/rdkb" } + ], + "build": { + "type": "autotools", + "build_dir": "build", + "configure_options": [ + "CPPFLAGS=-I$HOME/usr/include -I$HOME/usr/include/rdkb -I/usr/include -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I$HOME/usr/include/rdkb/rtmessage -I$HOME/usr/include/rdkb/MoCASsp", + "CFLAGS=-DSAFEC_DUMMY_API -D_ANSC_USE_OPENSSL_ -D_NO_PKI_KB5_SUPPORT -DENABLE_LLD_SUPPORT", + "SRC_DIRS=$HOME/build/moca-agent/source/MoCASsp", + "LDFLAGS=-L$HOME/usr/lib -L$HOME/usr/lib/ -L$HOME/usr/local/lib -L/usr/lib -L/usr/lib/x86_64-linux-gnu -L$HOME/usr/lib/x86_64-linux-gnu -L$HOME/usr/include/rdkb/MoCASsp -L$HOME/build/moca-agent/source/MoCASsp -ldbus-1 -lccsp_common -Wl,--allow-shlib-undefined -Wl,--unresolved-symbols=ignore-all" + ] + } + } +} diff --git a/cov_docker_script/setup_dependencies.sh b/cov_docker_script/setup_dependencies.sh new file mode 100755 index 0000000..a4835f8 --- /dev/null +++ b/cov_docker_script/setup_dependencies.sh @@ -0,0 +1,241 @@ +#!/usr/bin/env bash +set -e + +################################################################################ +# Generic Dependency Setup Script +# Usage: ./setup_dependencies.sh [config_file] +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +CONFIG_FILE="${1:-$SCRIPT_DIR/component_config.json}" + +# Source common utilities +source "$SCRIPT_DIR/common_build_utils.sh" + +# Default directories +BUILD_DIR="${BUILD_DIR:-$HOME/build}" +USR_DIR="${USR_DIR:-$HOME/usr}" + +# Validate environment +if [[ ! -f "$CONFIG_FILE" ]]; then + err "Config file not found: $CONFIG_FILE" + exit 1 +fi + +check_dependencies || exit 1 + +# Initialize environment +initialize_environment() { + print_banner "Dependency Setup" + + log "Configuration: $CONFIG_FILE" + log "Build directory: $BUILD_DIR" + log "Install directory: $USR_DIR" + echo "" + + # Clean if requested + if [[ "${CLEAN_BUILD:-false}" == "true" ]]; then + warn "Cleaning previous build artifacts" + [[ -d "$BUILD_DIR" ]] && rm -rf "$BUILD_DIR" + [[ -d "$USR_DIR" ]] && rm -rf "$USR_DIR" + fi + + # Create directories + mkdir -p "$BUILD_DIR" + mkdir -p "$USR_DIR/include/rdkb" + mkdir -p "$USR_DIR/local/lib" + mkdir -p "$USR_DIR/local/lib/pkgconfig" + mkdir -p "$USR_DIR/lib" + + # Setup PKG_CONFIG_PATH and LD_LIBRARY_PATH for dependencies + export PKG_CONFIG_PATH="$USR_DIR/local/lib/pkgconfig:$USR_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}" + export LD_LIBRARY_PATH="$USR_DIR/local/lib:$USR_DIR/lib:${LD_LIBRARY_PATH:-}" + export CPPFLAGS="${CPPFLAGS:-} -I$USR_DIR/include" + export LDFLAGS="${LDFLAGS:-} -L$USR_DIR/local/lib" + + log "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" + log "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" + echo "" + + ok "Environment initialized" +} + +# Process header paths for a repository +process_headers() { + local index="$1" + local repo_dir="$2" + local name="$3" + + local count + count=$(jq ".dependencies.repos[$index].header_paths | length" "$CONFIG_FILE") + + if [[ "$count" -eq 0 ]]; then + log "No headers configured for $name" + return 0 + fi + + local i=0 + while [[ $i -lt $count ]]; do + local src dst + src=$(jq -r ".dependencies.repos[$index].header_paths[$i].source" "$CONFIG_FILE") + dst=$(jq -r ".dependencies.repos[$index].header_paths[$i].destination" "$CONFIG_FILE") + + copy_headers "$repo_dir/$src" "$dst" + i=$((i + 1)) + done + + return 0 +} + +# Build a repository +build_repository() { + local index="$1" + local repo_dir="$2" + local name="$3" + + local build_type + build_type=$(jq -r ".dependencies.repos[$index].build.type // empty" "$CONFIG_FILE") + + if [[ -z "$build_type" ]]; then + log "No build configuration for $name (headers only)" + return 0 + fi + + step "Building $name (type: $build_type)" + + case "$build_type" in + autotools) + local configure_flags make_targets parallel_make + configure_flags=$(jq -r ".dependencies.repos[$index].build.configure_flags // empty" "$CONFIG_FILE") + make_targets=$(jq -r ".dependencies.repos[$index].build.make_targets[]? // \"all\"" "$CONFIG_FILE" | tr '\n' ' ') + parallel_make=$(jq -r ".dependencies.repos[$index].build.parallel_make // true" "$CONFIG_FILE") + + build_autotools "$repo_dir" "$configure_flags" "$make_targets" "$parallel_make" || return 1 + ;; + + cmake) + local build_dir cmake_flags make_targets parallel_make + build_dir=$(jq -r ".dependencies.repos[$index].build.build_dir // \"build\"" "$CONFIG_FILE") + cmake_flags=$(jq -r ".dependencies.repos[$index].build.cmake_flags // empty" "$CONFIG_FILE") + make_targets=$(jq -r ".dependencies.repos[$index].build.make_targets[]? // \"all\"" "$CONFIG_FILE" | tr '\n' ' ') + parallel_make=$(jq -r ".dependencies.repos[$index].build.parallel_make // true" "$CONFIG_FILE") + + build_cmake "$repo_dir" "$build_dir" "$cmake_flags" "$make_targets" "$parallel_make" || return 1 + ;; + + meson) + local build_dir meson_flags ninja_targets + build_dir=$(jq -r ".dependencies.repos[$index].build.build_dir // \"builddir\"" "$CONFIG_FILE") + meson_flags=$(jq -r ".dependencies.repos[$index].build.meson_flags // empty" "$CONFIG_FILE") + ninja_targets=$(jq -r ".dependencies.repos[$index].build.ninja_targets[]? // \"all\"" "$CONFIG_FILE" | tr '\n' ' ') + + build_meson "$repo_dir" "$build_dir" "$meson_flags" "$ninja_targets" || return 1 + ;; + + commands) + execute_commands "$repo_dir" "$CONFIG_FILE" "$index" || return 1 + ;; + + script) + local script_path + script_path=$(jq -r ".dependencies.repos[$index].build.script" "$CONFIG_FILE") + local full_script="$repo_dir/$script_path" + + if [[ -f "$full_script" ]]; then + step "Executing build script: $script_path" + chmod +x "$full_script" + + export PARENT_BUILD_DIR="$BUILD_DIR" + export PARENT_USR_DIR="$USR_DIR" + + pushd "$repo_dir" >/dev/null || return 1 + if ! "$full_script"; then + err "Build script failed" + popd >/dev/null + return 1 + fi + popd >/dev/null + + unset PARENT_BUILD_DIR PARENT_USR_DIR + else + err "Build script not found: $full_script" + return 1 + fi + ;; + + *) + err "Unknown build type: $build_type" + return 1 + ;; + esac + + # Copy libraries + copy_libraries "$repo_dir" "$USR_DIR/local/lib" + copy_libraries "$repo_dir" "$USR_DIR/lib" + + ok "$name build completed" + return 0 +} + +# Process a single dependency +process_dependency() { + local index="$1" + + local name repo branch + name=$(jq -r ".dependencies.repos[$index].name" "$CONFIG_FILE") + repo=$(jq -r ".dependencies.repos[$index].repo" "$CONFIG_FILE") + branch=$(jq -r ".dependencies.repos[$index].branch" "$CONFIG_FILE") + + local repo_dir="$BUILD_DIR/$name" + + print_section "Processing: $name" + + # Clone repository + if ! clone_repo "$name" "$repo" "$branch" "$repo_dir"; then + err "Failed to process $name" + return 1 + fi + + # Copy headers + if ! process_headers "$index" "$repo_dir" "$name"; then + err "Failed to copy headers for $name" + return 1 + fi + + # Build if needed + if ! build_repository "$index" "$repo_dir" "$name"; then + err "Failed to build $name" + return 1 + fi + + ok "$name processed successfully" + return 0 +} + +# Main execution +main() { + initialize_environment + + local count + count=$(jq ".dependencies.repos | length" "$CONFIG_FILE") + + log "Found $count dependencies to process" + echo "" + + local i=0 + while [[ $i -lt $count ]]; do + if ! process_dependency "$i"; then + err "Dependency setup failed" + exit 1 + fi + i=$((i + 1)) + done + + echo "" + print_banner "Dependencies Setup Completed Successfully" + log "Headers installed: $USR_DIR/include/rdkb" + log "Libraries installed: $USR_DIR/local/lib and $USR_DIR/lib" + echo "" +} + +main From 76ad893f3f1f52d7f629cdbde576c93acf0f1afb Mon Sep 17 00:00:00 2001 From: dm097 Date: Wed, 21 Jan 2026 10:28:17 +0000 Subject: [PATCH 2/9] Update native-build.yml Signed-off-by: dm097 --- .github/workflows/native-build.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/native-build.yml diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml new file mode 100644 index 0000000..2bde1b1 --- /dev/null +++ b/.github/workflows/native-build.yml @@ -0,0 +1,28 @@ +name: Build Cable Modem Agent Component in Native Environment + +on: + push: + branches: [ main, 'sprint/**', 'release/**', develop ] + pull_request: + branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] + +jobs: + build-moca-agent-on-pr: + name: Build CMAgent 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: | + chmod +x cov_docker_script/setup_dependencies.sh + ./cov_docker_script/setup_dependencies.sh + chmod +x cov_docker_script/build_native.sh + ./cov_docker_script/build_native.sh + + env: + GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }} From ecd7d8d6236229a1b23f677d3b1bf5d05fd96a15 Mon Sep 17 00:00:00 2001 From: Deepak_M Date: Wed, 21 Jan 2026 17:05:08 +0530 Subject: [PATCH 3/9] Update native-build.yml test native-build.yml --- .github/workflows/native-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index 2bde1b1..eaa6b53 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -2,7 +2,7 @@ name: Build Cable Modem Agent Component in Native Environment on: push: - branches: [ main, 'sprint/**', 'release/**', develop ] + branches: [ main, 'sprint/**', 'release/**', 'feature/**', develop ] pull_request: branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] From 4cb46eaaec7249a79c57499d88041173f03cf2bd Mon Sep 17 00:00:00 2001 From: Deepak_M Date: Wed, 21 Jan 2026 18:11:08 +0530 Subject: [PATCH 4/9] Update native-build.yml --- .github/workflows/native-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index eaa6b53..2bde1b1 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -2,7 +2,7 @@ name: Build Cable Modem Agent Component in Native Environment on: push: - branches: [ main, 'sprint/**', 'release/**', 'feature/**', develop ] + branches: [ main, 'sprint/**', 'release/**', develop ] pull_request: branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] From b4560084bfd8d31c40da5077a176a63d5dd5733e Mon Sep 17 00:00:00 2001 From: dm097 Date: Thu, 29 Jan 2026 06:49:51 +0000 Subject: [PATCH 5/9] RDKB-62988 [GitHub Coverity] Enable Coverity Scan for cable-modem-agent using Native Build Integration Reason for change: Standardized the native build with wrapper script architecture and Github Action Workflow Changes for Enabling Coverity Scan for github cable-modem-agent Test Procedure: verify able-modem-agent dependency and build native build and using Github workflow Risks: Low Priority: P1 Signed-off-by: dm097 --- .github/workflows/native-build.yml | 11 +- cov_docker_script/README.md | 648 +++++++++----------- cov_docker_script/build_native.sh | 340 ---------- cov_docker_script/common_build_utils.sh | 287 --------- cov_docker_script/common_external_build.sh | 92 --- cov_docker_script/component_config.json | 38 +- cov_docker_script/configure_options.conf | 146 +++++ cov_docker_script/run_native_build.sh | 51 ++ cov_docker_script/run_setup_dependencies.sh | 67 ++ cov_docker_script/setup_dependencies.sh | 241 -------- 10 files changed, 558 insertions(+), 1363 deletions(-) delete mode 100755 cov_docker_script/build_native.sh delete mode 100755 cov_docker_script/common_build_utils.sh delete mode 100755 cov_docker_script/common_external_build.sh create mode 100644 cov_docker_script/configure_options.conf create mode 100755 cov_docker_script/run_native_build.sh create mode 100755 cov_docker_script/run_setup_dependencies.sh delete mode 100755 cov_docker_script/setup_dependencies.sh diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index 2bde1b1..576382c 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -2,7 +2,7 @@ name: Build Cable Modem Agent Component in Native Environment on: push: - branches: [ main, 'sprint/**', 'release/**', develop ] + branches: [ main, 'sprint/**', 'release/**', 'feature/**', develop ] pull_request: branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] @@ -19,10 +19,9 @@ jobs: - name: native build run: | - chmod +x cov_docker_script/setup_dependencies.sh - ./cov_docker_script/setup_dependencies.sh - chmod +x cov_docker_script/build_native.sh - ./cov_docker_script/build_native.sh - + chmod +x cov_docker_script/run_setup_dependencies.sh + ./cov_docker_script/run_setup_dependencies.sh + chmod +x cov_docker_script/run_native_build.sh + ./cov_docker_script/run_native_build.sh env: GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }} diff --git a/cov_docker_script/README.md b/cov_docker_script/README.md index f449390..861ab98 100644 --- a/cov_docker_script/README.md +++ b/cov_docker_script/README.md @@ -1,476 +1,402 @@ -# Coverity Build System for RDK-B Components +# Component Native Build Configuration -**Generic, reusable build system for any RDK-B component.** Just copy the scripts and customize `component_config.json`. +**Coverity/Native build configuration for RDK-B components.** -## Quick Start +--- -### Complete Build (Recommended) +## 📋 Overview -```bash -cd /path/to/component/cov_docker_script -./common_external_build.sh +This directory contains the configuration and wrapper scripts necessary for building RDK-B components in a native (non-Yocto) environment. This setup enables Coverity static analysis and validates that components can be built with explicitly declared dependencies. + +### Directory Contents + +``` +/cov_docker_script/ +├── README.md # This file +├── component_config.json # Dependency & build configuration +├── configure_options.conf # Autotools configure flags (optional) +├── run_setup_dependencies.sh # Wrapper: Setup build tools & dependencies +└── run_native_build.sh # Wrapper: Setup build tools & build component ``` -This runs the complete 2-step pipeline: -1. **Setup Dependencies** - Clones repos, copies headers, builds libraries -2. **Build Component** - Applies patches, builds component, installs libraries +### Important: Add to .gitignore -### Clean Build +Add the following to your component's `.gitignore` to exclude temporary build artifacts: -```bash -CLEAN_BUILD=true ./common_external_build.sh +```gitignore +# Build tools (downloaded by wrapper scripts) +build_tools_workflows/ + +# Dependency build artifacts +build/ ``` -Removes all previous build artifacts before starting. +--- -## Scripts Overview +## 🚀 Quick Start -### 1. common_build_utils.sh +### Prerequisites -**Purpose:** Shared utility library with common functions used by all build scripts. +- Docker container with [docker-rdk-ci](https://github.com/rdkcentral/docker-rdk-ci) image +- All wrapper scripts have execute permissions -**Key Functions:** -- `log()`, `ok()`, `warn()`, `err()`, `step()` - Color-coded logging -- `expand_path()` - Expands `$HOME` variables in paths -- `check_dependencies()` - Validates required system tools (git, jq, gcc, make) -- `clone_repo()` - Clones git repositories with depth 1 -- `copy_headers()` - Copies header files from source to destination -- `apply_patch()` - Applies patches using Python3 for safe string replacement -- `build_autotools()`, `build_cmake()`, `build_meson()` - Build functions for different systems -- `execute_commands()` - Runs custom command sequences -- `copy_libraries()` - Finds and copies library files (.so, .a, .la) +### Build Commands + +#### Complete Build Pipeline -**Usage:** ```bash -# This script is sourced by other scripts, not run directly -source common_build_utils.sh +# From your component root directory +cd /path/to/your-component + +# Run complete build pipeline +./cov_docker_script/run_setup_dependencies.sh +./cov_docker_script/run_native_build.sh + +# Clean build (removes previous artifacts) +CLEAN_BUILD=true ./cov_docker_script/run_setup_dependencies.sh +./cov_docker_script/run_native_build.sh ``` -**Auto-configured:** -- Validates presence of git, jq, gcc, make -- Sets up color-coded terminal output -- Exports all functions for use in other scripts +#### Individual Steps + +```bash +# Step 1: Setup dependencies only +./cov_docker_script/run_setup_dependencies.sh + +# Step 2: Build component only (requires Step 1 completed) +./cov_docker_script/run_native_build.sh +``` --- -### 2. setup_dependencies.sh +## 📖 Scripts Reference + +### 1. run_setup_dependencies.sh -**Purpose:** Clones dependency repositories, copies headers, and builds required libraries. +**Purpose:** Sets up build tools and runs dependency setup. **What it does:** -1. Reads dependency list from `component_config.json` -2. Clones each repository to `$HOME/build/` -3. Copies headers to `$HOME/usr/include/rdkb/` -4. Builds libraries (if `build` section present) -5. Installs libraries to `$HOME/usr/local/lib/` and `$HOME/usr/lib/` -6. Configures PKG_CONFIG_PATH and LD_LIBRARY_PATH +1. Clones `build_tools_workflows` repository (develop branch) +2. Verifies required scripts are present +3. Runs `setup_dependencies.sh` from build_tools_workflows with config path to: + - Clone all dependency repositories + - Copy headers to `$HOME/usr/include/rdkb/` + - Build and install dependency libraries +4. Leaves build_tools_workflows in place for run_native_build.sh **Usage:** ```bash -# Use default config (component_config.json in same directory) -./setup_dependencies.sh +./run_setup_dependencies.sh -# Use custom config file -./setup_dependencies.sh /path/to/custom_config.json - -# Clean build (removes $HOME/build and $HOME/usr first) -CLEAN_BUILD=true ./setup_dependencies.sh - -# Custom directories -BUILD_DIR=/tmp/build USR_DIR=/opt/rdkb ./setup_dependencies.sh +# Clean build +CLEAN_BUILD=true ./run_setup_dependencies.sh ``` -**Environment Variables:** -- `BUILD_DIR` - Where to clone repos (default: `$HOME/build`) -- `USR_DIR` - Install directory (default: `$HOME/usr`) -- `CLEAN_BUILD` - Set to `true` to remove previous artifacts +**Required files:** +- `component_config.json` (defines dependencies) -**Output:** +**Outputs:** +- Downloads: `$HOME/build/` (dependency repositories) - Headers: `$HOME/usr/include/rdkb/` -- Libraries: `$HOME/usr/local/lib/` and `$HOME/usr/lib/` +- Libraries: `$HOME/usr/local/lib/`, `$HOME/usr/lib/` +- build_tools_workflows: Remains in place for run_native_build.sh + +**Environment Variables:** +- `BUILD_DIR` - Override build directory (default: `$HOME/build`) +- `USR_DIR` - Override install directory (default: `$HOME/usr`) +- `CLEAN_BUILD` - Set to `true` to remove previous builds --- -### 3. build_native.sh +### 2. run_native_build.sh -**Purpose:** Builds the native component after dependencies are setup. +**Purpose:** Verifies build tools and builds the component. **What it does:** -1. Reads component configuration from `component_config.json` -2. Processes native component headers (copies to destination) -3. Applies source patches (if configured) -4. Configures build environment (PKG_CONFIG_PATH, LD_LIBRARY_PATH, CPPFLAGS, LDFLAGS) -5. Runs autogen.sh or autoreconf (for autotools) -6. Executes configure/cmake with specified options -7. Builds component with make (parallel by default) -8. Copies libraries to configured output path +1. Verifies `build_tools_workflows` directory exists (cloned by `run_setup_dependencies.sh`) +2. Verifies `build_native.sh` is present +3. Runs `build_native.sh` from build_tools_workflows with config and component paths to: + - Apply patches to source code + - Configure build environment + - Build component + - Install libraries +4. Cleans up build_tools_workflows directory **Usage:** ```bash -# Use defaults (assumes setup_dependencies.sh already run) -./build_native.sh - -# Specify custom config and component directory -./build_native.sh /path/to/config.json /path/to/component - -# With environment overrides -HEADER_PATH=/custom/include ./build_native.sh +./run_native_build.sh ``` **Prerequisites:** -- `setup_dependencies.sh` must have run successfully -- Headers and libraries must be in `$HOME/usr/` +- `run_setup_dependencies.sh` must be run first (to clone build_tools_workflows) +- All dependency headers/libraries must be available + +**Required files:** +- `component_config.json` (defines component build settings) +- `configure_options.conf` (autotools configuration) -**Output:** -- Component libraries in path specified by `native_component.lib_output_path` -- Default: `$HOME/usr/local/lib/` +**Outputs:** +- Component libraries in `$HOME/usr/local/lib/` +- Build artifacts in component root directory --- -### 4. common_external_build.sh +## 📝 Configuration Files -**Purpose:** Orchestrates complete build pipeline (dependencies + component). +### component_config.json -**What it does:** -1. Validates configuration and paths -2. Runs `setup_dependencies.sh` (Step 1/2) -3. Runs `build_native.sh` (Step 2/2) -4. Displays progress banners and status +**JSON configuration defining all dependencies and build settings.** -**Usage:** -```bash -# Complete build with defaults -./common_external_build.sh +**Key Sections:** -# With custom config and component directory -./common_external_build.sh /path/to/config.json /path/to/component +1. **dependencies.repos[]** - External dependencies required by your component + ```json + { + "name": "rbus", + "repo": "https://github.com/rdkcentral/rbus.git", + "branch": "v2.7.0", + "header_paths": [...], + "build": {...} + } + ``` + +2. **native_component** - Component build configuration + ```json + { + "name": "your-component", + "build": { + "type": "autotools", + "configure_options_file": "cov_docker_script/configure_options.conf" + } + } + ``` + +**Example Dependencies:** +Your component may require dependencies such as: +- rbus +- rdk_logger +- safec +- common-library +- halinterface +- And other component-specific dependencies + +See [component_config.json](component_config.json) for your component's specific dependency configuration. -# Clean build -CLEAN_BUILD=true ./common_external_build.sh -``` +--- -**This is the recommended entry point for complete builds.** +### configure_options.conf -**Output:** -- Complete dependency setup -- Built component with all libraries -- Success/failure status for entire pipeline +**Autotools configuration file with preprocessor, compiler, and linker flags.** ---- +**Format:** +```properties +[CPPFLAGS] +-I$HOME/usr/include/rdkb/ +-DFEATURE_FLAG -### 5. component_config.json +[CFLAGS] +-Wall -Wextra -**Purpose:** JSON configuration defining all dependencies and build settings. +[LDFLAGS] +-L$HOME/usr/local/lib/ +``` -**Key Sections:** -- `dependencies.repos[]` - List of dependency repositories -- `native_component` - Component-specific build configuration -- `source_patches[]` - Patches to apply before building +**Sections:** +- `[CPPFLAGS]` - Preprocessor flags (includes `-I`, defines `-D`) +- `[CFLAGS]` - C compiler flags +- `[CXXFLAGS]` - C++ compiler flags +- `[LDFLAGS]` - Linker flags (library paths `-L`, linker options `-Wl`) -**Not a script, but required by all build scripts.** +**Component-Specific Flags:** +Customize flags based on your component's requirements: +- Platform defines: `_COSA_INTEL_USG_ARM_`, `_COSA_BCM_ARM_`, etc. +- Product defines: `_XB6_PRODUCT_REQ_`, `_XB7_PRODUCT_REQ_`, etc. +- Feature flags: `FEATURE_SUPPORT_RDKLOG`, component-specific features, etc. -See **Configuration** section below for detailed format. +See [configure_options.conf](configure_options.conf) for your component's complete flag list. --- -## Configuration - -All build configuration is in **`component_config.json`**. This file defines: -- Dependencies to clone and build -- Headers to copy -- Patches to apply -- Build settings - -### Key Configuration Sections - -#### Dependencies - -```json -{ - "dependencies": { - "repos": [ - { - "name": "repo-name", - "repo": "https://github.com/org/repo.git", - "branch": "main", - "header_paths": [ - { "source": "include", "destination": "$HOME/usr/include/rdkb" } - ], - "build": { - "type": "autotools|cmake|meson|commands|script", - "configure_flags": "--prefix=$HOME/usr", - "parallel_make": true - } - } - ] - } -} -``` +## 🔧 Build System Architecture -**Note:** The `build` section is optional - omit it for header-only dependencies. - -#### Native Component - -```json -{ - "native_component": { - "name": "component-name", - "include_path": "$HOME/usr/include/rdkb/", - "lib_output_path": "$HOME/usr/local/lib/", - "header_sources": [ - { "source": "source/ccsp/include", "destination": "$HOME/usr/include/rdkb" }, - { "source": "source/cosa/include", "destination": "$HOME/usr/include/rdkb" } - ], - "source_patches": [ - { - "file": "$HOME/usr/include/rdkb/header.h", - "type": "replace", - "search": "old text", - "replace": "new text" - } - ], - "build": { - "type": "autotools|cmake", - "configure_options": [ - "CPPFLAGS=-I$HOME/usr/include/rdkb", - "LDFLAGS=-L$HOME/usr/lib" - ] - } - } -} +``` +┌─────────────────────────────────────────────────────┐ +│ run_setup_dependencies.sh │ +│ ┌──────────────────────────────────────────────┐ │ +│ │ 1. Clone build_tools_workflows │ │ +│ │ (develop branch) │ │ +│ │ │ │ +│ │ 2. Verify required scripts present │ │ +│ │ │ │ +│ │ 3. Run setup_dependencies.sh from │ │ +│ │ build_tools_workflows with config path │ │ +│ │ - Read component_config.json │ │ +│ │ - Clone dependency repos │ │ +│ │ - Copy headers │ │ +│ │ - Build & install libraries │ │ +│ └──────────────────────────────────────────────┘ │ +└─────────────────────────────────────────────────────┘ + │ + ▼ +┌─────────────────────────────────────────────────────┐ +│ run_native_build.sh │ +│ ┌──────────────────────────────────────────────┐ │ +│ │ 1. Verify build_tools_workflows exists │ │ +│ │ (cloned by run_setup_dependencies.sh) │ │ +│ │ │ │ +│ │ 2. Run build_native.sh from │ │ +│ │ build_tools_workflows with config and │ │ +│ │ component directory paths │ │ +│ │ - Process component headers │ │ +│ │ - Apply source patches (if configured) │ │ +│ │ - Read configure_options.conf │ │ +│ │ - Configure build (autogen/configure) │ │ +│ │ - Build component (make/cmake/meson) │ │ +│ │ - Install libraries │ │ +│ │ │ │ +│ │ 3. Cleanup build_tools_workflows directory │ │ +│ └──────────────────────────────────────────────┘ │ +└─────────────────────────────────────────────────────┘ ``` -**Configuration Details:** -- `header_sources[]` - Component headers to copy before building. Source paths are relative to component directory. -- `source_patches[]` - Patches to apply after headers are copied. Use absolute paths with `$HOME` for files in install directories. -- `include_path` - Colon-separated include paths for building -- `lib_output_path` - Where to install built libraries +--- -## Build Types +## 🐛 Troubleshooting -### Autotools -```json -"build": { - "type": "autotools", - "configure_flags": "--prefix=$HOME/usr --enable-feature" -} -``` +### Build Failures -### CMake -```json -"build": { - "type": "cmake", - "build_dir": "build", - "cmake_flags": "-DCMAKE_INSTALL_PREFIX=$HOME/usr" -} -``` +**Problem:** Missing headers -### Meson -```json -"build": { - "type": "meson", - "meson_flags": "--prefix=$HOME/usr" -} -``` +```bash +# Solution: Check if dependencies were installed +ls -la $HOME/usr/include/rdkb/ -### Custom Commands -```json -"build": { - "type": "commands", - "commands": ["meson setup build --prefix=$HOME/usr", "meson compile -C build"] -} -``` +# Verify component_config.json has correct header_paths +cat component_config.json | jq '.dependencies.repos[].header_paths' -### Custom Script -```json -"build": { - "type": "script", - "script": "cov_docker_script/build.sh" -} +# Re-run dependency setup +CLEAN_BUILD=true ./cov_docker_script/run_setup_dependencies.sh ``` -## Troubleshooting +**Problem:** Missing libraries -### Build fails with "command not found" -**Install required tools:** ```bash -sudo apt-get install git jq gcc make autoconf automake libtool cmake python3 +# Solution: Check library installation +ls -la $HOME/usr/local/lib/ +ls -la $HOME/usr/lib/ + +# Verify PKG_CONFIG_PATH +echo $PKG_CONFIG_PATH + +# Check if dependency build failed +cd $HOME/build/ +cat config.log # For autotools +cat build/meson-log.txt # For meson ``` -### Dependencies fail to build -- Check `$HOME/build/` for build logs -- Verify `configure_flags` in JSON are correct -- Ensure system packages for build type are installed (cmake, meson, etc.) - -### Headers not found during component build -- Verify `setup_dependencies.sh` completed successfully -- Check `$HOME/usr/include/rdkb/` contains expected headers -- Verify `header_paths` in JSON point to correct source directories - -### Libraries not found -- Check library directories: - - `$HOME/usr/local/lib/` - Primary location - - `$HOME/usr/lib/` - Secondary location -- Verify dependencies built successfully (look for `.so`, `.a` files) -- Check build logs for `make install` errors - -### Patches fail to apply -- **File not found:** Verify file path is relative to component directory -- **Use `../`** for files outside component (e.g., `../usr/include/rdkb/header.h`) -- **Exact match required:** Search string must exactly match file content -- **Python3 required:** Ensure Python3 is installed - -### Clean build needed +**Problem:** Configure errors + ```bash -# Remove all previous build artifacts -CLEAN_BUILD=true ./common_external_build.sh +# Solution: Check configure_options.conf syntax +cat cov_docker_script/configure_options.conf + +# Verify flags are valid +./configure --help ``` -### Validate configuration +### Script Errors + +**Problem:** Script not found + ```bash -# Check JSON syntax -jq . component_config.json +# Solution: Ensure scripts are executable +chmod +x cov_docker_script/*.sh -# List all dependencies -jq '.dependencies.repos[].name' component_config.json +# Check if build_tools_workflows was cloned +ls -la ../build_tools_workflows/ ``` -## Directory Structure After Build +**Problem:** Permission denied -``` -$HOME/ -├── build/ # Cloned repositories (removed after build) -└── usr/ - ├── include/ - │ └── rdkb/ # All dependency headers - ├── lib/ # Secondary library location - └── local/ - └── lib/ # Primary library location (.so, .a files) +```bash +# Solution: Fix container permissions +# (Run on host, not in container) +sudo docker exec rdkb-builder groupadd $USER --gid=$(id -g $USER) +sudo docker exec rdkb-builder useradd -m $USER -G users \ + --uid=$(id -u $USER) --gid=$(id -g $USER) ``` -## Environment Variables +--- -These are automatically configured by the scripts: +## 📚 Related Documentation -- `BUILD_DIR` - Repository clone location (default: `$HOME/build`) -- `USR_DIR` - Install directory (default: `$HOME/usr`) -- `PKG_CONFIG_PATH` - Configured for dependency detection -- `LD_LIBRARY_PATH` - Configured for runtime linking -- `CPPFLAGS` - Include paths for compilation -- `LDFLAGS` - Library paths for linking -- `CLEAN_BUILD` - Set to `true` to clean before build +- **Build Tools Repository:** [build_tools_workflows](https://github.com/rdkcentral/build_tools_workflows/tree/develop) +- **Docker Environment:** [docker-rdk-ci](https://github.com/rdkcentral/docker-rdk-ci) +- **Example Component:** [cable-modem-agent](https://github.com/rdkcentral/cable-modem-agent) (reference implementation) +- **Detailed Build Guide:** See `build_tools_workflows/cov_docker_script/README.md` -## Required System Tools +--- -- `bash` (version 4.0+) -- `git` - Repository cloning -- `jq` - JSON parsing -- `gcc`/`g++` - C/C++ compiler -- `make` - Build automation -- `python3` - Patch application +## ⚠️ Important Notes -**Optional (based on dependency types):** -- `autoconf`, `automake`, `libtool` - For autotools builds -- `cmake` - For CMake builds -- `meson`, `ninja` - For Meson builds -- `pkg-config` - For dependency detection +### DO NOT Modify ---- +The following scripts are automatically copied from `build_tools_workflows` and **must not be modified locally**: -## Adopting for Another Component +- ❌ `build_native.sh` +- ❌ `common_build_utils.sh` +- ❌ `common_external_build.sh` +- ❌ `setup_dependencies.sh` -**These scripts are 100% generic and component-agnostic.** To use them for a different component: +Any changes will be overwritten when wrapper scripts run. -### Step 1: Copy the Scripts +### DO Modify -```bash -# Copy all scripts to your component's build directory -cp common_build_utils.sh setup_dependencies.sh build_native.sh common_external_build.sh /path/to/new-component/cov_docker_script/ +The following files are component-specific and **should be customized**: -# Make executable -chmod +x /path/to/new-component/cov_docker_script/*.sh -``` +- ✅ `component_config.json` - Dependency and build configuration +- ✅ `configure_options.conf` - Autotools flags +- ✅ `run_setup_dependencies.sh` - Wrapper script (if needed) +- ✅ `run_native_build.sh` - Wrapper script (if needed) -### Step 2: Create component_config.json - -Create a new `component_config.json` for your component: - -```json -{ - "_comment": "Component Build Configuration", - "_version": "2.0", - - "dependencies": { - "repos": [ - { - "name": "your-dependency", - "repo": "https://github.com/org/your-dependency.git", - "branch": "main", - "header_paths": [ - { "source": "include", "destination": "$HOME/usr/include/rdkb" } - ], - "build": { - "type": "cmake", - "cmake_flags": "-DCMAKE_INSTALL_PREFIX=$HOME/usr" - } - } - ] - }, - - "native_component": { - "name": "your-component-name", - "include_path": "$HOME/usr/include/rdkb/", - "lib_output_path": "$HOME/usr/local/lib/", - "source_patches": [], - "build": { - "type": "autotools", - "configure_options": [ - "CPPFLAGS=-I$HOME/usr/include/rdkb", - "LDFLAGS=-L$HOME/usr/local/lib" - ] - } - } -} -``` +--- -### Step 3: Run the Build +## 🔄 Workflow Integration + +### Local Development ```bash -cd /path/to/new-component/cov_docker_script -./common_external_build.sh +# Make changes to source code +vim source/your_component.c + +# Rebuild component +CLEAN_BUILD=true ./cov_docker_script/run_native_build.sh ``` -**That's it!** No script modifications needed. The scripts automatically: -- Read component name from JSON -- Find component directory (parent of script directory) -- Clone dependencies listed in JSON -- Copy headers from paths specified in JSON -- Build using build type specified in JSON -- Apply patches listed in JSON +### CI/CD Integration -### What Makes These Scripts Generic? +This configuration is used by GitHub Actions to validate builds: -✅ **No hardcoded paths** - All paths from JSON or environment variables -✅ **No hardcoded component names** - Component name read from JSON -✅ **No hardcoded dependencies** - All dependencies defined in JSON -✅ **No hardcoded build commands** - Build type and options from JSON -✅ **Flexible build systems** - Supports autotools, cmake, meson, custom commands, custom scripts -✅ **Configurable patches** - All patches defined in JSON +```yaml +- name: Setup Dependencies + run: ./cov_docker_script/run_setup_dependencies.sh -### Example: Migrating from Utopia to CcspPandM +- name: Build Component + run: ./cov_docker_script/run_native_build.sh +``` -```bash -# 1. Copy scripts to CcspPandM -cp utopia/cov_docker_script/*.sh ccsp-p-and-m/cov_docker_script/ +See `.github/workflows/` for complete CI configuration. -# 2. Create ccsp-p-and-m/cov_docker_script/component_config.json -# Update: component name, dependencies, build settings +--- -# 3. Run build -cd ccsp-p-and-m/cov_docker_script -./common_external_build.sh -``` +## 📞 Support -**Scripts remain unchanged - only JSON changes!** +For issues or questions: + +1. Check [Troubleshooting](#troubleshooting) section +2. Review [build_tools_workflows README](https://github.com/rdkcentral/build_tools_workflows/blob/develop/cov_docker_script/README.md) +3. Raise issue in your component repository or [build_tools_workflows](https://github.com/rdkcentral/build_tools_workflows/issues) --- + +**Last Updated:** January 2026 diff --git a/cov_docker_script/build_native.sh b/cov_docker_script/build_native.sh deleted file mode 100755 index ce1bd67..0000000 --- a/cov_docker_script/build_native.sh +++ /dev/null @@ -1,340 +0,0 @@ -#!/usr/bin/env bash -set -e - -################################################################################ -# Generic Native Component Build Script -# Usage: ./build_native.sh [config_file] [component_dir] -################################################################################ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -CONFIG_FILE="${1:-$SCRIPT_DIR/component_config.json}" -COMPONENT_DIR="${2:-$(cd "$SCRIPT_DIR/.." && pwd)}" - -# Source common utilities -source "$SCRIPT_DIR/common_build_utils.sh" - -# Validate environment -if [[ ! -f "$CONFIG_FILE" ]]; then - err "Config file not found: $CONFIG_FILE" - exit 1 -fi - -if [[ ! -d "$COMPONENT_DIR" ]]; then - err "Component directory not found: $COMPONENT_DIR" - exit 1 -fi - -check_dependencies || exit 1 - -# Read component configuration -COMPONENT_NAME=$(jq -r '.native_component.name' "$CONFIG_FILE") -BUILD_TYPE=$(jq -r '.native_component.build.type' "$CONFIG_FILE") -HEADER_PATH=$(expand_path "$(jq -r '.native_component.include_path' "$CONFIG_FILE")") -LIB_PATH=$(expand_path "$(jq -r '.native_component.lib_output_path' "$CONFIG_FILE")") - -# Configure environment -configure_environment() { - print_banner "Building Native Component: $COMPONENT_NAME" - - log "Component: $COMPONENT_NAME" - log "Build type: $BUILD_TYPE" - log "Component directory: $COMPONENT_DIR" - log "Header path: $HEADER_PATH" - log "Library path: $LIB_PATH" - echo "" - - # Setup PKG_CONFIG_PATH and LD_LIBRARY_PATH - export PKG_CONFIG_PATH="$LIB_PATH/pkgconfig:${PKG_CONFIG_PATH:-}" - export LD_LIBRARY_PATH="$LIB_PATH:${LD_LIBRARY_PATH:-}" - - # Add common include and lib paths - export CPPFLAGS="${CPPFLAGS:-} -I$HEADER_PATH" - export CFLAGS="${CFLAGS:-} -I$HEADER_PATH" - export LDFLAGS="${LDFLAGS:-} -L$LIB_PATH" - - log "Environment configured" - log " PKG_CONFIG_PATH=$PKG_CONFIG_PATH" - log " LD_LIBRARY_PATH=$LD_LIBRARY_PATH" - echo "" -} - -# Apply source patches -apply_source_patches() { - local patch_count - patch_count=$(jq -r '.native_component.source_patches // [] | length' "$CONFIG_FILE") - - if [[ "$patch_count" -eq 0 ]]; then - log "No source patches configured" - return 0 - fi - - step "Applying source patches ($patch_count patches)" - - local i=0 - while [[ $i -lt $patch_count ]]; do - local file search replace type content - file=$(jq -r ".native_component.source_patches[$i].file" "$CONFIG_FILE") - type=$(jq -r ".native_component.source_patches[$i].type // \"replace\"" "$CONFIG_FILE") - search=$(jq -r ".native_component.source_patches[$i].search // \"\"" "$CONFIG_FILE") - replace=$(jq -r ".native_component.source_patches[$i].replace // \"\"" "$CONFIG_FILE") - content=$(jq -r ".native_component.source_patches[$i].content // \"\"" "$CONFIG_FILE") - - # Expand $HOME in file path, then resolve relative paths from COMPONENT_DIR - local expanded_file=$(expand_path "$file") - local target_file - if [[ "$expanded_file" = /* ]]; then - # Absolute path - use as is - target_file="$expanded_file" - else - # Relative path - prepend COMPONENT_DIR - target_file="$COMPONENT_DIR/$expanded_file" - fi - - if ! apply_patch "$target_file" "$search" "$replace" "$type" "$content"; then - err "Failed to apply patch $((i+1))/$patch_count" - return 1 - fi - - i=$((i + 1)) - done - - ok "All patches applied successfully" - echo "" - return 0 -} - -# Process native headers -process_native_headers() { - local header_count - header_count=$(jq -r '.native_component.header_sources // [] | length' "$CONFIG_FILE") - - if [[ "$header_count" -eq 0 ]]; then - log "No header sources configured" - return 0 - fi - - step "Processing native component headers ($header_count sources)" - - local i=0 - while [[ $i -lt $header_count ]]; do - local src dst - src=$(jq -r ".native_component.header_sources[$i].source" "$CONFIG_FILE") - dst=$(jq -r ".native_component.header_sources[$i].destination" "$CONFIG_FILE") - - # Expand paths - src="$COMPONENT_DIR/$src" - dst=$(expand_path "$dst") - - copy_headers "$src" "$dst" - i=$((i + 1)) - done - - ok "All headers processed successfully" - echo "" - return 0 -} - -# Build with autotools -build_component_autotools() { - cd "$COMPONENT_DIR" - - # Read configure options as array - local configure_options=() - local opt_count - opt_count=$(jq -r '.native_component.build.configure_options // [] | length' "$CONFIG_FILE") - - local i=0 - while [[ $i -lt $opt_count ]]; do - local option - option=$(jq -r ".native_component.build.configure_options[$i]" "$CONFIG_FILE") - option=$(expand_path "$option") - configure_options+=("$option") - i=$((i + 1)) - done - - # Run autogen if exists - if [[ -f "./autogen.sh" ]]; then - step "Running autogen.sh" - chmod +x ./autogen.sh - # Set NOCONFIGURE to prevent autogen.sh from automatically running configure - if ! NOCONFIGURE=1 ./autogen.sh; then - err "autogen.sh failed" - return 1 - fi - ok "autogen.sh completed" - echo "" - fi - - # Configure - step "Running configure" - - # Export configure options as environment variables - for option in "${configure_options[@]}"; do - export "$option" - done - - if ! ./configure; then - err "Configure failed" - return 1 - fi - ok "Configure completed" - echo "" - - # Make - local make_targets - make_targets=$(jq -r '.native_component.build.make_targets[]? // "all"' "$CONFIG_FILE" | tr '\n' ' ') - - local parallel_make - parallel_make=$(jq -r '.native_component.build.parallel_make // true' "$CONFIG_FILE") - - local make_jobs="" - [[ "$parallel_make" == "true" ]] && make_jobs="-j$(nproc)" - - step "Running make $make_jobs $make_targets" - if ! make $make_jobs $make_targets; then - err "Make failed" - return 1 - fi - ok "Make completed" - echo "" - - return 0 -} - -# Run pre-build commands from native_component.pre_build_commands[] -run_pre_build_commands() { - - log "copying python files generic..." - copy_python_files_generic - - log "Running pre-build commands..." - - if [[ -z "$CONFIG_FILE" ]] || [[ ! -f "$CONFIG_FILE" ]]; then - err "CONFIG_FILE not set or file missing" - return 1 - fi - - if [[ -z "$COMPONENT_DIR" ]] || [[ ! -d "$COMPONENT_DIR" ]]; then - err "COMPONENT_DIR not set or directory missing" - return 1 - fi - - local cmd_count - cmd_count=$(jq '.native_component.pre_build_commands // [] | length' "$CONFIG_FILE") - - if [[ "$cmd_count" -eq 0 ]]; then - log "No pre-build commands to run" - return 0 - fi - - pushd "$COMPONENT_DIR" >/dev/null || { - err "Failed to enter component root: $COMPONENT_DIR" - return 1 - } - - local i description command - for ((i=0; i/dev/null - return 1 - fi - done - - popd >/dev/null - ok "Pre-build commands completed" - return 0 -} - -# Build with CMake -build_component_cmake() { - cd "$COMPONENT_DIR" - - local build_dir cmake_flags make_targets parallel_make - build_dir=$(jq -r '.native_component.build.build_dir // "build"' "$CONFIG_FILE") - cmake_flags=$(jq -r '.native_component.build.cmake_flags // empty' "$CONFIG_FILE") - cmake_flags=$(expand_path "$cmake_flags") - make_targets=$(jq -r '.native_component.build.make_targets[]? // "all"' "$CONFIG_FILE" | tr '\n' ' ') - parallel_make=$(jq -r '.native_component.build.parallel_make // true' "$CONFIG_FILE") - - build_cmake "$COMPONENT_DIR" "$build_dir" "$cmake_flags" "$make_targets" "$parallel_make" || return 1 - - return 0 -} - -# Install libraries -install_libraries() { - step "Installing libraries to $LIB_PATH" - mkdir -p "$LIB_PATH" - - # Find and copy all library files (shared objects, static, libtool archives) - find "$COMPONENT_DIR" \( -name "*.so*" -o -name "*.a" -o -name "*.la*" \) \( -type f -o -type l \) -exec cp -Pv {} "$LIB_PATH/" \; 2>/dev/null || true - - ok "Libraries installed" - echo "" -} - -# Main execution -main() { - configure_environment - - # Process native headers - if ! process_native_headers; then - err "Header processing failed" - exit 1 - fi - - # Apply patches - if ! apply_source_patches; then - err "Patch application failed" - exit 1 - fi - - # Run pre-build commands - if ! run_pre_build_commands; then - err "Pre-build commands failed" - exit 1 - fi - - # Build based on type - case "$BUILD_TYPE" in - autotools) - if ! build_component_autotools; then - err "Autotools build failed" - exit 1 - fi - ;; - - cmake) - if ! build_component_cmake; then - err "CMake build failed" - exit 1 - fi - ;; - - *) - err "Unsupported build type: $BUILD_TYPE" - exit 1 - ;; - esac - - # Install libraries - install_libraries - - print_banner "Native Component Build Completed Successfully" - log "Component: $COMPONENT_NAME" - log "Headers: $HEADER_PATH" - log "Libraries: $LIB_PATH" - echo "" -} - -main diff --git a/cov_docker_script/common_build_utils.sh b/cov_docker_script/common_build_utils.sh deleted file mode 100755 index a38db9e..0000000 --- a/cov_docker_script/common_build_utils.sh +++ /dev/null @@ -1,287 +0,0 @@ -#!/usr/bin/env bash - -################################################################################ -# Common Build Utilities -# Shared functions for dependency and component builds -################################################################################ - -# Colors -RED="\e[31m"; GREEN="\e[32m"; YELLOW="\e[33m" -BLUE="\e[34m"; CYAN="\e[36m"; BOLD="\e[1m"; NC="\e[0m" - -# Logging functions -log() { echo -e "${CYAN}[INFO]${NC} $1"; } -ok() { echo -e "${GREEN}[OK]${NC} $1"; } -warn() { echo -e "${YELLOW}[WARN]${NC} $1"; } -err() { echo -e "${RED}[ERROR]${NC} $1"; } -step() { echo -e "${BLUE}[STEP]${NC} $1"; } - -# Expand $HOME in paths -expand_path() { - echo "${1//\$HOME/$HOME}" -} - -# Validate required tools -check_dependencies() { - local required_tools=("git" "jq" "gcc" "make") - local missing=() - - for tool in "${required_tools[@]}"; do - if ! command -v "$tool" &> /dev/null; then - missing+=("$tool") - fi - done - - if [ ${#missing[@]} -gt 0 ]; then - err "Missing required tools: ${missing[*]}" - err "Please install them before continuing" - return 1 - fi - return 0 -} - -# Clone a git repository -clone_repo() { - local name="$1" repo="$2" branch="$3" dest="$4" - - if [[ -d "$dest" ]]; then - warn "$name already exists, skipping clone" - return 0 - fi - - log "Cloning $name (branch: $branch)" - if ! git clone --branch "$branch" "$repo" "$dest" --depth 1; then - err "Failed to clone $name" - return 1 - fi - ok "$name cloned successfully" - return 0 -} - -# Copy headers from source to destination -copy_headers() { - local src="$1" dst="$2" - - src=$(expand_path "$src") - dst=$(expand_path "$dst") - - mkdir -p "$dst" - - if [[ -d "$src" ]]; then - log "Copying headers: $src → $dst" - if ! find "$src" -maxdepth 1 -name "*.h" -exec cp {} "$dst/" \; 2>/dev/null; then - warn "No headers found in $src" - fi - else - warn "Header source not found: $src" - fi -} - -# Apply source patches -apply_patch() { - local file="$1" search="$2" replace="$3" type="${4:-replace}" content="$5" - - if [[ "$type" == "create" ]]; then - log "Creating file: $file" - local dir=$(dirname "$file") - mkdir -p "$dir" - echo -e "$content" > "$file" - if [[ $? -ne 0 ]]; then - err "Failed to create file: $file" - return 1 - fi - ok "File created successfully" - return 0 - fi - - if [[ ! -f "$file" ]]; then - err "Patch target not found: $file" - return 1 - fi - - log "Patching: $file ($type)" - - # Use python for safe string replacement with literal matching - if ! python3 -c " -import sys -with open('$file', 'r') as f: - content = f.read() -content = content.replace('''$search''', '''$replace''') -with open('$file', 'w') as f: - f.write(content) -"; then - err "Failed to apply patch to $file" - return 1 - fi - - ok "Patch applied successfully" - return 0 -} - -# Build with autotools -build_autotools() { - local repo_dir="$1" configure_flags="$2" make_targets="$3" parallel_make="${4:-true}" - - pushd "$repo_dir" >/dev/null || return 1 - - # Run autogen or autoreconf if needed - if [[ -f "autogen.sh" ]]; then - step "Running autogen.sh" - chmod +x autogen.sh - # Set NOCONFIGURE to prevent autogen.sh from automatically running configure - if ! NOCONFIGURE=1 ./autogen.sh; then - err "autogen.sh failed" - popd >/dev/null - return 1 - fi - elif [[ -f "configure.ac" ]] || [[ -f "configure.in" ]]; then - step "Running autoreconf" - if ! autoreconf -fi; then - err "autoreconf failed" - popd >/dev/null - return 1 - fi - fi - - # Configure - step "Running configure" - # Ensure PKG_CONFIG_PATH is set for configure - export PKG_CONFIG_PATH="${HOME}/usr/local/lib/pkgconfig:${HOME}/usr/lib/pkgconfig:${PKG_CONFIG_PATH:-}" - if ! eval "./configure $configure_flags"; then - err "Configure failed" - popd >/dev/null - return 1 - fi - - # Make - local make_jobs="" - [[ "$parallel_make" == "true" ]] && make_jobs="-j$(nproc)" - - step "Running make $make_jobs $make_targets" - if ! make $make_jobs $make_targets; then - err "Make failed" - popd >/dev/null - return 1 - fi - - popd >/dev/null - ok "Autotools build completed" - return 0 -} - -# Build with CMake -build_cmake() { - local repo_dir="$1" build_dir="$2" cmake_flags="$3" make_targets="$4" parallel_make="${5:-true}" - - pushd "$repo_dir" >/dev/null || return 1 - mkdir -p "$build_dir" - - step "Running cmake" - if ! eval "cmake -S . -B $build_dir $cmake_flags"; then - err "CMake configuration failed" - popd >/dev/null - return 1 - fi - - local make_jobs="" - [[ "$parallel_make" == "true" ]] && make_jobs="-j$(nproc)" - - step "Building with make $make_jobs $make_targets" - if ! make $make_jobs -C "$build_dir" $make_targets; then - err "Make failed" - popd >/dev/null - return 1 - fi - - popd >/dev/null - ok "CMake build completed" - return 0 -} - -# Build with Meson -build_meson() { - local repo_dir="$1" build_dir="$2" meson_flags="$3" ninja_targets="$4" - - pushd "$repo_dir" >/dev/null || return 1 - - step "Running meson setup" - if ! eval "meson setup $build_dir $meson_flags"; then - err "Meson setup failed" - popd >/dev/null - return 1 - fi - - step "Running ninja -C $build_dir $ninja_targets" - if ! ninja -C "$build_dir" $ninja_targets; then - err "Ninja build failed" - popd >/dev/null - return 1 - fi - - popd >/dev/null - ok "Meson build completed" - return 0 -} - -# Execute custom commands -execute_commands() { - local repo_dir="$1" config_file="$2" index="$3" - - pushd "$repo_dir" >/dev/null || return 1 - - local cmd_count - cmd_count=$(jq ".dependencies.repos[$index].build.commands | length" "$config_file") - - local i=0 - while [[ $i -lt $cmd_count ]]; do - local cmd - cmd=$(jq -r ".dependencies.repos[$index].build.commands[$i]" "$config_file") - step "Executing: $cmd" - if ! eval "$cmd"; then - err "Command failed: $cmd" - popd >/dev/null - return 1 - fi - i=$((i + 1)) - done - - popd >/dev/null - ok "Commands executed successfully" - return 0 -} - -# Copy shared libraries to destination -copy_libraries() { - local src_dir="$1" dst_dir="$2" - - dst_dir=$(expand_path "$dst_dir") - mkdir -p "$dst_dir" - - log "Copying libraries to $dst_dir" - find "$src_dir" \( -name "*.so*" -o -name "*.a" -o -name "*.la*" \) \( -type f -o -type l \) -exec cp -Pv {} "$dst_dir/" \; 2>/dev/null || true -} - -# Print banner -print_banner() { - local title="$1" - echo "" - echo -e "${BLUE}================================================${NC}" - echo -e "${BLUE} $title${NC}" - echo -e "${BLUE}================================================${NC}" - echo "" -} - -# Print section header -print_section() { - local title="$1" - echo "" - echo -e "${BLUE}------------------------------------------------${NC}" - echo -e "${BOLD}${CYAN}▶ $title${NC}" - echo -e "${BLUE}------------------------------------------------${NC}" -} - -# Export this file's functions -export -f log ok warn err step -export -f expand_path check_dependencies clone_repo copy_headers apply_patch -export -f build_autotools build_cmake build_meson execute_commands copy_libraries -export -f print_banner print_section diff --git a/cov_docker_script/common_external_build.sh b/cov_docker_script/common_external_build.sh deleted file mode 100755 index 3826f78..0000000 --- a/cov_docker_script/common_external_build.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env bash -set -e - -################################################################################ -# Common External Build Script -# Orchestrates the complete build process: dependencies + native component -# Usage: ./common_external_build.sh [config_file] [component_dir] -################################################################################ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -CONFIG_FILE="${1:-$SCRIPT_DIR/component_config.json}" -COMPONENT_DIR="${2:-$(cd "$SCRIPT_DIR/.." && pwd)}" - -# Source common utilities -source "$SCRIPT_DIR/common_build_utils.sh" - -# Validate inputs -if [[ ! -f "$CONFIG_FILE" ]]; then - err "Config file not found: $CONFIG_FILE" - exit 1 -fi - -if [[ ! -d "$COMPONENT_DIR" ]]; then - err "Component directory not found: $COMPONENT_DIR" - exit 1 -fi - -# Get component name from config -COMPONENT_NAME=$(jq -r '.native_component.name' "$CONFIG_FILE") - -# Print main banner -echo "" -echo -e "${BOLD}${BLUE}================================================================${NC}" -echo -e "${BOLD}${BLUE} Complete Build Pipeline for: ${COMPONENT_NAME}${NC}" -echo -e "${BOLD}${BLUE}================================================================${NC}" -echo "" -log "Configuration: $CONFIG_FILE" -log "Component directory: $COMPONENT_DIR" -echo "" - -# Step 1: Setup Dependencies -print_banner "Step 1/2: Setting Up Dependencies" -log "Running dependency setup script..." -echo "" - -if ! "$SCRIPT_DIR/setup_dependencies.sh" "$CONFIG_FILE"; then - err "Dependency setup failed" - exit 1 -fi - -echo "" -ok "Dependencies setup completed successfully" -echo "" - -# Step 2: Build Native Component -print_banner "Step 2/2: Building Native Component" -log "Running native component build script..." -echo "" - -if ! "$SCRIPT_DIR/build_native.sh" "$CONFIG_FILE" "$COMPONENT_DIR"; then - err "Native component build failed" - exit 1 -fi - -echo "" -ok "Native component build completed successfully" -echo "" - -# Final summary -echo "" -echo -e "${BOLD}${GREEN}================================================================${NC}" -echo -e "${BOLD}${GREEN} Complete Build Pipeline Completed Successfully!${NC}" -echo -e "${BOLD}${GREEN}================================================================${NC}" -echo "" -log "Component: ${BOLD}$COMPONENT_NAME${NC}" -log "All dependencies built and installed" -log "Native component compiled successfully" -echo "" - -# Display installation paths -HEADER_PATH=$(jq -r '.native_component.include_path' "$CONFIG_FILE") -LIB_PATH=$(jq -r '.native_component.lib_output_path' "$CONFIG_FILE") -HEADER_PATH="${HEADER_PATH//\$HOME/$HOME}" -LIB_PATH="${LIB_PATH//\$HOME/$HOME}" - -echo -e "${CYAN}Installation Locations:${NC}" -log " Headers: $HEADER_PATH" -log " Libraries: $LIB_PATH" -echo "" - -echo -e "${GREEN}✓ Ready for Coverity analysis or deployment${NC}" -echo "" diff --git a/cov_docker_script/component_config.json b/cov_docker_script/component_config.json index 9d8fb23..9e8905f 100644 --- a/cov_docker_script/component_config.json +++ b/cov_docker_script/component_config.json @@ -6,22 +6,6 @@ "dependencies": { "_comment": "External repositories needed by this component", "repos": [ - { - "name": "rbus", - "repo": "https://github.com/rdkcentral/rbus.git", - "branch": "v2.7.0", - "header_paths": [ - { "source": "include", "destination": "$HOME/usr/include/rdkb/rbus" }, - { "source": "src/rbus", "destination": "$HOME/usr/include/rdkb/rbus" }, - { "source": "src/core", "destination": "$HOME/usr/include/rdkb/rbus" }, - { "source": "src/rtmessage", "destination": "$HOME/usr/include/rdkb/rtmessage" } - ], - "build": { - "type": "cmake", - "build_dir": "build", - "cmake_flags": "-DCMAKE_INSTALL_PREFIX=$HOME/usr -DCMAKE_PREFIX_PATH=/usr -DBUILD_FOR_DESKTOP=ON -DCMAKE_BUILD_TYPE=Debug" - } - }, { "name": "safec", "repo": "https://github.com/rurban/safeclib.git", @@ -30,22 +14,6 @@ { "source": "include", "destination": "$HOME/usr/include/rdkb" } ] }, - { - "name": "trower-base64", - "repo": "https://github.com/xmidt-org/trower-base64.git", - "branch": "v1.2.7", - "header_paths": [ - { "source": "include/trower-base64", "destination": "$HOME/usr/include/rdkb" }, - { "source": "include/trower-base64", "destination": "$HOME/usr/include/rdkb/trower-base64" } - ], - "build": { - "type": "commands", - "commands": [ - "meson setup build --prefix=$HOME/usr", - "meson compile -C build" - ] - } - }, { "name": "Utopia", "repo": "https://github.com/rdkcentral/utopia.git", @@ -157,11 +125,9 @@ "build": { "type": "autotools", "build_dir": "build", + "configure_options_file": "cov_docker_script/configure_options.conf", "configure_options": [ - "CPPFLAGS=-I$HOME/usr/include -I$HOME/usr/include/rdkb -I/usr/include -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I$HOME/usr/include/rdkb/rtmessage -I$HOME/usr/include/rdkb/MoCASsp", - "CFLAGS=-DSAFEC_DUMMY_API -D_ANSC_USE_OPENSSL_ -D_NO_PKI_KB5_SUPPORT -DENABLE_LLD_SUPPORT", - "SRC_DIRS=$HOME/build/moca-agent/source/MoCASsp", - "LDFLAGS=-L$HOME/usr/lib -L$HOME/usr/lib/ -L$HOME/usr/local/lib -L/usr/lib -L/usr/lib/x86_64-linux-gnu -L$HOME/usr/lib/x86_64-linux-gnu -L$HOME/usr/include/rdkb/MoCASsp -L$HOME/build/moca-agent/source/MoCASsp -ldbus-1 -lccsp_common -Wl,--allow-shlib-undefined -Wl,--unresolved-symbols=ignore-all" + "SRC_DIRS=$HOME/build/cable-model-agent/source/CMAgentSsp/" ] } } diff --git a/cov_docker_script/configure_options.conf b/cov_docker_script/configure_options.conf new file mode 100644 index 0000000..0aa9831 --- /dev/null +++ b/cov_docker_script/configure_options.conf @@ -0,0 +1,146 @@ +# Cable Modem Agent Configure Options +# This file contains autotools configure options for the cable-modem-agent component +# Each section can be edited independently for better maintainability + +# ============================================================================ +# CPPFLAGS - Preprocessor flags (includes and defines) +# ============================================================================ +[CPPFLAGS] +# Autotools configuration +-DHAVE_CONFIG_H + +# Include paths +-I$HOME/usr/include +-I$HOME/usr/include/rdkb/ +-I/usr/include/dbus-1.0 +-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include + +# Core system defines +-DSAFEC_DUMMY_API +-D_COSA_HAL_ +-U_COSA_SIM_ +-DCONFIG_SYSTEM_MOCA + +# ANSC framework defines +-D_ANSC_LINUX +-D_ANSC_USER +-D_ANSC_LITTLE_ENDIAN_ +-D_ANSC_USE_OPENSSL_ +-D_ANSC_AES_USED_ +-D_NO_ANSC_ZLIB_ +-U_ANSC_IPV6_COMPATIBLE_ + +# CCSP/Component defines +-D_CCSP_CWMP_TCP_CONNREQ_HANDLER +-D_DSLH_STUN_ +-D_NO_PKI_KB5_SUPPORT +-D_BBHM_SSE_FILE_IO +-DCCSP_SUPPORT_ENABLED + +# Product/Platform defines +-D_COSA_INTEL_USG_ARM_ +-D_COSA_FOR_COMCAST_ +-D_COSA_BCM_ARM_ +-D_XB6_PRODUCT_REQ_ +-D_XB7_PRODUCT_REQ_ +-D_XB8_PRODUCT_REQ_ + +# Vendor/Customer configuration +-DCONFIG_VENDOR_CUSTOMER_COMCAST +-DCONFIG_CISCO_HOTSPOT + +# Security and debugging +-DENABLE_SA_KEY +-D_NO_EXECINFO_H_ +-D_DEBUG +-DINCLUDE_BREAKPAD + +# System features +-DFEATURE_SUPPORT_RDKLOG +-DFEATURE_SUPPORT_SYSLOG +-DBUILD_WEB +-DUSE_NOTIFY_COMPONENT +-DNTPD_ENABLE +-DUTC_ENABLE +-DUTC_ENABLE_ATOM +-DXDNS_ENABLE + +# MoCA specific +-DMOCA_HOME_ISOLATION +-DMOCA_DIAGONISTIC + +# Cable Modem Agent specific +-DENABLE_LLD_SUPPORT + +# Network features +-DENABLE_ETH_WAN +-DEROUTER_DHCP_OPTION_MTA +-DETH_4_PORTS +-D_2_5G_ETHERNET_SUPPORT_ +-D_MACSEC_SUPPORT_ +-D_BRIDGE_UTILS_BIN_ +-DAUTOWAN_ENABLE +-DENABLE_WANMODECHANGE_NOREBOOT +-DFEATURE_RDKB_WAN_MANAGER +-DFEATURE_RDKB_CONFIGURABLE_WAN_INTERFACE +-DWAN_MANAGER_UNIFICATION_ENABLED +-DWAN_FAILOVER_SUPPORTED +-DGATEWAY_FAILOVER_SUPPORTED + +# WiFi features +-D_ENABLE_BAND_STEERING_ +-D_BEACONRATE_SUPPORT +-D_TRI_BAND_WIFI_ +-D_WIFI_AX_SUPPORT_ +-D_WIFI_CONSOLIDATED_STANDARDS_ +-DWIFI_HAL_VERSION_3 +-DFEATURE_SUPPORT_MESH +-DFEATURE_SUPPORT_WEBCONFIG +-DFEATURE_SUPPORT_INTERWORKING +-DFEATURE_SUPPORT_PASSPOINT +-DWIFI_STATS_DISABLE_SPEEDTEST_RUNNING +-DFEATURE_SUPPORT_RADIUSGREYLIST +-DFEATURE_SUPPORT_ACL_SELFHEAL +-DFEATURE_CSI +-DFEATURE_SUPPORT_ONBOARD_LOGGING +-DFEATURE_OFF_CHANNEL_SCAN_5G +-DRDK_ONEWIFI +-DWIFI_MANAGE_SUPPORTED + +# Advanced features +-D_PSM_TRANS_RDK_TRIGG_ +-D_CM_HIGHSPLIT_SUPPORTED_ +-DFEATURE_RDKB_INTER_DEVICE_MANAGER +-DFEATURE_SUPPORT_MAPT_NAT46 +-DMAPT_UNIFICATION_ENABLED +-DSPEED_BOOST_SUPPORTED +-DAMENITIES_NETWORK_ENABLED + +# Test/Development +-DCOLUMBO_HWTEST + +# Build system +-DRBUS_BUILD_FLAG_ENABLE + +# Standard defines +-D_GNU_SOURCE +-D__USE_XOPEN + +# ============================================================================ +# CFLAGS - Compiler flags +# ============================================================================ +[CFLAGS] +-ffunction-sections +-fdata-sections +-fomit-frame-pointer +-fno-strict-aliasing + +# ============================================================================ +# LDFLAGS - Linker flags +# ============================================================================ +[LDFLAGS] +-L$HOME/usr/local/lib/ +-Wl,--allow-shlib-undefined +-Wl,--unresolved-symbols=ignore-all +-ldbus-1 +-lccsp_common diff --git a/cov_docker_script/run_native_build.sh b/cov_docker_script/run_native_build.sh new file mode 100755 index 0000000..9d3aea3 --- /dev/null +++ b/cov_docker_script/run_native_build.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +set -e + +################################################################################ +# Native Build Wrapper Script +# Verifies build tools and runs build_native.sh +# Usage: ./run_native_build.sh +# Note: run_setup_dependencies.sh should be executed first +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +NATIVE_COMPONENT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +BUILD_TOOLS_DIR="$NATIVE_COMPONENT_DIR/build_tools_workflows" + +# Basic logging functions +log() { echo "[INFO] $*"; } +ok() { echo "[OK] $*"; } +err() { echo "[ERROR] $*" >&2; } + +echo "" +echo "===== Native Build Pipeline =====" +echo "" + +# Verify build_tools_workflows exists (should be cloned by run_setup_dependencies.sh) +if [[ ! -d "$BUILD_TOOLS_DIR" ]]; then + err "build_tools_workflows directory not found. Please run run_setup_dependencies.sh first." + exit 1 +fi + +if [[ ! -f "$BUILD_TOOLS_DIR/cov_docker_script/build_native.sh" ]]; then + err "build_native.sh not found in build_tools_workflows. Please run run_setup_dependencies.sh first." + exit 1 +fi + +log "Build script found, proceeding with build..." + +# Run build_native.sh from build_tools_workflows +echo "" +log "Running build_native.sh from build_tools_workflows..." +cd "$NATIVE_COMPONENT_DIR" +"$BUILD_TOOLS_DIR/cov_docker_script/build_native.sh" "$SCRIPT_DIR/component_config.json" "$NATIVE_COMPONENT_DIR" + +echo "" +ok "Native build completed successfully!" + +# Cleanup build_tools_workflows directory +log "Cleaning up build_tools_workflows directory..." +rm -rf "$BUILD_TOOLS_DIR" +ok "Cleanup completed" + +echo "" diff --git a/cov_docker_script/run_setup_dependencies.sh b/cov_docker_script/run_setup_dependencies.sh new file mode 100755 index 0000000..5223c84 --- /dev/null +++ b/cov_docker_script/run_setup_dependencies.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +set -e + +################################################################################ +# Setup Dependencies Wrapper Script +# Sets up build tools and runs setup_dependencies.sh +# Usage: ./run_setup_dependencies.sh +################################################################################ + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +NATIVE_COMPONENT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" +BUILD_TOOLS_REPO_URL="https://github.com/rdkcentral/build_tools_workflows" +BUILD_TOOLS_DIR="$NATIVE_COMPONENT_DIR/build_tools_workflows" +REQUIRED_SCRIPTS=("build_native.sh" "common_build_utils.sh" "common_external_build.sh" "setup_dependencies.sh") + +# Basic logging functions +log() { echo "[INFO] $*"; } +ok() { echo "[OK] $*"; } +err() { echo "[ERROR] $*" >&2; } + +echo "" +echo "===== Setup Dependencies Pipeline =====" +echo "" + +# Setup build tools +log "Setting up build tools..." + +# Clone build_tools_workflows +if [[ -d "$BUILD_TOOLS_DIR" ]]; then + log "build_tools_workflows already exists, skipping clone" +else + log "Cloning build_tools_workflows (develop)" + cd "$NATIVE_COMPONENT_DIR" + git clone -b develop "$BUILD_TOOLS_REPO_URL" || { err "Clone failed"; exit 1; } + ok "Repository cloned" +fi + +# Verify required scripts +[[ ! -d "$BUILD_TOOLS_DIR/cov_docker_script" ]] && { err "cov_docker_script not found"; exit 1; } + +log "Verifying required scripts..." +MISSING=() +for script in "${REQUIRED_SCRIPTS[@]}"; do + [[ -f "$BUILD_TOOLS_DIR/cov_docker_script/$script" ]] || MISSING+=("$script") +done + +if [[ ${#MISSING[@]} -gt 0 ]]; then + err "Missing scripts: ${MISSING[*]}" + exit 1 +fi +ok "All required scripts found" + +# Verify setup_dependencies.sh exists before running +if [[ ! -f "$BUILD_TOOLS_DIR/cov_docker_script/setup_dependencies.sh" ]]; then + err "setup_dependencies.sh not found in build_tools_workflows" + exit 1 +fi + +# Run setup_dependencies.sh from build_tools_workflows +echo "" +log "Running setup_dependencies.sh from build_tools_workflows..." +cd "$NATIVE_COMPONENT_DIR" +"$BUILD_TOOLS_DIR/cov_docker_script/setup_dependencies.sh" "$SCRIPT_DIR/component_config.json" + +echo "" +echo "[OK] Dependencies setup completed successfully!" +echo "" diff --git a/cov_docker_script/setup_dependencies.sh b/cov_docker_script/setup_dependencies.sh deleted file mode 100755 index a4835f8..0000000 --- a/cov_docker_script/setup_dependencies.sh +++ /dev/null @@ -1,241 +0,0 @@ -#!/usr/bin/env bash -set -e - -################################################################################ -# Generic Dependency Setup Script -# Usage: ./setup_dependencies.sh [config_file] -################################################################################ - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -CONFIG_FILE="${1:-$SCRIPT_DIR/component_config.json}" - -# Source common utilities -source "$SCRIPT_DIR/common_build_utils.sh" - -# Default directories -BUILD_DIR="${BUILD_DIR:-$HOME/build}" -USR_DIR="${USR_DIR:-$HOME/usr}" - -# Validate environment -if [[ ! -f "$CONFIG_FILE" ]]; then - err "Config file not found: $CONFIG_FILE" - exit 1 -fi - -check_dependencies || exit 1 - -# Initialize environment -initialize_environment() { - print_banner "Dependency Setup" - - log "Configuration: $CONFIG_FILE" - log "Build directory: $BUILD_DIR" - log "Install directory: $USR_DIR" - echo "" - - # Clean if requested - if [[ "${CLEAN_BUILD:-false}" == "true" ]]; then - warn "Cleaning previous build artifacts" - [[ -d "$BUILD_DIR" ]] && rm -rf "$BUILD_DIR" - [[ -d "$USR_DIR" ]] && rm -rf "$USR_DIR" - fi - - # Create directories - mkdir -p "$BUILD_DIR" - mkdir -p "$USR_DIR/include/rdkb" - mkdir -p "$USR_DIR/local/lib" - mkdir -p "$USR_DIR/local/lib/pkgconfig" - mkdir -p "$USR_DIR/lib" - - # Setup PKG_CONFIG_PATH and LD_LIBRARY_PATH for dependencies - export PKG_CONFIG_PATH="$USR_DIR/local/lib/pkgconfig:$USR_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}" - export LD_LIBRARY_PATH="$USR_DIR/local/lib:$USR_DIR/lib:${LD_LIBRARY_PATH:-}" - export CPPFLAGS="${CPPFLAGS:-} -I$USR_DIR/include" - export LDFLAGS="${LDFLAGS:-} -L$USR_DIR/local/lib" - - log "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" - log "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" - echo "" - - ok "Environment initialized" -} - -# Process header paths for a repository -process_headers() { - local index="$1" - local repo_dir="$2" - local name="$3" - - local count - count=$(jq ".dependencies.repos[$index].header_paths | length" "$CONFIG_FILE") - - if [[ "$count" -eq 0 ]]; then - log "No headers configured for $name" - return 0 - fi - - local i=0 - while [[ $i -lt $count ]]; do - local src dst - src=$(jq -r ".dependencies.repos[$index].header_paths[$i].source" "$CONFIG_FILE") - dst=$(jq -r ".dependencies.repos[$index].header_paths[$i].destination" "$CONFIG_FILE") - - copy_headers "$repo_dir/$src" "$dst" - i=$((i + 1)) - done - - return 0 -} - -# Build a repository -build_repository() { - local index="$1" - local repo_dir="$2" - local name="$3" - - local build_type - build_type=$(jq -r ".dependencies.repos[$index].build.type // empty" "$CONFIG_FILE") - - if [[ -z "$build_type" ]]; then - log "No build configuration for $name (headers only)" - return 0 - fi - - step "Building $name (type: $build_type)" - - case "$build_type" in - autotools) - local configure_flags make_targets parallel_make - configure_flags=$(jq -r ".dependencies.repos[$index].build.configure_flags // empty" "$CONFIG_FILE") - make_targets=$(jq -r ".dependencies.repos[$index].build.make_targets[]? // \"all\"" "$CONFIG_FILE" | tr '\n' ' ') - parallel_make=$(jq -r ".dependencies.repos[$index].build.parallel_make // true" "$CONFIG_FILE") - - build_autotools "$repo_dir" "$configure_flags" "$make_targets" "$parallel_make" || return 1 - ;; - - cmake) - local build_dir cmake_flags make_targets parallel_make - build_dir=$(jq -r ".dependencies.repos[$index].build.build_dir // \"build\"" "$CONFIG_FILE") - cmake_flags=$(jq -r ".dependencies.repos[$index].build.cmake_flags // empty" "$CONFIG_FILE") - make_targets=$(jq -r ".dependencies.repos[$index].build.make_targets[]? // \"all\"" "$CONFIG_FILE" | tr '\n' ' ') - parallel_make=$(jq -r ".dependencies.repos[$index].build.parallel_make // true" "$CONFIG_FILE") - - build_cmake "$repo_dir" "$build_dir" "$cmake_flags" "$make_targets" "$parallel_make" || return 1 - ;; - - meson) - local build_dir meson_flags ninja_targets - build_dir=$(jq -r ".dependencies.repos[$index].build.build_dir // \"builddir\"" "$CONFIG_FILE") - meson_flags=$(jq -r ".dependencies.repos[$index].build.meson_flags // empty" "$CONFIG_FILE") - ninja_targets=$(jq -r ".dependencies.repos[$index].build.ninja_targets[]? // \"all\"" "$CONFIG_FILE" | tr '\n' ' ') - - build_meson "$repo_dir" "$build_dir" "$meson_flags" "$ninja_targets" || return 1 - ;; - - commands) - execute_commands "$repo_dir" "$CONFIG_FILE" "$index" || return 1 - ;; - - script) - local script_path - script_path=$(jq -r ".dependencies.repos[$index].build.script" "$CONFIG_FILE") - local full_script="$repo_dir/$script_path" - - if [[ -f "$full_script" ]]; then - step "Executing build script: $script_path" - chmod +x "$full_script" - - export PARENT_BUILD_DIR="$BUILD_DIR" - export PARENT_USR_DIR="$USR_DIR" - - pushd "$repo_dir" >/dev/null || return 1 - if ! "$full_script"; then - err "Build script failed" - popd >/dev/null - return 1 - fi - popd >/dev/null - - unset PARENT_BUILD_DIR PARENT_USR_DIR - else - err "Build script not found: $full_script" - return 1 - fi - ;; - - *) - err "Unknown build type: $build_type" - return 1 - ;; - esac - - # Copy libraries - copy_libraries "$repo_dir" "$USR_DIR/local/lib" - copy_libraries "$repo_dir" "$USR_DIR/lib" - - ok "$name build completed" - return 0 -} - -# Process a single dependency -process_dependency() { - local index="$1" - - local name repo branch - name=$(jq -r ".dependencies.repos[$index].name" "$CONFIG_FILE") - repo=$(jq -r ".dependencies.repos[$index].repo" "$CONFIG_FILE") - branch=$(jq -r ".dependencies.repos[$index].branch" "$CONFIG_FILE") - - local repo_dir="$BUILD_DIR/$name" - - print_section "Processing: $name" - - # Clone repository - if ! clone_repo "$name" "$repo" "$branch" "$repo_dir"; then - err "Failed to process $name" - return 1 - fi - - # Copy headers - if ! process_headers "$index" "$repo_dir" "$name"; then - err "Failed to copy headers for $name" - return 1 - fi - - # Build if needed - if ! build_repository "$index" "$repo_dir" "$name"; then - err "Failed to build $name" - return 1 - fi - - ok "$name processed successfully" - return 0 -} - -# Main execution -main() { - initialize_environment - - local count - count=$(jq ".dependencies.repos | length" "$CONFIG_FILE") - - log "Found $count dependencies to process" - echo "" - - local i=0 - while [[ $i -lt $count ]]; do - if ! process_dependency "$i"; then - err "Dependency setup failed" - exit 1 - fi - i=$((i + 1)) - done - - echo "" - print_banner "Dependencies Setup Completed Successfully" - log "Headers installed: $USR_DIR/include/rdkb" - log "Libraries installed: $USR_DIR/local/lib and $USR_DIR/lib" - echo "" -} - -main From 51fb043d31e7efe094bcb479550f2fd161146887 Mon Sep 17 00:00:00 2001 From: dm097 Date: Thu, 29 Jan 2026 07:24:53 +0000 Subject: [PATCH 6/9] RDKB-62988 [GitHub Coverity] Enable Coverity Scan for cable-modem-agent using Native Build Integration Reason for change: Standardized the native build with wrapper script architecture and Github Action Workflow Changes for Enabling Coverity Scan for github cable-modem-agent Test Procedure: verify able-modem-agent dependency and build native build and using Github workflow Risks: Low Priority: P1 Signed-off-by: dm097 --- .github/workflows/native-build.yml | 4 ++-- cov_docker_script/component_config.json | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index 576382c..bf9a26c 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -7,8 +7,8 @@ on: branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] jobs: - build-moca-agent-on-pr: - name: Build CMAgent component in github rdkcentral + build-cable-modem-agent-on-pr: + name: Build Cable Modem Agent component in github rdkcentral runs-on: ubuntu-latest container: image: ghcr.io/rdkcentral/docker-rdk-ci:latest diff --git a/cov_docker_script/component_config.json b/cov_docker_script/component_config.json index 9e8905f..659f024 100644 --- a/cov_docker_script/component_config.json +++ b/cov_docker_script/component_config.json @@ -52,16 +52,8 @@ }, { "name": "rdkb-halif-vlan", - "repo": "https://github.com/rdkcentral/rdkb-halif-cm.git", - "branch": "main", - "header_paths": [ - { "source": "include", "destination": "$HOME/usr/include" } - ] - }, - { - "name": "rdkb-halif-dhcp", "repo": "https://github.com/rdkcentral/rdkb-halif-vlan.git", - "branch": "main", + "branch": "main", "header_paths": [ { "source": "include", "destination": "$HOME/usr/include" } ] From e04eb49ba0fa1b2e0a3c9e372fd282cb37f760bf Mon Sep 17 00:00:00 2001 From: Deepak_M Date: Thu, 29 Jan 2026 14:30:35 +0530 Subject: [PATCH 7/9] Update native-build.yml --- .github/workflows/native-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index bf9a26c..26ceb14 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -2,7 +2,7 @@ name: Build Cable Modem Agent Component in Native Environment on: push: - branches: [ main, 'sprint/**', 'release/**', 'feature/**', develop ] + branches: [ main, 'sprint/**', 'release/**', develop ] pull_request: branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] From 045f1052d23d82c5ea53a5bf45daf91720e01407 Mon Sep 17 00:00:00 2001 From: dm097 Date: Mon, 2 Feb 2026 10:45:01 +0000 Subject: [PATCH 8/9] RDKB-62988 [GitHub Coverity] Enable Coverity Scan for cable-modem-agent using Native Build Integration Reason for change: addressed co-pilot review comments Test Procedure: verify cable-modem-agent dependency and build native build and using Github workflow Risks: Low Priority: P1 Signed-off-by: dm097 --- .github/workflows/native-build.yml | 2 +- cov_docker_script/component_config.json | 18 +++++++++--------- cov_docker_script/configure_options.conf | 6 +----- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index 26ceb14..42b8c1c 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -2,7 +2,7 @@ name: Build Cable Modem Agent Component in Native Environment on: push: - branches: [ main, 'sprint/**', 'release/**', develop ] + branches: [ main, 'sprint/**', 'release/**','feature/**', develop ] pull_request: branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ] diff --git a/cov_docker_script/component_config.json b/cov_docker_script/component_config.json index 659f024..d152893 100644 --- a/cov_docker_script/component_config.json +++ b/cov_docker_script/component_config.json @@ -75,20 +75,20 @@ ] }, { - "name": "hal-cm-generic", - "repo": "https://code.rdkcentral.com/r/rdkb/components/opensource/ccsp/hal" , + "name": "hal-cm-generic", + "repo": "https://code.rdkcentral.com/r/rdkb/components/opensource/ccsp/hal.git", "branch": "rdk-next", - "repo_dir": "hal-cm-generic/source/cm", - "include_path": "$HOME/usr/include/rdkb/", + "repo_dir": "hal-cm-generic/source/cm", + "include_path": "$HOME/usr/include/rdkb/", "lib_output_path": "$HOME/usr/local/lib", "build": { "type": "commands", "commands": [ - "echo \"${PWD}\"", - "cd source/cm", - "autoreconf -i", + "echo \"${PWD}\"", + "cd source/cm", + "autoreconf -i", "./configure", - "make CFLAGS=\"-Os -pipe -g -feliminate-unused-debug-types -I${HOME}/usr/include/rdkb -I${HOME}/build/rdkb-halif-cm/include\" LDFLAGS=\"-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed\"" + "make CFLAGS=\"-Os -pipe -g -feliminate-unused-debug-types -I${HOME}/usr/include/rdkb -I${HOME}/build/rdkb-halif-cm/include\" LDFLAGS=\"-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed\"" ] } } @@ -119,7 +119,7 @@ "build_dir": "build", "configure_options_file": "cov_docker_script/configure_options.conf", "configure_options": [ - "SRC_DIRS=$HOME/build/cable-model-agent/source/CMAgentSsp/" + "SRC_DIRS=$HOME/build/cable-modem-agent/source/CMAgentSsp/" ] } } diff --git a/cov_docker_script/configure_options.conf b/cov_docker_script/configure_options.conf index 0aa9831..051356c 100644 --- a/cov_docker_script/configure_options.conf +++ b/cov_docker_script/configure_options.conf @@ -65,10 +65,6 @@ -DUTC_ENABLE_ATOM -DXDNS_ENABLE -# MoCA specific --DMOCA_HOME_ISOLATION --DMOCA_DIAGONISTIC - # Cable Modem Agent specific -DENABLE_LLD_SUPPORT @@ -142,5 +138,5 @@ -L$HOME/usr/local/lib/ -Wl,--allow-shlib-undefined -Wl,--unresolved-symbols=ignore-all --ldbus-1 +-ldbus-1 -lccsp_common From c82a0fb1124d7823eee8b0055fcb9e1dc2a0a0e0 Mon Sep 17 00:00:00 2001 From: dm097 Date: Mon, 2 Feb 2026 11:51:52 +0000 Subject: [PATCH 9/9] RDKB-62988 [GitHub Coverity] Enable Coverity Scan for cable-modem-agent using Native Build Integration Reason for change: undoing yml script test changes Test Procedure: verify cable-modem-agent dependency and build native build and using Github workflow Risks: Low Priority: P1 Signed-off-by: dm097 --- .github/workflows/native-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index 42b8c1c..26ceb14 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -2,7 +2,7 @@ name: Build Cable Modem Agent Component in Native Environment on: push: - branches: [ main, 'sprint/**', 'release/**','feature/**', develop ] + branches: [ main, 'sprint/**', 'release/**', develop ] pull_request: branches: [ main, 'sprint/**', 'release/**', topic/RDK*, develop ]