Module: sip-router
Branch: andrei/cdefs2doc
Commit: a9255ea7e90978fcd6f955f51aae28883efc6282
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a9255ea…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Oct 19 18:05:25 2009 +0200
doc: script to generate cfg var lists from C code
Added a perl script that generates the list of config variables
defined in a C file.
The script uses gcc to generate a syntax tree structure for an
entire file and then parses and uses the tree to locate
the config vars. definition, initialization and default values.
E.g.: dump_cfg_defs.pl --file ../../../cfg_core.c --grp core
=> ...
31. core.udp_mtu
fallback to a congestion controlled protocol if send size
exceeds udp_mtu.
Default: 0.
Range: 0 - 65535.
Type: integer.
...
The config group (--grp) needs to be specified only if it cannot
be auto-detected (under normal circumstances it is auto-detected
from the type name of the variable holding the default values,
e.g. cfg_group_core).
If the default values are set in the same .c file, they will be
added to the list.
Note: the script requires a patched version of the
GCC:TranslationUnit perl package. To get the patch use:
dump_cfg_defs.pl --patch
---
doc/scripts/cdefs2doc/dump_cfg_defs.pl | 434 ++++++++++++++++++++++++++++++++
1 files changed, 434 insertions(+), 0 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=a92…
Module: sip-router
Branch: andrei/cdefs2doc
Commit: 8de15e2147533941b18a1ea1c018b420a667a374
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8de15e2…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Oct 19 18:36:52 2009 +0200
doc: added makefiles for auto-gen. rpc and cfg vars lists
---
doc/cfg_list/Makefile | 145 +++++++++++++++++++++++++++++++++++++++++++++++++
doc/rpc_list/Makefile | 144 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 289 insertions(+), 0 deletions(-)
diff --git a/doc/cfg_list/Makefile b/doc/cfg_list/Makefile
new file mode 100644
index 0000000..881f735
--- /dev/null
+++ b/doc/cfg_list/Makefile
@@ -0,0 +1,145 @@
+
+COREPATH=../..
+
+#include $(COREPATH)/Makefile.defs
+
+CFG2TXT=../scripts/cdefs2doc/dump_cfg_defs.pl
+
+# list of files contanining cfg defs in the following format:
+# <filename>:<cfg_grp_name>
+files_list=$(COREPATH)/cfg_core.c:core $(COREPATH)/tcp_options.c:tcp \
+ $(COREPATH)/sctp_options.c:sctp \
+ $(COREPATH)/modules_s/maxfwd/maxfwd.c:maxfwd \
+ $(COREPATH)/modules/tm/config.c:tm
+
+# list of excluded groups
+grp_exclude=pa
+# list of file prefixes to exclude (full path needed)
+file_exclude= $(COREPATH)/modules_s/tls/
+
+# special per file group overrides
+# format= grp_filename=... ,where filename does not contain the extension
+# e.g.:
+# grp_f_tcp_options=tcp
+# grp_f_sctp_options=sctp
+
+# special per group group name overrides
+# e.g.:
+# grp_g_maxfwd=mf
+
+# override auto-detected group if set to 1 (else the group is used inside the
+# file only if it cannot be aut-odetected)
+ifeq ($(group_override),1)
+override force_grp=force-
+else
+override force_grp=
+endif
+
+# command used for gcc (contains extra includes)
+gcc=gcc -I$(COREPATH)/lib -I/usr/include/libxml2
+
+#filtered files list
+flist=$(filter-out $(join $(file_exclude),%),\
+ $(filter-out $(join %:,$(grp_exclude)),$(files_list)) )
+
+# throws an error if input is not in the format filename:grp
+check_fname_grp=$(if $(filter-out 2,$(words $(subst :, ,$(1)))),\
+ $(error bad format "$(1)", it should be filename:grp))
+
+# get prereq from file:grp (get_prereq(file:grp) => file)
+get_prereq=$(firstword $(subst :, ,$(1)))
+
+# get grp from file:grp (get_grp(file:grp) => grp)
+get_listed_grp=$(word 2, $(subst :, ,$(1)))
+
+# get base file name from file:grp: get_bname(file:grp)
+# => basename(file) without extension (e.g. get_bname(foo/bar.c:x) => bar)
+#
+get_bname=$(basename $(notdir $(call get_prereq,$(1))))
+
+#get grp from file:grp, using the overrides
+get_grp=$(strip $(if $(grp_f_$(call get_bname,$(1))), \
+ $(grp_f_$(call get_bname,$(1))),\
+ $(if $(grp_g_$(call get_listed_grp,$(1))),\
+ $(grp_g_$(call get_listed_grp,$(1))),\
+ $(call get_listed_grp,$(1))) ) )
+
+# get target from file:grp (get_target(file:grp) => cfg_grp.txt)
+get_target=cfg_$(call get_grp,$(1)).txt
+
+define mk_rules
+
+$(call check_fname_grp, $(1))
+
+#$$(info generating cfg_$$(call get_grp,$(1)).txt: $$(call get_prereq,$(1)))
+
+$$(call get_target,$(1)): $$(call get_prereq,$(1)) Makefile $(CFG2TXT)
+ $(CFG2TXT) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
+ --gcc="$(gcc)" > "$$@" || (rm -f "$$@"; exit 1)
+
+
+clean_$$(call get_target,$(1)):
+ rm -f "$$(call get_target,$(1))"
+
+all: $$(call get_target,$(1))
+
+clean: clean_$$(call get_target,$(1))
+
+
+endef
+
+
+# help will be the default rule (on-purpose since without having a patched
+# GCC:TranslationUnit module, make all won't work)
+.PHONY: help
+help:
+ @echo "To regenerate $(foreach f,$(flist),$(call get_target,$f) )"
+ @echo "type: $(MAKE) all ."
+ @echo "or to regenerate all the cfg documentation by searching all"
+ @echo " the source files for definitions, type: $(MAKE) autogen ."
+ @echo "NOTE: you need the GCC:TranslationUnit perl module with an "
+ @echo "extra patch applied (see $(CFG2TXT) --patch)."
+
+.PHONY: all
+all:
+
+.PHONY: clean
+clean:
+
+.PHONY: proper
+proper:
+ @rm -f cfg_*.txt
+
+find_cfg_files_cmd= find $(COREPATH) -type f -name "*.c" \
+ -exec grep "cfg_def_t[ ][a-zA-Z0-9_]*\[\][ ]*=" /dev/null {} \; \
+ | cut -d: -f1
+
+# shell command to generate a file:grp list from a list of files
+# grp will be the modulename if the file is in a module directory or
+# the file name with the extension and _cfg, cfg_ or _options stripped out of
+# it.
+# output: list of " "filename":"grpname
+gen_file_grp_cmd=\
+sed -e "s!\(.*/modules[^/]*/\([^/][^/]*\)/.*\)! \1:\2!" \
+ -e "s!^\([^ ].*/\([^/.]*\)[^/]*$$\)!\1:\2!" \
+ -e "s!^\([^ :]*\):\(.*\)_cfg[_]*!:\1:\2!" \
+ -e "s!^\([^ :]*\):\(.*\)cfg[_]*!\1:\2!" \
+ -e "s!^\([^ :]*\):\(.*\)_options[_]*!\1:\2!"
+
+# finds all the files containing cfg defs
+.PHONY: find
+find:
+ @$(find_cfg_files_cmd)
+
+# print the list of the autogenerated files
+.PHONY: print-lst
+print-lst:
+ @$(find_cfg_files_cmd) | $(gen_file_grp_cmd)
+
+# try to generate the docs from all the sources
+.PHONY: autogen
+autogen:
+ LST=`$(find_cfg_files_cmd)| $(gen_file_grp_cmd) | xargs echo` && \
+ [ -n "$$LST" ] && $(MAKE) all files_list="$$LST"
+
+$(foreach f,$(flist),$(eval $(call mk_rules,$(f))))
diff --git a/doc/rpc_list/Makefile b/doc/rpc_list/Makefile
new file mode 100644
index 0000000..18d6918
--- /dev/null
+++ b/doc/rpc_list/Makefile
@@ -0,0 +1,144 @@
+
+COREPATH=../..
+
+#include $(COREPATH)/Makefile.defs
+
+CFG2TXT=../scripts/cdefs2doc/dump_rpcs.pl
+
+# list of files contanining rpc defs in the following format:
+# <filename>:<cfg_grp_name>
+# one way to quickly fill it up is pasting the output of
+# make print-lst|xargs echo
+files_list=$(COREPATH)/core_cmd.c:core
+
+# list of excluded groups
+grp_exclude=pa
+# list of file prefixes to exclude (full path needed)
+file_exclude=$(COREPATH)/modules_s/tls/
+
+# special per file group overrides
+# format= grp_filename=... ,where filename does not contain the extension
+# e.g.:
+# grp_f_tcp_options=tcp
+# grp_f_sctp_options=sctp
+
+# special per group group name overrides
+# e.g.:
+# grp_g_maxfwd=mf
+
+# override auto-detected group if set to 1 (else the group is used inside the
+# file only if it cannot be aut-odetected)
+ifeq ($(group_override),1)
+override force_grp=force-
+else
+override force_grp=
+endif
+
+# command used for gcc (contains extra includes)
+gcc=gcc -I$(COREPATH)/lib -I/usr/include/libxml2
+
+#filtered files list
+flist=$(filter-out $(join $(file_exclude),%),\
+ $(filter-out $(join %:,$(grp_exclude)),$(files_list)) )
+
+# throws an error if input is not in the format filename:grp
+check_fname_grp=$(if $(filter-out 2,$(words $(subst :, ,$(1)))),\
+ $(error bad format "$(1)", it should be filename:grp))
+
+# get prereq from file:grp (get_prereq(file:grp) => file)
+get_prereq=$(firstword $(subst :, ,$(1)))
+
+# get grp from file:grp (get_grp(file:grp) => grp)
+get_listed_grp=$(word 2, $(subst :, ,$(1)))
+
+# get base file name from file:grp: get_bname(file:grp)
+# => basename(file) without extension (e.g. get_bname(foo/bar.c:x) => bar)
+#
+get_bname=$(basename $(notdir $(call get_prereq,$(1))))
+
+#get grp from file:grp, using the overrides
+get_grp=$(strip $(if $(grp_f_$(call get_bname,$(1))), \
+ $(grp_f_$(call get_bname,$(1))),\
+ $(if $(grp_g_$(call get_listed_grp,$(1))),\
+ $(grp_g_$(call get_listed_grp,$(1))),\
+ $(call get_listed_grp,$(1))) ) )
+
+# get target from file:grp (get_target(file:grp) => rpc_grp.txt)
+get_target=rpc_$(call get_grp,$(1)).txt
+
+define mk_rules
+
+$(call check_fname_grp, $(1))
+
+#$$(info generating rpc_$$(call get_grp,$(1)).txt: $$(call get_prereq,$(1)))
+
+$$(call get_target,$(1)): $$(call get_prereq,$(1)) Makefile $(CFG2TXT)
+ $(CFG2TXT) --file $$< --$(force_grp)grp=$$(call get_grp,$(1)) \
+ --gcc="$(gcc)" > "$$@" || (rm -f "$$@"; exit 1)
+
+
+clean_$$(call get_target,$(1)):
+ rm -f "$$(call get_target,$(1))"
+
+all: $$(call get_target,$(1))
+
+clean: clean_$$(call get_target,$(1))
+
+
+endef
+
+
+# help will be the default rule (on-purpose since without having a patched
+# GCC:TranslationUnit module, make all won't work)
+.PHONY: help
+help:
+ @echo "To regenerate $(foreach f,$(flist),$(call get_target,$f) )"
+ @echo "type: $(MAKE) all ."
+ @echo "or to regenerate all the rpc lists by searching all"
+ @echo " the source files for definitions, type: $(MAKE) autogen ."
+ @echo "NOTE: you need the GCC:TranslationUnit perl module with an "
+ @echo "extra patch applied (see $(CFG2TXT) --patch)."
+
+.PHONY: all
+all:
+
+.PHONY: clean
+clean:
+
+.PHONY: proper
+proper:
+ @rm -f rpc_*.txt
+
+find_rpc_files_cmd= find $(COREPATH) -type f -name "*.c" \
+ -exec grep "rpc_export_t[ ][a-zA-Z0-9_]*\[\][ ]*=" /dev/null {} \; \
+ | cut -d: -f1
+
+# shell command to generate a file:grp list from a list of files
+# grp will be the modulename if the file is in a module directory or
+# the file name with the extension and _cmd, cmd_ or _rpc stripped out of
+# it.
+# output: list of " "filename":"grpname
+gen_file_grp_cmd=\
+sed -e "s!\(.*/modules[^/]*/\([^/][^/]*\)/.*\)! \1:\2!" \
+ -e "s!^\([^ ].*/\([^/.]*\)[^/]*$$\)!\1:\2!" \
+ -e "s!^\([^ :]*\):\(.*\)_cmd[_]*!\1:\2!" \
+ -e "s!^\([^ :]*\):\(.*\)cmd[_]*!\1:\2!" \
+ -e "s!^\([^ :]\):\(.*\)_rpc[_]*!\1:\2!"
+
+# finds all the files containing cfg defs
+.PHONY: find
+find:
+ @$(find_rpc_files_cmd)
+
+# print the list of the autogenerated files
+.PHONY: print-lst
+print-lst:
+ @$(find_rpc_files_cmd) | $(gen_file_grp_cmd)
+
+# try to generate the docs from all the sources
+.PHONY: autogen
+autogen:
+ LST=`$(find_rpc_files_cmd)| $(gen_file_grp_cmd) | xargs echo` && \
+ [ -n "$$LST" ] && $(MAKE) all files_list="$$LST"
+
+$(foreach f,$(flist),$(eval $(call mk_rules,$(f))))
Module: sip-router
Branch: andrei/cdefs2doc
Commit: 2b37b2df33aeec32448fa2a765538e561507720b
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2b37b2d…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Oct 19 18:22:55 2009 +0200
doc: script to generate rpc lists from C code
Added a perl script that generates the list of RPCs defined in a C
file. The list contains also the RPC documentation.
The script works by looking for the first rpc_export_t array in
the file that has an initializer and using it to get all the rpc
definitions. Then it looks for all the corresponding *doc
variables (char* arrays holding the help message and the
signature) and extracts the doc string from their initializer.
E.g.:
dump_rpcs.pl --file ../../../core_cmd.c
...
37. dst_blacklist.view
dst blacklist dump in human-readable format.
...
---
doc/scripts/cdefs2doc/dump_rpcs.pl | 389 ++++++++++++++++++++++++++++++++++++
1 files changed, 389 insertions(+), 0 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=2b3…
Module: sip-router
Branch: andrei/cdefs2doc
Commit: 56a77aea9b3af5540f2415f0d8b751375f5d876d
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=56a77ae…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Mon Oct 19 18:30:45 2009 +0200
doc: script to generate select lists from C code
Added a perl script that tries to generate the list of selects
defined in a C file.
The script works by looking for the first select_row_t array with
an initializer in the .c file. It then tries to generate the list
of all possible selects (but it still has some bugs, especially on
matching params to a select part).
Note: there is no documentation generated besides the list
(the select format is not auto-documented).
---
doc/scripts/cdefs2doc/dump_selects.pl | 392 +++++++++++++++++++++++++++++++++
1 files changed, 392 insertions(+), 0 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=56a…