4 # fsyntax: TASK_CMPL <srcfile> [<taskparam> ... ]
5 # fdesc: running compile task accroding srcfile sfx name.
6 # it recognize srcfile, and invoke corresponding function.
11 local ext="${srcfile##*.}"
12 local name="${ext^^}_SRC_CMPL"
14 declare -F $name >/dev/null 2>&1
15 [[ -v $name && $? == 0 ]] && ${!name} "$@"
19 # fsyntax: TASK_LINK <objlist> <dest>
20 # fdesc: compile obj list to dest accroding dest type.
28 # fsyntax: TASK_STEP_RUNNING <task-name-var> <taskparam>
29 # fdesc: running tasks by the name of var in arg.
34 local stepdef=( ${!1} )
36 for step in $stepdef; do
37 declare -F $step >/dev/null 2>&1
38 [[ $? == 0 ]] && shift 2; $step "$@"
39 declare -F ${!step} >/dev/null 2>&1
40 [[ -v $step && $? == 0 ]] && shift 2; ${!step} SRC_FILE "$@"
47 declare -F $1 >/dev/null 2>&1
48 [[ $? == 0 ]] && shift 2; $1 "$@"
49 declare -F ${!1} >/dev/null 2>&1
50 [[ -v $1 && $? == 0 ]] && shift 2; ${!1} SRC_FILE "$@"
63 info "..................... dest_build ($dest)\n"
65 if [[ -z $dest ]]; then
66 warn "specified list var name '$1' is not valid.\n"
70 # init one dest cfg paramter
71 eval "DEST_GENERAL_CFG_DIR=\"${DEST_GENERAL_CFG_DIR_EVL}\""
73 one_dest_init dest-general
78 mkdir -p ${OUTPUT_DIR}/${DEST_CFG_DIR_NAME}/
80 dbgout_construct_param
82 # check src file list to be compiled.
83 check_and_get_src_compile_list
86 if [[ $? == 0 ]]; then
91 [[ -z $data ]] && continue
93 dbgoutd "SRC_FILE=${SRC_FILE[@]}\n"
94 # TASK_RUNNING $task SRC_FILE "$@"
95 TASK_RUNNING STEP_DEFAULT_DEST $SRC_FILE "$@"
96 # break tasklist running if one of them failed.
97 [[ $? != 0 ]] && return 2
100 [[ $? != 0 ]] && dbgoutd "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1\n" && return 2
112 DEST_CFG_DIR_NAME="$dest"
114 construct_one_dest $dest
115 [[ $? != 0 ]] && err "${CHIGHL}[build-dest][${dest#*-}]: build dest file \"$dest\" err.${CNORMAL}" && return 2
120 # fsyntax: construct_one_dest <dest-name>
121 # fdesc: construct one dest executables.
123 construct_one_dest ()
125 local dest=${dest#*-}
129 dbgoutd "############################\n"
130 dbgoutd "construct_one_dest(${1#*-})\n"
135 # try to check dest and obj tp, it output OBJ_LIST.
136 dest_link_check $dest
137 [[ $? != 0 ]] && dbgoutd "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx2\n" && return 2
144 # fsyntax: check_and_get_src_compile_list <lang-list-var>
145 # fdesc: check if src file is newer then dest file in $obj,
147 check_and_get_src_compile_list ()
152 local SRC_LIST_N2B_CMPL=
153 local langlist=( $1 )
158 # check ${lang}_SRC_LIST list.
160 for lang in ${langlist[@]} ; do
161 vname="${lang}_SRC_LIST[@]"
162 if [[ -z ${!vname} ]]; then
163 eval ${lang}_SRC_CMPL_LIST=""
164 task_info no src file in src list \'\${${lang}_SRC_LIST[@]}\'.
168 # get obj file list that has been compiled.
169 OBJ_LIST_N2B_CPLE=`cd ${OUTPUT_DIR}/${DEST_CFG_DIR_NAME}/; ls -1 ${!vname//\.c/\.o} 2>/dev/null`
170 [[ -z "$OBJ_LIST_N2B_CPLE" ]] && eval ${lang}_SRC_CMPL_LIST=\"\${\!vname}\" && continue
172 # test compiled obj file, to check if it need to be recompiled.
173 # dbgoutd "OBJ_LIST_N2B_CPLE=${OBJ_LIST_N2B_CPLE}\n"
174 for obj in ${OBJ_LIST_N2B_CPLE}; do
175 srcfile="${obj//\.o/\.cpp}"
176 dstfile="${OUTPUT_DIR}/${DEST_CFG_DIR_NAME}/${obj}"
178 # check if file does not need to be compiled.
179 if [[ "${dstfile}" -nt "${srcfile}" ]]; then
181 lang_src_hdrtpchk $dstfile
182 [[ $? == 0 ]] && SRC_LIST_N2B_CMPL+="${srcfile}"$'\n'
186 # get files to be compiled.
187 if [[ -n $SRC_LIST_N2B_CMPL ]]; then
189 eval ${lang}_SRC_CMPL_LIST="`comm <(echo "${!vname}" | sort) <(echo "$SRC_LIST_N2B_CMPL" | sort) -1`"
192 eval task_info ${lang}_SRC_CMPL_LIST="\${${lang}_SRC_CMPL_LIST}"
201 full_lang_src_tpchk ()
206 local SRC_LIST_N2B_CMPL=
207 local langlist=( $1 )
211 info "lang_src_tpchk ($@)"
214 # check ${lang}_SRC list.
216 for lang in ${langlist[@]} ; do
217 vname="${lang}_SRC_LIST[@]"
218 if [[ -z ${!vname} ]]; then
219 eval ${lang}_SRC_CMPL_LIST=""
220 task_info "no src file in src list \'\${${lang}_SRC_LIST[@]}\'."
224 # get obj file list that has been compiled.
225 OBJ_LIST_N2B_CPLE=`cd ${OUTPUT_DIR}/${DEST_CFG_DIR_NAME}/; ls -1 ${!vname//\.c/\.o} 2>/dev/null`
226 [[ -z "$OBJ_LIST_N2B_CPLE" ]] && eval ${lang}_SRC_CMPL_LIST=\"\${\!vname}\" && continue
228 # test compiled obj file, to check if it need to be recompiled.
229 # dbgoutd "OBJ_LIST_N2B_CPLE=${OBJ_LIST_N2B_CPLE}\n"
230 for obj in ${OBJ_LIST_N2B_CPLE}; do
231 srcfile="${obj//\.o/\.cpp}"
232 dstfile="${OUTPUT_DIR}/${DEST_CFG_DIR_NAME}/${obj}"
234 # check if file does not need to be compiled.
235 if [[ "${dstfile}" -nt "${srcfile}" ]]; then
237 lang_src_hdrtpchk $dstfile
238 [[ $? == 0 ]] && SRC_LIST_N2B_CMPL+="${srcfile}"$'\n'
242 # get files to be compiled.
243 if [[ -n $SRC_LIST_N2B_CMPL ]]; then
245 eval ${lang}_SRC_CMPL_LIST="`comm <(echo "${!vname}" | sort) <(echo "$SRC_LIST_N2B_CMPL" | sort) -1`"
248 eval task_info "${lang}_SRC_CMPL_LIST=\"\${${lang}_SRC_CMPL_LIST}\""
255 # fsyntax: desttpchk <objlist-var> <dstfile-var>
256 # fdesc: chk tp between src-file and dest-file.
260 local extname="${DEST_EXTNAME}"
262 local destfile="${!2}"
264 task_info "desttpchk ($@)"
265 task_info "destfile($2)=$destfile"
269 [[ -z "$srcfile" ]] && err "input file list '${1}' does not have content" && return 2
270 [[ -z "$destfile" ]] && err "output file list '${2}' does not have content" && return 2
272 [[ ! -f ${destfile} ]] && return 0
273 [[ ${srcfile} -nt ${destfile} ]] && return 2
277 # fsyntax: tpchk <srcfile> <dstfile>
278 # fdesc: chk tp between src-file and dest-file.
282 local extname="${LANG_EXT_NAME[$2]}"
284 local destfile="${OUTPUT_DIR}/${3}/${1//\.${extname}/\.o}"
286 task_info "tpchk ($@)"
287 task_info "destfile=$destfile"
288 [[ ! -f ${destfile} ]] && return 0
289 [[ ${srcfile} -nt ${destfile} ]] && return 2
295 # fsyntax: src2exe <srcfile> <dstfile>
296 # fdesc: compile srcfile, and output exe file directly.
300 [[ $1 -nt $2 ]] && return 2