2 ############################################################
3 # source: param-load.shlib
4 # author: devenkong(18151155@qq.com)
6 ############################################################
8 # this file is used to load param defined in
9 # build/dest/dest-<dest>/*.
10 # before using func in toolchain.shlib, inc this file,
11 # and invoke one_dest_init() to load parameters in config
13 ############################################################
26 ######################
27 # section: common comment info
28 ######################
30 ######################
31 # section: variable define
32 ######################
36 ######################
37 # section: private function
38 ######################
40 buildimilist_dbgout
()
47 # fsyntax: buildparam_dbgout <output-string>
48 # fdesc: output string by dbgout switch.
52 if [[ ! "${dbgout_opt}" =~ buildparam_dbgout
]]; then
57 echo -ne "$@" >> ${OUTDIR}/buildparam.log
58 echo -ne "$@" >> ${OUTDIR}/buildinfo.log
67 ######################
68 # section: public function
69 ######################
72 # fsyntax: dbgout_construct_param
88 for name
in $namelist; do
92 namelist
="${!ASFLAGS*}"
93 for name
in $namelist; do
97 namelist
="${!CFLAGS*}"
98 for name
in $namelist; do
102 namelist
="${!CXXFLAGS*}"
103 for name
in $namelist; do
107 namelist
="${!CPPFLAGS*}"
108 for name
in $namelist; do
112 namelist
="${!ARFLAGS*}"
113 for name
in $namelist; do
117 namelist
="${!LDFLAGS*}"
118 for name
in $namelist; do
130 [[ "$DEST_NAME" == general
]] && DEST_TYPE
=null
&& return
133 eval "DEST_CFG_DIR_NAME=\"${DEST_CFG_DIR_NAME_EVL}\""
134 eval "DEST_IMI_FILE=\"${DEST_IMI_FILE_EVL}\""
135 loadimi
$DEST_IMI_FILE
137 if [[ -z "${DEST_TYPE}" ]]; then
138 echo "[error] DEST_TYPE is NULL in $DEST_IMI_FILE."
142 # append [] on DEST_TYPE just for good looking.
143 if [[ "${DEST_TYPE:0:1}" == \
[ && "${DEST_TYPE: -1:1}" == \
] ]]; then
144 DEST_TYPE
="${DEST_TYPE:1:-1}"
149 # fsyntax: one_dest_cflags_init <dest-name>
150 # fdesc: specified dest paramter load
152 one_dest_cflags_init
()
157 cd build
/dest
/dest-
$1
159 filelist
=$
(ls -1 FLAGS
* 2>/dev
/null
)
160 for file in $filelist; do
161 # echo load file $file
162 if [[ "${file}" =~ \.imi$
]]; then
169 filelist
=$
(ls -1 ASFLAGS
* 2>/dev
/null
)
170 for file in $filelist; do
171 # echo load file $file
172 if [[ "${file}" =~ \.imi$
]]; then
179 filelist
=$
(ls -1 CFLAGS
* 2>/dev
/null
)
180 for file in $filelist; do
181 # echo load file $file
182 if [[ "${file}" =~ \.imi$
]]; then
189 filelist
=$
(ls -1 CXXFLAGS
* 2>/dev
/null
)
190 for file in $filelist; do
191 # echo load file $file
192 if [[ "${file}" =~ \.imi$
]]; then
199 filelist
=$
(ls -1 CPPFLAGS
* 2>/dev
/null
)
200 for file in $filelist; do
201 # echo load file $file
202 if [[ "${file}" =~ \.imi$
]]; then
211 buildparam_dbgout
"CFLAGS=$CFLAGS\n"
215 # fsyntax: one_dest_ldflags_init <dest-name>
216 # fdesc: specified dest paramter load
218 one_dest_ldflags_init
()
223 cd build
/dest
/dest-
$1
225 filelist
=$
(ls -1 ARFLAGS
* 2>/dev
/null
)
226 for file in $filelist; do
227 # echo load file $file
228 if [[ "${file}" =~ \.imi$
]]; then
235 filelist
=$
(ls -1 LDFLAGS
* 2>/dev
/null
)
236 for file in $filelist; do
237 # echo load file $file
238 if [[ "${file}" =~ \.imi$
]]; then
247 buildparam_dbgout
"LDFLAGS=$LDFLAGS\n"
251 # fsyntax: one_dest_cfg <dest-name>
252 # fdesc: specified dest paramter load
256 buildparam_dbgout
"###################################\n"
257 buildparam_dbgout
"###################################\n"
258 buildparam_dbgout
"one_dest_cfg($1)\n"
260 DEST_CFG_DIR_NAME
="dest-$1"
261 eval "DEST_CFG_DIR=\"${DEST_CFG_DIR_EVL}\""
264 declare -g -a DST_FILE
266 declare -g -a SRC_FILE
268 one_dest_cflags_init
"$@"
269 buildparam_dbgout
"===================== CFLAGS_DEF_LIST_Y=\"$CFLAGS_DEF_LIST_Y\"\n"
271 one_dest_ldflags_init
"$@"
273 buildparam_dbgout
"+++++++++++++++++++++ CFLAGS_DEF_LIST_Y=\"$CFLAGS_DEF_LIST_Y\"\n"
274 buildparam_dbgout
"===================== CFLAGS=\"$CFLAGS\"\n"
276 buildparam_dbgout
"+++++++++++++++++++++ CFLAGS=\"$CFLAGS\"\n"
280 # fsyntax: one_dest_srclist_init <dest-name>
281 # fdesc: specified dest paramter load
283 one_dest_srclist_init
()
285 # TBD: disable src-list load in init. load it before corresponding
286 # program language src file list compile.
288 # load src list files
289 # -src-file and -src-dir can be included in this loading.
291 [[ ! ${file} =~ .
+-src-.
+ ]] && continue
294 done < <(ls -d -1 -f $DEST_CFG_DIR/{*.lst
,*.list
} 2>/dev
/null
)
297 # load LDFLAGS_LIBPATH.list
298 eval "STATIC_LIB_FILE_LIST=\"${STATIC_LIB_FILE_LIST_FILE_EVL}\""
299 # buildparam_dbgout "STATIC_LIB_FILE_LIST=$STATIC_LIB_FILE_LIST\n"
300 loadlist
$STATIC_LIB_FILE_LIST
304 # fsyntax: load_param_imi <dest>
305 # fdesc: this func should be invoked after one_dest_cfg().
310 local DEST_CFG_DIR_NAME
=
312 # load global param define
313 loadimi tools
/build-srcpkg
/info
/paramters.imi
315 # load general param define in srcpkg
316 DEST_CFG_DIR_NAME
=dest-general
317 eval PARAMTERS_IMI_FILE
="\"$PARAMTERS_IMI_FILE_EVL\""
318 [[ -e $PARAMTERS_IMI_FILE ]] && loadimi
$PARAMTERS_IMI_FILE
320 # load one dest param define in srcpkg
321 DEST_CFG_DIR_NAME
="dest-$1"
322 [[ -e $PARAMTERS_IMI_FILE ]] && loadimi
$PARAMTERS_IMI_FILE
350 if [[ ${1} == 'TARGET' || ${1} == 'BUILD' || ${1} == 'HOST' ]]; then
356 for cmd
in $cmdlist; do
357 eval ${cmd}=\${${PFX}_${cmd}}
362 # fsyntax: one_dest_init <dest-name>
363 # fdesc: specified dest paramter load
367 [[ -z "$1" ]] && err
"specify the dest name to be init."
373 # some param in .imi file should be defined as _SYNTAX suffix.
377 # load general parameter files.
379 # loadimi ${SRCPKG_DIR_FULL}/tools/build-srcpkg/info/ParamFiles.imi
380 # loadimi ${SRCPKG_DIR_FULL}/tools/build-srcpkg/info/SrcPkgDirs.imi
383 # init toolchain in auto, for compiler cmd infos in host/target.
387 echo =========================== 1 MACHTYPE
=$MACHTYPE
390 # create $OUTDIR & $OBJDIR for compile.
392 mkdir
-p $OUTDIR $OBJDIR
396 # load parameter files in one dest, .imi & .list.
401 # update extname info if dest build type changed.
403 inc
${SRCPKG_DIR_FULL}/tools
/build-srcpkg
/info
/extname.imi
404 loadimi tools
/build-srcpkg
/info
/SrcPkgDirs.imi
409 one_dest_srclist_init
$1
411 # update toolchain cmd lnfo by Dest.imi
412 # set build type for compiler cross prefix.
413 [[ -n $DEST_BUILDTYPE ]] && set_cmplr
$DEST_BUILDTYPE
415 buildparam_dbgout
"==================== DEST_BUILDTYPE=$DEST_BUILDTYPE\n"
416 buildparam_dbgout
"==================== CC=$CC\n"
420 ######################
422 ######################
446 param_imi_list
="PARAMTERS_IMI_FILE"
449 ARFLAGS_MISC_IMI_FILE
450 CFLAGS_DEF_LIST_FILE_Y
451 CFLAGS_INCPATH_LIST_FILE_Y
452 CFLAGS_MISC_IMI_FILE"
456 LDFLAGS_LIB_LIST_FILE
457 LDFLAGS_LIBPATH_LIST_FILE_Y
458 LDFLAGS_MISC_IMI_FILE"
461 # fsyntax: load_param_file_list <file-name-list-envar>
462 # fdesc: specified dest paramter load
464 load_param_file_list
()
466 # echo "load_param_file_list(${!1})"
467 for name
in ${!1}; do
468 if [[ -z $name ||
$name =~ ^
[[:blank
:]][#] ]]; then
473 # echo $name=${!name}
474 eval "local $name=\"\${${name}_EVL}\""
475 # buildparam_dbgout "param: $name=${!name}\n"
476 eval "$name=\"${!name}\""
477 # buildparam_dbgout "$name=${!name}\n"
479 [[ -z "${!name}" ]] && continue
481 if [[ "${!name}" =~ \.imi$
]]; then