From b88622f211ffefc75fe3b047823a4c972c5239ae Mon Sep 17 00:00:00 2001 From: Kristofer Berggren Date: Mon, 25 Dec 2023 15:18:07 +0800 Subject: [PATCH] add make.sh support for disabling protocols --- FLAGS.md | 8 ++ lib/common/src/version.h | 2 +- make.sh | 161 +++++++++++++++++++++++---------------- src/nchat.1 | 2 +- 4 files changed, 107 insertions(+), 66 deletions(-) diff --git a/FLAGS.md b/FLAGS.md index 769ef358..050eef99 100644 --- a/FLAGS.md +++ b/FLAGS.md @@ -15,3 +15,11 @@ to cmake: mkdir -p build && cd build cmake -DHAS_WHATSAPP=OFF .. && make -s +Similarly the `make.sh` script provides options, example: + + ./make.sh --no-telegram build + +and + + ./make.sh --no-whatsapp build + diff --git a/lib/common/src/version.h b/lib/common/src/version.h index 0db604c9..989571b3 100644 --- a/lib/common/src/version.h +++ b/lib/common/src/version.h @@ -7,4 +7,4 @@ #pragma once -#define NCHAT_VERSION "4.16" +#define NCHAT_VERSION "4.17" diff --git a/make.sh b/make.sh index f212aac2..7afedff3 100755 --- a/make.sh +++ b/make.sh @@ -7,13 +7,38 @@ # # See LICENSE for redistribution information. -# exiterr +# helper functions exiterr() { >&2 echo "${1}" exit 1 } +show_usage() +{ + echo "usage: make.sh [OPTIONS] ACTION" + echo "" + echo "Options:" + echo " --no-telegram - build without telegram support" + echo " --no-whatsapp - build without whatsapp support" + echo " --yes,-y - non-interactive mode, assume yes" + echo "" + echo "Action:" + echo " deps - install project dependencies" + echo " build - perform build" + echo " debug - perform debug build" + echo " tests - perform build and run tests" + echo " doc - perform build and generate documentation" + echo " install - perform build and install" + echo " all - perform deps, build, tests, doc and install" + echo " src - perform source code reformatting" + echo "" +} + +function version_ge() { + test "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$2"; +} + # process arguments DEPS="0" BUILD="0" @@ -22,66 +47,78 @@ TESTS="0" DOC="0" INSTALL="0" SRC="0" -case "${1%/}" in - deps) - DEPS="1" - ;; - - build) - BUILD="1" - ;; - - debug) - DEBUG="1" - ;; - - test*) - BUILD="1" - TESTS="1" - ;; - - doc) - BUILD="1" - DOC="1" - ;; - - install) - BUILD="1" - INSTALL="1" - ;; - - src) - SRC="1" - ;; - - all) - DEPS="1" - BUILD="1" - TESTS="1" - DOC="1" - INSTALL="1" - ;; - - *) - echo "usage: make.sh [-y]" - echo " deps - install project dependencies" - echo " build - perform build" - echo " debug - perform debug build" - echo " tests - perform build and run tests" - echo " doc - perform build and generate documentation" - echo " install - perform build and install" - echo " all - perform deps, build, tests, doc and install" - echo " src - perform source code reformatting" - echo " -y - non-interactive mode, assume " - exit 1 - ;; -esac -[[ "${2}" == "-y" ]] && YES="-y" || YES="" +YES="" +CMAKEARGS="" -# helper functions -function version_ge() { - test "$(printf '%s\n' "$@" | sort -V | head -n 1)" == "$2"; -} +if [[ "${#}" == "0" ]]; then + show_usage + exit 1 +fi + +while [[ ${#} -gt 0 ]]; do + case "${1%/}" in + deps) + DEPS="1" + ;; + + build) + BUILD="1" + ;; + + debug) + DEBUG="1" + ;; + + test*) + BUILD="1" + TESTS="1" + ;; + + doc) + BUILD="1" + DOC="1" + ;; + + install) + BUILD="1" + INSTALL="1" + ;; + + src) + SRC="1" + ;; + + all) + DEPS="1" + BUILD="1" + TESTS="1" + DOC="1" + INSTALL="1" + ;; + + --no-telegram) + CMAKEARGS="${CMAKEARGS} -DHAS_TELEGRAM=OFF" + ;; + + --no-whatsapp) + CMAKEARGS="${CMAKEARGS} -DHAS_WHATSAPP=OFF" + ;; + + -y) + YES="-y" + ;; + + --yes) + YES="-y" + ;; + + *) + show_usage + exit 1 + ;; + esac + shift +done # deps if [[ "${DEPS}" == "1" ]]; then @@ -161,8 +198,6 @@ if [[ "${BUILD}" == "1" ]]; then MAKEARGS="-j${MAX_THREADS}" echo "-- Using ${MAKEARGS} (${CPU_MAX_THREADS} cores, ${MEM} MB phys mem, ${MEM_NEEDED_PER_CORE} MB mem per core needed)" - CMAKEARGS="" - mkdir -p build && cd build && cmake ${CMAKEARGS} .. && make -s ${MAKEARGS} && cd .. || exiterr "build failed, exiting." fi @@ -200,8 +235,6 @@ if [[ "${DEBUG}" == "1" ]]; then MAKEARGS="-j${MAX_THREADS}" echo "-- Using ${MAKEARGS} (${CPU_MAX_THREADS} cores, ${MEM} MB phys mem, ${MEM_NEEDED_PER_CORE} MB mem per core needed)" - CMAKEARGS="" - mkdir -p dbgbuild && cd dbgbuild && cmake -DCMAKE_BUILD_TYPE=Debug ${CMAKEARGS} .. && make -s ${MAKEARGS} && cd .. || exiterr "debug build failed, exiting." fi diff --git a/src/nchat.1 b/src/nchat.1 index 03abe8c4..5db06f06 100644 --- a/src/nchat.1 +++ b/src/nchat.1 @@ -1,5 +1,5 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man. -.TH NCHAT "1" "December 2023" "nchat v4.16" "User Commands" +.TH NCHAT "1" "December 2023" "nchat v4.17" "User Commands" .SH NAME nchat \- ncurses chat .SH SYNOPSIS