2016-12-07 20:30:10 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-06-19 14:01:16 +00:00
|
|
|
## dev pre-processor bootstrap rev 2017061901
|
2016-12-07 20:30:10 +00:00
|
|
|
## Yeah !!! A really tech sounding name... In fact it's just include emulation in bash
|
|
|
|
|
2017-06-19 14:01:16 +00:00
|
|
|
function Usage {
|
|
|
|
echo "$0 - Quick and dirty preprocessor for including ofunctions into programs"
|
|
|
|
echo "Creates and executes $0.tmp.sh"
|
|
|
|
echo "Usage:"
|
|
|
|
echo ""
|
|
|
|
echo "$0 --program=osync|osync_target_helper|obackup|pmocr [options to pass to program]"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-13 18:28:47 +00:00
|
|
|
if [ ! -f "./merge.sh" ]; then
|
2016-12-13 11:33:30 +00:00
|
|
|
echo "Plrase run bootstrap.sh from osync/dev directory."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-06-19 14:01:16 +00:00
|
|
|
bootstrapProgram=""
|
|
|
|
opts=""
|
2016-12-07 20:30:10 +00:00
|
|
|
outputFileName="$0"
|
2017-06-19 14:01:16 +00:00
|
|
|
|
|
|
|
for i in "$@"; do
|
|
|
|
case $i in
|
|
|
|
--program=*)
|
|
|
|
bootstrapProgram="${i##*=}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
opts=$opts" $i"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$bootstrapProgram" == "" ]; then
|
|
|
|
Usage
|
|
|
|
exit 128
|
2017-06-18 20:48:38 +00:00
|
|
|
fi
|
2016-12-07 20:30:10 +00:00
|
|
|
|
|
|
|
source "merge.sh"
|
2017-06-18 20:48:38 +00:00
|
|
|
|
2017-06-19 14:01:16 +00:00
|
|
|
__PREPROCESSOR_PROGRAM=$bootstrapProgram
|
2016-12-07 20:30:10 +00:00
|
|
|
__PREPROCESSOR_Constants
|
|
|
|
|
|
|
|
cp "n_$__PREPROCESSOR_PROGRAM.sh" "$outputFileName.tmp.sh"
|
|
|
|
if [ $? != 0 ]; then
|
2016-12-11 21:40:27 +00:00
|
|
|
echo "Cannot copy original file [n_$__PREPROCESSOR_PROGRAM.sh] to [$outputFileName.tmp.sh]."
|
2016-12-07 20:30:10 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
for subset in "${__PREPROCESSOR_SUBSETS[@]}"; do
|
|
|
|
__PREPROCESSOR_MergeSubset "$subset" "${subset//SUBSET/SUBSET END}" "ofunctions.sh" "$outputFileName.tmp.sh"
|
|
|
|
done
|
2017-06-18 20:48:38 +00:00
|
|
|
chmod +x "$outputFileName.tmp.sh"
|
2016-12-07 20:30:10 +00:00
|
|
|
if [ $? != 0 ]; then
|
2017-06-18 20:48:38 +00:00
|
|
|
echo "Cannot make [$outputFileName] executable."
|
2016-12-07 20:30:10 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-12-10 16:56:03 +00:00
|
|
|
# Termux fix
|
|
|
|
if type termux-fix-shebang > /dev/null 2>&1; then
|
|
|
|
termux-fix-shebang "$outputFileName.tmp.sh"
|
|
|
|
fi
|
|
|
|
|
2017-06-19 14:01:16 +00:00
|
|
|
"$outputFileName.tmp.sh" $opts
|