2 ############################################################
3 # source: worklist.shlib
4 # author: devenkong(18151155@qq.com)
6 ############################################################
7 # Copyright (C) 2022- Free Software Foundation, Inc.
8 # This configure script is free software; the Free Software
9 # Foundation gives unlimited permission to copy, distribute
11 ############################################################
13 # this file is the supporting libarary for bulid-step.
15 ############################################################
20 # @ modify prefix CATA_ID_ to <XXX>_CID_, and change code in relative
21 # functions. use create catalog id function to create/release a catalog
22 # id. so, thare are more then one catalog id can work in a time.
33 ##############################
34 # section: public comment info
35 ##############################
39 ##############################
40 # section: variable define
41 ##############################
44 shlib_worklist_init
()
52 # global variable init function invoking.
53 # invoke GVAR_INIT if it is running at first time.
58 ##############################
59 # section: private function
60 ##############################
68 # fsyntax: cmpl_dbgout <srcfile> <dstfile>
69 # fdesc: display compile info.
73 infoo
" [CC] $1 => $(basename ${1%.*}.o)"
77 # fsyntax: link_dbgout <srcfile> <dstfile>
78 # fdesc: display link info.
82 local DST_FILE
="${OUTDIR}/${!2}"
83 local SRC_FILE
=( $OBJ_LIST )
86 if test "$((${#SRC_FILE[@]} + ${#STATIC_LIB_LIST_Y[@]}))" -gt 10 ; then
87 infoo
" [LINK] ${SRC_FILE[0]} ... ${SRC_FILE[$((${#SRC_FILE[@]}-1))]}"
89 tmp
="${SRC_FILE[@]} ${STATIC_LIB_LIST_Y[@]}"
92 tmp
="$(echo ${tmp} | sed -e 's/[[:space:]]+/ /g')"
93 infoo
" [LINK] ${tmp//\ /$'\n '}"
96 if test "${DEST_TYPE,,}" == 'libdll' ; then
97 infoo
" [LINK] => $(basename ${DST_FILE%\.*}).a"
98 infoo
" [LINK] => $(basename ${DST_FILE%\.*}).so"
100 infoo
" [LINK] => $(basename ${DST_FILE})"
105 # fsyntax: src2exe_dbgout <srcfile> <dstfile>
106 # fdesc: display compile info.
110 infoo
" [EXE] $1 => $(basename ${1%%.*})"
125 # fsyntax: taskinfo_dbgout <output-string>
126 # fdesc: output string by dbgout switch.
130 if [[ ! "${dbgout_opt}" =~ taskinfo
]]; then
135 echo -ne "$@" >> ${OUTDIR}/buildinfo.log
140 # fsyntax: taskfunc_dbgout <output-string>
141 # fdesc: task func info.
148 if [[ ! "${dbgout_switch}" =~ taskfunc
]]; then
152 for ((i
=0; i
<$task_level; i
++)); do
157 echo -ne "${pfx}>$@" >> ${OUTDIR}/buildstep.log
158 [[ "${dbgout_switch}" =~ taskinfo ]] && echo -ne "${pfx}>$@" >> ${OUTDIR}/buildinfo.log
163 # fsyntax: taskstep_dbgout <output-string>
164 # fdesc: used for task info output, and it can be setted in
165 # build_step_dbgout_list.
173 if [[ ! "${dbgout_switch}" =~ taskstep ]]; then
177 [[ -z $1 ]] && err "taskstep_dbgout
() invoked without parameter.
" && return
178 # step info filter by env.
179 if [[ -n $build_step_dbgout_list && ! "${build_step_dbgout_list}" =~ "$1" ]]; then
182 if [[ -n $build_step_dbgout_dis_list && "${build_step_dbgout_dis_list}" =~ "$1" ]]; then
187 [[ -z $1 ]] && err "taskstep_dbgout
() invoked without parameter.
" && return
189 for ((i=0; i<$task_level; i++)); do
194 echo -ne "${pfx}>$@
" >> ${OUTDIR}/buildstep.log
195 [[ "${dbgout_switch}" =~ taskinfo ]] && echo -ne "${pfx}>$@" >> ${OUTDIR}/buildinfo.log
200 # fsyntax: tasklist_dbgout <output-string>
201 # fdesc: used for tasklist info output.
208 if [[ ! "${dbgout_switch}" =~ tasklist
]]; then
212 for ((i
=0; i
<$task_level; i
++)); do
217 echo -ne "${pfx}>$@" >> ${OUTDIR}/buildstep.log
218 [[ "${dbgout_switch}" =~ taskinfo ]] && echo -ne "${pfx}>$@" >> ${OUTDIR}/buildinfo.log
223 # fsyntax: buildstep_dbgout <output-string>
224 # fdesc: used in build step func.
231 if [[ ! "${dbgout_switch}" =~ buildstep ]]; then
235 for ((i=0; i<$task_level; i++)); do
240 echo -ne "${pfx}>$@
" >> ${OUTDIR}/buildstep.log
241 [[ "${dbgout_switch}" =~ taskinfo ]] && echo -ne "${pfx}>$@" >> ${OUTDIR}/buildinfo.log
246 # fsyntax: info_dbgout_init <output-string>
247 # fdesc: init debug out info.
252 # echo "info_dbgout_init()"
253 [[ -z ${OUTDIR} ]] && err
"\${OUTDIR} is NULL string.\n" && return
256 # echo \${OUTDIR}=${OUTDIR}
259 if [[ "${dbgout_switch}" =~ buildstep|taskstep
]]; then
260 echo > ${OUTDIR}/buildstep.log
263 if [[ "${dbgout_switch}" =~ taskinfo
]]; then
264 echo > ${OUTDIR}/buildinfo.log
267 if [[ "${dbgout_switch}" =~ buildparam
]]; then
268 echo > ${OUTDIR}/buildparam.log
274 ##############################
275 # section: public function
276 ##############################
278 #############################################################################
281 # @ desttpchk(): dest & src tp chk.
282 # @ step_lang_src_tpchk(): lang src tp chk.
283 # @ tpchk(): src & obj tp chk, and hdr tp chk.
285 ############################################################################
288 # fsyntax: srcdesttpchk
289 # fdesc: load src-list file.
300 # skip condition for .o file checking changing.
301 dstfile
="${OUTDIR}/$(basename ${1%\.*})"
302 if test -f "${dstfile}" ; then
304 [[ ${OUTDIR}/${DEST_CFG_DIR_NAME}/$srcfile -nt $dstfile ]] && return 0
309 # skip condition for .a file checking changing.
310 for param
in $LDFLAGS; do
311 if [[ $param =~ ^
-l(.
*) ]]; then
312 srcfile
="${OUTDIR}/lib${BASH_REMATCH[1]}.a"
313 if test -f "$srcfile" ; then
314 [[ $srcfile -nt $dstfile ]] && return 0
317 if [[ $param =~ ^
-L(.
*) ]]; then
318 libdir
+=( "${BASH_REMATCH[1]}" )
322 # skip condition for .a file checking changing.
324 for srcfile
in $STATIC_LIB_LIST_Y; do
326 if test -f $srcfile ; then
327 [[ $srcfile -nt $dstfile ]] && ret
=0 && filelist
+="$srcfile "
328 elif test -f "${OUTDIR}/${srcfile}" ; then
329 srcfile
="${OUTDIR}/${srcfile}"
330 [[ $srcfile -nt $dstfile ]] && ret
=0 && filelist
+="$srcfile "
332 for param
in ${libdir[@]}; do
333 if test -f $srcfile ; then
334 [[ $srcfile -nt $dstfile ]] && ret
=0
335 # echo srcfile=$srcfile
336 # echo dstfile=$dstfile
337 filelist
+="$srcfile "
342 [[ $flag != 1 ]] && warn
"static lib file '$srcfile' is not in specified lib path.\n"
346 STATIC_LIB_LIST_Y
="$filelist"
347 if test $ret == 0 ; then
350 infoo
"dest file ($dstfile) is existing, skip linking."
357 # fdesc: load src-list file.
368 # skip condition for .o file checking changing.
369 dstfile
="${OUTDIR}/${!2}"
370 if test -f "${dstfile}" ; then
371 for srcfile
in ${!1}; do
372 [[ ${OUTDIR}/${DEST_CFG_DIR_NAME}/$srcfile -nt $dstfile ]] && return 0
378 # skip condition for .a file checking changing.
379 for param
in $LDFLAGS; do
380 if [[ $param =~ ^
-l(.
*) ]]; then
381 srcfile
="${OUTDIR}/lib${BASH_REMATCH[1]}.a"
382 if test -f "$srcfile" ; then
383 [[ $srcfile -nt $dstfile ]] && return 0
386 if [[ $param =~ ^
-L(.
*) ]]; then
387 libdir
+=( "${BASH_REMATCH[1]}" )
391 # skip condition for .a file checking changing.
393 for srcfile
in $STATIC_LIB_LIST_Y; do
395 if test -f $srcfile ; then
396 [[ $srcfile -nt $dstfile ]] && ret
=0 && filelist
+="$srcfile "
397 elif test -f "${OUTDIR}/${srcfile}" ; then
398 srcfile
="${OUTDIR}/${srcfile}"
399 [[ $srcfile -nt $dstfile ]] && ret
=0 && filelist
+="$srcfile "
401 for param
in ${libdir[@]}; do
402 if test -f $srcfile ; then
403 [[ $srcfile -nt $dstfile ]] && ret
=0
404 # echo srcfile=$srcfile
405 # echo dstfile=$dstfile
406 filelist
+="$srcfile "
411 [[ $flag != 1 ]] && warn
"static lib file '$srcfile' is not in specified lib path.\n"
415 STATIC_LIB_LIST_Y
="$filelist"
416 if test $ret == 0 ; then
419 infoo
"dest file ($dstfile) is existing, skip linking."
425 # fsyntax: src_hdr_tpchk <dstfile>
426 # fdesc: chk tp between srcfile and hdrfile.
431 local extname
="${LANG_EXT_NAME[${1,,}]}"
433 local deplistfile
="${objfile//\.o/.dep}"
435 buildstep_dbgout
"src_hdr_tpchk ($@) $deplistfile\n"
437 [[ ! -f $deplistfile ]] && return 0
440 [[ ! -n "$line" ]] && continue
442 [[ ! -e $line ]] && warn
"hdr file ($line) in $deplistfile file does not exist." && return 2
444 if test ${line:0:1} == '/' ; then
445 SYS_INC_LIST
+="$line"$
'\n'
446 [[ $line -nt $1 ]] && echo "sys in file $line is modified." && return 0
448 APP_INC_LIST
+="$line"$
'\n'
450 # hdr file newer then src file,
451 # src file to be recompiled.
453 [[ $line -nt $objfile ]] && echo "file $line is modified." && return 0
455 done < <(cat ${deplistfile} |
grep -v "[\\]$" |
tr -s ' ' $
'\n')
461 # fsyntax: tpchk <srcfile> <dstfile>
462 # fdesc: chk tp between src-file and dest-file, it also chk tp
471 file="${srcfile%%\,*}"
473 destfile
="${OBJDIR}/${file}${EXT_NAME[obj]}"
475 [[ ! -f ${destfile} ]] && return 0
476 for file in ${srcfile//\,/ }; do
477 [[ ${file} -nt ${destfile} ]] && echo recompile
$srcfile && return 0
480 src_hdr_tpchk
"${destfile}"
481 [[ $?
== 0 ]] && return 0;
488 # fsyntax: step_lang_src_tpchk <langlist-var> [<parameter-list> ... ]
489 # fdesc: chk tp between srcfile and dstfile(obj).
491 step_lang_src_tpchk
()
497 local SRC_LIST_N2B_CMPL
=
498 local langlist
=( $1 )
502 # taskinfo_dbgout "step_lang_src_tpchk ($@)"
505 # check ${lang}_SRlanglistC_LIST_Y list.
508 extname
=${LANG_EXT_NAME[${lang,,}]}
509 # for lang in ${langlist[@]} ; do
510 vname
="${lang}_SRC_LIST_Y"
511 eval ${vname}="\"\${${vname}[@]//,/ }\""
513 if test -z "${!vname}" ; then
514 eval ${lang}_SRC_CMPL_LIST=""
515 taskinfo_dbgout "no src
file in src list
\'\
${${lang}_SRC_LIST_Y
[@
]}\'.
"
518 OBJ_LIST+="${!vname//\.${extname}/\.o}"
519 # OBJ_LIST+="${!vname}"
521 # get obj file list that has been compiled.
523 OBJ_LIST_N2B_CPLE=`cd ${OBJDIR}/; ls -1 $(echo "${!vname//\.c/\.o}" | tr ',' ' ') 2>/dev/null`
524 [[ -z "$OBJ_LIST_N2B_CPLE" ]] && eval ${lang}_SRC_CMPL_LIST=\"\${\!vname}\" && return 0
526 # test compiled obj file, to check if it need to be recompiled.
527 for obj in ${OBJ_LIST_N2B_CPLE}; do
528 srcfile="${obj//\.o/\.${extname}}"
529 dstfile="${OBJDIR}/${obj}"
531 # check if file does not need to be compiled.
532 if test "${dstfile}" -nt "${srcfile}" ; then
534 src_hdr_tpchk $dstfile
535 [[ $? == 1 ]] && SRC_LIST_N2B_CMPL+="${srcfile}"$'\n'
536 [[ $? == 2 ]] && echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
539 # echo "SRC_LIST_N2B_CMPL
=$SRC_LIST_N2B_CMPL"
541 # get files to be compiled.
542 if test -n "$SRC_LIST_N2B_CMPL" ; then
544 eval "${lang}_SRC_CMPL_LIST
=\"`comm <(echo \"${!vname}\" | sort) <(echo \"$SRC_LIST_N2B_CMPL\" | sort) -3`\""
547 eval "${lang}_SRC_CMPL_LIST
=\"${!vname}\""
549 # eval echo "========= ${lang}_SRC_CMPL_LIST=\"\${${lang}_SRC_CMPL_LIST}\""
550 # eval taskinfo_dbgout "========= ${lang}_SRC_CMPL_LIST=\"\${${lang}_SRC_CMPL_LIST}\""
556 #############################################################################
560 ############################################################################
562 # $ [[ "VOID on_prev_construct
(int a
)" =~ ((.*)[[:space:]]+)?([[:alnum:]_]*)[[:space:]]*([\(](.*)[\)])? ]] && echo "BASH_REMATCH
=\"${BASH_REMATCH[@]}\""
563 # BASH_REMATCH="VOID on_prev_construct
(int a
) VOID on_prev_construct VOID on_prev_construct
(int a
) int a
"
565 # @ detect latest non "(" string as the function name.
566 # @ string after "(" string is paramter
567 # @ string before function name is ret type.
571 # fdesc: dispose input string in $1, output P_RET P_FUNC & P_PARAM[]
578 unset P_RET P_PARAM P_FUNC
580 declare -g P_PARAM=""
585 if [[ "$1" =~ ((.*)[[:space:]]+)?([[:alnum:]_]*)[[:space:]]*([\(](.*)[\)])? ]]; then
586 for ((i=0; i<${#BASH_REMATCH[@]}; i++)); do
587 # echo BASH_REMATCH[$i]=${BASH_REMATCH[$i]}
588 [[ -n ${BASH_REMATCH[$i]} ]] && idx=$i
589 [[ ${BASH_REMATCH[$i]:0:1} == '(' ]] && idx=$((i-1)) && break;
591 # dbgoutd "idx
=$idx\n"
592 P_FUNC="${BASH_REMATCH[$idx]}"
593 P_PARAM="${BASH_REMATCH[$((idx+2))]}"
594 P_RET="${BASH_REMATCH[$((idx-1))]}"
596 if test -n "$P_PARAM" ; then
597 # dbgoutd "P_PARAM
=$P_PARAM\n"
598 # P_PARAM="\"${P_PARAM//,/\" \"}\""
599 P_PARAM="${P_PARAM//,/ }"
601 eval P_PARAM=( ${P_PARAM} )
602 # dbgoutd "P_PARAM
[@
]=${P_PARAM[@]}\n"
604 # dbgoutd "P_RET
=$P_RET\n"
605 # dbgoutd "P_FUNC
=$P_FUNC\n"
606 # dbgoutd "P_PARAM
[@
]=${P_PARAM[@]}\n"
607 elif test -z "${1//[[:alnum:]_]/}" ; then
614 declare -F $P_FUNC >/dev/null 2>&1
615 # [[ $? != 0 ]] && warn "'$P_FUNC' is a defination of func form
, but it is not defined.
" && return 2
616 [[ $? != 0 ]] && return 3
621 # fsyntax: TASK_RUNNING <task-name-var> [<taskparam>, ... ]
622 # fdesc: running a task by the name of var in arg.
623 # freturn: 0, normal.
624 # 1, break current step.
625 # 2, err, stop doing.
638 if [[ -n $task_skip_list && $task_skip_list =~ $bakstep ]]; then
642 [[ -z $1 ]] && err "task name is not specified.
\n" && return 0;
645 taskstep_dbgout "$1" "TASK_RUNNING
($@
)\n"
648 [[ ! -n $1 ]] && warn "'$1' is not a valid step name.
" && ret=2 && break
651 # check if it is an array.
652 # if yes, use array directly.
653 # the form between multi-line string and array define are all well.
654 # sometimes, use array is better, it can write config info in the
657 # use seperator with new line, to avoid ' ' in func param.
660 # use cmdline to strip string.
669 # skip undefined step.
670 if [[ ${#stepdef[@]} == 0 && ! -v $stepdef ]]; then
672 warn "\
$content=$content"
673 warn "\
$stepdef=$stepdef"
674 warn "'$name' is not a valid step.\
${#stepdef[@]}=${#stepdef[@]}"
675 warn "set it
in 'build/dest/build-step.imi'.
"
681 # if only one item in defination, and it's not a variable define,
682 # it's a func, invoke it.
684 if test "${#stepdef[@]}" == 1 ; then
685 str2func "${stepdef[@]}"
687 if test $ret != 3 && test ! -n "${!P_FUNC}" ; then
689 taskfunc_dbgout "func
$P_FUNC(${P_PARAM[@]} "$@")\n"
690 $P_FUNC ${P_PARAM[@]} "$@
"
692 taskfunc_dbgout "func ret
$P_FUNC($ret)\n"
694 [[ $ret == 1 ]] && ret=0 && break
695 [[ $ret != 0 ]] && warn "1 func
'$P_FUNC (${P_PARAM[@]//\ /,\ })("$@")' return failed
($ret).
" && break
701 taskstep_dbgout "$bakstep" "xxxxxxxxxxxxxxxxxxxxxxxxx x stepdef
[@
]=$
(echo "${stepdef[@]}" |
tr -s '\t' $
'\n')\n"
704 # if there are several sub-steps, or the only one is also a step defination,
705 # use nestly invoking.
707 for ((j=0; j<${#stepdef[@]}; j++)); do
708 step="$
(echo ${stepdef[$j]})"
709 # taskinfo_dbgout "x xxxxxxxxxxxxxxxxxxxxxxxx xx step
[$j]=$step\n"
711 # skip null content and comment content
712 [[ -z $step ]] && continue
713 [[ "$step" =~ ^[[:blank:]]*\# ]] && continue
715 if [[ ! $step =~ '(' ]]; then
716 # if it's an existing var, it's may be a sub-step, invoke TASK_RUNNING() nestly.
717 # but not use ${!step} to access content.
718 # if it's also an existing func, it will be invoked in TASK_RUNNING.
721 # $step="$
(echo $step)"
722 TASK_RUNNING "$step" "${param[@]}"
724 # [[ $ret == 1 ]] && ret=0 && break
725 [[ $ret != 0 ]] && break
727 # if it's a func, invoke func also.
730 # taskinfo_dbgout "ret
=$ret\n"
731 if test $ret == 0 ; then
732 if test "${P_FUNC^^}" == "${P_FUNC}" ; then
733 # if full upper char, it's a step
734 # P_FUNC="$
(echo $P_FUNC)"
735 TASK_RUNNING $P_FUNC ${P_PARAM[@]} "${param[@]}"
736 # [[ $ret == 1 ]] && ret=0 && break
737 [[ $? != 0 ]] && taskinfo_dbgout "aaaaaaaaa
" && break
740 # otherwize, it's a normal function.
744 taskfunc_dbgout "func
$P_FUNC(${P_PARAM[@]} "$@")\n"
745 $P_FUNC ${P_PARAM[@]} "$@
"
747 taskfunc_dbgout "func ret
$P_FUNC($ret)\n"
749 [[ $ret == 1 ]] && ret=0 && break
750 [[ $ret != 0 ]] && warn "2 func
'$P_FUNC (${P_PARAM[@]//\ /,\ })("$@")' return failed
($ret).
" && break
751 elif test $ret == 3 ; then
752 # $P_FUNC="$
(echo $P_FUNC)"
754 TASK_RUNNING $P_FUNC ${P_PARAM[@]} "${param[@]}"
756 # [[ $ret == 1 ]] && ret=0 && break
757 [[ $ret != 0 ]] && taskinfo_dbgout "task
($step) invoking failed
($ret).
\n" && break
759 dbgoutd "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\n"
764 # echo "j
=$j; \
${#stepdef[@]}=${#stepdef[@]}; ret
=$ret"
765 # echo "if it
's a func, invoke func also."
766 if test ! $j -lt "${#stepdef[@]}" && test ret == 0 ; then
769 if test $ret == 0 ; then
771 taskfunc_dbgout "func $P_FUNC(${P_PARAM[@]} "$@")\n"
772 $P_FUNC ${P_PARAM[@]} "$@"
774 taskfunc_dbgout "func ret $P_FUNC($ret)\n"
776 [[ $ret == 1 ]] && ret=0 && break
777 [[ $ret != 0 ]] && warn "3 func '$P_FUNC (${P_PARAM[@]//\ /,\ })("$@")' return failed($ret)." && break
785 taskstep_dbgout "$bakstep" "ret $ret TASK_RUNNING ($name)\n"
791 foo () { local i=0; while [[ -n $1 ]]; do echo "\$1=$1"; shift; done; }
797 # $ abc=( aaa "a b c" abc a b c )
809 # fsyntax: tasklist <list> <task> [<taskparam> ... ]
810 # fdesc: running task accroding the list variable.
816 local task="$(echo $2)"
819 tasklist_dbgout "x TASK_RUNNING TASKLIST ($@)\n"
821 if test -z "$1" ; then
822 warn "specified list var name '$1' is not valid."
826 tasklist_dbgout "list=$list\n"
827 tasklist_dbgout "$list=${!list}\n"
830 [[ -z $data ]] && continue
832 # taskinfo_dbgout "SRC_FILE=${SRC_FILE[@]}\n"
833 TASK_RUNNING "$task" $data "$@"
834 # break tasklist running if one of them failed.
835 if test $? != 0 ; then
836 tasklist_dbgout "x ret 2 TASK_RUNNING TASKLIST ($@)\n"
843 tasklist_dbgout "x ret 0 TASK_RUNNING TASKLIST ($@)\n"
849 step_build_one_dest ()
851 # echo "step_build_dest($@)"
855 TASK_RUNNING "STEP_${DEST_TYPE^^}_DEST" $DEST_NAME
859 # fsyntax: step_one_dest_init
860 # fdesc: init one dest build. it loads the relative paramter files.
862 step_one_dest_init ()
868 buildstep_dbgout "############################\n"
869 buildstep_dbgout "step_one_dest_init($1, ${!1}, ${2#*-})\n"
870 buildstep_dbgout "############################\n"
872 [[ -n "$2" ]] && declare -g $1="${2#*-}"
874 # init one dest cfg paramter
875 eval "DEST_GENERAL_CFG_DIR=\"${DEST_GENERAL_CFG_DIR_EVL}\""
881 mkdir -p ${OUTDIR}/${DEST_CFG_DIR_NAME}/
884 declare -g OBJ_LIST=""
889 step_one_lang_cmpl ()
892 local langlist="${!1}"
894 # for lang in $langlist; do
895 TASK_RUNNING STEP_${lang^^}_LANG_CMPL "$@"
905 taskinfo_dbgout "step_link ($@)"
907 taskinfo_dbgout "OBJ_LIST=$OBJ_LIST"
909 DST_FILE="${OUTDIR}/${!2}"
910 SRC_FILE=( $OBJ_LIST )
912 taskinfo_dbgout "DST_FILE=$DST_FILE\n"
913 taskinfo_dbgout "DEST_NAME=$DEST_NAME\n"
914 taskinfo_dbgout "DEST_FILENAME=$DEST_FILENAME\n"
915 taskinfo_dbgout "DEST_TYPE=$DEST_TYPE\n"
916 taskinfo_dbgout "DEST_EXTNAME=$DEST_EXTNAME\n"
918 if test "${DEST_TYPE:0:1}" == '[' ; then
919 DEST_TYPE=${DEST_TYPE:1:-1}
921 taskinfo_dbgout "DEST_TYPE=$DEST_TYPE\n"
923 linkstep="STEP_${DEST_TYPE^^}_LINK"
924 taskinfo_dbgout "${linkstep}=${!linkstep}"
925 [[ -z ${!linkstep} ]] && err "dest type ${DEST_TYPE} have not define a step named 'STEP_${DEST_TYPE^^}_LINK'.
\n" && return 2
926 TASK_RUNNING "${linkstep}" "$@
"
928 [[ $? != 0 ]] && err "${CHIGHL}[build-link
]: link
file \"$DEST_FILENAME\" err.
${CNORMAL}" && exit && return 2
938 TASK_RUNNING STEP_${lang^^}_LANG_SRC2EXE
942 step_lang_src2unitsrc ()
949 # echo ============== ${lang^^}_SRC_LIST_Y
950 name="${lang^^}_SRC_LIST_Y
"
951 for file in ${!name}; do
952 # echo "file=${file%%\.*}_test.
${file##*.}"
953 filelist+="${file%%\.*}_test.
${file##*.}"$'\n'
955 eval ${lang^^}_SRC_LIST_Y=\"\$filelist\"
958 C_SRC_LIST_Y+="$OUTDIR/greatest
/greatest.c
"
959 mkdir -p $OUTDIR/greatest/
960 [[ ! -e $OUTDIR/greatest/greatest.c ]] && cat - > $OUTDIR/greatest/greatest.c << EOF
961 #include "greatest.h
"
967 CFLAGS_EXT="-DGREATEST_MULTIPLE"
968 # LDFLAGS_EXT="-Wl,-T,tools
/build-srcpkg
/greatest
/test.lds
"
969 STATIC_LIB_LIST_Y+=" $OUTDIR/${DEST_FILENAME[0]}"
970 DEST_FILENAME="${DEST_FILENAME[1]}"
975 # fsyntax: build_step_init
976 # fdesc: load build-step.imi cfg file.
980 # load CFLAGS-MISC.imi
981 eval "BUILD_STEP_IMI
=\"${BUILD_STEP_IMI_EVL}\""
982 buildparam_dbgout "BUILD_STEP_IMI
=$BUILD_STEP_IMI\n"
983 # load_imi_file $BUILD_STEP_IMI
984 # use source instead of load_imi_file
988 eval "BUILD_LANG_LIST
=\"${BUILD_LANG_LIST_EVL}\""
993 # fsyntax: dest_list_init
994 # fdesc: load dest.imi cfg file, to get dest-list.
1001 buildparam_dbgout "SRCPKG_DIR
=$SRCPKG_DIR\n"
1003 # BUILD_DEST is defined in this file
1004 eval DEST_LIST_FILE="$DEST_LIST_FILE_EVL"
1005 source $DEST_LIST_FILE
1006 DEST_LIST="${BUILD_DEST//dest-/$'\ndest-'}"
1008 buildparam_dbgout "###############################\n"
1009 buildparam_dbgout
"dest_list_init($DEST_LIST_FILE)\n"
1010 buildparam_dbgout
"DEST_LIST=\"$DEST_LIST\"\n"
1012 declare -g -A DEST_CFG_DIR
=( )
1013 # INST_PKG is defined in this file
1014 INSTPKG_LIST_FILE
="${SRCPKG_DIR}/build/instpkg/instpkg.list"
1015 declare -g -A INSTPKG_CFG_DIR
=( )
1018 construct_init_flag
=
1022 # skip if initialized.
1023 [[ $construct_init_flag == 1 ]] && return
1027 construct_init_flag
=1
1031 # fsyntax: construct_init
1032 # fdesc: init construct variables.
1034 # SRCPKG_DIR, src pkg root dir.
1035 # OUTDIR, it stores compile mid-file.
1040 construct_init_work
()
1045 if [[ -d build
]]; then
1047 eval "SRCPKG_DIR_ABP=\"$PWD\""
1048 elif [[ $
(basename $PWD) == build
]]; then
1051 eval "SRCPKG_DIR_ABP=\"$PWD\""
1054 # if it has been defined, create src-pkg name sub-dir
1055 if [[ -z $OUTDIR ]]; then
1056 eval "OUTDIR=\"$OUTDIR_EVL\""
1058 if [[ -z $OUTDIR_ABP ]]; then
1059 eval "OUTDIR_ABP=\"$OUTDIR_ABP_EVL\""
1064 date > ${OUTDIR}/build.log
1065 echo >> ${OUTDIR}/build.log
1067 # load srcpkg name & version string.
1068 eval "VERSION_FILE=\"$VERSION_FILE_EVL\""
1070 source $VERSION_FILE
1071 buildparam_dbgout VERSION_STRING
=$VERSION_STRING
1072 buildparam_dbgout SRCPKG_FILENAME
=$SRCPKG_FILENAME
1073 buildparam_dbgout SRCPKG_NAME
=$SRCPKG_NAME
1076 PATH
="$SRCPKG_DIR/support/:$PATH"
1080 # load dest.list & build-step.imi to get dest list.
1084 # load srcpkg shlib file, for some on_xxx() funcs.
1085 [[ -z $SRCPKG_NAME ]] && err
"SRCPKG_NAME defined in file of doc/VERSION is not valid.\n"
1086 if [[ -f build
/${SRCPKG_NAME}.shlib
]]; then
1087 inc build
/${SRCPKG_NAME}.shlib
1088 elif [[ -f build
/shlib
/${SRCPKG_NAME}.shlib
]]; then
1089 inc build
/shlib
/${SRCPKG_NAME}.shlib
1094 buildstep_dbgout
"############################\n"
1095 buildstep_dbgout
"construct_init()\n"
1096 buildstep_dbgout
"############################\n"
1101 # construct_all_dest => dest_list_init()/construct_one_dest() => one_dest_init() =>
1102 # compile_src_list()/link_list() => c2o()/o2exe()
1108 TASK_RUNNING
"STEP_BUILD_DEST"
1113 ##############################
1114 # section: file tail
1115 ##############################
1123 # fsyntax: worklist_create <worklist-name>
1124 # fdesc: create variables about a worklist object.
1132 # worklist can be create/release dynamically.
1133 # the default worklist is named null string.
1137 # fsyntax: worklist_release <worklist-name>
1138 # fdesc: release variables about a worklist object.
1146 # fsyntax: src_list_init
1147 # fdesc: load src-list file.
1154 local extname
="${LANG_EXT_NAME[${lang,,}]}"
1155 local SRC_LIST_FILE
="build/dest/dest-$DEST_NAME/${lang,,}-src-file.list"
1156 # local ${lang^^}_SRC_LIST_Y=
1158 # infoo "src_list_init($extname, $@)\n"
1160 vname
=${lang^^}_SRC_LIST_Y
1161 eval "${vname}=\"\""
1162 if test -e "${SRC_LIST_FILE}" ; then
1163 .
$SRC_LIST_FILE 2>/dev
/null
1164 eval "${vname}=\"\${!vname//\.${extname,,}/\$'.${extname,,}\n'}\""
1165 taskinfo_dbgout
${vname}="${!vname}"
1168 # [[ -e $SRC_LIST_FILE ]] && eval "${lang^^}_SRC_LIST_Y=( $(cat $SRC_LIST_FILE | grep -v \"[[:space:]]*#\" | sed -e \"s/^[[:space:]]*#.*$//g\") )"
1170 [[ -z ${!vname} ]] && taskinfo_dbgout no src
file in src list.
&& return 0
1172 # taskinfo_dbgout ${lang^^}_SRC_LIST_Y=${${lang^^}_SRC_LIST_Y[$i]}
1177 # fsyntax: step_lang_src_tpchk <langlist-var> [<parameter-list> ... ]
1178 # fdesc: chk tp between srcfile and dstfile(obj).
1180 step_lang_exe_tpchk
()
1191 TASK_RUNNING STEP_
${lang^^}_LANG_CMPL