Major refactoring effort underway.
This commit is contained in:
68
scripts/check-code.sh
Executable file
68
scripts/check-code.sh
Executable file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
######################################################################
|
||||
# @author : kyle (kyle@midgard)
|
||||
# @file : check-code
|
||||
# @created : Tuesday Oct 17, 2023 22:39:39 PDT
|
||||
#
|
||||
# @description :
|
||||
######################################################################
|
||||
|
||||
|
||||
run_clang_tidy () {
|
||||
sources="${1:-*.cc}"
|
||||
echo "[+] clang-tidy ${sources}"
|
||||
|
||||
if [ ! -e compile_commands.json ]
|
||||
then
|
||||
echo "[!] compile_commands.json not found" > /dev/stderr
|
||||
candidate=$(find -name compile_commands.json | head)
|
||||
|
||||
if [ -z "${candidates}" ]
|
||||
then
|
||||
echo "[!] no suitable candidates found; can't proceed" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[+] compile_commands.json candidate: $candidate"
|
||||
ln -s ${candidate} .
|
||||
echo "[+] if this isn't correct, you will need to manually link it"
|
||||
fi
|
||||
|
||||
clang-tidy ${sources}
|
||||
}
|
||||
|
||||
|
||||
run_cppcheck () {
|
||||
sources="${1:-*.cc}"
|
||||
echo "[+] cppcheck ${sources}"
|
||||
|
||||
cppcheck --enable=all --suppress=unusedFunction --suppress=missingIncludeSystem -I. ${sources}
|
||||
}
|
||||
|
||||
|
||||
run_trunk () {
|
||||
sources="${1:-}"
|
||||
echo "[+] trunk check ${sources}"
|
||||
|
||||
trunk check --filter clang-tidy ${sources}
|
||||
}
|
||||
|
||||
|
||||
main () {
|
||||
command="${1:-usage}"
|
||||
shift
|
||||
|
||||
case ${command} in
|
||||
clang-tidy) run_clang_tidy $@ ;;
|
||||
cppcheck) run_cppcheck $@ ;;
|
||||
trunk) run_trunk $@ ;;
|
||||
*)
|
||||
echo "[!] scanner ${command} isn't supported" > /dev/stderr
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main $@
|
||||
|
||||
42
scripts/install-cmake-debian.sh
Executable file
42
scripts/install-cmake-debian.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
|
||||
source /etc/lsb-release
|
||||
|
||||
preinstall () {
|
||||
echo "[+] preparing to install"
|
||||
sudo apt-get update
|
||||
sudo apt-get install ca-certificates gpg wget
|
||||
}
|
||||
|
||||
do_install () {
|
||||
if [ ! -f /etc/apt/sources.list.d/kitware.list ]
|
||||
then
|
||||
echo "[+] fetching initial keyring"
|
||||
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
|
||||
|
||||
echo "[+] adding repo to sources.list.d"
|
||||
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${DISTRIB_CODENAME} main" | \
|
||||
sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
|
||||
sudo apt-get update
|
||||
|
||||
echo "[+] installing kitware keyring"
|
||||
if [ -f "/usr/share/keyrings/kitware-archive-keyring.gpg" ]
|
||||
then
|
||||
sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg
|
||||
fi
|
||||
sudo apt-get install kitware-archive-keyring
|
||||
fi
|
||||
|
||||
if [ "${USE_CMAKE_RC}" = "YES" ]
|
||||
then
|
||||
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${DISTRIB_RELEASE}-rc main' | \
|
||||
sudo tee -a /etc/apt/sources.list.d/kitware.list >/dev/null
|
||||
sudo apt-get update
|
||||
fi
|
||||
}
|
||||
|
||||
do_install
|
||||
sudo apt-get install cmake
|
||||
85
scripts/install-depdendencies.sh
Executable file
85
scripts/install-depdendencies.sh
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#####################################################################
|
||||
# This script attempts to install the appopriate build dependencies #
|
||||
# for the host system. #
|
||||
# #
|
||||
# This is primarily developed on the latest Ubuntu LTS release and #
|
||||
# MacOS; other platforms are not supported. #
|
||||
#####################################################################
|
||||
|
||||
set -eu
|
||||
|
||||
AUTOMATED_MODE=${AUTOMATED_MODE:-}
|
||||
|
||||
install_debianesque () {
|
||||
APTARGS=""
|
||||
|
||||
if [ ! -z "${AUTOMATED_MODE}" ]
|
||||
then
|
||||
APTARGS="-y"
|
||||
fi
|
||||
|
||||
echo "[+] distribution is ${DISTRIB_ID}, choosing Debianesque install."
|
||||
|
||||
if [ -z "$(command -v cmake)" ]
|
||||
then
|
||||
./scripts/install-cmake-debian.sh
|
||||
|
||||
echo "[+] installing tools"
|
||||
sudo apt-get $APTARGS install git cmake clang scdoc python3-pip
|
||||
|
||||
( cd docs/ && python3 -m pip install -r requirements.txt )
|
||||
}
|
||||
|
||||
install_unsupported () {
|
||||
echo "[+] distribution is ${DISTRIB_ID}, choosing Redhat install."
|
||||
echo "[!] This distribution is unsupported." > /dev/stderr
|
||||
exit 1;
|
||||
}
|
||||
|
||||
install_macos () {
|
||||
# TODO: consider supporting macports?
|
||||
echo "[+] host system is MacOS"
|
||||
|
||||
echo "[+] installing tools"
|
||||
brew install git cmake scdoc
|
||||
|
||||
echo "[+] installing libraries and development headers"
|
||||
# TODO: look up proper package names in homebrew
|
||||
}
|
||||
|
||||
|
||||
install_linux () {
|
||||
echo "[+] host system is Linux"
|
||||
[[ -f "/etc/lsb-release" ]] && source /etc/lsb-release
|
||||
if [ -z "${DISTRIB_ID}" ]
|
||||
then
|
||||
if [ -d /etc/apt ]
|
||||
then
|
||||
DISTRIB_ID="apt-based"
|
||||
else
|
||||
DISTRIB_ID="unsupported/unknown"
|
||||
fi
|
||||
fi
|
||||
|
||||
case ${DISTRIB_ID} in
|
||||
Ubuntu) install_debianesque ;;
|
||||
Debian) install_debianesque ;;
|
||||
apt-based) install_debianesque ;;
|
||||
*)
|
||||
echo "[!] distribution ${DISTRIB_ID} isn't supported in this script." > /dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
case "$(uname -s)" in
|
||||
Linux) install_linux ;;
|
||||
Darwin) install_macos ;;
|
||||
*)
|
||||
echo "[!] platform $(uname -s) isn't supported in this script." > /dev/null
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user