Skip to content

Commit 47120df

Browse files
authored
Helper script maintenance (#268)
make_all.sh: - Rename --config option to --no-build. - Remove --staging option from help text. It is experimental and should not be advertised. config-cross-recipe.sh: - Swap short and long option names in switch statement to make it clearer that the names are alphabetized by long name. - Address shellcheck issue. make-cross-ovs.sh: - Divide help text into Paths and Options sections. - Make _DRY_RUN a numeric variable, and rename _JOBS to _NJOBS, for consistency with other helper scripts. make-cross-deps.sh: - Divide help text into Paths and Options sections. - Implement --no-build option. - Rename _JOBS variable to _NJOBS. make-host-deps.sh: - Divide help text into Paths and Options sections. - Rename --config option to --no-build. Signed-off-by: Derek G Foster <[email protected]>
1 parent a6cd6cd commit 47120df

File tree

5 files changed

+92
-65
lines changed

5 files changed

+92
-65
lines changed

make-all.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ _TGT_TYPE="DPDK"
2525
_TOOLFILE=${CMAKE_TOOLCHAIN_FILE}
2626

2727
_BLD_DIR=build
28-
_CFG_ONLY=0
28+
_DO_BUILD=1
2929
_DRY_RUN=0
30-
_CFG_ONLY=0
3130
_OVS_BLD="ovs/build"
3231
_WITH_OVS=1
3332

@@ -45,16 +44,16 @@ print_help() {
4544
echo " --ovs=DIR -O OVS install directory [${_OVS_DIR}]"
4645
echo " --prefix=DIR -P Install directory prefix [${_PREFIX}]"
4746
echo " --sde=DIR -S SDE install directory [${_SDE_DIR}]"
48-
echo " --staging=DIR Staging directory prefix [${_STAGING}]"
47+
# echo " --staging=DIR Staging directory prefix [${_STAGING}]"
4948
echo " --toolchain=FILE -T CMake toolchain file"
5049
echo ""
5150
echo "Options:"
52-
echo " --config Configure without building"
5351
echo " --coverage Instrument build to measure code coverage"
5452
echo " --cxx-std=STD C++ standard (11|14|17) [$_CXX_STD])"
5553
echo " --dry-run -n Display cmake parameter values and exit"
5654
echo " --help -h Display this help text"
5755
echo " --jobs=NJOBS -j Number of build threads [${_NJOBS}]"
56+
echo " --no-build Configure without building"
5857
echo " --no-krnlmon Exclude Kernel Monitor"
5958
echo " --no-ovs Exclude OVS support"
6059
echo " --target=TARGET Target to build (dpdk|es2k|tofino) [${_TGT_TYPE}]"
@@ -97,7 +96,7 @@ print_cmake_params() {
9796
[ -n "${_COVERAGE}" ] && echo "${_COVERAGE:2}"
9897
echo "${_SET_RPATH:2}"
9998
echo "${_TARGET_TYPE:2}"
100-
if [ ${_CFG_ONLY} -ne 0 ]; then
99+
if [ ${_DO_BUILD} -eq 0 ]; then
101100
echo ""
102101
echo "Configure without building"
103102
echo ""
@@ -167,10 +166,11 @@ SHORTOPTS=D:H:O:P:S:T:
167166
SHORTOPTS=${SHORTOPTS}hj:n
168167

169168
LONGOPTS=deps:,hostdeps:,ovs:,prefix:,sde:,toolchain:
170-
LONGOPTS=${LONGOPTS},cxx-std:,staging:,target:
169+
LONGOPTS=${LONGOPTS},cxx-std:,jobs:,staging:,target:
171170
LONGOPTS=${LONGOPTS},debug,release,minsize,reldeb
172-
LONGOPTS=${LONGOPTS},dry-run,help,jobs:,no-krnlmon,no-ovs
173-
LONGOPTS=${LONGOPTS},config,coverage,ninja,rpath,no-rpath
171+
LONGOPTS=${LONGOPTS},dry-run,help
172+
LONGOPTS=${LONGOPTS},coverage,ninja,rpath
173+
LONGOPTS=${LONGOPTS},no-build,no-krnlmon,no-ovs,no-rpath
174174

175175
GETOPTS=$(getopt -o ${SHORTOPTS} --long ${LONGOPTS} -- "$@")
176176
eval set -- "${GETOPTS}"
@@ -214,9 +214,6 @@ while true ; do
214214
_BLD_TYPE="Release"
215215
shift ;;
216216
# Options
217-
--config)
218-
_CFG_ONLY=1
219-
shift ;;
220217
--coverage)
221218
_COVERAGE="-DTEST_COVERAGE=ON"
222219
shift ;;
@@ -235,6 +232,9 @@ while true ; do
235232
--ninja)
236233
_GENERATOR="-G Ninja"
237234
shift 1 ;;
235+
--no-build)
236+
_DO_BUILD=0
237+
shift ;;
238238
--no-krnlmon)
239239
_WITH_KRNLMON=FALSE
240240
shift ;;
@@ -296,6 +296,6 @@ if [ ${_WITH_OVS} -ne 0 ]; then
296296
fi
297297

298298
config_recipe
299-
if [ ${_CFG_ONLY} -eq 0 ]; then
299+
if [ ${_DO_BUILD} -ne 0 ]; then
300300
build_recipe
301301
fi

scripts/es2k/config-cross-recipe.sh

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,32 +106,32 @@ eval set -- "${GETOPTS}"
106106
while true ; do
107107
case "$1" in
108108
# Paths
109-
-B|--build)
109+
--build|-B)
110110
_BLD_DIR=$2
111111
shift 2 ;;
112-
-D|--deps)
112+
--deps|-D)
113113
_DEPS_DIR=$2
114114
shift 2 ;;
115-
-H|--hostdeps)
115+
--hostdeps|-H)
116116
_HOST_DIR=$2
117117
shift 2 ;;
118-
-O|--ovs)
118+
--ovs|-O)
119119
_OVS_DIR=$2
120120
shift 2 ;;
121-
-P|--prefix)
121+
--prefix|-P)
122122
_PREFIX=$2
123123
shift 2 ;;
124-
-S|--sde)
124+
--sde|-S)
125125
_SDE_DIR=$2
126126
shift 2 ;;
127-
-T|--toolchain)
127+
--toolchain|-T)
128128
_TOOLFILE=$2
129129
shift 2 ;;
130130
# Options
131-
-n|--dry-run)
131+
--dry-run|-n)
132132
_DRY_RUN=1
133133
shift 1 ;;
134-
-h|--help)
134+
--help|-h)
135135
print_help
136136
exit 99 ;;
137137
--no-krnlmon)
@@ -176,7 +176,8 @@ fi
176176

177177
rm -fr "${_BLD_DIR}"
178178

179-
cmake -S . -B "${_BLD_DIR}" \
179+
# shellcheck disable=SC2086
180+
cmake -S . -B "${_BLD_DIR}" \
180181
-DCMAKE_BUILD_TYPE=${_BLD_TYPE} \
181182
-DCMAKE_INSTALL_PREFIX="${_PREFIX}" \
182183
-DCMAKE_TOOLCHAIN_FILE="${_TOOLFILE}" \

scripts/es2k/make-cross-ovs.sh

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ _SYSROOT=${SDKTARGETSYSROOT}
2727

2828
_BLD_DIR=ovs/build
2929
_BLD_TYPE=RelWithDebInfo
30-
_JOBS=8
30+
_DRY_RUN=0
31+
_NJOBS=8
3132
_PREFIX=//opt/ovs
3233
_TOOLFILE=${CMAKE_TOOLCHAIN_FILE}
3334

@@ -39,13 +40,16 @@ print_help() {
3940
echo ""
4041
echo "Build and install Open vSwitch"
4142
echo ""
42-
echo "Options:"
43+
echo "Paths:"
4344
echo " --build=DIR -B Build directory path [${_BLD_DIR}]"
44-
echo " --dry-run -n Display cmake parameters and exit"
45-
echo " --jobs=NJOBS -j Number of build threads (Default: ${_JOBS})"
4645
echo " --prefix=DIR* -P Install directory prefix [${_PREFIX}]"
4746
echo " --toolchain=FILE -T CMake toolchain file"
4847
echo ""
48+
echo "Options:"
49+
echo " --dry-run -n Display cmake parameters and exit"
50+
echo " --help -h Display this help text"
51+
echo " --jobs=NJOBS -j Number of build threads [${_NJOBS}]"
52+
echo ""
4953
echo "* '//' at the beginning of the directory path will be replaced"
5054
echo " with the sysroot directory path."
5155
echo ""
@@ -64,7 +68,7 @@ print_cmake_params() {
6468
echo "CMAKE_BUILD_TYPE=${_BLD_TYPE}"
6569
echo "CMAKE_INSTALL_PREFIX=${_PREFIX}"
6670
echo "CMAKE_TOOLCHAIN_FILE=${_TOOLFILE}"
67-
echo "JOBS=${_JOBS}"
71+
echo "JOBS=${_NJOBS}"
6872
echo ""
6973
}
7074

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

8488
while true ; do
8589
case "$1" in
86-
-B|--build)
90+
# Paths
91+
--build|-B)
8792
_BLD_DIR=$2
8893
shift 2 ;;
89-
-n|--dry-run)
90-
_DRY_RUN=true
91-
shift 1 ;;
92-
-h|--help)
93-
print_help
94-
exit 99 ;;
95-
-j|--jobs)
96-
_JOBS=$2
97-
shift 2 ;;
98-
-P|--prefix)
94+
--prefix|-P)
9995
_PREFIX=$2
10096
shift 2 ;;
101-
-T|--toolchain)
97+
--toolchain|-T)
10298
_TOOLFILE=$2
10399
shift 2 ;;
100+
# Options
101+
--dry-run|-n)
102+
_DRY_RUN=1
103+
shift 1 ;;
104+
--help|-h)
105+
print_help
106+
exit 99 ;;
107+
--jobs|-j)
108+
_NJOBS=$2
109+
shift 2 ;;
104110
--)
105111
shift
106112
break ;;
@@ -117,7 +123,8 @@ done
117123
# Substitute ${_SYSROOT}/ for '//' prefix
118124
[ "${_PREFIX:0:2}" = "//" ] && _PREFIX=${_SYSROOT}/${_PREFIX:2}
119125

120-
if [ "${_DRY_RUN}" = "true" ]; then
126+
# Show parameters if this is a dry run
127+
if [ ${_DRY_RUN} -ne 0 ]; then
121128
print_cmake_params
122129
exit 0
123130
fi
@@ -138,4 +145,4 @@ cmake -S ovs -B "${_BLD_DIR}" \
138145
# Build OVS #
139146
#############
140147

141-
cmake --build "${_BLD_DIR}" "-j${_JOBS}" -- V=0
148+
cmake --build "${_BLD_DIR}" "-j${_NJOBS}" -- V=0

setup/make-cross-deps.sh

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ _SYSROOT=${SDKTARGETSYSROOT}
2727
##################
2828

2929
_BLD_DIR=build
30+
_DO_BUILD=true
3031
_DRY_RUN=false
31-
_JOBS=8
32+
_NJOBS=8
3233
_PREFIX=//opt/deps
3334
_TOOLFILE=${CMAKE_TOOLCHAIN_FILE}
3435

@@ -40,17 +41,21 @@ print_help() {
4041
echo ""
4142
echo "Build target dependency libraries"
4243
echo ""
43-
echo "Options:"
44+
echo "Paths:"
4445
echo " --build=DIR -B Build directory path [${_BLD_DIR}]"
46+
echo " --host=DIR -H Host dependencies directory [${_HOST_DIR}]"
47+
echo " --prefix=DIR* -P Install directory prefix [${_PREFIX}]"
48+
echo " --toolchain=FILE -T CMake toolchain file"
49+
echo ""
50+
echo "Options:"
4551
echo " --cxx=VERSION CXX_STANDARD to build dependencies (Default: empty)"
4652
echo " --dry-run -n Display cmake parameters and exit"
4753
echo " --force -f Specify -f when patching (Default: false)"
48-
echo " --host=DIR -H Host dependencies directory [${_HOST_DIR}]"
49-
echo " --jobs=NJOBS -j Number of build threads (Default: ${_JOBS})"
54+
echo " --help -h Display this help text"
55+
echo " --jobs=NJOBS -j Number of build threads (Default: ${_NJOBS})"
56+
echo " --no-build Configure without building"
5057
echo " --no-download Do not download repositories (Default: false)"
51-
echo " --prefix=DIR* -P Install directory prefix [${_PREFIX}]"
5258
echo " --sudo Use sudo when installing (Default: false)"
53-
echo " --toolchain=FILE -T CMake toolchain file"
5459
echo ""
5560
echo "* '//' at the beginning of the directory path will be replaced"
5661
echo " with the sysroot directory path."
@@ -67,7 +72,7 @@ print_help() {
6772

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

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

@@ -97,11 +102,14 @@ while true ; do
97102
print_help
98103
exit 99 ;;
99104
-j|--jobs)
100-
_JOBS=$2
105+
_NJOBS=$2
101106
shift 2 ;;
102107
-n|--dry-run)
103108
_DRY_RUN=true
104109
shift 1 ;;
110+
--no-build)
111+
_DO_BUILD=false
112+
shift ;;
105113
--no-download)
106114
_DOWNLOAD="-DDOWNLOAD=FALSE"
107115
shift 1 ;;
@@ -132,12 +140,18 @@ if [ "${_DRY_RUN}" = "true" ]; then
132140
echo ""
133141
echo "CMAKE_INSTALL_PREFIX=${_PREFIX}"
134142
echo "CMAKE_TOOLCHAIN_FILE=${_TOOLFILE}"
135-
echo "JOBS=${_JOBS}"
143+
echo "JOBS=${_NJOBS}"
136144
[ -n "${_CXX_STANDARD_OPTION}" ] && echo "${_CXX_STANDARD_OPTION:2}"
137145
[ -n "${_DOWNLOAD}" ] && echo "${_DOWNLOAD:2}"
138146
[ -n "${_HOST_DEPEND_DIR}" ] && echo "${_HOST_DEPEND_DIR:2}"
139147
[ -n "${_FORCE_PATCH}" ] && echo "${_FORCE_PATCH:2}"
140148
[ -n "${_USE_SUDO}" ] && echo "${_USE_SUDO:2}"
149+
150+
if [ "${_DO_BUILD}" = "false" ]; then
151+
echo ""
152+
echo "Configure without building"
153+
fi
154+
141155
echo ""
142156
exit 0
143157
fi
@@ -155,4 +169,6 @@ cmake -S . -B ${_BLD_DIR} \
155169
${_CXX_STANDARD_OPTION} \
156170
${_DOWNLOAD} ${_FORCE_PATCH} ${_USE_SUDO}
157171

158-
cmake --build ${_BLD_DIR} -j${_JOBS}
172+
if [ "${_DO_BUILD}" = "true" ]; then
173+
cmake --build ${_BLD_DIR} -j${_NJOBS}
174+
fi

0 commit comments

Comments
 (0)