Skip to content

Commit

Permalink
add make.sh support for disabling protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
d99kris committed Dec 25, 2023
1 parent f4e3f37 commit b88622f
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 66 deletions.
8 changes: 8 additions & 0 deletions FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion lib/common/src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

#pragma once

#define NCHAT_VERSION "4.16"
#define NCHAT_VERSION "4.17"
161 changes: 97 additions & 64 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 <deps|build|tests|doc|install|all> [-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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/nchat.1
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit b88622f

Please sign in to comment.