summaryrefslogtreecommitdiff
path: root/doc/user/scanners.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/user/scanners.xml')
-rw-r--r--doc/user/scanners.xml111
1 files changed, 75 insertions, 36 deletions
diff --git a/doc/user/scanners.xml b/doc/user/scanners.xml
index 749db36..32faf29 100644
--- a/doc/user/scanners.xml
+++ b/doc/user/scanners.xml
@@ -1,6 +1,27 @@
+<?xml version='1.0'?>
+<!DOCTYPE sconsdoc [
+ <!ENTITY % scons SYSTEM "../scons.mod">
+ %scons;
+
+ <!ENTITY % builders-mod SYSTEM "../generated/builders.mod">
+ %builders-mod;
+ <!ENTITY % functions-mod SYSTEM "../generated/functions.mod">
+ %functions-mod;
+ <!ENTITY % tools-mod SYSTEM "../generated/tools.mod">
+ %tools-mod;
+ <!ENTITY % variables-mod SYSTEM "../generated/variables.mod">
+ %variables-mod;
+]>
+
+<chapter id="chap-scanners"
+ xmlns="http://www.scons.org/dbxsd/v1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0/scons.xsd scons.xsd">
+<title>Writing Scanners</title>
+
<!--
- Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 The SCons Foundation
+ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 The SCons Foundation
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@@ -151,7 +172,7 @@ over the file scanning rather than being called for each input line:
</para>
<programlisting>
- include filename.foo
+include filename.foo
</programlisting>
<para>
@@ -165,13 +186,13 @@ over the file scanning rather than being called for each input line:
</para>
<programlisting>
- import re
-
- include_re = re.compile(r'^include\s+(\S+)$', re.M)
-
- def kfile_scan(node, env, path, arg):
- contents = node.get_text_contents()
- return env.File(include_re.findall(contents))
+import re
+
+include_re = re.compile(r'^include\s+(\S+)$', re.M)
+
+def kfile_scan(node, env, path, arg):
+ contents = node.get_text_contents()
+ return env.File(include_re.findall(contents))
</programlisting>
<para>
@@ -274,9 +295,9 @@ over the file scanning rather than being called for each input line:
</para>
<programlisting>
- kscan = Scanner(function = kfile_scan,
- skeys = ['.k'])
- env.Append(SCANNERS = kscan)
+kscan = Scanner(function = kfile_scan,
+ skeys = ['.k'])
+env.Append(SCANNERS = kscan)
</programlisting>
<para>
@@ -285,24 +306,38 @@ over the file scanning rather than being called for each input line:
</para>
- <programlisting>
- import re
-
- include_re = re.compile(r'^include\s+(\S+)$', re.M)
-
- def kfile_scan(node, env, path):
- contents = node.get_text_contents()
- includes = include_re.findall(contents)
- return env.File(includes)
-
- kscan = Scanner(function = kfile_scan,
- skeys = ['.k'])
-
- env = Environment(ENV = {'PATH' : '/usr/local/bin'})
- env.Append(SCANNERS = kscan)
-
- env.Command('foo', 'foo.k', 'kprocess &lt; $SOURCES &gt; $TARGET')
- </programlisting>
+ <scons_example name="scanners_scan">
+ <file name="SConstruct" printme="1">
+ import re
+
+ include_re = re.compile(r'^include\s+(\S+)$', re.M)
+
+ def kfile_scan(node, env, path):
+ contents = node.get_text_contents()
+ includes = include_re.findall(contents)
+ return env.File(includes)
+
+ kscan = Scanner(function = kfile_scan,
+ skeys = ['.k'])
+
+ env = Environment(ENV = {'PATH' : '__ROOT__/usr/local/bin'})
+ env.Append(SCANNERS = kscan)
+
+ env.Command('foo', 'foo.k', 'kprocess &lt; $SOURCES &gt; $TARGET')
+ </file>
+ <file name="foo.k">
+include other_file
+ </file>
+ <file name="other_file">
+other_file
+ </file>
+ <directory name="__ROOT__/usr"></directory>
+ <directory name="__ROOT__/usr/local"></directory>
+ <directory name="__ROOT__/usr/local/bin"></directory>
+ <file name="__ROOT_/usr/local/bin/kprocess" chmod="755">
+cat
+ </file>
+ </scons_example>
<!--
@@ -316,7 +351,7 @@ over the file scanning rather than being called for each input line:
</para>
- <scons_output example="scan">
+ <scons_output example="scanners_scan" suffix="1">
<scons_output_command>scons -Q</scons_output_command>
<scons_output_command output=" [CHANGE THE CONTENTS OF other_file]">edit other_file</scons_output_command>
<scons_output_command>scons -Q</scons_output_command>
@@ -356,11 +391,13 @@ over the file scanning rather than being called for each input line:
</para>
- <programlisting>
- kscan = Scanner(function = kfile_scan,
- skeys = ['.k'],
- path=FindPathDirs('KPATH'))
- </programlisting>
+ <scons_example name="scanners_findpathdirs">
+ <file name="SConstruct" printme="1">
+kscan = Scanner(function = kfile_scan,
+ skeys = ['.k'],
+ path=FindPathDirs('KPATH'))
+ </file>
+ </scons_example>
<para>
@@ -374,3 +411,5 @@ over the file scanning rather than being called for each input line:
</para>
</section>
+
+</chapter>