chore: setup fltk
This commit is contained in:
parent
a1ff42eed7
commit
5c81d426b8
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Install FLTK and dependenices
|
||||
#
|
||||
# Author: donkey <anjingyu_ws@foxmail.com>
|
||||
|
||||
readonly CUR_DIR=$(cd $(dirname "$0") || exit; pwd)
|
||||
readonly THIRD_PARTY_DIR="${CUR_DIR}/cpp/3rd-party"
|
||||
|
||||
function fetch_latest_git_tag()
|
||||
{
|
||||
if [ $# -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
local GIT_HOST="$1"
|
||||
local GREP_FILTER=""
|
||||
local GREP_OPTIONS=""
|
||||
|
||||
if [ $# -gt 1 ]; then
|
||||
GREP_FILTER="$2"
|
||||
fi
|
||||
|
||||
if [ $# -gt 2 ]; then
|
||||
GREP_OPTIONS="$3"
|
||||
fi
|
||||
|
||||
local _LATEST_TAG_LINE=""
|
||||
|
||||
if [ -z "${GREP_FILTER}" ]; then
|
||||
# --refs: Do not show peeled tags or pseudorefs like HEAD in the output.
|
||||
# the tags ends with '^{}'
|
||||
_LATEST_TAG_LINE=$(git ls-remote --refs -t --sort=-v:refname $GIT_HOST | head -n 1 | cut -f 2)
|
||||
else
|
||||
_LATEST_TAG_LINE=$(git ls-remote --refs -t --sort=-v:refname $GIT_HOST | grep ${GREP_OPTIONS} "${GREP_FILTER}" | head -n 1 | cut -f 2)
|
||||
fi
|
||||
|
||||
if [ -z "${_LATEST_TAG_LINE}" ]; then
|
||||
echo ""
|
||||
else
|
||||
local LATEST_TAG=$(echo "${_LATEST_TAG_LINE}" | cut -d "/" -f 3)
|
||||
echo "${LATEST_TAG}"
|
||||
fi
|
||||
}
|
||||
|
||||
function prepare_fltk()
|
||||
{
|
||||
local _REPO_URL="https://github.com/fltk/fltk"
|
||||
local _VER=""
|
||||
|
||||
if [ ! -d "$THIRD_PARTY_DIR/fltk" ]; then
|
||||
if [ $# -gt 0 ]; then
|
||||
_VER=$1
|
||||
else
|
||||
_VER=$(fetch_latest_git_tag "$_REPO_URL" "/release-[0-9]\+\.[0-9]\+\.[0-9]\+$")
|
||||
fi
|
||||
|
||||
pushd $THIRD_PARTY_DIR 1>/dev/null 2>&1
|
||||
git clone --recursive --branch ${_VER} --depth 1 ${_REPO_URL}
|
||||
popd 1>/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
function main()
|
||||
{
|
||||
# Install dependencies on Debian/Ubuntu
|
||||
sudo apt install -y libx11-dev \
|
||||
libxext-dev \
|
||||
libxft-dev \
|
||||
libxinerama-dev \
|
||||
libxcursor-dev \
|
||||
libxrender-dev \
|
||||
libxfixes-dev \
|
||||
libpango1.0-dev \
|
||||
libgl1-mesa-dev \
|
||||
libglu1-mesa-dev
|
||||
|
||||
# Runtime libraries
|
||||
# libx11-6 \
|
||||
# libxinerama1 \
|
||||
# libxft2 \
|
||||
# libxext6 \
|
||||
# libxcursor1 \
|
||||
# libxrender1 \
|
||||
# libxfixes3 \
|
||||
# libcairo2 \
|
||||
# libpango-1.0-0 \
|
||||
# libpangocairo-1.0-0 \
|
||||
# libpangoxft-1.0-0 \
|
||||
# libglib2.0-0 \
|
||||
# libfontconfig1 \
|
||||
# libglu1-mesa \
|
||||
# libgl1
|
||||
|
||||
if [ ! -d "$THIRD_PARTY_DIR" ]; then
|
||||
mkdir -p "$THIRD_PARTY_DIR"
|
||||
fi
|
||||
|
||||
prepare_fltk
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue