Begin modularizing the scripts

This commit is contained in:
T. Joseph Carter 2015-02-08 16:16:00 -08:00
parent d1ff87d827
commit 3a19c26d22
3 changed files with 86 additions and 30 deletions

View File

@ -11,38 +11,10 @@ else
BASE_DIR="$WORKDIR/$BASE_DIR" BASE_DIR="$WORKDIR/$BASE_DIR"
fi fi
. $BASE_DIR/iKarith-libretro-config.sh
WORKDIR=$(pwd) WORKDIR=$(pwd)
echo_cmd() { . $BASE_DIR/iKarith-libretro-config.sh
echo "$@" . $BASE_DIR/iKarith-super/fetch-rules.sh
"$@"
}
# fetch_git <repository> <local directory>
# Clones or pulls updates from a git repository into a local directory
#
# $1 The URI to fetch
# $2 The local directory to fetch to (relative)
# $3 Set to clone --recursive
# $4 Set to pull --recursive
fetch_git() {
fetch_dir="$WORKDIR/$2"
echo "=== Fetching $2 ==="
if [ -d "$fetch_dir/.git" ]; then
echo_cmd git -C "$fetch_dir" pull
if [ -n "$4" ]; then
echo_cmd git -C "$fetch_dir" submodule foreach git pull origin master
fi
else
echo_cmd git clone "$1" "$fetch_dir"
if [ -n "$3" ]; then
echo_cmd git -C "$fetch_dir" submodule update --init
fi
fi
}
# Keep three copies so we don't have to rebuild stuff all the time. # Keep three copies so we don't have to rebuild stuff all the time.

56
iKarith-super/cpu.sh Normal file
View File

@ -0,0 +1,56 @@
# vim: set ts=3 sw=3 noet ft=sh : bash
# CPU identification
#
# All of these functions can be overridden by $1 for use in buildbots, etc.
# The rest are meant to replace test or [ in if statements.
# Use with $() syntax
host_cpu() {
echo ${1:-`uname -m`}
}
cpu_isx86() {
case ${1:-`uname -m`} in
i386|i586|i686|x86_64) echo "true" ;;
*) [ "${PROCESSOR_ARCHITEW6432}" = "AMD64" ] && echo "true" ;;
esac
}
cpu_isx86_64() {
[ ${1:-`uname -m`} = "x86_64" ] && return 0
return 1
}
cpu_isarm() {
case ${1:-`uname -m`} in
armv*) return 0 ;;
esac
return 1
}
cpu_isarmv5() {
[ "${1:-`uname -m`}" = "armv5tel" ] && return 0
return 1
}
# Consider using armv6* here?
cpu_isarmv6() {
case ${1:-`uname -m`} in
armv6l|armv6) return 0 ;;
esac
return 1
}
# Consider using armv7* here?
# armv7s is Apple A6 chip
cpu_isarmv7() {
case ${1:-`uname -m`} in
armv7l|armv7|armv7s) return 0 ;;
esac
return 1
}

View File

@ -0,0 +1,28 @@
# vim: set ts=3 sw=3 noet ft=sh : bash
# FIXME: This doesn't belong here, move it
echo_cmd() {
echo "$@"
"$@"
}
# fetch_git <repository> <local directory>
# Clones or pulls updates from a git repository into a local directory
#
# $1 The URI to fetch
# $2 The local directory to fetch to (relative)
# $3 Set to clone --recursive
# $4 Set to pull --recursive
fetch_git() {
fetch_dir="$WORKDIR/$2"
echo "=== Fetching $2 ==="
if [ -d "$fetch_dir/.git" ]; then
echo_cmd git -C "$fetch_dir" pull
[ -n "$4" ]&& echo_cmd git -C "$fetch_dir" submodule foreach git pull origin master
else
echo_cmd git clone "$1" "$fetch_dir"
[ -n "$3" ]&& echo_cmd git -C "$fetch_dir" submodule update --init
fi
}