1 | # Copyright (C) Vladimir Prus 2003-2004. Permission to copy, use, modify, sell and |
---|
2 | # distribute this software is granted provided this copyright notice appears in |
---|
3 | # all copies. This software is provided "as is" without express or implied |
---|
4 | # warranty, and with no claim as to its suitability for any purpose. |
---|
5 | |
---|
6 | # |
---|
7 | # This file shows some of the primary customization mechanisms in Boost.Build V2 |
---|
8 | # and should serve as a basic for your own customization. |
---|
9 | # Each part has a comment describing its purpose, and you can pick the parts |
---|
10 | # which are relevant to your case, remove everything else, and then change names |
---|
11 | # and actions to taste. |
---|
12 | |
---|
13 | # Declare a new target type. This allows Boost.Build to do something sensible |
---|
14 | # when targets with the .verbatim extension are found in sources. |
---|
15 | import type ; |
---|
16 | type.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. |
---|
21 | import 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. |
---|
26 | class 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. |
---|
37 | scanner.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. |
---|
42 | type.set-scanner VERBATIM : verbatim-scanner ; |
---|
43 | |
---|
44 | import generators ; |
---|
45 | generators.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. |
---|
50 | actions inline-file |
---|
51 | { |
---|
52 | "./inline_file.py" $(<) $(>) |
---|
53 | } |
---|