diff options
Diffstat (limited to '')
-rw-r--r-- | src/boost/tools/build/example/generate/README.txt | 11 | ||||
-rw-r--r-- | src/boost/tools/build/example/generate/a.cpp | 10 | ||||
-rw-r--r-- | src/boost/tools/build/example/generate/gen.jam | 26 | ||||
-rw-r--r-- | src/boost/tools/build/example/generate/gen.py | 16 | ||||
-rw-r--r-- | src/boost/tools/build/example/generate/jamroot.jam | 9 |
5 files changed, 72 insertions, 0 deletions
diff --git a/src/boost/tools/build/example/generate/README.txt b/src/boost/tools/build/example/generate/README.txt new file mode 100644 index 000000000..018cbb564 --- /dev/null +++ b/src/boost/tools/build/example/generate/README.txt @@ -0,0 +1,11 @@ +# Copyright 2007 Vladimir Prus +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +This example shows the 'generate' rule, that allows you to construct target +using any arbitrary set of transformation and commands. + +The rule is similar to 'make' and 'notfile', but unlike those, you can operate +in terms of B2 'virtual targets', which is more flexible. + +Please consult the docs for more explanations. diff --git a/src/boost/tools/build/example/generate/a.cpp b/src/boost/tools/build/example/generate/a.cpp new file mode 100644 index 000000000..90dc5cc9b --- /dev/null +++ b/src/boost/tools/build/example/generate/a.cpp @@ -0,0 +1,10 @@ + +int main() +{ +} + +/* +Copyright 2007 Vladimir Prus +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) + */ diff --git a/src/boost/tools/build/example/generate/gen.jam b/src/boost/tools/build/example/generate/gen.jam new file mode 100644 index 000000000..73232aab5 --- /dev/null +++ b/src/boost/tools/build/example/generate/gen.jam @@ -0,0 +1,26 @@ + +import "class" : new ; +import common ; + +rule generate-example ( project name : property-set : sources * ) +{ + local result ; + for local s in $(sources) + { + #local source-name = [ $(s).name ] ; + #local source-action = [ $(s).action ] ; + #local source-properties = [ $(source-action).properties ] ; + + # Create a new action, that takes the source target and runs the + # 'common.copy' command on it. + local a = [ new non-scanning-action $(s) : common.copy : $(property-set) + ] ; + + # Create a target to represent the action result. Uses the target name + # passed here via the 'name' parameter and the same type and project as + # the source. + result += [ new file-target $(name) : [ $(s).type ] : $(project) : $(a) + ] ; + } + return $(result) ; +}
\ No newline at end of file diff --git a/src/boost/tools/build/example/generate/gen.py b/src/boost/tools/build/example/generate/gen.py new file mode 100644 index 000000000..09ee15b43 --- /dev/null +++ b/src/boost/tools/build/example/generate/gen.py @@ -0,0 +1,16 @@ + +from b2.build.virtual_target import NonScanningAction, FileTarget + +def generate_example(project, name, ps, sources): + + result = [] + for s in sources: + + a = NonScanningAction([s], "common.copy", ps) + + # Create a target to represent the action result. Uses the target name + # passed here via the 'name' parameter and the same type and project as + # the source. + result.append(FileTarget(name, s.type(), project, a)) + + return result diff --git a/src/boost/tools/build/example/generate/jamroot.jam b/src/boost/tools/build/example/generate/jamroot.jam new file mode 100644 index 000000000..b190b322a --- /dev/null +++ b/src/boost/tools/build/example/generate/jamroot.jam @@ -0,0 +1,9 @@ +# Copyright 2007 Vladimir Prus +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) + +import generate ; + +import gen ; + +generate a2 : a.cpp : <generating-rule>@gen.generate-example ; |