Rename senfscons to site_scons and move python files arround
[senf.git] / site_scons / site_tools / PkgDraw.py
diff --git a/site_scons/site_tools/PkgDraw.py b/site_scons/site_tools/PkgDraw.py
new file mode 100644 (file)
index 0000000..5cd0989
--- /dev/null
@@ -0,0 +1,35 @@
+## \file
+# \brief PkgDraw builder
+
+## \package senfscons.PkgDraw
+# \brief Generate network packet diagram
+#
+# This builder will call pkgdraw to scan a header file and create network package diagrams
+# from SENF_PARSER macro calls.
+#
+# \par Construction Envrionment Variables:
+# <table class="senf">
+# <tr><td>\c PKGDRAWCOM</td><td>pkgdraw command, defaults to \c #/doclib/pkgdraw</td></tr>
+# <tr><td>\c PKGDRAWPACKETS</td><td>list packet types to include in
+#            the diagram, defaults to empty (include all packets)</td></tr>
+# </table>
+#
+# \ingroup builder
+
+import os
+import SCons.Builder, SCons.Action
+
+PkgDraw = SCons.Builder.Builder(
+    suffix = ".png",
+    src_suffix = ".hh",
+    action = SCons.Action.Action("$PKGDRAWCOM"),
+    single_source = 1)
+
+def generate(env):
+    env['BUILDERS']['PkgDraw'] = PkgDraw
+    env['PKGDRAW'] = "pkgdraw"
+    env['PKGDRAWCOM'] = "$PKGDRAW $SOURCE $TARGET $PKGDRAWPACKETS -- $CPPFLAGS $_CPPINCFLAGS $_CPPDEFFLAGS"
+    env['PKGDRAWPACKETS'] = ''
+
+def exists(env):
+    return env.Detect("#/doclib/pkgdraw")