summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build.sh115
-rwxr-xr-xscripts/release.sh4
2 files changed, 86 insertions, 33 deletions
diff --git a/scripts/build.sh b/scripts/build.sh
index 94c62b8..470f39a 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+set -e
usage() {
echo "Usage: build.sh [-b [release|debug]] "
@@ -16,8 +17,10 @@ usage() {
echo "configs with meson:"
echo " [default] default settings"
echo " fallback download all dependencies"
- echo " and build them as shared libaries"
+ echo " and build them as shared libraries"
echo " cross use cross toolchain to build"
+ echo " coverage build coverage report"
+ echo " appimage build AppImage target"
echo ""
echo "configs with muon:"
echo " [default] minimal static build"
@@ -56,6 +59,9 @@ CONFIG=${1:-"default"}
cd "$(git rev-parse --show-toplevel)" || exit 1
BUILDDIR="$(pwd)/.build-ci"
+TOOLDIR="$(pwd)/.build-tools"
+
+fn_exists() { declare -F "$1" > /dev/null; }
config_meson_default() {
CC="${CC}" "${MESON}" setup \
@@ -89,6 +95,26 @@ config_meson_cross() {
"${BUILDDIR}"
}
+config_meson_coverage() {
+ CC="${CC}" "${MESON}" setup \
+ --werror \
+ --buildtype="${BUILDTYPE}" \
+ --force-fallback-for=libnvme \
+ -Dlibnvme:werror=false \
+ -Db_coverage=true \
+ "${BUILDDIR}"
+}
+
+config_meson_appimage() {
+ CC="${CC}" "${MESON}" setup \
+ --werror \
+ --buildtype="${BUILDTYPE}" \
+ --force-fallback-for=libnvme \
+ --prefix=/usr \
+ -Dlibnvme:werror=false \
+ "${BUILDDIR}"
+}
+
build_meson() {
"${MESON}" compile \
-C "${BUILDDIR}"
@@ -99,45 +125,68 @@ test_meson() {
-C "${BUILDDIR}"
}
+test_meson_coverage() {
+ "${MESON}" test \
+ -C "${BUILDDIR}"
+ ninja -C "${BUILDDIR}" coverage --verbose
+}
+
+install_meson_appimage() {
+ "${MESON}" install \
+ -C "${BUILDDIR}"
+}
+
tools_build_samurai() {
- mkdir -p "${BUILDDIR}"/build-tools
- git clone --depth 1 https://github.com/michaelforney/samurai.git \
- "${BUILDDIR}/build-tools/samurai"
- pushd "${BUILDDIR}/build-tools/samurai" || exit 1
+ if [ ! -d "${TOOLDIR}"/samurai ]; then
+ git clone --depth 1 https://github.com/michaelforney/samurai.git \
+ "${TOOLDIR}/samurai"
+ fi
- CC="${CC}" make
- SAMU="${BUILDDIR}/build-tools/samurai/samu"
+ if [[ -f "${TOOLDIR}/samurai/samu" ]]; then
+ return
+ fi
+ pushd "${TOOLDIR}/samurai" || exit 1
+ CC="${CC}" make
popd || exit 1
}
tools_build_muon() {
- mkdir -p "${BUILDDIR}"/build-tools
- git clone --depth 1 https://git.sr.ht/~lattis/muon \
- "${BUILDDIR}/build-tools/muon"
- pushd "${BUILDDIR}/build-tools/muon" || exit 1
+ if [ ! -d "${TOOLDIR}/muon" ]; then
+ git clone --depth 1 https://git.sr.ht/~lattis/muon \
+ "${TOOLDIR}/muon"
+ fi
- CC="${CC}" ninja="${SAMU}" ./bootstrap.sh stage1
+ if [[ -f "${TOOLDIR}/build-muon/muon" ]]; then
+ return
+ fi
+
+ pushd "${TOOLDIR}/muon" || exit 1
+
+ CC="${CC}" CFLAGS="${CFLAGS} -std=c99" ninja="${SAMU}" ./bootstrap.sh stage1
CC="${CC}" ninja="${SAMU}" stage1/muon setup \
- -Dprefix="${BUILDDIR}/build-tools" \
- -Dlibcurl=enabled \
- -Dlibarchive=enabled \
- -Dlibpkgconf=enabled \
+ -Dprefix="${TOOLDIR}" \
-Ddocs=disabled \
-Dsamurai=disabled \
- "${BUILDDIR}/build-tools/.build-muon"
- "${SAMU}" -C "${BUILDDIR}/build-tools/.build-muon"
+ -Dbestline=disabled \
+ "${TOOLDIR}/build-muon"
+ "${SAMU}" -C "${TOOLDIR}/build-muon"
MUON="${BUILDDIR}/build-tools/.build-muon/muon"
- # "${MUON}" -C "${BUILDDIR}/build-tools/.build-muon" test
+ # "${TOOLDIR}/build-muon/muon" \
+ # -C "${TOOLDIR}/build-muon" test
popd || exit 1
}
config_muon_default() {
- CC="${CC}" CFLAGS="${CFLAGS} -static" \
- ninja="${SAMU}" "${MUON}" setup \
+ # wrap_mode=forcefallback depends on git being available
+
+ CC="${CC}" CFLAGS="${CFLAGS}" ninja="${SAMU}" \
+ "${MUON}" setup \
+ -Ddefault_library=static \
+ -Dc_link_args="-static" \
-Dwrap_mode=forcefallback \
-Dlibnvme:json-c=disabled \
-Dlibnvme:python=disabled \
@@ -156,22 +205,26 @@ test_muon() {
ldd "${BUILDDIR}/nvme" 2>&1 | grep 'not a dynamic executable' || exit 1
}
-rm -rf "${BUILDDIR}"
-
if [[ "${BUILDTOOL}" == "muon" ]]; then
- if ! which samu ; then
+ SAMU="$(which samu 2> /dev/null)" || true
+ if [[ -z "${SAMU}" ]]; then
tools_build_samurai
- else
- SAMU="$(which samu)"
+ SAMU="${TOOLDIR}/samurai/samu"
fi
- if ! which muon ; then
+ MUON="$(which muon 2> /dev/null)" || true
+ if [[ -z "${MUON}" ]]; then
tools_build_muon
- else
- MUON="$(which muon)"
+ MUON="${TOOLDIR}/build-muon/muon"
fi
fi
+echo "samu: ${SAMU}"
+echo "muon: ${MUON}"
+
+rm -rf "${BUILDDIR}"
+
config_"${BUILDTOOL}"_"${CONFIG}"
-build_"${BUILDTOOL}"
-test_"${BUILDTOOL}"
+fn_exists "build_${BUILDTOOL}_${CONFIG}" && "build_${BUILDTOOL}_${CONFIG}" || build_"${BUILDTOOL}"
+fn_exists "test_${BUILDTOOL}_${CONFIG}" && "test_${BUILDTOOL}_${CONFIG}" || test_"${BUILDTOOL}"
+fn_exists "install_${BUILDTOOL}_${CONFIG}" && "install_${BUILDTOOL}_${CONFIG}" || true;
diff --git a/scripts/release.sh b/scripts/release.sh
index dad3f25..d2cbb08 100755
--- a/scripts/release.sh
+++ b/scripts/release.sh
@@ -60,7 +60,7 @@ cd "$(git rev-parse --show-toplevel)" || exit 1
if [[ -f subprojects/libnvme.wrap ]]; then
git -C subprojects/libnvme fetch --all
- # extract the vesion string from libnvme by using the ref
+ # extract the version string from libnvme by using the ref
# defined in libnvme.wrap.
libnvme_ref=$(sed -n "s/revision = \([0-9a-z]\+\)/\1/p" subprojects/libnvme.wrap)
libnvme_VERSION=$(git -C subprojects/libnvme describe "${libnvme_ref}")
@@ -94,7 +94,7 @@ if [ -d "Documentation" ]; then
elif [ -d "doc" ]; then
doc_dir="doc"
else
- echo "documenation directory not found"
+ echo "documentation directory not found"
exit 1
fi