MAKEALL 20 KB

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