check_format.sh: add Darwin/MacOS support
check_format.sh requires the following, none of which are supported by default on MacOS and require alternative homebrew installation for GNU variants: * mapfile command not supported by bash * -f option for readlink * -P option for grep Note that SPDK is not supported on MacOS, the changes here are added only for developer convenience. Fixes issue #2255. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: Ic3d4ed49d9bfb4be50a8dd090a34090037f592c0 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10476 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Michal Berger <michalx.berger@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
91bd8744a9
commit
468755200a
@ -1,6 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
rootdir=$(readlink -f "$(dirname "$0")")/..
|
||||
if [[ $(uname -s) == Darwin ]]; then
|
||||
# SPDK is not supported on MacOS, but as a developer
|
||||
# convenience we support running the check_format.sh
|
||||
# script on MacOS.
|
||||
# Running "brew install bash greadlink ggrep" should be
|
||||
# sufficient to get the correct versions of these utilities.
|
||||
if [[ $(type -t mapfile) != builtin ]]; then
|
||||
# We need bash version >= 4.0 for mapfile builtin
|
||||
echo "Please install bash version >= 4.0"
|
||||
exit 1
|
||||
fi
|
||||
if ! hash greadlink 2> /dev/null; then
|
||||
# We need GNU readlink for -f option
|
||||
echo "Please install GNU readlink"
|
||||
exit 1
|
||||
fi
|
||||
if ! hash ggrep 2> /dev/null; then
|
||||
# We need GNU grep for -P option
|
||||
echo "Please install GNU grep"
|
||||
exit 1
|
||||
fi
|
||||
GNU_READLINK="greadlink"
|
||||
GNU_GREP="ggrep"
|
||||
else
|
||||
GNU_READLINK="readlink"
|
||||
GNU_GREP="grep"
|
||||
fi
|
||||
|
||||
rootdir=$($GNU_READLINK -f "$(dirname "$0")")/..
|
||||
source "$rootdir/scripts/common.sh"
|
||||
|
||||
cd "$rootdir"
|
||||
@ -611,7 +639,7 @@ function check_rpc_args() {
|
||||
local rc=0
|
||||
|
||||
echo -n "Checking rpc.py argument option names..."
|
||||
grep add_argument scripts/rpc.py | grep -oP "(?<=--)[a-z0-9\-\_]*(?=\')" | grep "_" > badargs.log
|
||||
grep add_argument scripts/rpc.py | $GNU_GREP -oP "(?<=--)[a-z0-9\-\_]*(?=\')" | grep "_" > badargs.log
|
||||
|
||||
if [[ -s badargs.log ]]; then
|
||||
echo "rpc.py arguments with underscores detected!"
|
||||
|
Loading…
Reference in New Issue
Block a user