5 # two part in this file:
6 # @ code in catalog.shlib
16 ############################################################################
18 ############################################################################
35 DEF_TESTING_CATALOG="funclist.txt"
39 onDirSubjectDirEntering ()
44 eval tmp="\"\${LAYEDDIR_${DIR_TYPE^^}[@]}\""
45 cata_dbgout "@@@@@ onDirSubjectDirEntering($1, $2, $(echo "$tmp" | tr -s ' ' '/'))\n"
47 mkdir -p "$OUTPUT_DIR"
50 # fyntax: onItemSubjectDirEntering <item-node-type> <item-node-name> <item-node-layerddir>
51 # fdesc: get other info by 'ITEM_XXX' and other vars.
52 onItemSubjectDirEntering ()
54 cata_dbgout "=====> onItemSubjectDirEntering($1, $2, $3)\n"
61 cata_dbgout "=====> onItemEntering($1, $2, $3)\n"
63 ITEM_CHKSUM="$(echo "$NTYPE $NNAME $NDESC" | cksum)"
64 ITEM_CHKSUM="${ITEM_CHKSUM:0:6}"
65 save_curr_ctx "$ITEM_CHKSUM"
66 #declare -A -g ITEM_CTX[$ITEM_CHKSUM]="$(declare -p NFULLCATAID ${!LAYEDDIR_*})"
67 # echo $ITEM_CHKSUM ${CONTEX_BAK[$ITEM_CHKSUM]} >&2
70 # fyntax onItemExiting <item-node-type> <item-node-name>
71 # fdesc: get other info by 'ITEM_XXX' and other vars.
77 cata_dbgout "=======================================\n"
78 cata_dbgout "onItemExiting($1, $2, $3)\n"
80 [[ -z $ITEM_CONT_TYPE_LIST ]] && return
82 # echo CONTENT LIST INFO:
83 for cont in $ITEM_CONT_TYPE_LIST; do
84 vname="CONT_${cont^^}_LIST"
85 # echo "$vname=\"${!vname}\""
89 declare -p FILE_EXT_LIST DIR_TYPE_LIST
94 ITEM_CONT_TYPE_LIST=""
99 cata_dbgout "== onItemFileProc() $STR\n"
105 cata_dbgout "== onDirFileProc() $STR\n"
113 cata_dbgout "onContProc($1, $2, $3)\n"
116 vname="CONT_${1^^}_LIST"
117 declare -g ${vname}+="$2"$'\n'
118 declare -g ${vname}+="$3"$'\n'
120 if [[ ! "$ITEM_CONT_TYPE_LIST" =~ $1 ]]; then
121 ITEM_CONT_TYPE_LIST+="$1"$'\n'
127 THISDOC="${THISDOC:0:-1}"
128 [[ -z "${THISDOC//[[:space:]]/}" ]] && return
130 echo THISDOC="\"$THISDOC\""
138 # at the end of file output, record file list in output dir
139 tmp="$(envar_get catalog::testdir::SUBJECTDIR)/* "
140 tmp+="$(envar_get catalog::docdir::SUBJECTDIR)/* "
141 tmp+="$(envar_get catalog::designdir::SUBJECTDIR)/* "
142 tmp+="$(envar_get catalog::exdir::SUBJECTDIR)/* "
143 tmp+="$(envar_get catalog::incdir::SUBJECTDIR)/* "
144 tmp+="$(envar_get catalog::srcdir::SUBJECTDIR)/* "
145 tmp+="$(envar_get catalog::libdir::SUBJECTDIR)/* "
146 tmp+="$(envar_get catalog::bindir::SUBJECTDIR)/* "
147 tmp+="$(envar_get catalog::shlibdir::SUBJECTDIR)/* "
149 mkdir "$(dirname $1)"
151 find $tmp > "$1" 2>/dev/null
154 load_catanode_param ()
157 include param/param.shlib
159 # init node parameter.
160 declare -g G_NODE_STR_FMT="$(envar_get catalog::catanode::STR_FMT)"
161 declare -g G_NODE_PAIRCHARS="$(envar_get catalog::catanode::PAIRCHARS)"
163 declare -p G_NODE_STR_FMT G_NODE_PAIRCHARS
165 # envar_create catalog::catanode::STR_FMT='<@{NCATAID}>@{ALIGN}[@{NTYPE}]@{ALIGN}@{NNAME}@{ALIGN}[@{NDESC}]'
166 G_OUTPUT_DIR_FMT="$(envar_get catalog::dirnode::OUTPUT_DIR_FMT)"
167 declare -p G_OUTPUT_DIR_FMT
172 vonItemEntering=onItemEntering
173 vonItemSubjectDirEntering=onItemSubjectDirEntering
174 vonItemExiting=onItemExiting
175 vonItemFileProc=onItemFileProc
177 vonDirSubjectDirEntering=onDirSubjectDirEntering
178 vonDirFileProc=onDirFileProc
180 vonContProc=onContProc
183 catalog_2_dirfiles ()
192 cataid_set_init_state TEST "inner"
197 # envar_create catalog::catanode::STR_FMT='<@{NCATAID}>@{ALIAN}[@{NTYPE}]@{ALIAN}@{NNAME}@{ALIAN}[@{NDESC}]'
198 G_OUTPUT_DIR_FMT="$(envar_get catalog::dirnode::OUTPUT_DIR_FMT)"
199 declare -p G_OUTPUT_DIR_FMT
201 finput=${finput:-"${DEF_TESTING_CATALOG}"}
202 if [[ ! -e $finput ]]; then
203 err "function list file '$finput' is not exist.\n"
207 cp "$finput" "$TESTING_TMP_DIR/"
208 finput=$TESTING_TMP_DIR/`basename $finput`
211 mkdir -p $SRCPKG_DIR/build/
212 cp $finput $SRCPKG_DIR/build/$(basename $finput)
214 # analyze catalog file.
215 vonCataNodeProc=onDefaultCataNodeProc
216 catalog_each_line "$finput"
218 save_file_list "$SRCPKG_DIR/build/codegen.dir.txt"
235 ############################################################################
237 ############################################################################
257 for file in $FILE_EXT_LIST; do
264 # catanode analyzing for comparation.
266 OnAnyalyzeCataNodeProc ()
268 ITEM_CHKSUM="$(echo "$NTYPE $NNAME $NDESC" | cksum)"
270 if [[ ${NODE_TYPE} != 'cont' ]]; then
271 NODE_TBL[$ITEM_CHKSUM]="$(declare -p NCATAID NTYPE NNAME NDESC NODE_TYPE NFULLCATAID CONT_TYPE ITEM_TYPE SRC_TYPE CATACNT)"
272 NODE_TBL[$ITEM_CHKSUM]="$(NODE_TBL[$ITEM_CHKSUM]//declare/declare -g)"
273 NODE_TBL_EXIST[$ITEM_CHKSUM]="1"
275 if [[ ${NODE_TYPE} == 'item' ]]; then
276 ITEM_CHKSUM_ID="$ITEM_CHKSUM"
277 save_curr_ctx "$ITEM_CHKSUM"
280 eval CONT_NODE_TBL_${ITEM_CHKSUM_ID}[$ITEM_CHKSUM]="\"$(declare -p NCATAID NTYPE NNAME NDESC NODE_TYPE NFULLCATAID CONT_TYPE ITEM_TYPE SRC_TYPE CATACNT)\""
281 eval CONT_NODE_TBL_${ITEM_CHKSUM_ID}[$ITEM_CHKSUM]="\"\$(CONT_NODE_TBL_${ITEM_CHKSUM_ID}[$ITEM_CHKSUM]//declare/declare -g)\""
286 # catanode comparing.
288 OnCompareCataNodeProc ()
290 ITEM_CHKSUM="$(echo "$NTYPE $NNAME $NDESC" | cksum)"
292 if [[ ${NODE_TYPE} != 'cont' ]]; then
293 if [[ -n ${NODE_TBL[$ITEM_CHKSUM]} ]]; then
294 # unset NODE_TBL[$ITEM_CHKSUM]
295 # del_bak_ctx "$ITEM_CHKSUM"
296 unset NODE_TBL_EXIST[$ITEM_CHKSUM]
298 NEW_NODE_TBL="$(declare -p NCATAID NTYPE NNAME NDESC NODE_TYPE NFULLCATAID CONT_TYPE ITEM_TYPE SRC_TYPE CATACNT)"
299 NEW_NODE_TBL[$ITEM_CHKSUM]="$(NEW_NODE_TBL[$ITEM_CHKSUM]//declare/declare -g)"
302 if [[ ${NODE_TYPE} == 'item' ]]; then
303 ITEM_CHKSUM_ID="$ITEM_CHKSUM"
308 vname="CONT_NODE_TBL_${ITEM_CHKSUM_ID}[$ITEM_CHKSUM]"
309 if [[ -n ${!vname} ]]; then
313 eval $vname="\"$(declare -p NCATAID NTYPE NNAME NDESC NODE_TYPE NFULLCATAID CONT_TYPE ITEM_TYPE SRC_TYPE CATACNT)\""
314 eval $vname="$(!vname//declare/declare -g)"
319 deleted_node_tbl_foreach ()
324 # ergodic deleted list, and get the ITEM_CHKSUM_ID from main design file.
327 cnt="${#NODE_TBL[@]}"
328 for ITEM_CHKSUM in ${!NODE_TBL[@]}; do
330 eval ${NODE_TBL[$ITEM_CHKSUM]}
332 # get foreach file in current node.
334 # TBD: output operation.
338 new_file_node_tbl_foreach ()
344 cnt="${#NODE_TBL[@]}"
345 for ITEM_CHKSUM in ${!NODE_TBL_EXIST[@]}; do
346 # restore NODE contex
353 new_cont_node_tbl_foreach ()
360 local item_node_list=
363 cnt="${#NODE_TBL[@]}"
364 item_node_list="${!NEW_CONT_NODE_TBL_} ${!CONT_NODE_TBL_}"
365 item_node_list="${item_node_list//NEW_CONT_NODE_TBL_/}"
366 item_node_list="${item_node_list//CONT_NODE_TBL_/}"
367 item_node_list="$(echo "$item_node_list" | uniq)"
368 for itemid in ${item_node_list}; do
369 var="NEW_CONT_NODE_TBL_${itemid}[@]"
370 for ITEM_CHKSUM in ${!var}; do
371 # restore NODE contex
372 var="NEW_CONT_NODE_TBL_${itemid}[$ITEM_CHKSUM]"
378 for cont in $ITEM_CONT_TYPE_LIST; do
379 vname="CONT_${cont^^}_LIST"
380 eval "NEW_$vname=\"${!vname}\""
385 var="CONT_NODE_TBL_${itemid}[@]"
386 for ITEM_CHKSUM in ${!var}; do
387 # restore NODE contex
388 var="${itemid}[$ITEM_CHKSUM]"
394 for cont in $ITEM_CONT_TYPE_LIST; do
395 vname="CONT_${cont^^}_LIST"
396 eval "DEL_$vname=\"${!vname}\""
400 # TBD: item file re-gen
404 catalog_content_cmp ()
408 tmp=${tmp:-"${DEF_TESTING_CATALOG}"}
409 [[ ! -e ${tmp} ]] && return
411 [[ ! -e $SRCPKG_DIR/build/${DEF_TESTING_CATALOG} ]] && return
413 vonCataNodeProc=OnAnyalyzeCataNodeProc
414 catalog_each_line "$SRCPKG_DIR/build/${DEF_TESTING_CATALOG}"
416 vonCataNodeProc=OnCompareCataNodeProc
417 catalog_each_line "$tmp"
419 # TBD: chk if NEW_* info is modified or new.
421 deleted_node_tbl_foreach
422 new_file_node_tbl_foreach
423 new_cont_node_tbl_foreach
428 save_file_list /tmp/codegen.dir.txt
433 # * this feature is hard to be implemented in this code.
437 # foreach deleted node, compare NNAME NDESC in new catalog file.