DEADSOFTWARE

Add Makefile
[mp3cc.git] / build.sh
1 #!/bin/bash
3 bin_path="./bin/bin.jar"
4 src_path="./src"
5 class_path="./classes"
6 plib_path="./libs" #project libs
7 res_path="./res"
9 llib_path="./libs" #global libs
10 stubs_path='./stubs'
12 canvas_type=1 #0 - MIDP1.0, 1 - MIDP2.0, 2 - NOKIAAPI
13 math_type=0 #0 - fixed, 1 - float
14 create_jar=1
16 gen_only_classname=''
18 start_time=$(date +%H:%M:%S)
20 while [[ $#>0 ]]; do
21 case "$1" in
22 '-h' )
23 echo "Build script MidletPascal Сompiler 3.5"
24 echo " -bin <path> path to jar"
25 echo " -src <path> path to sources(*.mpsrc/*.pas)"
26 echo " -libs <path> path to local libraries"
27 echo " -classes <path> path to *.class and *.bsf files"
28 echo " -canvas <type> MIDlet type:"
29 echo " MIDP1"
30 echo " MIDP2"
31 echo " NOKIA"
32 echo " -math <type> type real:"
33 echo " FIXED"
34 echo " FLOAT"
35 echo " -njar do not package to jar"
36 echo " -only <name> compile only <name>"
37 exit 1
38 ;;
39 '-bin' )
40 shift
41 bin_path=$1
42 ;;
43 '-src' )
44 shift
45 src_path=$1
46 ;;
47 '-libs' )
48 shift
49 plib_path=$1
50 ;;
51 '-classes' )
52 shift
53 class_path=$1
54 ;;
55 '-canvas' )
56 shift
57 case "$1" in
58 'MIDP1' )
59 canvas_type=0
60 ;;
61 'MIDP2' )
62 canvas_type=1
63 ;;
64 'NOKIA' )
65 canvas_type=2
66 ;;
67 * )
68 echo "Unknown canvas type '$1'"
69 exit 1
70 ;;
71 esac
72 ;;
73 '-math' )
74 shift
75 case "$1" in
76 'FIXED' )
77 math_type=0
78 ;;
79 'FLOAT' )
80 math_type=1
81 ;;
82 * )
83 echo "Unknown math type '$1'"
84 exit 1
85 ;;
86 esac
87 ;;
88 '-njar' )
89 shift
90 create_jar=0
91 ;;
92 '-only' )
93 shift
94 gen_only_classname=$1
95 ;;
96 * )
97 echo "Unknown argument '$1'"
98 exit 1
99 ;;
100 esac
101 shift
102 done
104 #Ищем все файлы исходников в папке src
105 sources=$(ls -R $src_path/*.pas $src_path/*.mpsrc)
107 if [[ gen_only_classname == '' ]]; then
108 rm -rf classes
109 mkdir classes
110 fi
112 #Генерируем bsf файлы, необходимые для использования модулей.
113 for file in $sources; do
114 ./mp3CC -s$file -o$class_path -p$plib_path -l$llib_path -c$canvas_type -m$math_type -d
115 if [[ $? != '0' ]]; then
116 exit 1
117 fi
118 done
120 #Собираем исходники в классы
121 if [[ "$gen_only_classname" != '' ]]; then
122 ./mp3CC -s$src_path/$gen_only_classname -o$class_path -p$plib_path -l$llib_path -c$canvas_type -m$math_type
123 if [[ $? != '0' ]]; then
124 exit 1
125 fi
126 else
127 for file in $sources; do
128 ./mp3CC -s$file -o$class_path -p$plib_path -l$llib_path -c$canvas_type -m$math_type
129 if [[ $? != '0' ]]; then
130 exit 1
131 fi
132 done
133 fi
136 #Упаковываем в jar
137 if [[ $create_jar>0 ]]; then
138 rm -f $bin_path
140 cd $stubs_path
141 files=$(ls *.class)
142 zip -Z deflate -9 ../$bin_path $files
144 cd ../$llib_path
145 files=$(ls *.class)
146 zip -Z deflate -u -9 ../$bin_path $files
148 cd ../$plib_path
149 files=$(ls *.class)
150 zip -Z deflate -u -9 ../$bin_path $files
152 cd ../$class_path
153 files=$(ls *.class)
154 zip -Z deflate -u -9 ../$bin_path $files
156 cd ../$res_path
157 files=$(find)
158 zip -Z deflate -u -9 ../$bin_path $files
159 cd ..
160 fi
162 echo "Done!"
163 echo "Start: $start_time"
164 echo "End : "$(date +%H:%M:%S)