2 ############################################################
3 # source: toolchain.shlib
4 # author: devenkong(18151155@qq.com)
6 ############################################################
9 # file & dir name stored in envar for using. as an auxiliary
10 # method, arg param in func update to local envar for using.
11 # those var are store dir/file name for using.
13 # SRC_FILE[0], input src file name. in compile, it's xxx.c, in link, it's xxx.o
14 # DSTFILE/DST_FILE[0], output dst file name. lib/dll/exe
15 # OBJFILE/DST_FILE[1], output obj file name.
16 # DEPFILE/DST_FILE[2], output hdr dep file name.
17 # CGRAPHFILE/DST_FILE[3], output call graph file name.
19 # @ all dir defined without '/' surffix, but root dir.
20 # @ ext name with '.' prefix in envar.
21 # @ {} should be added for envar using.
22 # @ ${var} should be quoted with double quote.
24 # this copy of src can be used as a single file. it process
26 # @ public defination.
28 # @ param var, defined in .imi for config.
29 # DEST_NAME/DEST_TYPE/OUTDIR=
30 # @ *_EVL format define var, defined in this file.
31 # DSTDIR_EVL/OBJDIR_EVL/DSTFILE_FMT/OBJFILE_FMT/DEPFILE_FMT
33 # @ output var, generated in func in this file.
34 # DSTDIR/OBJDIR/DSTFILE/OBJFILE/DEPFILE/CGRAPHFILE/DST_FILE[]
36 ############################################################
46 ######################
47 # section: common comment info
48 ######################
50 ######################
51 # section: variable define
52 ######################
55 # XXX: dir param _EVL defined in info/SrcPkgDirs.imi & info/extname.imi
60 ######################
61 # section: private function
62 ######################
66 ######################
67 # section: public function
68 ######################
70 # syntax: fname_dstdir
73 eval DSTDIR
="$DSTDIR_EVL"
76 # syntax: fname_objdir
79 eval OBJDIR
="$OBJDIR_EVL"
82 # syntax: fname_src2obj <src-file>
86 # append SRC_FILE as a local variable,
87 # it will not change global content.
89 [[ -n "$1" ]] && local SRC_FILE
[0]="$1"
90 [[ -z ${SRC_FILE[0]} ]] && return -1
92 local tmp
="${SRC_FILE}"
93 SRC_FILE
="${SRC_FILE%%\,*}"
95 eval OBJFILE
="$OBJFILE_FMT"
100 # syntax: fname_src2dst <obj-file> <dst-type>
103 [[ -n "$1" ]] && local SRC_FILE
[0]="$1"
104 [[ -z ${SRC_FILE[0]} ]] && return -1
106 local tmp
="${SRC_FILE}"
107 SRC_FILE
="${SRC_FILE%%\,*}"
109 eval DSTFILE
="$DSTFILE_FMT"
114 # syntax: fname_src2dep <src-file>
117 [[ -n "$1" ]] && local SRC_FILE
[0]="$1"
118 [[ -z ${SRC_FILE[0]} ]] && return -1
120 local tmp
="${SRC_FILE}"
121 SRC_FILE
="${SRC_FILE%%\,*}"
123 eval DEPFILE
="$DEPFILE_FMT"
128 # fsyntax: fname_src2graph <src-file>
131 [[ -n "$1" ]] && local SRC_FILE
[0]="$1"
132 [[ -z ${SRC_FILE[0]} ]] && return -1
134 local tmp
="${SRC_FILE}"
135 SRC_FILE
="${SRC_FILE%%\,*}"
137 eval CGRAPHFILE
="$CGRAPHFILE_FMT"
139 DST_FILE
[3]=$CGRAPHFILE
142 fname_func_testing
()
144 echo "========================"
145 echo "= fname_func_testing()"
146 echo "========================"
150 export DEST_NAME
=bush
151 SRC_FILE
[0]="src/lxrgmr/subst.c"
152 echo DEST_NAME
=$DEST_NAME
153 echo DEST_TYPE
=$DEST_TYPE
155 echo "SRC_FILE[0]=${SRC_FILE[0]}"
158 echo DSTDIR
="\"$DSTDIR\""
161 echo OBJDIR
="\"$OBJDIR\""
164 echo OBJFILE
="\"$OBJFILE\""
166 fname_obj2dst src
/runner
/xxx.c
167 echo DSTFILE
="\"$DSTFILE\""
169 fname_src2dep src
/var
/variable.c
170 echo DEPFILE
="\"$DEPFILE\""
172 echo CGRAPHFILE
="\"$CGRAPHFILE\""
175 ######################
177 ######################