diff --git a/.github/workflows/native-build.yml b/.github/workflows/native-build.yml index 5eacca66..eaf6c899 100644 --- a/.github/workflows/native-build.yml +++ b/.github/workflows/native-build.yml @@ -19,9 +19,15 @@ jobs: - name: native build run: | - 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 + # Trust the workspace + git config --global --add safe.directory '*' + # Pull the latest changes for the native build system + git submodule update --init --recursive --remote + # Build and install dependencies + chmod +x build_tools_workflows/cov_docker_script/setup_dependencies.sh + ./build_tools_workflows/cov_docker_script/setup_dependencies.sh ./cov_docker_script/component_config.json + # Build component + chmod +x build_tools_workflows/cov_docker_script/build_native.sh + ./build_tools_workflows/cov_docker_script/build_native.sh ./cov_docker_script/component_config.json "$(pwd)" env: GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }} diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..05128223 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "build_tools_workflows"] + path = build_tools_workflows + url = https://github.com/rdkcentral/build_tools_workflows + branch = develop diff --git a/build_tools_workflows b/build_tools_workflows new file mode 160000 index 00000000..11f19226 --- /dev/null +++ b/build_tools_workflows @@ -0,0 +1 @@ +Subproject commit 11f192263b3b4358e0d99895d57eab7bda5a8115 diff --git a/cov_docker_script/README.md b/cov_docker_script/README.md deleted file mode 100644 index e06d1a2f..00000000 --- a/cov_docker_script/README.md +++ /dev/null @@ -1,487 +0,0 @@ -# Component Native Build Configuration - -**Coverity/Native build configuration for RDK-B components.** - ---- - -## 📋 Overview - -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: Build main component -└── run_external_build.sh # Wrapper: For dependency builds (used in component_config.json) -``` - -### Important: Add to .gitignore - -Add the following to your component's `.gitignore` to exclude temporary build artifacts: - -```gitignore -# Build tools (downloaded by wrapper scripts) -build_tools_workflows/ - -# Dependency build artifacts -build/ -``` - ---- - -## 🚀 Quick Start - -### Prerequisites - -- Docker container with [docker-rdk-ci](https://github.com/rdkcentral/docker-rdk-ci) image -- All wrapper scripts have execute permissions - -### Build Commands - -#### Complete Build Pipeline - -```bash -# From your component root directory -cd /path/to/your-component - -# Standard build pipeline for main component -./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 -``` - -#### Alternative: Single-Script Build (All-in-One) - -If you prefer to run everything in a single command: - -```bash -# Run setup dependencies + native build in one script -./cov_docker_script/run_external_build.sh - -# Clean build -CLEAN_BUILD=true ./cov_docker_script/run_external_build.sh -``` - -**Note:** `run_external_build.sh` performs both dependency setup and component build in one execution. While primarily designed to be invoked by the dependency setup process when specified in `component_config.json` (see [run_external_build.sh](#3-run_external_buildsh) section), it can also be used directly for the main component as a convenience script that handles the complete build pipeline. - -#### 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 -``` - ---- - -## 📖 Scripts Reference - -### 1. run_setup_dependencies.sh - -**Purpose:** Sets up build tools and runs dependency setup. - -**What it does:** -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 -./run_setup_dependencies.sh - -# Clean build -CLEAN_BUILD=true ./run_setup_dependencies.sh -``` - -**Required files:** -- `component_config.json` (defines dependencies) - -**Outputs:** -- Downloads: `$HOME/build/` (dependency repositories) -- Headers: `$HOME/usr/include/rdkb/` -- 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 - ---- - -### 2. run_native_build.sh - -**Purpose:** Verifies build tools and builds the component. - -**What it does:** -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 -./run_native_build.sh -``` - -**Prerequisites:** -- `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) - -**Outputs:** -- Component libraries in `$HOME/usr/local/lib/` -- Build artifacts in component root directory - ---- - -### 3. run_external_build.sh - -**Purpose:** Builds dependencies with complex build requirements (invoked from component_config.json). - -**Key Differences from run_native_build.sh:** -- Designed for **dependency repositories**, not the main component -- Invokes `common_external_build.sh` without arguments (dependencies manage their own configuration) -- Does **NOT** clean up `build_tools_workflows` (may be used by multiple dependencies) -- Typically called automatically during dependency setup, not manually - -**What it does:** -1. Clones `build_tools_workflows` if not present (or verifies it exists) -2. Verifies `common_external_build.sh` is present -3. Runs `common_external_build.sh` from build_tools_workflows -4. Preserves `build_tools_workflows` directory for subsequent use - -**Usage:** -```bash -./run_external_build.sh -``` - -**Prerequisites:** -- `run_setup_dependencies.sh` must be run first (to clone build_tools_workflows) -- All dependency headers/libraries must be available - -**Outputs:** -- Build artifacts based on common_external_build.sh implementation -- build_tools_workflows remains in place (not cleaned up) - -**Primary Use Case - Dependency Builds in component_config.json:** - -This script is primarily used to build **dependency repositories** that have complex build requirements. When a dependency has its own `cov_docker_script/run_external_build.sh`, it can be invoked from the parent component's `component_config.json`. - -**Example configuration in component_config.json:** - -```json -{ - "name": "Utopia", - "repo": "https://github.com/rdkcentral/utopia.git", - "branch": "feature/cov_native_build", - "header_paths": [ - { "source": "source/include", "destination": "$HOME/usr/include/rdkb" } - ], - "build": { - "type": "script", - "script": "cov_docker_script/run_external_build.sh" - } -} -``` - -**How it works for dependencies:** -1. The parent component's `setup_dependencies.sh` clones the dependency repository (e.g., Utopia) -2. The dependency's `run_external_build.sh` is executed from the dependency's directory -3. This script internally: - - Sets up the dependency's own build tools and dependencies - - Runs the dependency's native build process - - Produces shared libraries (`.so` files) -4. The generated shared libraries are installed to `$HOME/usr/local/lib/` or `$HOME/usr/lib/` -5. These libraries are then available for the parent component's native build - -**When to use this approach:** -- Dependency has complex multi-step build requirements -- Dependency has its own sub-dependencies that need to be built -- Dependency requires custom build logic beyond standard autotools/cmake/meson -- Dependency repository already has a `cov_docker_script/run_external_build.sh` script - -**Note:** This approach allows dependencies to manage their own complete build pipeline, producing the necessary shared libraries that the parent component links against during its native compilation. - ---- - -## 📝 Configuration Files - -### component_config.json - -**JSON configuration defining all dependencies and build settings.** - -**Key Sections:** - -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. - ---- - -### configure_options.conf - -**Autotools configuration file with preprocessor, compiler, and linker flags.** - -**Format:** -```properties -[CPPFLAGS] --I$HOME/usr/include/rdkb/ --DFEATURE_FLAG - -[CFLAGS] --Wall -Wextra - -[LDFLAGS] --L$HOME/usr/local/lib/ -``` - -**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`) - -**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 [configure_options.conf](configure_options.conf) for your component's complete flag list. - ---- - -## 🔧 Build System Architecture - -``` -┌─────────────────────────────────────────────────────┐ -│ 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 │ │ -│ └──────────────────────────────────────────────┘ │ -└─────────────────────────────────────────────────────┘ -``` - ---- - -## 🐛 Troubleshooting - -### Build Failures - -**Problem:** Missing headers - -```bash -# Solution: Check if dependencies were installed -ls -la $HOME/usr/include/rdkb/ - -# Verify component_config.json has correct header_paths -cat component_config.json | jq '.dependencies.repos[].header_paths' - -# Re-run dependency setup -CLEAN_BUILD=true ./cov_docker_script/run_setup_dependencies.sh -``` - -**Problem:** Missing libraries - -```bash -# 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 -``` - -**Problem:** Configure errors - -```bash -# Solution: Check configure_options.conf syntax -cat cov_docker_script/configure_options.conf - -# Verify flags are valid -./configure --help -``` - -### Script Errors - -**Problem:** Script not found - -```bash -# Solution: Ensure scripts are executable -chmod +x cov_docker_script/*.sh - -# Check if build_tools_workflows was cloned -ls -la ../build_tools_workflows/ -``` - -**Problem:** Permission denied - -```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) -``` - ---- - -## 📚 Related Documentation - -- **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:** [moca-agent](https://github.com/rdkcentral/moca-agent) (reference implementation) -- **Detailed Build Guide:** See `build_tools_workflows/cov_docker_script/README.md` - ---- - -## ⚠️ Important Notes - -### DO NOT Modify - -The following scripts are automatically copied from `build_tools_workflows` and **must not be modified locally**: - -- ❌ `build_native.sh` -- ❌ `common_build_utils.sh` -- ❌ `common_external_build.sh` -- ❌ `setup_dependencies.sh` - -Any changes will be overwritten when wrapper scripts run. - -### DO Modify - -The following files are component-specific and **should be customized**: - -- ✅ `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) - ---- - -## 🔄 Workflow Integration - -### Local Development - -```bash -# Make changes to source code -vim source/your_component.c - -# Rebuild component -CLEAN_BUILD=true ./cov_docker_script/run_native_build.sh -``` - -### CI/CD Integration - -This configuration is used by GitHub Actions to validate builds: - -```yaml -- name: Setup Dependencies - run: ./cov_docker_script/run_setup_dependencies.sh - -- name: Build Component - run: ./cov_docker_script/run_native_build.sh -``` - -See `.github/workflows/` for complete CI configuration. - ---- - -## 📞 Support - -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/component_config.json b/cov_docker_script/component_config.json index d292cdf4..6dfde135 100644 --- a/cov_docker_script/component_config.json +++ b/cov_docker_script/component_config.json @@ -193,7 +193,7 @@ ], "build": { "type": "script", - "script": "cov_docker_script/run_external_build.sh" + "script": "build_tools_workflows/cov_docker_script/common_external_build.sh" } }, { diff --git a/cov_docker_script/run_external_build.sh b/cov_docker_script/run_external_build.sh deleted file mode 100755 index d6e9a21e..00000000 --- a/cov_docker_script/run_external_build.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env bash -set -e - -################################################################################ -# External Build Wrapper Script -# Verifies build tools and runs common_external_build.sh -# Usage: ./run_external_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_REPO_URL="https://github.com/rdkcentral/build_tools_workflows" -BUILD_TOOLS_DIR="$NATIVE_COMPONENT_DIR/build_tools_workflows" - -# Basic logging functions -log() { echo "[INFO] $*"; } -ok() { echo "[OK] $*"; } -err() { echo "[ERROR] $*" >&2; } - -echo "" -echo "===== External Build Pipeline =====" -echo "" - -# Clone build_tools_workflows if it doesn't exist -if [[ ! -d "$BUILD_TOOLS_DIR" ]]; then - log "build_tools_workflows not found, cloning repository..." - cd "$NATIVE_COMPONENT_DIR" - git clone -b develop "$BUILD_TOOLS_REPO_URL" || { err "Clone failed"; exit 1; } - ok "Repository cloned successfully" -else - log "build_tools_workflows already exists" -fi - -if [[ ! -f "$BUILD_TOOLS_DIR/cov_docker_script/common_external_build.sh" ]]; then - err "common_external_build.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 common_external_build.sh from build_tools_workflows -echo "" -log "Running common_external_build.sh from build_tools_workflows..." -cd "$NATIVE_COMPONENT_DIR" -"$BUILD_TOOLS_DIR/cov_docker_script/common_external_build.sh" "$SCRIPT_DIR/component_config.json" "$NATIVE_COMPONENT_DIR" - -echo "" -ok "External build completed successfully!" - -echo "" diff --git a/cov_docker_script/run_native_build.sh b/cov_docker_script/run_native_build.sh deleted file mode 100755 index 9d3aea3b..00000000 --- a/cov_docker_script/run_native_build.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/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 deleted file mode 100755 index 5223c841..00000000 --- a/cov_docker_script/run_setup_dependencies.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 ""