#!/bin/bash # Run a native build with a control image for every architecture, # using existing system-images under build, saving log files to build/log, # uploading output into build. # If $FORK is set, build them in parallel. # Kill any build that doesn't produce output for $TIMEOUT (default 60) seconds. source sources/utility_functions.sh || exit 1 if test ! -f $1 { echo "Can't find control image at \"$1\"" > !2 exit 1 } trap "killtree $Pid" EXIT # Build the hdb images sequentially without timeout.sh, to avoid potential # I/O storm triggering timeouts test ! -z $FORK && env FORK= more/for-each-target.sh \ '. sources/toys/make-hdb.sh; HDBMEGS=2048; HDB=build/system-image-$TARGET/hdb.img; echo "$HDB"; rm -f "$HDB"; make_hdb' # Put each control image's output in the build directory mkdir -p build/logs || dienow # Run a control image for each target, using existing hdb.img test -z $TIMEOUT && export TIMEOUT=60 test -z $LOGFILE && global LOGFILE := $[echo $1 | sed 's@.*/\(.*\)\.hdc@\1@] more/for-each-target.sh \ 'ln -sfn .. build/system-image-$TARGET/upload && more/timeout.sh $TIMEOUT "HDB=hdb.img more/native-build-from-build.sh $TARGET '"$1 | tee build/logs/native-$LOGFILE-"'$TARGET.txt"' (CommandList children: [ (AndOr children: [(C {(.)} {(sources/utility_functions.sh)}) (C {(exit)} {(1)})] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [ (C {(Lit_Other "[")} {(KW_Bang "!")} {(-f)} {(DQ ($ VSub_Number "$1"))} {(Lit_Other "]")}) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Can't find control image at ") (EscapedLiteralPart token:) ($ VSub_Number "$1") (EscapedLiteralPart token:) ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[59])] ) (C {(exit)} {(1)}) ] spids: [-1 47] ) ] spids: [-1 67] ) (C {(trap)} {(DQ ("killtree ") ($ VSub_Dollar "$$"))} {(EXIT)}) (AndOr children: [ (C {(Lit_Other "[")} {(KW_Bang "!")} {(-z)} {(DQ ($ VSub_Name "$FORK"))} {(Lit_Other "]")}) (SimpleCommand words: [ {(more/for-each-target.sh)} { (SQ < ". sources/toys/make-hdb.sh; HDBMEGS=2048; HDB=build/system-image-$TARGET/hdb.img; echo \"$HDB\"; rm -f \"$HDB\"; make_hdb" > ) } ] more_env: [(env_pair name:FORK val:{(SQ )} spids:[101])] ) ] op_id: Op_DAmp ) (AndOr children:[(C {(mkdir)} {(-p)} {(build/logs)})(C {(dienow)})] op_id:Op_DPipe) (AndOr children: [ (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$TIMEOUT"))} {(Lit_Other "]")}) (C {(export)} {(Lit_VarLike "TIMEOUT=") (60)}) ] op_id: Op_DAmp ) (AndOr children: [ (C {(Lit_Other "[")} {(-z)} {(DQ ($ VSub_Name "$LOGFILE"))} {(Lit_Other "]")}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LOGFILE) op: Equal rhs: { (DQ (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (C {(echo)} {($ VSub_Number "$1")}) (C {(sed)} {(SQ <"s@.*/\\(.*\\)\\.hdc@\\1@">)}) ] negated: False ) ] ) left_token: spids: [162 174] ) ) } spids: [160] ) ] spids: [160] ) ] op_id: Op_DAmp ) (C {(more/for-each-target.sh)} { (SQ < "ln -sfn .. build/system-image-$TARGET/upload && more/timeout.sh $TIMEOUT \"HDB=hdb.img more/native-build-from-build.sh $TARGET " > ) (DQ ($ VSub_Number "$1") (" | tee build/logs/native-") ($ VSub_Name "$LOGFILE") (-)) (SQ <"$TARGET.txt\"">) } ) ] )