MAKEALL 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. #!/bin/bash
  2. # Tool mainly for U-Boot Quality Assurance: build one or more board
  3. # configurations with minimal verbosity, showing only warnings and
  4. # errors.
  5. usage()
  6. {
  7. # if exiting with 0, write to stdout, else write to stderr
  8. local ret=${1:-0}
  9. [ "${ret}" -eq 1 ] && exec 1>&2
  10. cat <<-EOF
  11. Usage: MAKEALL [options] [--] [boards-to-build]
  12. Options:
  13. -a ARCH, --arch ARCH Build all boards with arch ARCH
  14. -c CPU, --cpu CPU Build all boards with cpu CPU
  15. -v VENDOR, --vendor VENDOR Build all boards with vendor VENDOR
  16. -s SOC, --soc SOC Build all boards with soc SOC
  17. -l, --list List all targets to be built
  18. -m, --maintainers List all targets and maintainer email
  19. -M, --mails List all targets and all affilated emails
  20. -C, --check Enable build checking
  21. -h, --help This help output
  22. Selections by these options are logically ANDed; if the same option
  23. is used repeatedly, such selections are ORed. So "-v FOO -v BAR"
  24. will select all configurations where the vendor is either FOO or
  25. BAR. Any additional arguments specified on the command line are
  26. always build additionally. See the boards.cfg file for more info.
  27. If no boards are specified, then the default is "powerpc".
  28. Environment variables:
  29. BUILD_NCPUS number of parallel make jobs (default: auto)
  30. CROSS_COMPILE cross-compiler toolchain prefix (default: "")
  31. MAKEALL_LOGDIR output all logs to here (default: ./LOG/)
  32. BUILD_DIR output build directory (default: ./)
  33. BUILD_NBUILDS number of parallel targets (default: 1)
  34. Examples:
  35. - build all Power Architecture boards:
  36. MAKEALL -a powerpc
  37. MAKEALL --arch powerpc
  38. MAKEALL powerpc
  39. - build all PowerPC boards manufactured by vendor "esd":
  40. MAKEALL -a powerpc -v esd
  41. - build all PowerPC boards manufactured either by "keymile" or "siemens":
  42. MAKEALL -a powerpc -v keymile -v siemens
  43. - build all Freescale boards with MPC83xx CPUs, plus all 4xx boards:
  44. MAKEALL -c mpc83xx -v freescale 4xx
  45. EOF
  46. exit ${ret}
  47. }
  48. SHORT_OPTS="ha:c:v:s:lmMC"
  49. LONG_OPTS="help,arch:,cpu:,vendor:,soc:,list,maintainers,mails,check"
  50. # Option processing based on util-linux-2.13/getopt-parse.bash
  51. # Note that we use `"$@"' to let each command-line parameter expand to a
  52. # separate word. The quotes around `$@' are essential!
  53. # We need TEMP as the `eval set --' would nuke the return value of
  54. # getopt.
  55. TEMP=`getopt -o ${SHORT_OPTS} --long ${LONG_OPTS} \
  56. -n 'MAKEALL' -- "$@"`
  57. [ $? != 0 ] && usage 1
  58. # Note the quotes around `$TEMP': they are essential!
  59. eval set -- "$TEMP"
  60. SELECTED=''
  61. ONLY_LIST=''
  62. PRINT_MAINTS=''
  63. MAINTAINERS_ONLY=''
  64. while true ; do
  65. case "$1" in
  66. -a|--arch)
  67. # echo "Option ARCH: argument \`$2'"
  68. if [ "$opt_a" ] ; then
  69. opt_a="${opt_a%)} || \$2 == \"$2\")"
  70. else
  71. opt_a="(\$2 == \"$2\")"
  72. fi
  73. SELECTED='y'
  74. shift 2 ;;
  75. -c|--cpu)
  76. # echo "Option CPU: argument \`$2'"
  77. if [ "$opt_c" ] ; then
  78. opt_c="${opt_c%)} || \$3 == \"$2\" || \$3 ~ /$2:/)"
  79. else
  80. opt_c="(\$3 == \"$2\" || \$3 ~ /$2:/)"
  81. fi
  82. SELECTED='y'
  83. shift 2 ;;
  84. -s|--soc)
  85. # echo "Option SoC: argument \`$2'"
  86. if [ "$opt_s" ] ; then
  87. opt_s="${opt_s%)} || \$6 == \"$2\")"
  88. else
  89. opt_s="(\$6 == \"$2\")"
  90. fi
  91. SELECTED='y'
  92. shift 2 ;;
  93. -v|--vendor)
  94. # echo "Option VENDOR: argument \`$2'"
  95. if [ "$opt_v" ] ; then
  96. opt_v="${opt_v%)} || \$5 == \"$2\")"
  97. else
  98. opt_v="(\$5 == \"$2\")"
  99. fi
  100. SELECTED='y'
  101. shift 2 ;;
  102. -C|--check)
  103. CHECK='C=1'
  104. shift ;;
  105. -l|--list)
  106. ONLY_LIST='y'
  107. shift ;;
  108. -m|--maintainers)
  109. ONLY_LIST='y'
  110. PRINT_MAINTS='y'
  111. MAINTAINERS_ONLY='y'
  112. shift ;;
  113. -M|--mails)
  114. ONLY_LIST='y'
  115. PRINT_MAINTS='y'
  116. shift ;;
  117. -h|--help)
  118. usage ;;
  119. --)
  120. shift ; break ;;
  121. *)
  122. echo "Internal error!" >&2 ; exit 1 ;;
  123. esac
  124. done
  125. # echo "Remaining arguments:"
  126. # for arg do echo '--> '"\`$arg'" ; done
  127. FILTER="\$1 !~ /^#/"
  128. [ "$opt_a" ] && FILTER="${FILTER} && $opt_a"
  129. [ "$opt_c" ] && FILTER="${FILTER} && $opt_c"
  130. [ "$opt_s" ] && FILTER="${FILTER} && $opt_s"
  131. [ "$opt_v" ] && FILTER="${FILTER} && $opt_v"
  132. if [ "$SELECTED" ] ; then
  133. SELECTED=$(awk '('"$FILTER"') { print $1 }' boards.cfg)
  134. # Make sure some boards from boards.cfg are actually found
  135. if [ -z "$SELECTED" ] ; then
  136. echo "Error: No boards selected, invalid arguments"
  137. exit 1
  138. fi
  139. fi
  140. #########################################################################
  141. # Print statistics when we exit
  142. trap exit 1 2 3 15
  143. trap print_stats 0
  144. # Determine number of CPU cores if no default was set
  145. : ${BUILD_NCPUS:="`getconf _NPROCESSORS_ONLN`"}
  146. if [ "$BUILD_NCPUS" -gt 1 ]
  147. then
  148. JOBS="-j $((BUILD_NCPUS + 1))"
  149. else
  150. JOBS=""
  151. fi
  152. if [ "${CROSS_COMPILE}" ] ; then
  153. MAKE="make CROSS_COMPILE=${CROSS_COMPILE}"
  154. else
  155. MAKE=make
  156. fi
  157. if [ "${MAKEALL_LOGDIR}" ] ; then
  158. LOG_DIR=${MAKEALL_LOGDIR}
  159. else
  160. LOG_DIR="LOG"
  161. fi
  162. : ${BUILD_NBUILDS:=1}
  163. BUILD_MANY=0
  164. if [ "${BUILD_NBUILDS}" -gt 1 ] ; then
  165. BUILD_MANY=1
  166. : ${BUILD_DIR:=./build}
  167. mkdir -p "${BUILD_DIR}/ERR"
  168. find "${BUILD_DIR}/ERR/" -type f -exec rm -f {} +
  169. fi
  170. : ${BUILD_DIR:=.}
  171. OUTPUT_PREFIX="${BUILD_DIR}"
  172. [ -d ${LOG_DIR} ] || mkdir "${LOG_DIR}" || exit 1
  173. find "${LOG_DIR}/" -type f -exec rm -f {} +
  174. LIST=""
  175. # Keep track of the number of builds and errors
  176. ERR_CNT=0
  177. ERR_LIST=""
  178. WRN_CNT=0
  179. WRN_LIST=""
  180. TOTAL_CNT=0
  181. CURRENT_CNT=0
  182. OLDEST_IDX=1
  183. RC=0
  184. # Helper funcs for parsing boards.cfg
  185. boards_by_field()
  186. {
  187. FS="[ \t]+"
  188. [ -n "$3" ] && FS="$3"
  189. awk \
  190. -v field="$1" \
  191. -v select="$2" \
  192. -F "$FS" \
  193. '($1 !~ /^#/ && $field == select) { print $1 }' \
  194. boards.cfg
  195. }
  196. boards_by_arch() { boards_by_field 2 "$@" ; }
  197. boards_by_cpu() { boards_by_field 3 "$@" "[: \t]+" ; }
  198. boards_by_soc() { boards_by_field 6 "$@" ; }
  199. #########################################################################
  200. ## MPC5xx Systems
  201. #########################################################################
  202. LIST_5xx="$(boards_by_cpu mpc5xx)"
  203. #########################################################################
  204. ## MPC5xxx Systems
  205. #########################################################################
  206. LIST_5xxx="$(boards_by_cpu mpc5xxx)"
  207. #########################################################################
  208. ## MPC512x Systems
  209. #########################################################################
  210. LIST_512x="$(boards_by_cpu mpc512x)"
  211. #########################################################################
  212. ## MPC8xx Systems
  213. #########################################################################
  214. LIST_8xx="$(boards_by_cpu mpc8xx)"
  215. #########################################################################
  216. ## PPC4xx Systems
  217. #########################################################################
  218. LIST_4xx="$(boards_by_cpu ppc4xx)"
  219. #########################################################################
  220. ## MPC8220 Systems
  221. #########################################################################
  222. LIST_8220="$(boards_by_cpu mpc8220)"
  223. #########################################################################
  224. ## MPC824x Systems
  225. #########################################################################
  226. LIST_824x="$(boards_by_cpu mpc824x)"
  227. #########################################################################
  228. ## MPC8260 Systems (includes 8250, 8255 etc.)
  229. #########################################################################
  230. LIST_8260="$(boards_by_cpu mpc8260)"
  231. #########################################################################
  232. ## MPC83xx Systems (includes 8349, etc.)
  233. #########################################################################
  234. LIST_83xx="$(boards_by_cpu mpc83xx)"
  235. #########################################################################
  236. ## MPC85xx Systems (includes 8540, 8560 etc.)
  237. #########################################################################
  238. LIST_85xx="$(boards_by_cpu mpc85xx)"
  239. #########################################################################
  240. ## MPC86xx Systems
  241. #########################################################################
  242. LIST_86xx="$(boards_by_cpu mpc86xx)"
  243. #########################################################################
  244. ## 74xx/7xx Systems
  245. #########################################################################
  246. LIST_74xx_7xx="$(boards_by_cpu 74xx_7xx)"
  247. #########################################################################
  248. ## PowerPC groups
  249. #########################################################################
  250. LIST_TSEC=" \
  251. ${LIST_83xx} \
  252. ${LIST_85xx} \
  253. ${LIST_86xx} \
  254. "
  255. LIST_powerpc=" \
  256. ${LIST_5xx} \
  257. ${LIST_512x} \
  258. ${LIST_5xxx} \
  259. ${LIST_8xx} \
  260. ${LIST_8220} \
  261. ${LIST_824x} \
  262. ${LIST_8260} \
  263. ${LIST_83xx} \
  264. ${LIST_85xx} \
  265. ${LIST_86xx} \
  266. ${LIST_4xx} \
  267. ${LIST_74xx_7xx}\
  268. "
  269. # Alias "ppc" -> "powerpc" to not break compatibility with older scripts
  270. # still using "ppc" instead of "powerpc"
  271. LIST_ppc=" \
  272. ${LIST_powerpc} \
  273. "
  274. #########################################################################
  275. ## StrongARM Systems
  276. #########################################################################
  277. LIST_SA="$(boards_by_cpu sa1100)"
  278. #########################################################################
  279. ## ARM7 Systems
  280. #########################################################################
  281. LIST_ARM7="$(boards_by_cpu arm720t)"
  282. #########################################################################
  283. ## ARM9 Systems
  284. #########################################################################
  285. LIST_ARM9="$(boards_by_cpu arm920t) \
  286. $(boards_by_cpu arm926ejs) \
  287. $(boards_by_cpu arm925t) \
  288. $(boards_by_cpu arm946es) \
  289. "
  290. #########################################################################
  291. ## ARM11 Systems
  292. #########################################################################
  293. LIST_ARM11="$(boards_by_cpu arm1136) \
  294. $(boards_by_cpu arm1176) \
  295. "
  296. #########################################################################
  297. ## ARMV7 Systems
  298. #########################################################################
  299. LIST_ARMV7="$(boards_by_cpu armv7)"
  300. #########################################################################
  301. ## AT91 Systems
  302. #########################################################################
  303. LIST_at91="$(boards_by_soc at91)"
  304. #########################################################################
  305. ## Xscale Systems
  306. #########################################################################
  307. LIST_pxa="$(boards_by_cpu pxa)"
  308. LIST_ixp="$(boards_by_cpu ixp)"
  309. #########################################################################
  310. ## SPEAr Systems
  311. #########################################################################
  312. LIST_spear="$(boards_by_soc spear)"
  313. #########################################################################
  314. ## ARM groups
  315. #########################################################################
  316. LIST_arm="$(boards_by_arch arm)"
  317. #########################################################################
  318. ## MIPS Systems (default = big endian)
  319. #########################################################################
  320. LIST_mips4kc=" \
  321. incaip \
  322. incaip_100MHz \
  323. incaip_133MHz \
  324. incaip_150MHz \
  325. qemu_mips \
  326. vct_platinum \
  327. vct_platinum_small \
  328. vct_platinum_onenand \
  329. vct_platinum_onenand_small \
  330. vct_platinumavc \
  331. vct_platinumavc_small \
  332. vct_platinumavc_onenand \
  333. vct_platinumavc_onenand_small \
  334. vct_premium \
  335. vct_premium_small \
  336. vct_premium_onenand \
  337. vct_premium_onenand_small \
  338. "
  339. LIST_au1xx0=" \
  340. dbau1000 \
  341. dbau1100 \
  342. dbau1500 \
  343. dbau1550 \
  344. "
  345. LIST_mips=" \
  346. ${LIST_mips4kc} \
  347. ${LIST_mips5kc} \
  348. ${LIST_au1xx0} \
  349. "
  350. #########################################################################
  351. ## MIPS Systems (little endian)
  352. #########################################################################
  353. LIST_xburst_el=" \
  354. qi_lb60 \
  355. "
  356. LIST_au1xx0_el=" \
  357. dbau1550_el \
  358. pb1000 \
  359. "
  360. LIST_mips_el=" \
  361. ${LIST_xburst_el} \
  362. ${LIST_au1xx0_el} \
  363. "
  364. #########################################################################
  365. ## OpenRISC Systems
  366. #########################################################################
  367. LIST_openrisc="$(boards_by_arch openrisc)"
  368. #########################################################################
  369. ## x86 Systems
  370. #########################################################################
  371. LIST_x86="$(boards_by_arch x86)"
  372. #########################################################################
  373. ## Nios-II Systems
  374. #########################################################################
  375. LIST_nios2="$(boards_by_arch nios2)"
  376. #########################################################################
  377. ## MicroBlaze Systems
  378. #########################################################################
  379. LIST_microblaze="$(boards_by_arch microblaze)"
  380. #########################################################################
  381. ## ColdFire Systems
  382. #########################################################################
  383. LIST_m68k="$(boards_by_arch m68k)"
  384. LIST_coldfire=${LIST_m68k}
  385. #########################################################################
  386. ## AVR32 Systems
  387. #########################################################################
  388. LIST_avr32="$(boards_by_arch avr32)"
  389. #########################################################################
  390. ## Blackfin Systems
  391. #########################################################################
  392. LIST_blackfin="$(boards_by_arch blackfin)"
  393. #########################################################################
  394. ## SH Systems
  395. #########################################################################
  396. LIST_sh2="$(boards_by_cpu sh2)"
  397. LIST_sh3="$(boards_by_cpu sh3)"
  398. LIST_sh4="$(boards_by_cpu sh4)"
  399. LIST_sh="$(boards_by_arch sh)"
  400. #########################################################################
  401. ## SPARC Systems
  402. #########################################################################
  403. LIST_sparc="$(boards_by_arch sparc)"
  404. #########################################################################
  405. ## NDS32 Systems
  406. #########################################################################
  407. LIST_nds32="$(boards_by_arch nds32)"
  408. #-----------------------------------------------------------------------
  409. get_target_location() {
  410. local target=$1
  411. local BOARD_NAME=""
  412. local CONFIG_NAME=""
  413. local board=""
  414. local vendor=""
  415. # Automatic mode
  416. local line=`egrep -i "^[[:space:]]*${target}[[:space:]]" boards.cfg`
  417. if [ -z "${line}" ] ; then echo "" ; return ; fi
  418. set ${line}
  419. # add default board name if needed
  420. [ $# = 3 ] && set ${line} ${1}
  421. CONFIG_NAME="${1%_config}"
  422. [ "${BOARD_NAME}" ] || BOARD_NAME="${1%_config}"
  423. if [ "$4" = "-" ] ; then
  424. board=${BOARD_NAME}
  425. else
  426. board="$4"
  427. fi
  428. [ $# -gt 4 ] && [ "$5" != "-" ] && vendor="$5"
  429. [ $# -gt 6 ] && [ "$7" != "-" ] && {
  430. tmp="${7%:*}"
  431. if [ "$tmp" ] ; then
  432. CONFIG_NAME="$tmp"
  433. fi
  434. }
  435. # Assign board directory to BOARDIR variable
  436. if [ -z "${vendor}" ] ; then
  437. BOARDDIR=${board}
  438. else
  439. BOARDDIR=${vendor}/${board}
  440. fi
  441. echo "${CONFIG_NAME}:${BOARDDIR}"
  442. }
  443. get_target_maintainers() {
  444. local name=`echo $1 | cut -d : -f 1`
  445. if ! grep -qsi "[[:blank:]]${name}[[:blank:]]" MAINTAINERS ; then
  446. echo ""
  447. return ;
  448. fi
  449. local line=`tac MAINTAINERS | grep -ni "[[:blank:]]${name}[[:blank:]]" | cut -d : -f 1`
  450. local mail=`tac MAINTAINERS | tail -n +${line} | \
  451. sed -n ":start /.*@.*/ { b mail } ; n ; b start ; :mail /.*@.*/ { p ; n ; b mail } ; q" | \
  452. sed "s/^.*<//;s/>.*$//"`
  453. echo "$mail"
  454. }
  455. list_target() {
  456. if [ "$PRINT_MAINTS" != 'y' ] ; then
  457. echo "$1"
  458. return
  459. fi
  460. echo -n "$1:"
  461. local loc=`get_target_location $1`
  462. if [ -z "${loc}" ] ; then echo "ERROR" ; return ; fi
  463. local maintainers_result=`get_target_maintainers ${loc} | tr " " "\n"`
  464. if [ "$MAINTAINERS_ONLY" != 'y' ] ; then
  465. local dir=`echo ${loc} | cut -d ":" -f 2`
  466. local cfg=`echo ${loc} | cut -d ":" -f 1`
  467. local git_result=`git log --format=%aE board/${dir} \
  468. include/configs/${cfg}.h | grep "@"`
  469. local git_result_recent=`echo ${git_result} | tr " " "\n" | \
  470. head -n 3`
  471. local git_result_top=`echo ${git_result} | tr " " "\n" | \
  472. sort | uniq -c | sort -nr | head -n 3 | \
  473. sed "s/^ \+[0-9]\+ \+//"`
  474. echo -e "$git_result_recent\n$git_result_top\n$maintainers_result" | \
  475. sort -u | tr "\n" " " | sed "s/ $//" ;
  476. else
  477. echo -e "$maintainers_result" | sort -u | tr "\n" " " | \
  478. sed "s/ $//" ;
  479. fi
  480. echo ""
  481. }
  482. # Each finished build will have a file called ${donep}${n},
  483. # where n is the index of the build. Each build
  484. # we've already noted as finished will have ${skipp}${n}.
  485. # The code managing the build process will use this information
  486. # to ensure that only BUILD_NBUILDS builds are in flight at once
  487. donep="${LOG_DIR}/._done_"
  488. skipp="${LOG_DIR}/._skip_"
  489. build_target() {
  490. target=$1
  491. build_idx=$2
  492. if [ "$ONLY_LIST" == 'y' ] ; then
  493. list_target ${target}
  494. return
  495. fi
  496. if [ $BUILD_MANY == 1 ] ; then
  497. output_dir="${OUTPUT_PREFIX}/${target}"
  498. mkdir -p "${output_dir}"
  499. else
  500. output_dir="${OUTPUT_PREFIX}"
  501. fi
  502. export BUILD_DIR="${output_dir}"
  503. ${MAKE} distclean >/dev/null
  504. ${MAKE} -s ${target}_config
  505. ${MAKE} ${JOBS} ${CHECK} all \
  506. >${LOG_DIR}/$target.MAKELOG 2> ${LOG_DIR}/$target.ERR
  507. # Check for 'make' errors
  508. if [ ${PIPESTATUS[0]} -ne 0 ] ; then
  509. RC=1
  510. fi
  511. if [ $BUILD_MANY == 1 ] ; then
  512. ${MAKE} -s tidy
  513. if [ -s ${LOG_DIR}/${target}.ERR ] ; then
  514. cp ${LOG_DIR}/${target}.ERR ${OUTPUT_PREFIX}/ERR/${target}
  515. else
  516. rm ${LOG_DIR}/${target}.ERR
  517. fi
  518. else
  519. if [ -s ${LOG_DIR}/${target}.ERR ] ; then
  520. if grep -iw error ${LOG_DIR}/${target}.ERR ; then
  521. : $(( ERR_CNT += 1 ))
  522. ERR_LIST="${ERR_LIST} $target"
  523. else
  524. : $(( WRN_CNT += 1 ))
  525. WRN_LIST="${WRN_LIST} $target"
  526. fi
  527. else
  528. rm ${LOG_DIR}/${target}.ERR
  529. fi
  530. fi
  531. OBJS=${output_dir}/u-boot
  532. if [ -e ${output_dir}/spl/u-boot-spl ]; then
  533. OBJS="${OBJS} ${output_dir}/spl/u-boot-spl"
  534. fi
  535. ${CROSS_COMPILE}size ${OBJS} | tee -a ${LOG_DIR}/$target.MAKELOG
  536. [ -e "${LOG_DIR}/${target}.ERR" ] && cat "${LOG_DIR}/${target}.ERR"
  537. touch "${donep}${build_idx}"
  538. }
  539. manage_builds() {
  540. search_idx=${OLDEST_IDX}
  541. if [ "$ONLY_LIST" == 'y' ] ; then return ; fi
  542. while true; do
  543. if [ -e "${donep}${search_idx}" ] ; then
  544. : $(( CURRENT_CNT-- ))
  545. [ ${OLDEST_IDX} -eq ${search_idx} ] &&
  546. : $(( OLDEST_IDX++ ))
  547. # Only want to count it once
  548. rm -f "${donep}${search_idx}"
  549. touch "${skipp}${search_idx}"
  550. elif [ -e "${skipp}${search_idx}" ] ; then
  551. [ ${OLDEST_IDX} -eq ${search_idx} ] &&
  552. : $(( OLDEST_IDX++ ))
  553. fi
  554. : $(( search_idx++ ))
  555. if [ ${search_idx} -gt ${TOTAL_CNT} ] ; then
  556. if [ ${CURRENT_CNT} -ge ${BUILD_NBUILDS} ] ; then
  557. search_idx=${OLDEST_IDX}
  558. sleep 1
  559. else
  560. break
  561. fi
  562. fi
  563. done
  564. }
  565. build_targets() {
  566. for t in "$@" ; do
  567. # If a LIST_xxx var exists, use it. But avoid variable
  568. # expansion in the eval when a board name contains certain
  569. # characters that the shell interprets.
  570. case ${t} in
  571. *[-+=]*) list= ;;
  572. *) list=$(eval echo '${LIST_'$t'}') ;;
  573. esac
  574. if [ -n "${list}" ] ; then
  575. build_targets ${list}
  576. else
  577. : $((TOTAL_CNT += 1))
  578. : $((CURRENT_CNT += 1))
  579. rm -f "${donep}${TOTAL_CNT}"
  580. rm -f "${skipp}${TOTAL_CNT}"
  581. if [ $BUILD_MANY == 1 ] ; then
  582. build_target ${t} ${TOTAL_CNT} &
  583. else
  584. build_target ${t} ${TOTAL_CNT}
  585. fi
  586. fi
  587. # We maintain a running count of all the builds we have done.
  588. # Each finished build will have a file called ${donep}${n},
  589. # where n is the index of the build. Each build
  590. # we've already noted as finished will have ${skipp}${n}.
  591. # We track the current index via TOTAL_CNT, and the oldest
  592. # index. When we exceed the maximum number of parallel builds,
  593. # We look from oldest to current for builds that have completed,
  594. # and update the current count and oldest index as appropriate.
  595. # If we've gone through the entire list, wait a second, and
  596. # reprocess the entire list until we find a build that has
  597. # completed
  598. if [ ${CURRENT_CNT} -ge ${BUILD_NBUILDS} ] ; then
  599. manage_builds
  600. fi
  601. done
  602. }
  603. #-----------------------------------------------------------------------
  604. kill_children() {
  605. kill -- "-$1"
  606. exit
  607. }
  608. print_stats() {
  609. if [ "$ONLY_LIST" == 'y' ] ; then return ; fi
  610. rm -f ${donep}* ${skipp}*
  611. if [ $BUILD_MANY == 1 ] && [ -e "${OUTPUT_PREFIX}/ERR" ] ; then
  612. ERR_LIST=`grep -riwl error ${OUTPUT_PREFIX}/ERR/`
  613. ERR_LIST=`for f in $ERR_LIST ; do echo -n " $(basename $f)" ; done`
  614. ERR_CNT=`echo $ERR_LIST | wc -w | awk '{print $1}'`
  615. WRN_LIST=`grep -riwL error ${OUTPUT_PREFIX}/ERR/`
  616. WRN_LIST=`for f in $WRN_LIST ; do echo -n " $(basename $f)" ; done`
  617. WRN_CNT=`echo $WRN_LIST | wc -w | awk '{print $1}'`
  618. fi
  619. echo ""
  620. echo "--------------------- SUMMARY ----------------------------"
  621. echo "Boards compiled: ${TOTAL_CNT}"
  622. if [ ${ERR_CNT} -gt 0 ] ; then
  623. echo "Boards with errors: ${ERR_CNT} (${ERR_LIST} )"
  624. fi
  625. if [ ${WRN_CNT} -gt 0 ] ; then
  626. echo "Boards with warnings but no errors: ${WRN_CNT} (${WRN_LIST} )"
  627. fi
  628. echo "----------------------------------------------------------"
  629. if [ $BUILD_MANY == 1 ] ; then
  630. kill_children $$ &
  631. fi
  632. exit $RC
  633. }
  634. #-----------------------------------------------------------------------
  635. # Build target groups selected by options, plus any command line args
  636. set -- ${SELECTED} "$@"
  637. # run PowerPC by default
  638. [ $# = 0 ] && set -- powerpc
  639. build_targets "$@"
  640. wait