From aa534b656e35c9476e858df591228cd3f51ecad7 Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 13 Jun 2023 12:49:22 +0200 Subject: [PATCH] Check for dependencies, allow to skip homebrew path setup Signed-off-by: falkTX --- bootstrap-common.sh | 58 +++++++++++++++++++++++++++++++++----------- bootstrap-plugins.sh | 18 ++++++++++++++ build-plugins.sh | 29 ++++++++++++++-------- local.env | 1 - pack-plugins.sh | 15 +++++++++--- setup/env.sh | 37 ++++++++++++++++++++++++++++ setup/functions.sh | 14 +++++------ 7 files changed, 137 insertions(+), 35 deletions(-) diff --git a/bootstrap-common.sh b/bootstrap-common.sh index 8830b5b..659ded1 100755 --- a/bootstrap-common.sh +++ b/bootstrap-common.sh @@ -15,19 +15,6 @@ if [ -z "${target}" ]; then exit 1 fi -# --------------------------------------------------------------------------------------------------------------------- - -# TODO check for depedencies: -# - curl -# - cmake -# - make -# - jq -# - patch -# - pkg-config (linux only) -# - python (waf, meson) -# - sed -# - tar - # --------------------------------------------------------------------------------------------------------------------- # source setup code @@ -36,6 +23,49 @@ source setup/env.sh source setup/functions.sh source setup/versions.sh +# --------------------------------------------------------------------------------------------------------------------- +# check for depedencies + +if ! command -v curl >/dev/null; then + echo "missing 'curl' program, cannot continue!" + exit 2 +fi + +if ! command -v make >/dev/null; then + echo "missing 'make' program, cannot continue!" + exit 2 +fi + +if ! command -v patch >/dev/null; then + echo "missing 'patch' program, cannot continue!" + exit 2 +fi + +if ! command -v python3 >/dev/null; then + echo "missing 'python3' program, cannot continue!" + exit 2 +fi + +if ! command -v sed >/dev/null; then + echo "missing 'sed' program, cannot continue!" + exit 2 +fi + +if ! command -v tar >/dev/null; then + echo "missing 'tar' program, cannot continue!" + exit 2 +fi + +if [ "${LINUX}" -eq 1 ] && ! command -v pkg-config >/dev/null; then + echo "missing 'pkg-config' program, cannot continue!" + exit 2 +fi + +if [ -z "${cmake}" ]; then + echo "missing 'cmake' program, cannot continue!" + exit 2 +fi + # --------------------------------------------------------------------------------------------------------------------- # create common directories @@ -170,7 +200,7 @@ FLAC_EXTRAFLAGS+=" --disable-xmms-plugin" if [ -n "${PAWPAW_NOSIMD}" ] && [ "${PAWPAW_NOSIMD}" -ne 0 ]; then FLAC_EXTRAFLAGS+=" ac_cv_header_x86intrin_h=no ac_cv_header_arm_neon_h=no asm_opt=no" -elif [ "${WASM}" -eq 1 ]; then +elif [ "${MACOS_UNIVERSAL}" -eq 1 ] || [ "${WASM}" -eq 1 ]; then # FIXME FLAC_EXTRAFLAGS+=" ac_cv_header_x86intrin_h=no ac_cv_header_arm_neon_h=no asm_opt=no" else diff --git a/bootstrap-plugins.sh b/bootstrap-plugins.sh index dff2a70..1c0e221 100755 --- a/bootstrap-plugins.sh +++ b/bootstrap-plugins.sh @@ -35,6 +35,24 @@ source setup/env.sh source setup/functions.sh source setup/versions.sh +# --------------------------------------------------------------------------------------------------------------------- +# check for depedencies + +if [ -z "${autoconf}" ]; then + echo "missing 'autoconf' program, cannot continue!" + exit 2 +fi + +if [ -z "${meson}" ]; then + echo "missing 'meson' program, cannot continue!" + exit 2 +fi + +if [ -z "${ninja}" ]; then + echo "missing 'ninja' program, cannot continue!" + exit 2 +fi + # --------------------------------------------------------------------------------------------------------------------- # libpng diff --git a/build-plugins.sh b/build-plugins.sh index 3148fa7..ea74ef5 100755 --- a/build-plugins.sh +++ b/build-plugins.sh @@ -19,12 +19,21 @@ shift # TODO check that bootstrap.sh has been run # --------------------------------------------------------------------------------------------------------------------- +# source setup code source setup/check_target.sh source setup/env.sh source setup/functions.sh source setup/versions.sh +# --------------------------------------------------------------------------------------------------------------------- +# check for depedencies + +if [ -z "${jq}" ]; then + echo "missing 'jq' program, cannot continue!" + exit 2 +fi + # --------------------------------------------------------------------------------------------------------------------- LV2DIR="${PAWPAW_PREFIX}/lib/lv2" @@ -100,18 +109,18 @@ for plugin in ${@}; do exit 2 fi - name=$(jq -crM .name ${pfile}) - version=$(jq -crM .version ${pfile}) - buildtype=$(jq -crM .buildtype ${pfile}) - dlbaseurl=$(jq -crM .dlbaseurl ${pfile}) - lv2bundles=($(jq -crM .lv2bundles[] ${pfile})) + name=$(${jq} -crM .name ${pfile}) + version=$(${jq} -crM .version ${pfile}) + buildtype=$(${jq} -crM .buildtype ${pfile}) + dlbaseurl=$(${jq} -crM .dlbaseurl ${pfile}) + lv2bundles=($(${jq} -crM .lv2bundles[] ${pfile})) # optional args - buildargs=$(echo -e $(jq -ecrM .buildargs ${pfile} || echo '\n\n') | tail -n 1) - dlext=$(echo -e $(jq -ecrM .dlext ${pfile} || echo '\n\n') | tail -n 1) - dlmethod=$(echo -e $(jq -ecrM .dlmethod ${pfile} || echo '\n\n') | tail -n 1) - dlname=$(echo -e $(jq -ecrM .dlname ${pfile} || echo '\n\n') | tail -n 1) - combinedbundles=$(echo -e $(jq -ecrM .combinedbundles ${pfile} || echo '\n\n') | tail -n 1) + buildargs=$(echo -e $(${jq} -ecrM .buildargs ${pfile} || echo '\n\n') | tail -n 1) + dlext=$(echo -e $(${jq} -ecrM .dlext ${pfile} || echo '\n\n') | tail -n 1) + dlmethod=$(echo -e $(${jq} -ecrM .dlmethod ${pfile} || echo '\n\n') | tail -n 1) + dlname=$(echo -e $(${jq} -ecrM .dlname ${pfile} || echo '\n\n') | tail -n 1) + combinedbundles=$(echo -e $(${jq} -ecrM .combinedbundles ${pfile} || echo '\n\n') | tail -n 1) download "${name}" "${version}" "${dlbaseurl}" "${dlext}" "${dlmethod}" "${dlname}" diff --git a/local.env b/local.env index 070857d..c384f30 100644 --- a/local.env +++ b/local.env @@ -1,6 +1,5 @@ #!/bin/bash -PAWPAW_ROOT="${PWD}" SOURCING_FILES=1 target="${1}" diff --git a/pack-plugins.sh b/pack-plugins.sh index 1af39ca..e4bd99c 100755 --- a/pack-plugins.sh +++ b/pack-plugins.sh @@ -19,10 +19,19 @@ shift VERSION=$(cat VERSION) # --------------------------------------------------------------------------------------------------------------------- +# source setup code source setup/check_target.sh source setup/env.sh +# --------------------------------------------------------------------------------------------------------------------- +# check for depedencies + +if [ -z "${jq}" ]; then + echo "missing 'jq' program, cannot continue!" + exit 2 +fi + # --------------------------------------------------------------------------------------------------------------------- function download_and_install_innosetup { @@ -78,10 +87,10 @@ for plugin in ${@}; do exit 2 fi - name=$(jq -crM .name ${pfile}) + name=$(${jq} -crM .name ${pfile}) sname=$(echo ${name} | tr -ds '-' '_') - description=$(jq -crM .description ${pfile}) - lv2bundles=($(jq -crM .lv2bundles[] ${pfile})) + description=$(${jq} -crM .description ${pfile}) + lv2bundles=($(${jq} -crM .lv2bundles[] ${pfile})) if [ "${WIN32}" -eq 1 ]; then echo "Name: ${sname}; Description: \"${name}\"; Types: full;" >> /tmp/pawpaw/components.iss diff --git a/setup/env.sh b/setup/env.sh index 0d97b66..b7f3350 100644 --- a/setup/env.sh +++ b/setup/env.sh @@ -212,6 +212,43 @@ if [ -n "${PAWPAW_SKIP_STRIPPING}" ] && [ "${PAWPAW_SKIP_STRIPPING}" -eq 1 ]; th TARGET_STRIP="true" fi +# --------------------------------------------------------------------------------------------------------------------- +# find needed programs + +if [ -z "${SOURCING_FILES}" ]; then + set +e +fi + +autoconf=$(command -v autoconf) +cmake=$(command -v cmake) +jq=$(command -v jq) +meson=$(command -v meson) +ninja=$(command -v meson) + +if [ -z "${SOURCING_FILES}" ]; then + set -e +fi + +if [ -z "${autoconf}" ] && [ -e "/opt/homebrew/bin/autoconf" ]; then + autoconf="/opt/homebrew/bin/autoconf" +fi + +if [ -z "${cmake}" ] && [ -e "/opt/homebrew/bin/cmake" ]; then + cmake="/opt/homebrew/bin/cmake" +fi + +if [ -z "${jq}" ] && [ -e "/opt/homebrew/bin/jq" ]; then + jq="/opt/homebrew/bin/jq" +fi + +if [ -z "${meson}" ] && [ -e "/opt/homebrew/bin/meson" ]; then + meson="/opt/homebrew/bin/meson" +fi + +if [ -z "${ninja}" ] && [ -e "/opt/homebrew/bin/ninja" ]; then + ninja="/opt/homebrew/bin/ninja" +fi + # --------------------------------------------------------------------------------------------------------------------- # other diff --git a/setup/functions.sh b/setup/functions.sh index 7adbb7b..8eda2de 100644 --- a/setup/functions.sh +++ b/setup/functions.sh @@ -28,7 +28,7 @@ function download() { rm -rf "${tmprepodir}" git clone --recursive "${dlbaseurl}" "${tmprepodir}" git -C "${tmprepodir}" checkout "${version}" - git -C "${tmprepodir}" submodule update + git -C "${tmprepodir}" submodule update --recursive --init tar --exclude=".git" -czf "${dlfile}" -C "${PAWPAW_TMPDIR}" "${dlname}-${version}" rm -rf "${tmprepodir}" else @@ -96,7 +96,7 @@ function git_clone() { rm -rf "${tmprepodir}" git clone --recursive "${repourl}" "${tmprepodir}" git -C "${tmprepodir}" checkout "${hash}" - git -C "${tmprepodir}" submodule update + git -C "${tmprepodir}" submodule update --recursive --init tar --exclude=".git" -czf "${dlfile}" -C "${PAWPAW_TMPDIR}" "${dlname}-${hash}" rm -rf "${tmprepodir}" fi @@ -257,7 +257,7 @@ function build_autoconfgen() { if [ -f utils/autogen.sh ]; then ./utils/autogen.sh else - autoconf + ${autoconf} fi touch .stamp_preconfigured popd @@ -355,7 +355,7 @@ function build_cmake() { if [ ! -f "${pkgdir}/.stamp_configured" ]; then pushd "${pkgdir}/build" - ${CMAKE_EXE_WRAPPER} cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX="${PAWPAW_PREFIX}" ${extraconfrules} .. + ${CMAKE_EXE_WRAPPER} ${cmake} -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_PREFIX="${PAWPAW_PREFIX}" ${extraconfrules} .. touch ../.stamp_configured popd fi @@ -420,21 +420,21 @@ function build_meson() { if [ ! -f "${pkgdir}/.stamp_configured" ]; then pushd "${pkgdir}" - meson build --buildtype release --prefix "${PAWPAW_PREFIX}" --libdir lib ${extraconfrules} + env NINJA="${ninja}" ${meson} build --buildtype release --prefix "${PAWPAW_PREFIX}" --libdir lib ${extraconfrules} touch .stamp_configured popd fi if [ ! -f "${pkgdir}/.stamp_built" ]; then pushd "${pkgdir}" - ninja -v -C build + ${ninja} -v -C build touch .stamp_built popd fi if [ ! -f "${pkgdir}/.stamp_installed" ]; then pushd "${pkgdir}" - ninja -C build install + ${ninja} -C build install touch .stamp_installed popd fi