qb: Create qb.init.sh.

This commit is contained in:
orbea 2019-01-25 07:00:28 -08:00
parent b512c0aeb9
commit d7d5bc58b2
5 changed files with 47 additions and 34 deletions

2
configure vendored
View File

@ -4,6 +4,8 @@ PACKAGE_NAME=retroarch
cat /dev/null > config.log
. qb/qb.init.sh
. qb/qb.system.sh
. qb/qb.params.sh

43
qb/qb.init.sh Normal file
View File

@ -0,0 +1,43 @@
# Only add standalone functions to this file which are easy to source anywhere.
# die:
# Prints a warning or an exit error.
# $1 = exit code, use : to not exit when printing warnings
# $@ = exit or warning messages
die()
{ ret="$1"
shift 1
printf %s\\n "$@" >&2
case "$ret" in
: ) return 0 ;;
* ) exit "$ret" ;;
esac
}
# exists:
# Finds executable files in the $PATH
# $@ = files
exists()
{ v=1
while [ $# -gt 0 ]; do
arg="$1"
shift 1
case "$arg" in ''|*/) continue ;; esac
x="${arg##*/}"
z="${arg%/*}"
[ ! -f "$z/$x" ] || [ ! -x "$z/$x" ] && [ "$z/$x" = "$arg" ] &&
continue
[ "$x" = "$z" ] && [ -x "$z/$x" ] && [ ! -f "$arg" ] && z=
p=":$z:$PATH"
while [ "$p" != "${p#*:}" ]; do
p="${p#*:}"
d="${p%%:*}"
if [ -f "$d/$x" ] && [ -x "$d/$x" ]; then
printf %s\\n "$d/$x"
v=0
break
fi
done
done
return $v
}

View File

@ -6,7 +6,8 @@ SHARE_DIR="${SHARE_DIR:-${PREFIX}/share}"
# add_define:
# $1 = MAKEFILE or CONFIG
# $2 = define $3 = value
# $2 = define
# $3 = value
add_define()
{ eval "${1}_DEFINES=\"\${${1}_DEFINES} $2=$3\""; }

View File

@ -1,14 +1,3 @@
die() # $1 = exit code, use : to not exit when printing warnings $@ = exit or warning messages
{
ret="$1"
shift 1
printf %s\\n "$@" >&2
case "$ret" in
: ) return 0 ;;
* ) exit "$ret" ;;
esac
}
print_help_option() # $1 = option $@ = description
{
_opt="$1"

View File

@ -1,25 +1,3 @@
exists() # checks executables listed in $@ against the $PATH
{
v=1
while [ "$#" -gt 0 ]; do
arg="$1"
shift 1
case "$arg" in ''|*/) continue ;; esac
x="${arg##*/}"
z="${arg%/*}"
[ ! -f "$z/$x" ] || [ ! -x "$z/$x" ] && [ "$z/$x" = "$arg" ] && continue
[ "$x" = "$z" ] && [ -x "$z/$x" ] && [ ! -f "$arg" ] && z=
p=":$z:$PATH"
while [ "$p" != "${p#*:}" ]; do
p="${p#*:}"
d="${p%%:*}"
{ [ -f "$d/$x" ] && [ -x "$d/$x" ] && \
{ printf %s\\n "$d/$x"; v=0; break; }; } || :
done
done
return "$v"
}
if [ -n "$CROSS_COMPILE" ]; then
case "$CROSS_COMPILE" in
*'-mingw32'*) OS='Win32';;