1# Copyright 2003, 2004 Vladimir Prus
2# Distributed under the Boost Software License, Version 1.0.
3# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
4
5#  This file shows some of the primary customization mechanisms in B2 V2
6#  and should serve as a basic for your own customization.
7#  Each part has a comment describing its purpose, and you can pick the parts
8#  which are relevant to your case, remove everything else, and then change names
9#  and actions to taste.
10
11import os ;
12
13#  Declare a new target type. This allows B2 to do something sensible
14#  when targets with the .verbatim extension are found in sources.
15import type ;
16type.register VERBATIM : verbatim ;
17
18#  Declare a dependency scanner for the new target type. The
19#  'inline-file.py' script does not handle includes, so this is
20#  only for illustraction.
21import scanner ;
22#  First, define a new class, derived from 'common-scanner',
23#  that class has all the interesting logic, and we only need
24#  to override the 'pattern' method which return regular
25#  expression to use when scanning.
26class verbatim-scanner : common-scanner
27{
28    rule pattern ( )
29    {
30        return "//###include[ ]*\"([^\"]*)\"" ;
31    }
32}
33
34# Register the scanner class. The 'include' is
35# the property which specifies the search path
36# for includes.
37scanner.register verbatim-scanner : include ;
38# Assign the scanner class to the target type.
39# Now, all .verbatim sources will be scanned.
40# To test this, build the project, touch the
41# t2.verbatim file and build again.
42type.set-scanner VERBATIM : verbatim-scanner ;
43
44import generators ;
45generators.register-standard verbatim.inline-file : VERBATIM : CPP ;
46
47# Note: To use Cygwin Python on Windows change the following line
48# to "python inline_file.py $(<) $(>)"
49# Also, make sure that "python" in in PATH.
50actions inline-file
51{
52    "./inline_file.py" $(<) $(>)
53}
54
55if [ os.name ] = VMS
56{
57    actions inline-file
58    {
59        python inline_file.py $(<:W) $(>:W)
60    }
61}
62