chore: add (wip) build.sh

This commit is contained in:
d0p1 🏳️‍⚧️ 2024-05-28 08:24:28 +02:00
parent 3b064c7d24
commit 2a1dbf2e57
2 changed files with 115 additions and 3 deletions

116
build.sh
View file

@ -46,6 +46,90 @@ success() {
printf "${GREEN}==> SUCCESS:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@"
}
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# build
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
# tools
# -----------------------------------------------------------------------------
build_tools() {
msg "Builing tools"
plain "tools dir: %s" "${TOOLS_DIR}"
make tools
}
# -----------------------------------------------------------------------------
# doctor - check os dependancies
# -----------------------------------------------------------------------------
check_tool() {
local tool=$1; shift
printf "checking for %s " "${tool}"
tool_path="$(which "${tool}" 2> /dev/null)"
if [ "x${tool_path}" = "x" ]; then
printf "${BOLD}${RED}NO${ALL_OFF}\n"
false;
else
printf "${GREEN}${tool_path}${ALL_OFF}\n"
true;
fi
}
doctor() {
local err=0
check_tool fasm || ((err++))
check_tool gcc || ((err++))
check_tool bmake || ((err++))
check_tool sha256sum || ((err++))
check_tool python3 || ((err++))
if [ $err -gt 0 ]; then error "Some tools are missing"; fi
}
# -----------------------------------------------------------------------------
# usage & version
# -----------------------------------------------------------------------------
usage() {
local status=$1
if [ ${status} -eq 0 ]; then
cat <<EOF
Usage: $prgname [-hV] [COMMANDS]
Flags:
-h display this menu.
-V display version information.
Options:
Commands:
doctor
tools
build
EOF
else
printf "Try '%s -h' for more information.\n" "${prgname}" >&2
fi
exit ${status}
}
version() {
VERSION_MAJOR="$(grep VERSION_MAJOR kernel/const.inc | cut -d' ' -f 3)"
VERSION_MINOR="$(grep VERSION_MINOR kernel/const.inc | cut -d' ' -f 3)"
printf "%s (StupidOS) %d.%d\n" "${prgname}" ${VERSION_MAJOR} ${VERSION_MINOR}
exit 0
}
# -----------------------------------------------------------------------------
# entry
# -----------------------------------------------------------------------------
@ -81,8 +165,34 @@ BUILD_DIR="${topdir}/.build"
TOOLS_DIR="${topdir}/.tools"
TOOLS_PREFIX="stpd-"
if [ $# -eq 0 ]; then
printf "Try '%s -h' for more information.\n" "${prgname}" >&2
exit 1
export PATH="$PATH:$TOOLS_DIR"
if [ ! -f Makefile ] || [ ! -f LICENSE ]; then
error "Run this script at StupidOS root"
fi
if [ $# -eq 0 ]; then
usage 1
fi
while [ $# -gt 0 ]; do
op=$1; shift
case "${op}" in
help | --help | -h)
usage 0
;;
--version | -V)
version
;;
doctor)
doctor
;;
tools)
build_tools
;;
*)
usage 1
;;
esac
done

2
requirements.txt Normal file
View file

@ -0,0 +1,2 @@
pytest==8.0.1
qemu.qmp==0.0.3