summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fa2677f)
raw | patch | inline | side by side (parent: fa2677f)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 1 Nov 2014 14:35:00 +0000 (17:35 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 1 Nov 2014 14:35:00 +0000 (17:35 +0300) |
build.sh | [new file with mode: 0644] | patch | blob |
diff --git a/build.sh b/build.sh
--- /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> path to jar"
+ echo " -src <path> path to sources(*.mpsrc/*.pas)"
+ echo " -libs <path> path to local libraries"
+ echo " -classes <path> path to *.class and *.bsf files"
+ echo " -canvas <type> MIDlet type:"
+ echo " MIDP1"
+ echo " MIDP2"
+ echo " NOKIA"
+ echo " -math <type> type real:"
+ echo " FIXED"
+ echo " FLOAT"
+ echo " -njar do not package to jar"
+ echo " -only <name> compile only <name>"
+ 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)