#!/bin/bash
###############################################################################
# Copyright (C) Intel Corporation
#
# SPDX-License-Identifier: MIT
###############################################################################
# Build project.

if [ -z "$BASH_VERSION" ]
then
  echo "This script must be run under bash"
  exit 1
fi

if [ "$0" = "$BASH_SOURCE" ]
then
  set -o errexit
else
  echo "Warning: This script should not be sourced. Skipping exit on error."
fi

SCRIPT_DIR="$( cd "$(dirname "${BASH_SOURCE[0]:-$0}")" >/dev/null 2>&1 ; pwd -P )"

# Read command line options
. "${SCRIPT_DIR}/_buildopts.sh" \
    --name build \
    --desc "Build project." \
    -- "$@"

echo "Building project code..."

pushd "${ROOT_DIR}"
    echo "Building base component..."
    oneVPL/script/build ${FORWARD_OPTS}
    echo "Installing base component..."
    oneVPL/script/install ${FORWARD_OPTS}
    echo "Building cpu component..."
    oneVPL-cpu/script/build ${FORWARD_OPTS}
    echo "Installing cpu component..."
    oneVPL-cpu/script/install ${FORWARD_OPTS}
popd
