Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper script maintenance #268

Merged
merged 4 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions make-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ _TGT_TYPE="DPDK"
_TOOLFILE=${CMAKE_TOOLCHAIN_FILE}

_BLD_DIR=build
_CFG_ONLY=0
_DO_BUILD=1
_DRY_RUN=0
_CFG_ONLY=0
_OVS_BLD="ovs/build"
_WITH_OVS=1

Expand All @@ -45,16 +44,16 @@ print_help() {
echo " --ovs=DIR -O OVS install directory [${_OVS_DIR}]"
echo " --prefix=DIR -P Install directory prefix [${_PREFIX}]"
echo " --sde=DIR -S SDE install directory [${_SDE_DIR}]"
echo " --staging=DIR Staging directory prefix [${_STAGING}]"
# echo " --staging=DIR Staging directory prefix [${_STAGING}]"
echo " --toolchain=FILE -T CMake toolchain file"
echo ""
echo "Options:"
echo " --config Configure without building"
echo " --coverage Instrument build to measure code coverage"
echo " --cxx-std=STD C++ standard (11|14|17) [$_CXX_STD])"
echo " --dry-run -n Display cmake parameter values and exit"
echo " --help -h Display this help text"
echo " --jobs=NJOBS -j Number of build threads [${_NJOBS}]"
echo " --no-build Configure without building"
echo " --no-krnlmon Exclude Kernel Monitor"
echo " --no-ovs Exclude OVS support"
echo " --target=TARGET Target to build (dpdk|es2k|tofino) [${_TGT_TYPE}]"
Expand Down Expand Up @@ -97,7 +96,7 @@ print_cmake_params() {
[ -n "${_COVERAGE}" ] && echo "${_COVERAGE:2}"
echo "${_SET_RPATH:2}"
echo "${_TARGET_TYPE:2}"
if [ ${_CFG_ONLY} -ne 0 ]; then
if [ ${_DO_BUILD} -eq 0 ]; then
echo ""
echo "Configure without building"
echo ""
Expand Down Expand Up @@ -167,10 +166,11 @@ SHORTOPTS=D:H:O:P:S:T:
SHORTOPTS=${SHORTOPTS}hj:n

LONGOPTS=deps:,hostdeps:,ovs:,prefix:,sde:,toolchain:
LONGOPTS=${LONGOPTS},cxx-std:,staging:,target:
LONGOPTS=${LONGOPTS},cxx-std:,jobs:,staging:,target:
LONGOPTS=${LONGOPTS},debug,release,minsize,reldeb
LONGOPTS=${LONGOPTS},dry-run,help,jobs:,no-krnlmon,no-ovs
LONGOPTS=${LONGOPTS},config,coverage,ninja,rpath,no-rpath
LONGOPTS=${LONGOPTS},dry-run,help
LONGOPTS=${LONGOPTS},coverage,ninja,rpath
LONGOPTS=${LONGOPTS},no-build,no-krnlmon,no-ovs,no-rpath

GETOPTS=$(getopt -o ${SHORTOPTS} --long ${LONGOPTS} -- "$@")
eval set -- "${GETOPTS}"
Expand Down Expand Up @@ -214,9 +214,6 @@ while true ; do
_BLD_TYPE="Release"
shift ;;
# Options
--config)
_CFG_ONLY=1
shift ;;
--coverage)
_COVERAGE="-DTEST_COVERAGE=ON"
shift ;;
Expand All @@ -235,6 +232,9 @@ while true ; do
--ninja)
_GENERATOR="-G Ninja"
shift 1 ;;
--no-build)
_DO_BUILD=0
shift ;;
--no-krnlmon)
_WITH_KRNLMON=FALSE
shift ;;
Expand Down Expand Up @@ -296,6 +296,6 @@ if [ ${_WITH_OVS} -ne 0 ]; then
fi

config_recipe
if [ ${_CFG_ONLY} -eq 0 ]; then
if [ ${_DO_BUILD} -ne 0 ]; then
build_recipe
fi
21 changes: 11 additions & 10 deletions scripts/es2k/config-cross-recipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,32 +106,32 @@ eval set -- "${GETOPTS}"
while true ; do
case "$1" in
# Paths
-B|--build)
--build|-B)
_BLD_DIR=$2
shift 2 ;;
-D|--deps)
--deps|-D)
_DEPS_DIR=$2
shift 2 ;;
-H|--hostdeps)
--hostdeps|-H)
_HOST_DIR=$2
shift 2 ;;
-O|--ovs)
--ovs|-O)
_OVS_DIR=$2
shift 2 ;;
-P|--prefix)
--prefix|-P)
_PREFIX=$2
shift 2 ;;
-S|--sde)
--sde|-S)
_SDE_DIR=$2
shift 2 ;;
-T|--toolchain)
--toolchain|-T)
_TOOLFILE=$2
shift 2 ;;
# Options
-n|--dry-run)
--dry-run|-n)
_DRY_RUN=1
shift 1 ;;
-h|--help)
--help|-h)
print_help
exit 99 ;;
--no-krnlmon)
Expand Down Expand Up @@ -176,7 +176,8 @@ fi

rm -fr "${_BLD_DIR}"

cmake -S . -B "${_BLD_DIR}" \
# shellcheck disable=SC2086
cmake -S . -B "${_BLD_DIR}" \
-DCMAKE_BUILD_TYPE=${_BLD_TYPE} \
-DCMAKE_INSTALL_PREFIX="${_PREFIX}" \
-DCMAKE_TOOLCHAIN_FILE="${_TOOLFILE}" \
Expand Down
45 changes: 26 additions & 19 deletions scripts/es2k/make-cross-ovs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ _SYSROOT=${SDKTARGETSYSROOT}

_BLD_DIR=ovs/build
_BLD_TYPE=RelWithDebInfo
_JOBS=8
_DRY_RUN=0
_NJOBS=8
_PREFIX=//opt/ovs
_TOOLFILE=${CMAKE_TOOLCHAIN_FILE}

Expand All @@ -39,13 +40,16 @@ print_help() {
echo ""
echo "Build and install Open vSwitch"
echo ""
echo "Options:"
echo "Paths:"
echo " --build=DIR -B Build directory path [${_BLD_DIR}]"
echo " --dry-run -n Display cmake parameters and exit"
echo " --jobs=NJOBS -j Number of build threads (Default: ${_JOBS})"
echo " --prefix=DIR* -P Install directory prefix [${_PREFIX}]"
echo " --toolchain=FILE -T CMake toolchain file"
echo ""
echo "Options:"
echo " --dry-run -n Display cmake parameters and exit"
echo " --help -h Display this help text"
echo " --jobs=NJOBS -j Number of build threads [${_NJOBS}]"
echo ""
echo "* '//' at the beginning of the directory path will be replaced"
echo " with the sysroot directory path."
echo ""
Expand All @@ -64,7 +68,7 @@ print_cmake_params() {
echo "CMAKE_BUILD_TYPE=${_BLD_TYPE}"
echo "CMAKE_INSTALL_PREFIX=${_PREFIX}"
echo "CMAKE_TOOLCHAIN_FILE=${_TOOLFILE}"
echo "JOBS=${_JOBS}"
echo "JOBS=${_NJOBS}"
echo ""
}

Expand All @@ -83,24 +87,26 @@ eval set -- "${GETOPTS}"

while true ; do
case "$1" in
-B|--build)
# Paths
--build|-B)
_BLD_DIR=$2
shift 2 ;;
-n|--dry-run)
_DRY_RUN=true
shift 1 ;;
-h|--help)
print_help
exit 99 ;;
-j|--jobs)
_JOBS=$2
shift 2 ;;
-P|--prefix)
--prefix|-P)
_PREFIX=$2
shift 2 ;;
-T|--toolchain)
--toolchain|-T)
_TOOLFILE=$2
shift 2 ;;
# Options
--dry-run|-n)
_DRY_RUN=1
shift 1 ;;
--help|-h)
print_help
exit 99 ;;
--jobs|-j)
_NJOBS=$2
shift 2 ;;
--)
shift
break ;;
Expand All @@ -117,7 +123,8 @@ done
# Substitute ${_SYSROOT}/ for '//' prefix
[ "${_PREFIX:0:2}" = "//" ] && _PREFIX=${_SYSROOT}/${_PREFIX:2}

if [ "${_DRY_RUN}" = "true" ]; then
# Show parameters if this is a dry run
if [ ${_DRY_RUN} -ne 0 ]; then
print_cmake_params
exit 0
fi
Expand All @@ -138,4 +145,4 @@ cmake -S ovs -B "${_BLD_DIR}" \
# Build OVS #
#############

cmake --build "${_BLD_DIR}" "-j${_JOBS}" -- V=0
cmake --build "${_BLD_DIR}" "-j${_NJOBS}" -- V=0
36 changes: 26 additions & 10 deletions setup/make-cross-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ _SYSROOT=${SDKTARGETSYSROOT}
##################

_BLD_DIR=build
_DO_BUILD=true
_DRY_RUN=false
_JOBS=8
_NJOBS=8
_PREFIX=//opt/deps
_TOOLFILE=${CMAKE_TOOLCHAIN_FILE}

Expand All @@ -40,17 +41,21 @@ print_help() {
echo ""
echo "Build target dependency libraries"
echo ""
echo "Options:"
echo "Paths:"
echo " --build=DIR -B Build directory path [${_BLD_DIR}]"
echo " --host=DIR -H Host dependencies directory [${_HOST_DIR}]"
echo " --prefix=DIR* -P Install directory prefix [${_PREFIX}]"
echo " --toolchain=FILE -T CMake toolchain file"
echo ""
echo "Options:"
echo " --cxx=VERSION CXX_STANDARD to build dependencies (Default: empty)"
echo " --dry-run -n Display cmake parameters and exit"
echo " --force -f Specify -f when patching (Default: false)"
echo " --host=DIR -H Host dependencies directory [${_HOST_DIR}]"
echo " --jobs=NJOBS -j Number of build threads (Default: ${_JOBS})"
echo " --help -h Display this help text"
echo " --jobs=NJOBS -j Number of build threads (Default: ${_NJOBS})"
echo " --no-build Configure without building"
echo " --no-download Do not download repositories (Default: false)"
echo " --prefix=DIR* -P Install directory prefix [${_PREFIX}]"
echo " --sudo Use sudo when installing (Default: false)"
echo " --toolchain=FILE -T CMake toolchain file"
echo ""
echo "* '//' at the beginning of the directory path will be replaced"
echo " with the sysroot directory path."
Expand All @@ -67,7 +72,7 @@ print_help() {

SHORTOPTS=B:H:P:T:fhj:n
LONGOPTS=build:,cxx:,hostdeps:,jobs:,prefix:,toolchain:
LONGOPTS=${LONGOPTS},dry-run,force,help,no-download,sudo
LONGOPTS=${LONGOPTS},dry-run,force,help,no-build,no-download,sudo

eval set -- `getopt -o ${SHORTOPTS} --long ${LONGOPTS} -- "$@"`

Expand Down Expand Up @@ -97,11 +102,14 @@ while true ; do
print_help
exit 99 ;;
-j|--jobs)
_JOBS=$2
_NJOBS=$2
shift 2 ;;
-n|--dry-run)
_DRY_RUN=true
shift 1 ;;
--no-build)
_DO_BUILD=false
shift ;;
--no-download)
_DOWNLOAD="-DDOWNLOAD=FALSE"
shift 1 ;;
Expand Down Expand Up @@ -132,12 +140,18 @@ if [ "${_DRY_RUN}" = "true" ]; then
echo ""
echo "CMAKE_INSTALL_PREFIX=${_PREFIX}"
echo "CMAKE_TOOLCHAIN_FILE=${_TOOLFILE}"
echo "JOBS=${_JOBS}"
echo "JOBS=${_NJOBS}"
[ -n "${_CXX_STANDARD_OPTION}" ] && echo "${_CXX_STANDARD_OPTION:2}"
[ -n "${_DOWNLOAD}" ] && echo "${_DOWNLOAD:2}"
[ -n "${_HOST_DEPEND_DIR}" ] && echo "${_HOST_DEPEND_DIR:2}"
[ -n "${_FORCE_PATCH}" ] && echo "${_FORCE_PATCH:2}"
[ -n "${_USE_SUDO}" ] && echo "${_USE_SUDO:2}"

if [ "${_DO_BUILD}" = "false" ]; then
echo ""
echo "Configure without building"
fi

echo ""
exit 0
fi
Expand All @@ -155,4 +169,6 @@ cmake -S . -B ${_BLD_DIR} \
${_CXX_STANDARD_OPTION} \
${_DOWNLOAD} ${_FORCE_PATCH} ${_USE_SUDO}

cmake --build ${_BLD_DIR} -j${_JOBS}
if [ "${_DO_BUILD}" = "true" ]; then
cmake --build ${_BLD_DIR} -j${_NJOBS}
fi
Loading