From c99822e75cde45209ba60790a4ed12aa9571e6f8 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 1 Nov 2014 17:35:00 +0300 Subject: [PATCH] Adding script for compile MIDletPascal programms --- build.sh | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..6e965f5 --- /dev/null +++ b/build.sh @@ -0,0 +1,164 @@ +#!/bin/bash + +bin_path="./bin/bin.jar" +src_path="./src" +class_path="./classes" +plib_path="./libs" #project libs +res_path="./res" + +llib_path="./libs" #global libs +stubs_path='./stubs' + +canvas_type=1 #0 - MIDP1.0, 1 - MIDP2.0, 2 - NOKIAAPI +math_type=0 #0 - fixed, 1 - float +create_jar=1 + +gen_only_classname='' + +start_time=$(date +%H:%M:%S) + +while [[ $#>0 ]]; do + case "$1" in + '-h' ) + echo "Build script MidletPascal Сompiler 3.5" + echo " -bin path to jar" + echo " -src path to sources(*.mpsrc/*.pas)" + echo " -libs path to local libraries" + echo " -classes path to *.class and *.bsf files" + echo " -canvas MIDlet type:" + echo " MIDP1" + echo " MIDP2" + echo " NOKIA" + echo " -math type real:" + echo " FIXED" + echo " FLOAT" + echo " -njar do not package to jar" + echo " -only compile only " + exit 1 + ;; + '-bin' ) + shift + bin_path=$1 + ;; + '-src' ) + shift + src_path=$1 + ;; + '-libs' ) + shift + plib_path=$1 + ;; + '-classes' ) + shift + class_path=$1 + ;; + '-canvas' ) + shift + case "$1" in + 'MIDP1' ) + canvas_type=0 + ;; + 'MIDP2' ) + canvas_type=1 + ;; + 'NOKIA' ) + canvas_type=2 + ;; + * ) + echo "Unknown canvas type '$1'" + exit 1 + ;; + esac + ;; + '-math' ) + shift + case "$1" in + 'FIXED' ) + math_type=0 + ;; + 'FLOAT' ) + math_type=1 + ;; + * ) + echo "Unknown math type '$1'" + exit 1 + ;; + esac + ;; + '-njar' ) + shift + create_jar=0 + ;; + '-only' ) + shift + gen_only_classname=$1 + ;; + * ) + echo "Unknown argument '$1'" + exit 1 + ;; + esac + shift +done + +#Ищем все файлы исходников в папке src +sources=$(ls -R $src_path/*.pas $src_path/*.mpsrc) + +if [[ gen_only_classname == '' ]]; then + rm -rf classes + mkdir classes +fi + +#Генерируем bsf файлы, необходимые для использования модулей. +for file in $sources; do + ./mp3CC -s$file -o$class_path -p$plib_path -l$llib_path -c$canvas_type -m$math_type -d + if [[ $? != '0' ]]; then + exit 1 + fi +done + +#Собираем исходники в классы +if [[ "$gen_only_classname" != '' ]]; then + ./mp3CC -s$src_path/$gen_only_classname -o$class_path -p$plib_path -l$llib_path -c$canvas_type -m$math_type + if [[ $? != '0' ]]; then + exit 1 + fi +else + for file in $sources; do + ./mp3CC -s$file -o$class_path -p$plib_path -l$llib_path -c$canvas_type -m$math_type + if [[ $? != '0' ]]; then + exit 1 + fi + done +fi + + +#Упаковываем в jar +if [[ $create_jar>0 ]]; then + rm -f $bin_path + + cd $stubs_path + files=$(ls *.class) + zip -Z deflate -9 ../$bin_path $files + + cd ../$llib_path + files=$(ls *.class) + zip -Z deflate -u -9 ../$bin_path $files + + cd ../$plib_path + files=$(ls *.class) + zip -Z deflate -u -9 ../$bin_path $files + + cd ../$class_path + files=$(ls *.class) + zip -Z deflate -u -9 ../$bin_path $files + + cd ../$res_path + files=$(find) + zip -Z deflate -u -9 ../$bin_path $files + cd .. +fi + +echo "Done!" +echo "Start: $start_time" +echo "End : "$(date +%H:%M:%S) -- 2.29.2