Initialize
[sdk/ide/telephony-eplugin.git] / build.sh
1 #!/bin/bash
2 start_path=`pwd`
3
4 ###############################################################
5 ##
6 ## Please modify parameter value.
7 ##
8 ###############################################################
9 build_type=N
10 build_id=telephony_build
11 build_path="`pwd`/../build_result"
12
13 ###############################################################
14 ##
15 ## Do not touch here.
16 ##
17 ###############################################################
18 build_result_directory=${build_type}.${build_id}
19 builder_path="$start_path/builder"
20 equinox_launcher=`echo org.eclipse.equinox.launcher_*.jar`
21 pde_build=`echo org.eclipse.pde.build_*`
22 metadata_path=$start_path/builder
23
24 if [ "x$1" = "x" ]
25 then
26         echo "
27 Usage : build_ide.sh PLATFORM_NAME TARGET_ECLIPSE_PATH
28
29    PLATFORM_NAME                You can set \"linux\" or \"windows\"
30    TARGET_ECLIPSE_PATH          Set target eclipse path.
31                                 For example, $HOME/git/fresh-ide-pde
32 "
33         exit 1
34 fi
35
36 if [ "x$2" = "x" ]
37 then
38         echo "
39 Usage : build_ide.sh $1 TARGET_ECLIPSE_PATH
40    TARGET_ECLIPSE_PATH  Set target eclipse path.
41                         For example, $HOME/git/fresh-ide-pde
42 "
43         exit 1
44 fi
45
46 build_result_path="$build_path/$build_result_directory"
47 platform=$1
48 based_eclipse_path=$2
49 fresh_ide_path=$3
50 eventinjector_path=$4
51 parent_path_of_based_eclipse=${based_eclipse_path}/..
52 architecture=x86
53
54 case ${platform} in
55         linux)
56                 archive_platform_name=linux
57                 windowing=gtk
58                 ;;
59         windows)
60                 archive_platform_name=win32
61                 windowing=win32
62                 ;;
63         *)
64                 echo "${platform} is not support yet."
65                 exit 1
66                 ;;
67 esac
68
69 result_archive_file=${build_id}-${archive_platform_name}.${windowing}.${architecture}.zip
70
71 if [ -d $build_path ]
72 then
73         echo "Build result directory : [$build_path]"
74 else
75         echo "Make build result directory [$build_path]"
76         mkdir -p $build_path
77 fi
78
79 echo "Remove legacy build files..."
80 if [ -d ${build_result_path}/${archive_platform_name}.${windowing}.${architecture} ]
81 then
82         rm -rf ${build_result_path}/${archive_platform_name}.${windowing}.${architecture}
83 fi
84 if [ -e ${build_result_path}/${result_archive_file} ]
85 then
86         rm -rf ${build_result_path}/${result_archive_file}
87 fi
88
89 if [ -d $build_path/plugins ]
90 then
91         echo "plugins directory recreate..."
92         rm -rf $build_path/plugins
93         mkdir $build_path/plugins
94 else
95         echo "Make plugins directory..."
96         mkdir $build_path/plugins
97 fi
98 if [ -d $build_path/features/ ]
99 then
100         echo "features directory recreate..."
101         rm -rf $build_path/features
102         mkdir $build_path/features
103 else
104         echo "Make features directory..."
105         mkdir $build_path/features
106 fi
107
108 echo "Copy features from $start_path to $build_path/features"
109 cp -r $start_path/*.feature $build_path/features
110
111 echo "Copy plugins from $start_path to $build_path/plugins"
112 cp -r $start_path/* $build_path/plugins
113 rm -rf $build_path/plugins/*.feature
114
115 echo "Copy fresh ide plugins..."
116 if [ -d ${fresh_ide_path} ]
117 then
118         cp -rf ${fresh_ide_path}/${archive_platform_name}.${windowing}.${architecture}/IDE/features/* ${build_path}/features
119         cp -rf ${fresh_ide_path}/${archive_platform_name}.${windowing}.${architecture}/IDE/plugins/* ${build_path}/plugins
120 else
121         echo "ERROR : Fresh IDE does not exist..."
122         exit 1
123 fi
124
125 echo "Copy event injector plugin..."
126 if [ -d ${eventinjector_path} ]
127 then
128         cp -rf ${eventinjector_path}/${archive_platform_name}.${windowing}.${architecture}/eventinjector/features/* ${build_path}/features
129         cp -rf ${eventinjector_path}/${archive_platform_name}.${windowing}.${architecture}/eventinjector/plugins/* ${build_path}/plugins
130 else
131         echo "ERROR : Event Injector does not exist..."
132         exit 1
133 fi
134
135 echo "Make build.properties file..."
136 if [ ! -e $builder_path/build.properties.clean ] ; then
137         echo "ERROR : \"build.properties.clean\" file does not exist..."
138         exit 1
139 fi
140 cp $builder_path/build.properties.clean $build_path
141 cp $builder_path/customTargets.xml $build_path
142
143 if [ -d $based_eclipse_path ] 
144 then
145         sed -e "s;\(^buildDirectory=\).*;\1${build_path};g" -e "s;\(^base=\).*;\1${parent_path_of_based_eclipse};g" -e "s;\(^baseLocation=\).*;\1${based_eclipse_path};g" -e "s;\(^configs=\).*;\1${archive_platform_name},${windowing},${architecture};g" -e "s;\(^buildType=\).*;\1${build_type};g" -e "s;\(^buildId=\).*;\1${build_id};g" < $build_path/build.properties.clean > $build_path/build.properties
146 else
147         echo "ERROR : target eclipse is not exist."
148         exit 1
149 fi
150
151 echo "Execute Product Ant Builder..."
152 java -server -XX:+UseParNewGC -jar ${based_eclipse_path}/plugins/$equinox_launcher -application org.eclipse.ant.core.antRunner -buildfile ${based_eclipse_path}/plugins/$pde_build/scripts/productBuild/productBuild.xml -Dbuilder=$build_path 2>&1
153
154 if [ $? != 0 ];
155 then
156         echo "Build failed..."
157         exit 1
158 fi
159
160 echo "unzip to $build_result_path"
161 unzip -a $build_result_path/${result_archive_file} -d $build_result_path/${archive_platform_name}.${windowing}.${architecture}
162
163 #echo "Delete temp files..."
164 #rm -rf $build_path/features
165 #rm -rf $build_path/plugins
166 #rm $build_path/*.xml
167 #rm $build_path/*.properties
168 #rm $build_path/*.properties.clean
169
170 echo "Build SUCCESS. You will find SDK IDE in \"${build_result_path}\"."