在回答我的问题,我已经添加了非常的功能,我问:https://github.com/boostorg/build/pull/23
它利用现有选项的插件系统。无论何时你想创建一个新的命令行选项,在options
目录中创建一个新模块。在该新模块中,创建一个保存值或为空的变量。在变量上方创建评论。该注释用作命令行文档,并且该值(如果给出)用于描述该变量的默认值。
在新模块中创建process
规则并向系统注册您的选项。这允许导入option
模块并从单一来源获取值。这要求每个变量名都以模块的名称作为前缀。
创建一个名为.option-description
的变量。它的值是部分分隔符,它的注释是部分的描述。
例如:
# within options/cool.jam
# These are the options for the Cool option plugin
.option-description = Cool Options
# This enables option1
.option.--cool-option1 ?= ;
# This enables something cool
.option.--cool-default-option ?= "my default value" ;
rule process (
command # The option.
: values * # The values, starting after the "=".
)
{
option.set $(command) : $(values) ;
}
当与--help-options
标志运行bjam
,它会输出下面的options
目录内完成上述图形的所有模块。这将有类似以下的输出:
Boost.Build Usage:
b2 [ options... ] targets...
* -a; Build all targets, even if they are current.
* -fx; Read 'x' as the Jamfile for building instead of searching for the
Boost.Build system.
* -jx; Run up to 'x' commands concurrently.
* -n; Do not execute build commands. Instead print out the commands as they
would be executed if building.
* -ox; Output the used build commands to file 'x'.
* -q; Quit as soon as a build failure is encountered. Without this option
Boost.Jam will continue building as many targets as it can.
* -sx=y; Sets a Jam variable 'x' to the value 'y', overriding any value that
variable would have from the environment.
* -tx; Rebuild the target 'x', even if it is up-to-date.
* -v; Display the version of b2.
* --x; Any option not explicitly handled by Boost.Build remains available to
build scripts using the 'ARGV' variable.
* --abbreviate-paths; Use abbreviated paths for targets.
* --hash; Shorten target paths by using an MD5 hash.
* -dn; Enables output of diagnostic messages. The debug level 'n' and all
below it are enabled by this option.
* -d+n; Enables output of diagnostic messages. Only the output for debug
level 'n' is enabled.
Debug Levels:
Each debug level shows a different set of information. Usually with higher
levels producing more verbose information. The following levels are supported:
* 0; Turn off all diagnostic output. Only errors are reported.
* 1; Show the actions taken for building targets, as they are executed.
* 2; Show quiet actions and display all action text, as they are executed.
* 3; Show dependency analysis, and target/source timestamps/paths.
* 4; Show arguments of shell invocations.
* 5; Show rule invocations and variable expansions.
* 6; Show directory/header file/archive scans, and attempts at binding to
targets.
* 7; Show variable settings.
* 8; Show variable fetches, variable expansions, and evaluation of 'if'
expressions.
* 9; Show variable manipulation, scanner tokens, and memory usage.
* 10; Show execution times for rules.
* 11; Show parsing progress of Jamfiles.
* 12; Show graph for target dependencies.
* 13; Show changes in target status (fate).
Cool Options:
These are the options for the Cool option plugin
* --cool-option1: This enables option1. Default is disabled.
* --cool-default-option: This enables something cool. "my default value".
后来在自己的卡纸代码,然后你可以通过做您可以通过注册期权值保持:
import option ;
option1 = option.get '--cool-option1' ;
if $(option1) {
# do_something ;
}