Skip to content

Commit

Permalink
FIX: CMakeLists.txt to treat sample apps as binary runtime targets
Browse files Browse the repository at this point in the history
FIX: CMakeLists.txt to treat sample apps as binary runtime targets
ADD: `_build` and `_install` directories to `.dockerignore`
FIX: SDK build.sh script to work as intended
Minor code adjustments

Signed-off-by: Milosz Linkiewicz <[email protected]>
  • Loading branch information
Mionsz committed Nov 26, 2024
1 parent fc61dd7 commit 15e9d0e
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 73 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# .dockerignore

_build
_install
docs/_build/*
build
out/*
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ env:
PREFIX_DIR: "${{ github.workspace }}/_install"
MTL_BUILD_DISABLE_PCAPNG: true
DEBIAN_FRONTEND: noninteractive
TRY_CACHE_REFRESH: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

permissions:
contents: read
Expand Down Expand Up @@ -80,7 +81,7 @@ jobs:
run: eval 'source scripts/setup_build_env.sh && lib_install_grpc'

- name: 'Save local dependencies build cache'
if: steps.load-local-dependencies-cache.outputs.cache-hit != 'true'
if: env.TRY_CACHE_REFRESH == 'true' && steps.load-local-dependencies-cache.outputs.cache-hit != 'true'
id: save-local-dependencies-cache
uses: actions/cache/save@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
Expand Down
18 changes: 3 additions & 15 deletions .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,8 @@ jobs:
with:
ref: ${{ inputs.branch }}

- name: 'Install dependencies'
run: |
sudo apt-get update -y && \
sudo apt-get install -y --no-install-recommends \
git build-essential meson python3 python3-pyelftools pkg-config \
libnuma-dev libjson-c-dev libpcap-dev libgtest-dev libsdl2-dev \
libsdl2-ttf-dev libssl-dev ca-certificates m4 clang llvm zlib1g-dev \
libelf-dev libcap-ng-dev libcap2-bin gcc-multilib systemtap-sdt-dev ninja-build \
nasm dpdk-dev librdmacm-dev && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/*
- name: 'Install OS level dependencies'
run: eval 'source scripts/setup_build_env.sh && install_package_dependencies'

- name: 'Build and Install xdp and libbpf'
run: |
Expand Down Expand Up @@ -102,10 +93,7 @@ jobs:

- name: 'Patch and configure MCM FFmpeg plugin'
working-directory: ${{ github.workspace }}/ffmpeg-plugin
run: |
git config --global user.email "[email protected]"
git config --global user.name "Milosz Linkiewicz"
./clone-and-patch-ffmpeg.sh
run: ./clone-and-patch-ffmpeg.sh

- name: 'Run coverity'
uses: vapier/coverity-scan-action@2068473c7bdf8c2fb984a6a40ae76ee7facd7a85 # v1.8.0
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/ubuntu-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,8 @@ jobs:
- name: 'Checkout repository'
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: 'Install dependencies'
run: |
sudo apt-get update -y && \
sudo apt-get install -y --no-install-recommends \
git build-essential meson python3 python3-pyelftools pkg-config \
libnuma-dev libjson-c-dev libpcap-dev libgtest-dev libsdl2-dev \
libsdl2-ttf-dev libssl-dev ca-certificates m4 clang llvm zlib1g-dev \
libelf-dev libcap-ng-dev libcap2-bin gcc-multilib systemtap-sdt-dev ninja-build \
nasm dpdk-dev librdmacm-dev && \
sudo apt-get clean && \
sudo rm -rf /var/lib/apt/lists/*
- name: 'Install OS level dependencies'
run: eval 'source scripts/setup_build_env.sh && install_package_dependencies'

- name: 'Build and Install xdp and libbpf'
run: |
Expand Down
26 changes: 17 additions & 9 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation

# Passing custom path as a parameter to this script will install
# SDK in to default path and the one pointed as $1

set -eo pipefail

SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
BUILD_DIR="${BUILD_DIR:-${SCRIPT_DIR}/_build}"
MCM_BUILD_DIR="${MCM_BUILD_DIR:-${BUILD_DIR}/mcm}"

# shellcheck source="scripts/common.sh"
. "${SCRIPT_DIR}/scripts/common.sh"
Expand All @@ -16,21 +22,23 @@ BUILD_TYPE="${BUILD_TYPE:-Release}"
BUILD_UNIT_TESTS="${BUILD_UNIT_TESTS:-ON}"
INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}"

cmake -B "${BUILD_DIR}" \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
cmake -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DBUILD_UNIT_TESTS="${BUILD_UNIT_TESTS}" \
"${SCRIPT_DIR}"
cmake --build "${BUILD_DIR}" -j
-B "${MCM_BUILD_DIR}" -S "${SCRIPT_DIR}"
cmake --build "${MCM_BUILD_DIR}" -j

as_root make -C "${MCM_BUILD_DIR}" install

if [[ $# -ne 0 ]]; then
DESTDIR="${1:-$DESTDIR}" make -C "${MCM_BUILD_DIR}" install
fi

# Install
as_root cmake --install "${BUILD_DIR}"
as_root ln -s /usr/lib64/libbpf.so.1 /usr/lib/x86_64-linux-gnu/libbpf.so.1 2>/dev/null || true
as_root ldconfig

# Run unit tests
export LD_LIBRARY_PATH="${PREFIX_DIR}/usr/local/lib:/usr/local/lib64"
"${BUILD_DIR}/bin/sdk_unit_tests"
"${BUILD_DIR}/bin/media_proxy_unit_tests"
"${MCM_BUILD_DIR}/bin/sdk_unit_tests"
"${MCM_BUILD_DIR}/bin/media_proxy_unit_tests"

log_info "Build Succeeded"
27 changes: 19 additions & 8 deletions ffmpeg-plugin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,19 @@ SHELL ["/bin/bash", "-exo", "pipefail", "-c"]
RUN apt-get update && \
apt-get full-upgrade -y && \
apt-get install --no-install-recommends -y \
sudo apt-utils build-essential make cmake git ca-certificates pkg-config nasm libbsd-dev libx264-dev && \
build-essential \
ca-certificates \
libbsd-dev \
libx264-dev \
pkg-config \
apt-utils \
sudo \
make \
cmake \
git \
nasm \
curl \
tar && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p "${GRPC_DIR}" && \
Expand All @@ -35,9 +47,7 @@ RUN cmake -DgRPC_BUILD_TESTS=OFF -DgRPC_INSTALL=ON ../.. && \

COPY . ${MCM_DIR}
WORKDIR ${MCM_DIR}
RUN git config --global user.email "[email protected]" && \
git config --global user.name "Intel" && \
./sdk/build.sh && \
RUN ./sdk/build.sh && \
INSTALL_PREFIX="${PREFIX_DIR}/usr/local" ./sdk/build.sh && \
./ffmpeg-plugin/clone-and-patch-ffmpeg.sh && \
./ffmpeg-plugin/configure-ffmpeg.sh --enable-libx264 --enable-gpl --prefix="${PREFIX_DIR}/usr/local"
Expand Down Expand Up @@ -67,7 +77,11 @@ SHELL ["/bin/bash", "-exc"]
RUN apt-get update && \
apt-get full-upgrade -y && \
apt-get install --no-install-recommends -y \
libbsd0 vim net-tools ca-certificates sudo libx264-163 && \
ca-certificates \
vim net-tools \
libx264-163 \
libbsd0 \
sudo && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
groupadd -g 2110 vfio && \
Expand All @@ -76,9 +90,6 @@ RUN apt-get update && \
usermod -aG sudo mcm

COPY --chown=mcm --from=builder "${PREFIX_DIR}" /
COPY --chown=mcm --chmod=755 --from=builder "${MCM_DIR}/sdk/build/samples/recver_app" "${MCM_DIR}/recver_app"
COPY --chown=mcm --chmod=755 --from=builder "${MCM_DIR}/sdk/build/samples/sender_app" "${MCM_DIR}/sender_app"

RUN ldconfig

USER mcm
Expand Down
2 changes: 1 addition & 1 deletion media-proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ RUN ./build.sh build-only && \
# Build MCM
WORKDIR ${MCM_DIR}
COPY . ${MCM_DIR}
RUN INSTALL_PREFIX="${PREFIX_DIR}/usr/local" ./build.sh && \
RUN ./build.sh "${PREFIX_DIR}" && \
cp "${MTL_DIR}/build/manager/MtlManager" "${PREFIX_DIR}/usr/local/bin/" && \
cp -fR "/usr/local/lib/bpf/"* "${PREFIX_DIR}/usr/local/lib/bpf/" && \
rm -rf "${PREFIX_DIR}/usr/lib64/"*.a && \
Expand Down
18 changes: 11 additions & 7 deletions media-proxy/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation

# Passing custom path as a parameter to this script will install
# SDK in to default path and the one pointed as $1

set -eo pipefail
SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
REPO_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}"
MCM_MEDIA_PROXY_DIR="${MCM_MEDIA_PROXY_DIR:-${BUILD_DIR}/mcm-media-proxy}"

# shellcheck source="../scripts/common.sh"
. "${REPO_DIR}/scripts/common.sh"
Expand All @@ -14,11 +19,10 @@ REPO_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
BUILD_TYPE="${BUILD_TYPE:-Release}"
INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}"

cmake -B "${SCRIPT_DIR}/out" \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
"${SCRIPT_DIR}"
cmake --build "${SCRIPT_DIR}/out" -j
cmake -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -B "${MCM_MEDIA_PROXY_DIR}" -S "${SCRIPT_DIR}"

as_root make -C "${MCM_MEDIA_PROXY_DIR}" install

# Install
as_root cmake --install "${SCRIPT_DIR}/out"
if [[ $# -ne 0 ]]; then
DESTDIR="${1:-$DESTDIR}" make -C "${MCM_MEDIA_PROXY_DIR}" install
fi
10 changes: 10 additions & 0 deletions scripts/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@

COMMON_SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
REPOSITORY_DIR="$(readlink -f "${COMMON_SCRIPT_DIR}/..")"
VERSIONS_FILE_PATH="$(readlink -f "${VERSIONS_FILE_PATH:-${REPOSITORY_DIR}/versions.env}")"
export VERSIONS_FILE_PATH

# shellcheck source="versions.env"
. "${VERSIONS_FILE_PATH}"

PM="${PM:-apt-get}"
KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}"
export TZ="${TZ:-Europe/Warsaw}"
export NPROC="${NPROC:-$(nproc)}"

if ! grep "/root/.local/bin" <<< "${PATH}" > /dev/null 2>&1; then
export PATH="/root/.local/bin:/root/bin:/root/usr/bin:${PATH}"
Expand Down
20 changes: 8 additions & 12 deletions scripts/setup_build_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,17 @@ set +x

SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
REPO_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
VERSIONS_FILE_PATH="$(readlink -f "${VERSIONS_FILE_PATH:-${REPO_DIR}/versions.env}")"
BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}"
PREFIX_DIR="${PREFIX_DIR:-${REPO_DIR}/_install}"
DRIVERS_DIR="${DRIVERS_DIR:-/opt/intel/drivers}"

. "${VERSIONS_FILE_PATH}"
. "${SCRIPT_DIR}/common.sh"

ICE_DIR="${DRIVERS_DIR}/ice/${ICE_VER}"
IAVF_DIR="${DRIVERS_DIR}/iavf/${IAVF_VER}"
IRDMA_DIR="${DRIVERS_DIR}/irdma/${IRDMA_VER}"

export PM="${PM:-apt-get}"
export TZ="${TZ:-Europe/Warsaw}"
export NPROC="${NPROC:-$(nproc)}"
export DEBIAN_FRONTEND="noninteractive"

export KERNEL_VERSION="${KERNEL_VERSION:-$(uname -r)}"
Expand All @@ -45,7 +41,6 @@ LIBFABRIC_DIR="${BUILD_DIR}/libfabric"
LIBFDT_DIR="${BUILD_DIR}/libfdt"
JSONC_DIR="${BUILD_DIR}/json-c"
NASM_DIR="${BUILD_DIR}/nasm"
MCM_SDK_DIR="${BUILD_DIR}/mcm-sdk"

function install_package_dependencies()
{
Expand Down Expand Up @@ -197,16 +192,18 @@ function get_and_patch_intel_drivers()
pushd "${ICE_DIR}" && \
patch -p1 -i <(cat "${MTL_DIR}/patches/ice_drv/${ICE_VER}/"*.patch) && \
popd && \
log_info "Intel drivers: Finished download and patching actions."
{ log_success "Intel drivers: Finished download and patching actions." && return 0; } ||
{ log_error "Intel drivers: Failed to download or patch." && return 1; }
}

function build_install_and_config_intel_drivers()
{
log_info "Intel IAVF: Driver starting the build and install workflow." && \
as_root make "-j${NPROC}" -C "${IAVF_DIR}/src" install && \
log_info "Intel ICE: Driver starting the build and install workflow." && \
as_root make "-j${NPROC}" -C "${ICE_DIR}/src" install && \
return 0 || return 1
{ log_success "Intel IAVF and ICE: Drivers finished install process." && return 0; } ||
{ log_error "Intel IAVF and ICE: Failed to build and install drivers" && return 1; }
}

function build_install_and_config_irdma_drivers()
Expand All @@ -216,7 +213,8 @@ function build_install_and_config_irdma_drivers()
popd && \
as_root config_intel_rdma_driver && \
as_root modprobe irdma && \
return 0 || return 1
{ log_success "Intel irdma: Finished configuration and installation successfully." && return 0; } || \
{ log_error "Intel irdma: Error while performing configuration/installation." && return 1; }
}

# Download and install rpm repo for nasm
Expand Down Expand Up @@ -376,12 +374,10 @@ then
get_download_unpack_dependencies
log_info Finished: OS packages installation, MTL and DPDK download.
get_and_patch_intel_drivers
full_build_and_install_workflow || \
log_info Starting: Build, install and configuration of Intel drivers.
full_build_and_install_workflow
build_install_and_config_irdma_drivers
build_install_and_config_intel_drivers || \
{ log_error Intel drivers configuration/installation failed. && exit 1; }
build_install_and_config_irdma_drivers || \
{ log_error Intel irdma configuration/installation failed. && exit 1; }
log_success Finished: Build, install and configuration of Intel drivers.
log_success All tasks compleated. Reboot required.
log_warning ""
Expand Down
6 changes: 2 additions & 4 deletions sdk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ RUN cmake -DgRPC_BUILD_TESTS=OFF -DgRPC_INSTALL=ON ../.. && \
make install

COPY . ${MCM_DIR}

WORKDIR ${MCM_DIR}/sdk
RUN INSTALL_PREFIX="${PREFIX_DIR}/usr/local" ./build.sh
RUN ./build.sh "${PREFIX_DIR}"

ARG IMAGE_CACHE_REGISTRY
ARG IMAGE_NAME
Expand All @@ -47,7 +48,6 @@ LABEL org.opencontainers.image.version="1.0.0"
LABEL org.opencontainers.image.vendor="Intel Corporation"
LABEL org.opencontainers.image.licenses="BSD 3-Clause License"


ARG MCM_DIR="/opt/mcm"
ARG PREFIX_DIR="/install"

Expand All @@ -71,8 +71,6 @@ RUN apt-get update && \
usermod -aG sudo mcm

COPY --chown=1002 --from=builder "${PREFIX_DIR}" /
COPY --chown=1002 --chmod=755 --from=builder "${MCM_DIR}/sdk/build/samples/recver_app" "${MCM_DIR}/recver_app"
COPY --chown=1002 --chmod=755 --from=builder "${MCM_DIR}/sdk/build/samples/sender_app" "${MCM_DIR}/sender_app"

RUN ldconfig
WORKDIR /opt/mcm/
Expand Down
17 changes: 12 additions & 5 deletions sdk/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2024 Intel Corporation

# Passing custom path as a parameter to this script will install
# SDK in to default path and the one pointed as $1

set -eo pipefail

SCRIPT_DIR="$(readlink -f "$(dirname -- "${BASH_SOURCE[0]}")")"
REPO_DIR="$(readlink -f "${SCRIPT_DIR}/..")"
BUILD_DIR="${BUILD_DIR:-${REPO_DIR}/_build}"
MCM_SDK_DIR="${MCM_SDK_DIR:-${BUILD_DIR}/mcm/sdk}"
MCM_SDK_DIR="${MCM_SDK_DIR:-${BUILD_DIR}/mcm-sdk}"

# shellcheck source="../scripts/common.sh"
. "${SCRIPT_DIR}/../scripts/common.sh"

# Set build type. ("Debug" or "Release")
BUILD_TYPE="${BUILD_TYPE:-Release}"
INSTALL_PREFIX="${INSTALL_PREFIX:-/usr/local}"

cmake -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" -B "${MCM_SDK_DIR}" -S "${SCRIPT_DIR}"

cmake -B "${MCM_SDK_DIR}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" "${SCRIPT_DIR}"
cmake --build "${MCM_SDK_DIR}" -j
as_root make -C "${MCM_SDK_DIR}" install

# Install
as_root cmake --install "${MCM_SDK_DIR}" --prefix "${INSTALL_PREFIX}"
if [[ $# -ne 0 ]]; then
DESTDIR="${1:-$DESTDIR}" make -C "${MCM_SDK_DIR}" install
fi
2 changes: 2 additions & 0 deletions sdk/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ target_link_libraries(ping_app PRIVATE mcm_dp)
add_executable(pong_app pong_app.c pingpong_common.c)
target_include_directories(pong_app PRIVATE ../include)
target_link_libraries(pong_app PRIVATE mcm_dp)

install(TARGETS sender_app recver_app ping_app pong_app RUNTIME COMPONENT Runtime)

0 comments on commit 15e9d0e

Please sign in to comment.