20230322
[shlib.git] / bin / constructor
blobeef7bc3ffb1f89a13f97223f59b094fe52e71880
1 #!/bin/bash
2 ############################################################
3 # source: build
4 # author: devenkong(18151155@qq.com)
5 # date: 2022-04-21
6 ############################################################
7 # note:
8 # src-pkg compile utility. it orgnize compile file list
9 # and paramters like Makefile, but it is implemented by shell
10 # script.
11 ############################################################
14 # todoļ¼š
15 # @
16 # @
19 . shlibinc
21 include gplib.shlib
23 include stdio.shlib
24 #include term.shlib
25 include args.shlib
27 #include paths.shlib
29 ##############################
30 # section: public comment info
31 ##############################
35 ##############################
36 # section: variable define
37 ##############################
41 scripttest_desc_str="
42 |prog $0 'project build util-program.'
43 |blank '[compile operation]'
45 |blank '[general]'
46 |param |- |-- |---help |= |%<help> |&<on_help> |'this helper text doc.'
48 |blank '[information query]'
49 |param |- |-- |---list |=<content> |%<list> |&<on_list> |'<null>/target/pkg/instpkg/dest/dep.'
50 |param |- |-- |---get |=<pkgname> |%<get> |&<on_get> |'download the pkg.'
52 |param |- |-- |---init |= |%<init> |&<on_init> |'unpack archive src code pkg from backup dir to current dir.'
53 |param |- |-- |---srcbak |= |%<srcbak> |&<on_srcbak> |'backup src to default src bak dir, which is configured in build paramter files.'
54 |param |- |-- |---clean |= |%<clean> |&<on_clean> |'clean files in compile procedure.'
55 |param |- |-- |---distclean |= |%<distclean> |&<on_distclean> |'clean src pkg .'
57 |blank '[src-pkg setting]'
58 |param |- |-- |---setting |= |%<setting> |&<on_setting> |'set src pkg build paramters.'
59 |param |- |-- |---arch |=<arch> |%<arch> |&<on_arch> |'target cpu architechture.'
60 |param |- |-- |---release |= |%<release> |&<on_release> |'build release version.'
61 |param |- |-- |---debug |= |%<debug> |&<on_debug> |'build debug version.'
63 |blank '[build all]'
64 |param |- |-- |---config |= |%<config> |&<on_config> |'config src pkg.'
65 |param |- |-- |---test |= |%<test> |&<on_test> |'run test script for current src pkg.'
66 |param |- |-- |---doc |= |%<doc> |&<on_doc> |'build man and info helper doc.'
67 |param |- |-- |---umdoc |= |%<umdoc> |&<on_umdoc> |'build user manual doc in various kinds of doc type.'
68 |param |- |-- |---pkgs |= |%<pkgs> |&<on_pkgs> |'build compiled binary executables to an installable pkg.'
69 |param |- |-- |---install |= |%<install> |&<on_install> |'install compiled install pkg.'
71 |blank '[build type]'
72 |param |- |-- |---default |= |%<default> |&<on_default> |'compile all dest in a src pkg.'
73 |param |- |-- |---all |= |%<all> |&<on_all> |'buildinclude step of default, test, doc, umdoc, pkgs.'
74 |param |- |-- |---full |= |%<full> |&<on_full> |'compile all platform setted cpu platform in compiler toolchain.'
75 |param |- |-- |---cross |= |%<cross> |&<on_cross> |'build default cross platform setted in src-pkg. it is setted by arch subcmd.'
76 |param |- |-- |---target |=<arch> |%<target> |&<on_target> |'build specified cross platform.'
77 |param |- |-- |---srcpkg |=<pkgname> |%<srcpkg> |&<on_srcpkg> |'build specified sub src pkg.'
78 |param |- |-- |---instpkg |=<instpkg> |%<instpkg> |&<on_instpkg> |'build relative executables in a specified install pkg.'
79 |param |- |-- |---dest |=<destname> |%<dest> |&<on_dest> |'build specified executables in a src pkg.'
81 |blank '[build misc]'
82 |param |- |-- |---example |= |%<example> |&<on_example> |'build example code if it exist.'
83 |param |- |-- |---webpages |= |%<webpages> |&<on_webpages> |'build webpages translate various doc file .'
85 |blank '[doc gen]'
86 |param |- |-- |---mandoc |= |%<mandoc> |&<on_mandoc> |'build man doc.'
87 |param |- |-- |---infodoc |= |%<infodoc> |&<on_infodoc> |'build info doc.'
88 |param |- |-- |---tutorial |= |%<tutorial> |&<on_tutorial> |'build tutorial doc. it is an example guide doc.'
89 |param |- |-- |---pdfdoc |= |%<pdfdoc> |&<on_pdfdoc> |'build pdf user manual doc.'
90 |param |- |-- |---htmldoc |= |%<htmldoc> |&<on_htmldoc> |'build html user manual doc.'
92 |blank
98 helper="
99 help - this document.
100 [compile operation]
101 clean - clean all the project under this workspace.
102 all - default. use native compiler to compile program.
103 cross - use CROSS_COMPILE to compile a cross program.
105 [install operation]
106 pkg - copy headers libs and programs into pkg dir.
107 devinstall - install pkg to system.
108 install - install executables to system.
109 crosspkg - copy headers libs and programs into pkg dir.
110 crossdevinstall - install pkg to cross-compiler.
111 crossinstall - install executables to system.
113 # [project operation]
114 addtestprj - create test project as a templete, exe & lib.
115 addtestprj - create test project as a templete, exe & lib.
116 list - list project in this workspace
117 addexe PRJ=<name> - add a new executable project from templete.
118 addlib PRJ=<name> - add a new library project from templete.
119 files.
120 listclear - clear all sub project in ws compile list.
121 rename OPRJ=<pld-name> PRJ=<new-name>
122 - rename a project.
124 [version operation]
125 version - get workspace version as A.B.C format.
126 verinc1 - increase first version number A.
127 verinc2 - increase second version number B.
128 verinc3 - increase third version number C.
130 # [misc operation]
131 check-env - check running enviroument, check make, gcc, inc
132 path, lib path, and so on. espesially usefull under
133 CROSS_COMPILE, it can automatically check lib path.
134 # distclean - make src-tarball all project in workspace to
135 - source dir, clean project dirs, move other
136 - dirs to misc.
137 backup - distclean, and src-tarball the workspace.
138 init - init project code in source dir, add them to workspace.
139 src-tarball - make a src tarball for this workspace.
144 # general
145 v_help=
146 v_default=
148 # information query
149 v_list=
150 v_get=
152 v_init=
153 v_srcbak=
154 v_clean=
155 v_distclean=
157 # src-pkg setting
158 v_setting=
159 v_arch=
160 v_release=
161 v_debug=
163 # build all
164 v_config=
165 v_test=
166 v_doc=
167 v_umdoc=
168 v_pkgs=
169 v_install=
171 # build type
172 v_all=
173 v_full=
174 v_cross=
175 v_target=
176 v_srcpkg=
177 v_instpkg=
178 v_dest=
180 # build misc
181 v_example=
182 v_webpages=
184 # doc gen
185 v_mandoc=
186 v_infodoc=
187 v_tutorial=
188 v_pdfdoc=
189 v_htmldoc=
193 ##############################
194 # section: private function
195 ##############################
198 # fsyntax: on_subcmd_proc <param_name> <param_value>
199 # fdesc: on all sub-cmd response. it invoke paramter proc function
200 # defined in src pkg.
202 on_subcmd_proc ()
204 # TBD: invoke sub-cmd proc function defined in src pkg.
209 # fsyntax: on_help
210 # fdesc: on help sub-cmd.
212 on_help ()
214 # TBD:
219 # fsyntax: on_help
220 # fdesc: on help sub-cmd.
222 on_default ()
224 # TBD:
230 # fsyntax: on_help
231 # fdesc: on help sub-cmd.
233 on_list ()
235 # TBD:
240 # fsyntax: on_help
241 # fdesc: on help sub-cmd.
243 on_get ()
245 # TBD:
250 # fsyntax: on_help
251 # fdesc: on help sub-cmd.
253 on_init ()
255 # TBD:
260 # fsyntax: on_help
261 # fdesc: on help sub-cmd.
263 on_srcbak ()
265 # TBD:
270 # fsyntax: on_help
271 # fdesc: on help sub-cmd.
273 on_clean ()
275 # TBD:
280 # fsyntax: on_help
281 # fdesc: on help sub-cmd.
283 on_distclean ()
285 # TBD:
291 # fsyntax: on_help
292 # fdesc: on help sub-cmd.
294 on_setting ()
296 # TBD:
301 # fsyntax: on_help
302 # fdesc: on help sub-cmd.
304 on_arch ()
306 # TBD:
311 # fsyntax: on_help
312 # fdesc: on help sub-cmd.
314 on_release ()
316 # TBD:
321 # fsyntax: on_help
322 # fdesc: on help sub-cmd.
324 on_debug ()
326 # TBD:
332 # fsyntax: on_help
333 # fdesc: on help sub-cmd.
335 on_config ()
337 # TBD:
342 # fsyntax: on_help
343 # fdesc: on help sub-cmd.
345 on_test ()
347 # TBD:
352 # fsyntax: on_help
353 # fdesc: on help sub-cmd.
355 on_doc ()
357 # TBD:
362 # fsyntax: on_help
363 # fdesc: on help sub-cmd.
365 on_umdoc ()
367 # TBD:
372 # fsyntax: on_help
373 # fdesc: on help sub-cmd.
375 on_pkgs ()
377 # TBD:
382 # fsyntax: on_help
383 # fdesc: on help sub-cmd.
385 on_install ()
387 # TBD:
393 # fsyntax: on_help
394 # fdesc: on help sub-cmd.
396 on_all ()
398 # TBD:
403 # fsyntax: on_help
404 # fdesc: on help sub-cmd.
406 on_full ()
408 # TBD:
413 # fsyntax: on_help
414 # fdesc: on help sub-cmd.
416 on_cross ()
418 # TBD:
423 # fsyntax: on_help
424 # fdesc: on help sub-cmd.
426 on_target ()
428 # TBD:
433 # fsyntax: on_help
434 # fdesc: on help sub-cmd.
436 on_srcpkg ()
438 # TBD:
443 # fsyntax: on_help
444 # fdesc: on help sub-cmd.
446 on_instpkg ()
448 # TBD:
453 # fsyntax: on_help
454 # fdesc: on help sub-cmd.
456 on_dest ()
458 # TBD:
464 # fsyntax: on_help
465 # fdesc: on help sub-cmd.
467 on_example ()
469 # TBD:
474 # fsyntax: on_help
475 # fdesc: on help sub-cmd.
477 on_webpages ()
479 # TBD:
485 # fsyntax: on_help
486 # fdesc: on help sub-cmd.
488 on_mandoc ()
490 # TBD:
495 # fsyntax: on_help
496 # fdesc: on help sub-cmd.
498 on_infodoc ()
500 # TBD:
505 # fsyntax: on_help
506 # fdesc: on help sub-cmd.
508 on_tutorial ()
510 # TBD:
515 # fsyntax: on_help
516 # fdesc: on help sub-cmd.
518 on_pdfdoc ()
520 # TBD:
525 # fsyntax: on_help
526 # fdesc: on help sub-cmd.
528 on_htmldoc ()
530 # TBD:
536 ##############################
537 # section: public function
538 ##############################
542 main_build ()
545 return
549 #echo xxxxxxxxxxaaa
550 #exit
552 main_build "$@"
555 ##############################
556 # section: file tail
557 ##############################