summaryrefslogtreecommitdiff
path: root/gcc/test_driver
blob: 4ee3b1029397dd273cec26f4b716b119291d10a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#! /bin/sh
#
#  Test Driver
#
#  $Id$
#

vfile=`dirname $0`/../VERSIONS
if [ ! -r ${vfile} ] ; then
  echo VERSIONS file not found
  exit 1
fi

source ${vfile}

if [ ! -d ${BASEDIR} ] ; then
  echo Have you set the BASEDIR in VERSIONS correctly?
  exit 1
fi

BASEDIR=`pwd`

for d in ${AUTOCONF} ${AUTOMAKE} ${BINUTILSDIR} \
    ${GDBDIR} ${NEWLIBDIR} ${GCCDIR}
do
  if [ ! -d ${d} ] ; then
    echo "Cannot locate ${d} -- aborting"
    exit 1
  fi
done

toggle()
{
  case $1 in
    no)  echo "yes" ;;
    yes) echo "no" ;;
    *)   fatal "Unknown value to toggle ($1)" ;;
  esac
}

usage()
{
cat <<EOF
do_one [options] CPU ..  CPU
  -A - enable clean, native, and update
  -a - build Ada (default=yes)
  -c - clean install point (also installs auto tools)
  -m - mail results to lists (default=yes)
  -n - build native
  -T - run tests (default=yes)
  -u - update GNU source if version from CVS/SVN
  -U - update RTEMS source if version from CVS/SVN (will bootstrap)
  -v - verbose
EOF
}

doCleanInstallPoint="no"
doUpdateTools="no"
doUpdateRTEMS="no"
doNative="no"
verbose="no"
doAda="yes"
doMail="yes"
doTests="yes"

while getopts AacmnuUv OPT
do
  case "$OPT" in
    A) doCleanInstallPoint=`toggle ${doCleanInstallPoint}`
       doNative=`toggle ${doNative}`
       doUpdateTools=`toggle ${doUpdateTools}`
       doUpdateRTEMS=`toggle ${doUpdateRTEMS}`
       ;;
    a) doAda=`toggle ${doAda}` ;;
    c) doCleanInstallPoint=`toggle ${doCleanInstallPoint}` ;;
    m) doMail=`toggle ${doMail}` ;;
    n) doNative=`toggle ${doNative}` ;;
    T) doTests=`toggle ${doTests}` ;;
    u) doUpdateTools=`toggle ${doUpdateTools}` ;;
    U) doUpdateRTEMS=`toggle ${doUpdateRTEMS}` ;;
    v) verbose=`toggle ${verbose}` ;;
    *) usage; exit 1;
  esac
done

shiftcount=`expr $OPTIND - 1`
shift $shiftcount

args=$*

CPUs=""
for cpu in ${args}
do
  if [ ${cpu} = "native" ] ; then
    doNative="yes"
  else
    CPUs="${CPUs} ${cpu}"
  fi
done


if [ ${verbose} = "yes" ] ; then
  echo "Clean Install Point: " ${doCleanInstallPoint}
  echo "Install Autotools:   " ${doCleanInstallPoint}
  echo "Install Native:      " ${doNative}
  echo "Update Tool Source:  " ${doUpdateTools}
  echo "Update RTEMS:        " ${doUpdateRTEMS}
  echo "Build Ada            " ${doAda}
  echo "Email Results:       " ${doMail}
  echo "Run Tests:           " ${doTests}
  if [ X${CPUs} = X ] ; then
    echo "CPUs to Build:       " ALL
  else
    echo "CPUs to Build:       " ${CPUs}
  fi
fi

test ${doMail}  = "no"   && mailArg="-M"
test ${doTests} = "yes" && testArg="-T"
test ${doAda}   = "yes" && adaArg="-a"

start=`date`
echo Started at: ${start}

# HELPER - Update RTEMS
update_rtems()
{
  cd ${RTEMSDIR}
  if [ -d CVS ] ; then
    cvs up -Pd 2>&1 | grep -v ^cvs
    ./bootstrap -c
    ./bootstrap
  fi
}

# HELPER - Update GCC
update_gcc()
{
  cd ${GCCDIR}
  if [ -d .svn ] ; then
    grep "svn+ssh" .svn/entries >/dev/null
    if [ $? -eq 0 ] ; then
      echo "Skipping gcc update -- ssh keyed check out"
    else
      echo "Updating gcc -- anonymous check out"
      ./contrib/gcc_update
      if [ $? -ne 0 ] ; then
        echo "Update of GCC Failed."
        exit 1 
      fi
   fi
  fi
  return 0 
}

# HELPER - Remove all the installed previous builds
clean_up()
{
  rm -rf ${INSTALL}/* ${BSP_INSTALL}/*
}

install_auto()
{
  for auto in ${AUTOCONF} ${AUTOMAKE}
  do
    cd ${auto}
    make distclean
    ./configure --prefix=${INSTALL}
    make all install
  done
}

# This handles GNU tools from CVS
update_others()
{
  for d in ${BINUTILSDIR} ${GDBDIR} ${NEWLIBDIR}
  do
    
    cd ${d} 
    if [ -d .svn ] ; then
      echo "I do not update SVN for ${d}"
      exit 1
   fi
   if [ -d CVS ] ; then
     cvs up -P 2>&1 | grep -v ^cvs
   fi
  done
}

do_cpus()
{
  bsp=

  exitStatus=0
  for cpu in $*
  do
    case $cpu in
      arm)     bsp=edb7312      ;;
      avr)     bsp=avrtest      ;;
      bfin)    bsp=eZKit533     ;;
      h8300)   bsp=h8sim        ;;
      i386)    bsp=pc386        ;;
      lm32)    bsp=lm32_evr     ;;
      m32c)    bsp=m32csim      ;;
      m32r)    bsp=m32rsim      ;;
      m68k)    bsp=uC5282       ;;
      mips)    bsp=jmr3904      ;;
      powerpc) bsp=psim         ;;
      sh)      bsp=simsh1       ;;
      sparc)   bsp=sis          ;;
      *)
	echo "Unknown CPU ${cpu}"
	exit 1
	;;
    esac

    doOne=${SCRIPTDIR}/gcc/do_one 
    time sh -x ${doOne} -v -b -D -1 -d -r ${adaArg} ${mailArg} ${testArg} \
        ${cpu} ${bsp} >${BASEDIR}/${bsp}.log 2>&1
    echo $?
  done

  stopped=`date`
  echo Started at: ${start}
  echo Stopped at: ${stopped}
}

update_gcc

if [ ${doCleanInstallPoint} = "yes" ] ; then
  # Clean the install point
  clean_up
fi

# Update gcc and install autotools in parallel
  if [ ${doCleanInstallPoint} = "yes" ] ; then
    install_auto
  fi
  if [ ${doUpdateTools} = "yes" ] ; then
    update_gcc
    update_others
  fi
wait

# Do any remaining prep work in parallel
  if [ ${doUpdateRTEMS} = "yes" ] ; then
    update_rtems
  fi
wait

if [ ${doNative} = "yes" ]; then
  # Build the native compiler as a baseline to build the others
  time sh -x ${SCRIPTDIR}/gcc/do_one -n >${BASEDIR}/native.log 2>&1
fi

# Now cycle over all these CPUs
if [ $? -eq 0 ] ; then
  if [ $# -eq 0 ] ; then
    # Requires Skyeye install
    do_cpus arm

    # no simulator -- waiting for Skyeye
    do_cpus bfin m68k

    # Simulators included in gdb
    do_cpus h8300 lm32 m32c m32r mips powerpc sh sparc

    # Requires qemu installation
    do_cpus i386 m68k


    # port insufficient to run gcc tests
    do_cpus avr
  else
    for cpu in ${CPUs}
    do
      do_cpus ${cpu}
    done
  fi
  
fi

stopped=`date`
echo Started at: ${start}
echo Stopped at: ${stopped}