ARM: cpu topology: Add debugfs interface for cpu_power
[cmplus.git] / build.sh
blobc0f85478f064d088641c06a10c00fde11cef03ba
1 #!/bin/bash
3 BOARD=tuna
4 DEVICEDIR=/sdcard/AROM
5 KNAME=kernel.cyano.RELEASE
6 DEVICE_CM_DIR=$ANDROID_BUILD_TOP/device/samsung/${BOARD}
8 WaitForDevice()
10 adb start-server
11 if [ $(adb get-state) != device -a $(adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then
12 echo "No device is online. Waiting for one..."
13 echo "Please connect USB and/or enable USB debugging"
14 until [ $(adb get-state) = device -o $(adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do
15 sleep 1
16 done
17 echo "Device Found.."
21 setup ()
23 if [ x = "x$ANDROID_BUILD_TOP" ] ; then
24 echo "Android build environment must be configured"
25 exit 1
27 . "$ANDROID_BUILD_TOP"/build/envsetup.sh
29 KERNEL_DIR="$(dirname "$(readlink -f "$0")")"
30 BUILD_DIR="$KERNEL_DIR/build"
31 # add modules which should be copied after build below
32 MODULES=("")
34 if [ x = "x$NO_CCACHE" ] && ccache -V &>/dev/null ; then
35 CCACHE=ccache
36 CCACHE_BASEDIR="$KERNEL_DIR"
37 CCACHE_COMPRESS=1
38 CCACHE_DIR="$BUILD_DIR/.ccache"
39 export CCACHE_DIR CCACHE_COMPRESS CCACHE_BASEDIR
40 else
41 CCACHE=""
44 CROSS_PREFIX="$ANDROID_BUILD_TOP/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-"
47 CheckVersion ()
49 if [ ! -f .Mayor ]
50 then
51 echo 1 > .Mayor
53 if [ ! -f .Minor ]
54 then
55 echo 0 > .Minor
57 sVersion=$(cat build/${BOARD}/include/config/kernel.release)
58 echo $sVersion
59 sVersionMerge=${sVersion:(-8)}
60 echo sVersionMerge
61 iMayor=$(cat .Mayor)
62 iMinor=$(cat .Minor)
65 CreateKernelZip ()
67 cd bin
68 rm *.zip
69 KZIPNAME=$KNAME.v$iMayor.$iMinor.$sVersionMerge.zip
70 zip $KZIPNAME * -r
71 if [ "$responseSend" == "y" ] ; then
72 WaitForDevice
73 echo Going into fastboot
74 if adb reboot-bootloader ; then
75 sleep 4
76 echo Pushing kernel file
77 if fastboot flash zimage kernel/zImage ; then
78 sleep 1
79 fastboot reboot
80 WaitForDevice
81 sleep 2
82 adb root
83 sleep 4
84 adb remount
85 sleep 2
86 echo Sending modules
87 for filename in system/modules/* ; do
88 echo Sending $filename to /system/modules
89 if adb push $filename /system/modules ; then
90 echo "Rebooting again"
91 adb reboot
93 done
97 cd ..
98 echo $KZIPNAME
101 UpgradeMinor ()
103 iMinor=$(($iMinor+1))
104 echo $iMinor > .Minor
107 CompileError ()
109 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
110 echo ! COMPILACION FAILED
111 echo !
112 echo !
113 echo ! ---------------------- COMPILACION ERROR CODE: $RET
114 echo !
115 echo !
116 echo !
117 echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
120 build ()
122 local target=$1
123 echo "Building for $target"
124 local target_dir="$BUILD_DIR/$target"
125 local module
126 [ x = "x$NO_RM" ]
127 mkdir -p "$target_dir"
128 [ x = "x$NO_DEFCONFIG" ] && mka -C "$KERNEL_DIR" O="$target_dir" ARCH=arm ${BOARD}_defconfig HOSTCC="$CCACHE gcc"
129 if [ x = "x$NO_BUILD" ] ; then
130 mka -C "$KERNEL_DIR" O="$target_dir" ARCH=arm HOSTCC="$CCACHE gcc" CROSS_COMPILE="$CCACHE $CROSS_PREFIX" modules
131 RET=$?
132 if [[ $RET == 0 ]] ; then
133 mka -C "$KERNEL_DIR" O="$target_dir" ARCH=arm HOSTCC="$CCACHE gcc" CROSS_COMPILE="$CCACHE $CROSS_PREFIX" zImage
134 RET=$?
135 if [[ $RET == 0 ]] ; then
136 cp "$target_dir"/arch/arm/boot/zImage bin/kernel/zImage
137 for module in "${MODULES[@]}" ; do
138 cp "$target_dir/$module" bin/system/modules
139 done
140 CheckVersion
141 CreateKernelZip
142 UpgradeMinor
143 else
144 CompileError
146 else
147 CompileError
152 setup
154 echo Type y + \"intro\" to send kernel to your mobile:
155 read -t 10 responseSend;
156 if [ "$responseSend" == "y" ] ; then
157 echo Sending to device after build .. $responseSend
158 else
159 echo Only compile .. $responseSend
162 if [ "$1" = clean ] ; then
163 rm -fr "$BUILD_DIR"/*
164 exit 0
167 targets=("$@")
168 if [ 0 = "${#targets[@]}" ] ; then
169 targets=(tuna)
172 START=$(date +%s)
174 for target in "${targets[@]}" ; do
175 build $target
176 done
178 END=$(date +%s)
179 ELAPSED=$((END - START))
180 E_MIN=$((ELAPSED / 60))
181 E_SEC=$((ELAPSED - E_MIN * 60))
182 printf "Elapsed: "
183 [ $E_MIN != 0 ] && printf "%d min(s) " $E_MIN
184 printf "%d sec(s)\n" $E_SEC