Home | History | Annotate | Download | only in buildscripts
      1 #!/bin/bash 
      2 
      3 # usage: [-test -nobuild]
      4 function usage
      5 {
      6 	echo "usage: $0 [-test] [-nobuild] [-incremental | -clearmake] [-display] [[[[build-top dir] param1] param2] ....]"
      7 	echo " -test - include test tar in final package"
      8 	echo " -nobuild - do not compile - just create package"
      9 	echo " -clearmake | -cm - use clearmake instead of make. Automatically tracks dependencies and can use DO to speed up build."
     10 	echo " -display - displays compilation output instead of redirecting it to log/errors files"
     11 	echo " -bo | -buildonly - only compiles library files; don't recompile unittest and DMT files"
     12 	echo " -debug - only compiles x86 debug library files"
     13 	exit 1
     14 }
     15 
     16 # global flag
     17 ADDTEST=0
     18 BUILDPKG=1
     19 BUILD_MODE="default"
     20 BUILD_ONLY=0
     21 DEBUG_ONLY=0
     22 
     23 
     24 while [ $# -gt 0 ]; do
     25   case "$1" in 
     26    -test ) ADDTEST=1 ; shift ;;
     27    -nobuild ) BUILDPKG=0 ; shift ;;
     28    -cm | -clearmake ) BUILD_MODE="cm" ; shift ;;
     29    -bo | -buildonly ) BUILD_ONLY=1 ; shift ;;
     30    -debug ) DEBUG_ONLY=1 ; shift ;;
     31    -d | -display ) DISPLAY="y" ; shift ;;
     32    -? | -h | -help | --help ) usage ; shift ;;
     33    * ) break ;;
     34    -* ) echo "unknown option $1; try -? for list of supported options"; exit 1 ;;
     35    * ) break ;;
     36   esac
     37 done
     38 
     39 export BUILD_MODE DEBUG_ONLY
     40 
     41 DM_SRC=/vobs/linuxjava/device_mgmt/dm/core/src
     42 DM_XPL=/vobs/linuxjava/device_mgmt/dm/xpl
     43 
     44 read VERSION < release_version.txt
     45 echo "VERSION is $VERSION"
     46 MAJOR_VERSION=`cat release_version.txt | sed 's/^\([0-9][0-9]*\).*/\1/'`
     47 echo "MAJOR VERSION is $MAJOR_VERSION"
     48 
     49 BTOP=/tmp/build2.lj.`whoami`
     50 
     51 if [ "$BUILD_MODE-" == "cm-" ] ; then
     52 	BTOP=../../../build
     53 fi
     54 
     55 echo "BTOP=$BTOP"
     56 
     57 LOG_FILE=`pwd`/log-lj-`whoami`-pkg-`date "+%Y-%m-%d"`
     58 
     59  echo "write log to $LOG_FILE"
     60 
     61  date > $LOG_FILE
     62 
     63 #cleartool catcs >> $LOG_FILE
     64 
     65 echo "compiling..."
     66 rm -f errors.txt
     67 
     68 SUPER_AGEN="LJAgent"
     69 
     70 if [ "$BUILDPKG" == "1" ] ; then
     71 # Building now...
     72 	if [ "$BUILD_MODE-" == "default-" ] ; then
     73 		rm -rf $BTOP
     74 	fi
     75 
     76 	if [ "$DISPLAY" == "y" ] ; then
     77 		$DM_SRC/linux_java/buildscripts/buildLib.sh $BTOP -DDMSyncMLLibVersion=\\\"$VERSION\\\" -DDMSyncMLLibVersionMajor=\\\"$MAJOR_VERSION\\\" -DDM_SUPER_AGENT=\\\"$SUPER_AGEN\\\" $1 $2 $3 $4  || exit 1
     78 	else
     79 		$DM_SRC/linux_java/buildscripts/buildLib.sh $BTOP -DDMSyncMLLibVersion=\\\"$VERSION\\\" -DDMSyncMLLibVersionMajor=\\\"$MAJOR_VERSION\\\" -DDM_SUPER_AGENT=\\\"$SUPER_AGEN\\\" $1 $2 $3 $4  >> $LOG_FILE 2>> errors.txt || exit 1
     80 	fi
     81 fi
     82 
     83 
     84 TMP_FOLDER=/tmp/pckg.lj.`whoami`
     85 echo "TMP_FOLDER=$TMP_FOLDER"
     86 
     87 if [ "$BUILD_ONLY" == "0" ] ; then
     88 	rm -rf $TMP_FOLDER
     89 else
     90 	rm -rf $TMP_FOLDER/lib
     91 fi
     92 
     93 mkdir $TMP_FOLDER
     94 mkdir -p $TMP_FOLDER/lib/x86.r
     95 mkdir -p $TMP_FOLDER/lib/xscale.r
     96 mkdir -p $TMP_FOLDER/lib/x86.d
     97 mkdir -p $TMP_FOLDER/lib/xscale.d
     98 
     99 #copy lib .so files
    100 if [ "$DEBUG_ONLY" == "0" ] ; then
    101 	cp -v $BTOP/xscale/release-staging/usr/local/motorola/lib/*.a $TMP_FOLDER/lib/xscale.r/ >> $LOG_FILE
    102 	cp -v $BTOP/xscale/release-staging/usr/local/motorola/lib/*.so $TMP_FOLDER/lib/xscale.r/ >> $LOG_FILE
    103 	cp -v $BTOP/x86-Redhat/release-staging/usr/local/motorola/lib/*.a $TMP_FOLDER/lib/x86.r/ >> $LOG_FILE
    104 	cp -v $BTOP/x86-Redhat/release-staging/usr/local/motorola/lib/*.so $TMP_FOLDER/lib/x86.r/ >> $LOG_FILE
    105 	                                                                                                                                                   
    106 	cp -v $BTOP/xscale/staging/lib/*.a $TMP_FOLDER/lib/xscale.d/ >> $LOG_FILE
    107 	cp -v $BTOP/xscale/staging/lib/*.so $TMP_FOLDER/lib/xscale.d/ >> $LOG_FILE
    108 fi
    109 
    110 cp -v $BTOP/x86-Redhat/staging/lib/*.a $TMP_FOLDER/lib/x86.d/ >> $LOG_FILE
    111 cp -v $BTOP/x86-Redhat/staging/lib/*.so $TMP_FOLDER/lib/x86.d/ >> $LOG_FILE
    112 
    113 function create_links
    114 {
    115         DIR=$1
    116         pushd $DIR  >> $LOG_FILE
    117         mv libdmnative.so libdmnative.so.$VERSION
    118         mv libdmssession.so libdmssession.so.$VERSION
    119         ln  -s libdmnative.so.$VERSION libdmnative.so
    120         ln  -s libdmssession.so.$VERSION libdmssession.so
    121         ln  -s libdmnative.so.$VERSION libdmnative.so.$MAJOR_VERSION
    122         ln  -s libdmssession.so.$VERSION libdmssession.so.$MAJOR_VERSION
    123                                                                                                                                                    
    124         popd  >> $LOG_FILE
    125 }
    126 
    127 if [ "$DEBUG_ONLY" == "0" ] ; then
    128 	create_links $TMP_FOLDER/lib/xscale.r/
    129 	create_links $TMP_FOLDER/lib/x86.r/
    130 	create_links $TMP_FOLDER/lib/xscale.d/
    131 fi
    132 create_links $TMP_FOLDER/lib/x86.d/
    133                                                                                                                                                    
    134 if [ "$BUILD_ONLY" == "1" ] ; then
    135 	echo "Incremental build is done; unit-test skipped"
    136 	exit 0
    137 fi
    138 
    139 #copy public include files
    140 cp -rv $DM_SRC/api/native $TMP_FOLDER/include >> $LOG_FILE
    141 cp -rv $DM_SRC/api/common/* $TMP_FOLDER/include >> $LOG_FILE
    142 cp $DM_SRC/portlib/generic/xpl_dm_Manager.h $TMP_FOLDER/include >> $LOG_FILE
    143 cp -rv $DM_SRC/dmengine/dm_persist/hdr/SyncML_DM_FileHandle.H  $TMP_FOLDER/include >> $LOG_FILE
    144 cp -rv $DM_SRC/dmengine/dm_util/hdr/syncml_dm_data_types.h  $TMP_FOLDER/include >> $LOG_FILE
    145                                                                                                                                                    
    146                                                                                                                                                    
    147 #copy portlib header files needed by LJ
    148 mkdir -p $TMP_FOLDER/portlib
    149 cp -rv $DM_SRC/portlib/generic/xpl_dm_ServerAlert.h $TMP_FOLDER/portlib >> $LOG_FILE
    150 cp -rv $DM_SRC/portlib/generic/xpl_dm_ServerAlertDef.h $TMP_FOLDER/portlib >> $LOG_FILE
    151 cp -rv $DM_SRC/portlib/generic/dmMemory.h $TMP_FOLDER/portlib >> $LOG_FILE
    152 cp -rv $DM_SRC/portlib/lj/hdr/dmStringUtil.h  $TMP_FOLDER/portlib >> $LOG_FILE
    153 cp -rv $DM_XPL/code/portlib/linux/hdr/xpl_Types.h $TMP_FOLDER/portlib >> $LOG_FILE
    154 cp -rv $DM_XPL/code/portlib/hdr/xpl_File.h $TMP_FOLDER/portlib >> $LOG_FILE
    155 cp -rv $DM_XPL/code/portlib/hdr/xpl_Port.h $TMP_FOLDER/portlib >> $LOG_FILE
    156 cp -rv $DM_XPL/code/portlib/hdr/xpl_Time.h $TMP_FOLDER/portlib >> $LOG_FILE
    157 
    158 #copy docs, not send doc files, only pdf files if any...
    159 mkdir -p $TMP_FOLDER/docs/apidocs
    160 #cp -rv $DM_SRC/../docs/apidocs/* $TMP_FOLDER/docs/apidocs >> $LOG_FILE
    161 #cp -rv $DM_SRC/../docs/*.pdf $TMP_FOLDER/docs >> $LOG_FILE
    162 
    163 #create tools
    164 mkdir -p $TMP_FOLDER/tools
    165                                                                                                                                                    
    166 #create dmt tools
    167 mkdir -p $TMP_FOLDER/tools/dmt-tools
    168 cp -rv $DM_SRC/dmt-tools/* $TMP_FOLDER/tools/dmt-tools >> $LOG_FILE
    169 cp -rv $DM_SRC/linux_java/samples/settings/fstab $TMP_FOLDER/tools/dmt-tools >> $LOG_FILE
    170 
    171 #create server credential tools
    172 mkdir -p $TMP_FOLDER/tools/servercred
    173 pushd $DM_SRC/tool/servercred  >> $LOG_FILE
    174 ./build.sh || exit 1
    175 popd  >> $LOG_FILE
    176 cp -rv $DM_SRC/tool/servercred/*.txt $TMP_FOLDER/tools/servercred/ >> $LOG_FILE
    177 cp -rv $DM_SRC/tool/servercred/bin   $TMP_FOLDER/tools/servercred/bin >> $LOG_FILE
    178                                                                                                                                                    
    179 chmod -x $TMP_FOLDER/portlib/*
    180 chmod -x $TMP_FOLDER/include/*.h*
    181 chmod -x $TMP_FOLDER/include/plugin/*
    182 
    183 # create samples
    184 echo "Prepare samples"
    185 DM_SAMPLES=$DM_SRC/linux_java/samples
    186 echo "samples dir=$DM_SAMPLES"
    187                                                                                                                                                    
    188 mkdir $TMP_FOLDER/samples
    189 cp -rv $DM_SAMPLES/compile $TMP_FOLDER/samples/ >> $LOG_FILE
    190 cp -rv $DM_SAMPLES/run_test $TMP_FOLDER/samples/ >> $LOG_FILE
    191 cp -rv $DM_SAMPLES/ddd_test $TMP_FOLDER/samples/ >> $LOG_FILE
    192 chmod +x  $TMP_FOLDER/samples/compile
    193 chmod +x  $TMP_FOLDER/samples/run_test
    194 chmod +x  $TMP_FOLDER/samples/ddd_test
    195 
    196 #cp source files
    197 mkdir $TMP_FOLDER/samples/src
    198 cp -rv $DM_SAMPLES/unittest/src/*.cc $TMP_FOLDER/samples/src >> $LOG_FILE
    199 cp -v $DM_SRC/linux_java/samples/plugins/test*/src/*.cc $TMP_FOLDER/samples/src >> $LOG_FILE
    200                                                                                                                                                    
    201 #cp settings
    202 mkdir $TMP_FOLDER/samples/settings
    203 cp -v $DM_SAMPLES/plugins/settings/testplugins.ini $TMP_FOLDER/samples/settings/testplugins.ini >> $LOG_FILE
    204 cp -v $DM_SAMPLES/settings/Dmt.zip $TMP_FOLDER/samples/settings/ >> $LOG_FILE
    205                                                                                                                                                    
    206 chmod +w $TMP_FOLDER/samples/*
    207 
    208 # create packages
    209 ZIPFILE=DM-v$VERSION-`date "+%Y-%m-%d"`.tgz
    210 pushd $TMP_FOLDER
    211 tar zcvf $ZIPFILE * >> $LOG_FILE
    212 popd
    213                                                                                                                                                          
    214 cp -r $DM_SRC/linux_java/test $TMP_FOLDER/samples/unittest
    215 pushd $TMP_FOLDER
    216 
    217 echo "compiling unit test..."
    218 cd samples
    219 ./compile both || exit 1 >> $LOG_FILE
    220 
    221 
    222 #run unit test
    223 export DM_NOPRINTF=1
    224 
    225 export dm_setting_root=$PWD/dmt_data
    226 export dm_setting_version="1.1.2"
    227 export PLATFORM=x86
    228 export LD_LIBRARY_PATH=$PWD/../lib/x86.d:$PWD/lib/../x86
    229 export dm_setting_plugin=$PWD/plugins/x86
    230 
    231 
    232 echo "running unit test for DM 1.1.2..."
    233 ./bin/x86/testexe < unittest/dm11/testinput11 >  unittest/dm11/output11 || exit 1
    234 diff -q  unittest/dm11/output11  unittest/dm11/testoutput11 || echo "DM 1.1 unit test failed!"
    235 
    236 export dm_setting_version="1.2"
    237 
    238 echo "running unit test for DM 1.2..."
    239 ./bin/x86/testexe < unittest/dm12/testinput12 >  unittest/dm12/output12 || exit 1
    240 diff -q  unittest/dm12/output12  unittest/dm12/testoutput12 || echo "DM 1.2 unit test failed!" 
    241 popd
    242                                                                                                                                                    
    243 echo "done; result file is  $TMP_FOLDER/$ZIPFILE"
    244 
    245