[gobject-introspection] tools: use a template to generate the tools scripts
- From: Dieter Verfaillie <dieterv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] tools: use a template to generate the tools scripts
- Date: Mon, 29 Jun 2015 15:07:29 +0000 (UTC)
commit 7e0014607513fc335f96baf9408cdeb6d29c1375
Author: Dieter Verfaillie <dieterv optionexplicit be>
Date: Tue Apr 21 07:20:43 2015 +0200
tools: use a template to generate the tools scripts
g-ir-annotation-tool, g-ir-doc-tool and g-ir-scanner where identical
except for the module and function being invoked.
Avoid code duplication and generate these from a common template.
Makefile-tools.am | 18 +++----
tools/g-ir-annotation-tool.in | 58 ---------------------
tools/g-ir-scanner.in | 58 ---------------------
tools/{g-ir-doc-tool.in => g-ir-tool-template.in} | 4 +-
4 files changed, 10 insertions(+), 128 deletions(-)
---
diff --git a/Makefile-tools.am b/Makefile-tools.am
index 34d2a25..dbd264c 100644
--- a/Makefile-tools.am
+++ b/Makefile-tools.am
@@ -6,22 +6,20 @@ bin_SCRIPTS += g-ir-doc-tool
endif
EXTRA_DIST += \
- tools/g-ir-scanner.in \
- tools/g-ir-annotation-tool.in \
- tools/g-ir-doc-tool.in
+ tools/g-ir-tool-template.in
-TOOL_SUBSTITUTIONS = sed -e s,@libdir\@,$(libdir), -e s,@datarootdir\@,$(datarootdir), -e
s,@PYTHON\@,$(PYTHON),
+TOOL_SUBSTITUTIONS = -e s,@libdir\@,$(libdir), -e s,@datarootdir\@,$(datarootdir), -e s,@PYTHON\@,$(PYTHON),
-g-ir-scanner: tools/g-ir-scanner.in _giscanner.la Makefile
- $(AM_V_GEN) $(TOOL_SUBSTITUTIONS) $< > $ tmp && mv $ tmp $@
+g-ir-scanner: tools/g-ir-tool-template.in _giscanner.la Makefile
+ $(AM_V_GEN) sed $(TOOL_SUBSTITUTIONS) -e s,@TOOL_MODULE\@,scannermain, -e
s,@TOOL_FUNCTION\@,scanner_main, $< > $ tmp && mv $ tmp $@
@chmod a+x $@
-g-ir-annotation-tool: tools/g-ir-annotation-tool.in _giscanner.la Makefile
- $(AM_V_GEN) $(TOOL_SUBSTITUTIONS) $< > $ tmp && mv $ tmp $@
+g-ir-annotation-tool: tools/g-ir-tool-template.in _giscanner.la Makefile
+ $(AM_V_GEN) sed $(TOOL_SUBSTITUTIONS) -e s,@TOOL_MODULE\@,annotationmain, -e
s,@TOOL_FUNCTION\@,annotation_main, $< > $ tmp && mv $ tmp $@
@chmod a+x $@
-g-ir-doc-tool: tools/g-ir-doc-tool.in _giscanner.la Makefile
- $(AM_V_GEN) $(TOOL_SUBSTITUTIONS) $< > $ tmp && mv $ tmp $@
+g-ir-doc-tool: tools/g-ir-tool-template.in _giscanner.la Makefile
+ $(AM_V_GEN) sed $(TOOL_SUBSTITUTIONS) -e s,@TOOL_MODULE\@,docmain, -e s,@TOOL_FUNCTION\@,doc_main, $<
$ tmp && mv $ tmp $@
@chmod a+x $@
g_ir_compiler_SOURCES = tools/compiler.c
diff --git a/tools/g-ir-doc-tool.in b/tools/g-ir-tool-template.in
similarity index 95%
rename from tools/g-ir-doc-tool.in
rename to tools/g-ir-tool-template.in
index e3bf8a3..43eea46 100644
--- a/tools/g-ir-doc-tool.in
+++ b/tools/g-ir-tool-template.in
@@ -54,5 +54,5 @@ if srcdir is not None:
__builtin__.__dict__['DATADIR'] = datadir
sys.path.insert(0, pylibdir)
-from giscanner.docmain import doc_main
-sys.exit(doc_main(sys.argv))
+from giscanner TOOL_MODULE@ import @TOOL_FUNCTION@
+sys.exit(@TOOL_FUNCTION@(sys.argv))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]