From 3e102b6fce8f281bcda757f9f793e7b24852a99f Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 10 Apr 2006 11:34:53 +0000 Subject: [PATCH] Document make/notfile rules. Document action syntax. [SVN r33633] --- doc/src/advanced.xml | 105 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/doc/src/advanced.xml b/doc/src/advanced.xml index 5e3c18a7b..553e85377 100644 --- a/doc/src/advanced.xml +++ b/doc/src/advanced.xml @@ -200,6 +200,51 @@ import module : rule ; + + + Sometimes, you'd need to specify the actual command lines to be used + when creating targets. In jam language, you use named actions to do this. + For example: + +actions create-file-from-another +{ + create-file-from-another $(<) $(>) +} + + This specifies a named action called + create-file-from-another. The text inside braces is the + command to invoke. The $(<) variable will be expanded to list of + generated files, and the $(>) variable will be expanded + to the list of source files. + + + To flexibly adjust command line, you can define a rule with the + same name as the action, and taking three parameters -- targets, sources + and properties. For example: + +rule create-file-from-another ( targets * : sources * : properties * ) +{ + if <variant>debug in $(properties) + { + OPTIONS on $(targets) = --debug ; + } +} +actions create-file-from-another +{ + create-file-from-another $(OPTIONS) $(<) $(>) +} + + In this example, the rule checks if certain build property is specified. + If so, it sets variable OPIONS that's used inside + action. Note that the variable is set "on targets" -- the value will + be only visible inside action, not globally. Were it set globally, + using variable named OPTIONS in two unrelated + actions would be impossible. + + + More details can be found in Jam reference, + +
@@ -1609,6 +1654,66 @@ unit-test helpers_test are not covered here.
+ +
+ + Raw commands: 'make' and 'notfile' + + Sometimes, the builtin target types are not enough, and you + want Boost.Build to just run specific commands. There are two main + target rules that make it possible: make + and notfile. + + + The make rule is used when you want to + create one file from a number of sources using some specific command. + The notfile is used to unconditionally run + a command. + + + + Suppose you want to create file file.out from + file file.in by running command + in2out. Here's how you'd do this in Boost.Build: + +actions in2out +{ + in2out $(<) $(>) +} +make file.out : file.in : @in2out ; + + If you run bjam and file.out + does not exist, Boost.Build will run the in2out + command to create that file. For more details on specifying actions, + see . + + + + + The make rule is useful to express custom + transformation that are used just once or twice in your project. For + transformations that are used often, you are advised to declare + new generator, as described in . + + + + + It could be that you just want to run some command unconditionally, + and that command does not create any specific files. The, you can use + the notfile rule. For example: + +notfile echo_something : @echo ; +actions echo +{ + echo "something" +} + + The only difference from the make rule is + that the name of the target is not considered a name of a file, so + Boost.Build will unconditionally run the action. + + +