|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import modules ; |
|
import print ; |
|
import set ; |
|
import container ; |
|
import "class" ; |
|
import sequence ; |
|
import path ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
help-output = console ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
help-output-file = help ; |
|
|
|
|
|
|
|
.option.show-locals ?= ; |
|
|
|
|
|
|
|
|
|
.option.detailed ?= ; |
|
|
|
|
|
|
|
.option.debug ?= ; |
|
|
|
|
|
|
|
local rule set-option ( |
|
option |
|
: value ? |
|
) |
|
{ |
|
.option.$(option) = $(value) ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule set-output ( type ) |
|
{ |
|
help-output = $(type) ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule set-output-file ( file ) |
|
{ |
|
help-output-file = $(file) ; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
local rule brief-comment ( |
|
docs * |
|
) |
|
{ |
|
local d = $(docs:J=" ") ; |
|
local p = [ MATCH ".*([.])$" : $(d) ] ; |
|
if ! $(p) { d = $(d)"." ; } |
|
d = $(d)" " ; |
|
local m = [ MATCH "^([^.]+[.])(.*)" : $(d) ] ; |
|
local brief = $(m[1]) ; |
|
while $(m[2]) && [ MATCH "^([^ ])" : $(m[2]) ] |
|
{ |
|
m = [ MATCH "^([^.]+[.])(.*)" : $(m[2]) ] ; |
|
brief += $(m[1]) ; |
|
} |
|
return $(brief:J="") ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule set-module-doc ( |
|
module-name ? |
|
: docs * |
|
) |
|
{ |
|
module-name ?= * ; |
|
|
|
$(module-name).brief = [ brief-comment $(docs) ] ; |
|
$(module-name).docs = $(docs) ; |
|
|
|
if ! $(module-name) in $(documented-modules) |
|
{ |
|
documented-modules += $(module-name) ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule set-module-copyright ( |
|
module-name ? |
|
: copyright * |
|
) |
|
{ |
|
module-name ?= * ; |
|
|
|
$(module-name).copy-brief = [ brief-comment $(copyright) ] ; |
|
$(module-name).copy-docs = $(docs) ; |
|
|
|
if ! $(module-name) in $(documented-modules) |
|
{ |
|
documented-modules += $(module-name) ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
local rule set-rule-doc ( |
|
name |
|
module-name ? |
|
is-local ? |
|
: docs * |
|
) |
|
{ |
|
module-name ?= * ; |
|
|
|
$(module-name).$(name).brief = [ brief-comment $(docs) ] ; |
|
$(module-name).$(name).docs = $(docs) ; |
|
$(module-name).$(name).is-local = $(is-local) ; |
|
|
|
if ! $(name) in $($(module-name).rules) |
|
{ |
|
$(module-name).rules += $(name) ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule set-class-doc ( |
|
name |
|
module-name ? |
|
: super-name ? |
|
) |
|
{ |
|
module-name ?= * ; |
|
|
|
$(module-name).$(name).is-class = true ; |
|
$(module-name).$(name).super-name = $(super-name) ; |
|
$(module-name).$(name).class-rules = |
|
[ MATCH "^($(name)[.].*)" : $($(module-name).rules) ] ; |
|
$(module-name).$($(module-name).$(name).class-rules).is-class-rule = true ; |
|
|
|
$(module-name).classes += $(name) ; |
|
$(module-name).class-rules += $($(module-name).$(name).class-rules) ; |
|
$(module-name).rules = |
|
[ set.difference $($(module-name).rules) : |
|
$(name) $($(module-name).$(name).class-rules) ] ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule set-rule-arguments-signature ( |
|
name |
|
module-name ? |
|
: signature * |
|
) |
|
{ |
|
module-name ?= * ; |
|
|
|
$(module-name).$(name).signature = $(signature) ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule set-argument-doc ( |
|
name |
|
qualifier |
|
rule-name |
|
module-name ? |
|
: docs * |
|
) |
|
{ |
|
module-name ?= * ; |
|
|
|
$(module-name).$(rule-name).args.$(name).qualifier = $(qualifier) ; |
|
$(module-name).$(rule-name).args.$(name).docs = $(docs) ; |
|
|
|
if ! $(name) in $($(module-name).$(rule-name).args) |
|
{ |
|
$(module-name).$(rule-name).args += $(name) ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
local rule set-variable-doc ( |
|
name |
|
default |
|
initial |
|
module-name ? |
|
: docs * |
|
) |
|
{ |
|
module-name ?= * ; |
|
|
|
$(module-name).$(name).brief = [ brief-comment $(docs) ] ; |
|
$(module-name).$(name).default = $(default) ; |
|
$(module-name).$(name).initial = $(initial) ; |
|
$(module-name).$(name).docs = $(docs) ; |
|
|
|
if ! $(name) in $($(module-name).variables) |
|
{ |
|
$(module-name).variables += $(name) ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule print-help-top ( ) |
|
{ |
|
print.section "General command line usage" ; |
|
|
|
print.text " bjam [options] [properties] [targets] |
|
|
|
Options, properties and targets can be specified in any order. |
|
" ; |
|
|
|
print.section "Important Options" ; |
|
|
|
print.list-start ; |
|
print.list-item "--clean Remove targets instead of building" ; |
|
print.list-item "-a Rebuild everything" ; |
|
print.list-item "-n Don't execute the commands, only print them" ; |
|
print.list-item "-d+2 Show commands as they are executed" ; |
|
print.list-item "-d0 Supress all informational messages" ; |
|
print.list-item "-q Stop at first error" ; |
|
print.list-item "--debug-configuration Diagnose configuration" ; |
|
print.list-item "--debug-building Report which targets are built with what properties" ; |
|
print.list-item "--debug-generator Diagnose generator search/execution" ; |
|
print.list-end ; |
|
|
|
print.section "Further Help" |
|
The following options can be used to obtain additional documentation. |
|
; |
|
|
|
print.list-start ; |
|
print.list-item "--help-options Print more obscure command line options." ; |
|
print.list-item "--help-internal Boost.Build implementation details." ; |
|
print.list-item "--help-doc-options Implementation details doc formatting." ; |
|
print.list-end ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule print-help-usage ( ) |
|
{ |
|
print.section "Boost.Jam Usage" |
|
"bjam [ options... ] targets..." |
|
; |
|
print.list-start ; |
|
print.list-item -a; |
|
Build all targets, even if they are current. ; |
|
print.list-item -fx; |
|
Read '"x"' as the Jamfile for building instead of searching for the |
|
Boost.Build system. ; |
|
print.list-item -jx; |
|
Run up to '"x"' commands concurrently. ; |
|
print.list-item -n; |
|
Do not execute build commands. Instead print out the commands as they |
|
would be executed if building. ; |
|
print.list-item -ox; |
|
Output the used build commands to file '"x"'. ; |
|
print.list-item -q; |
|
Quit as soon as a build failure is encountered. Without this option |
|
Boost.Jam will continue building as many targets as it can. |
|
print.list-item -sx=y; |
|
Sets a Jam variable '"x"' to the value '"y"', overriding any value that |
|
variable would have from the environment. ; |
|
print.list-item -tx; |
|
Rebuild the target '"x"', even if it is up-to-date. ; |
|
print.list-item -v; |
|
Display the version of bjam. ; |
|
print.list-item --x; |
|
Any option not explicitly handled by Boost.Jam remains available to |
|
build scripts using the '"ARGV"' variable. ; |
|
print.list-item -dn; |
|
Enables output of diagnostic messages. The debug level '"n"' and all |
|
below it are enabled by this option. ; |
|
print.list-item -d+n; |
|
Enables output of diagnostic messages. Only the output for debug level |
|
'"n"' is enabled. ; |
|
print.list-end ; |
|
print.section "Debug Levels" |
|
Each debug level shows a different set of information. Usually with |
|
higher levels producing more verbose information. The following levels |
|
are supported: ; |
|
print.list-start ; |
|
print.list-item 0; |
|
Turn off all diagnostic output. Only errors are reported. ; |
|
print.list-item 1; |
|
Show the actions taken for building targets, as they are executed. ; |
|
print.list-item 2; |
|
Show "quiet" actions and display all action text, as they are executed. ; |
|
print.list-item 3; |
|
Show dependency analysis, and target/source timestamps/paths. ; |
|
print.list-item 4; |
|
Show arguments of shell invocations. ; |
|
print.list-item 5; |
|
Show rule invocations and variable expansions. ; |
|
print.list-item 6; |
|
Show directory/header file/archive scans, and attempts at binding to targets. ; |
|
print.list-item 7; |
|
Show variable settings. ; |
|
print.list-item 8; |
|
Show variable fetches, variable expansions, and evaluation of '"if"' expressions. ; |
|
print.list-item 9; |
|
Show variable manipulation, scanner tokens, and memory usage. ; |
|
print.list-item 10; |
|
Show execution times for rules. ; |
|
print.list-item 11; |
|
Show parsing progress of Jamfiles. ; |
|
print.list-item 12; |
|
Show graph for target dependencies. ; |
|
print.list-item 13; |
|
Show changes in target status (fate). ; |
|
print.list-end ; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
local rule print-help-options ( |
|
module-name |
|
) |
|
{ |
|
print.section "Help Options" |
|
These are all the options available for enabling or disabling to control |
|
the help system in various ways. Options can be enabled or disabled with |
|
'"--help-enable-<option>"', and "'--help-disable-<option>'" |
|
respectively. |
|
; |
|
local options-to-list = [ MATCH ^[.]option[.](.*) : $($(module-name).variables) ] ; |
|
if $(options-to-list) |
|
{ |
|
print.list-start ; |
|
for local option in [ sequence.insertion-sort $(options-to-list) ] |
|
{ |
|
local def = disabled ; |
|
if $($(module-name)..option.$(option).default) != "(empty)" |
|
{ |
|
def = enabled ; |
|
} |
|
print.list-item $(option): $($(module-name)..option.$(option).docs) |
|
Default is $(def). ; |
|
} |
|
print.list-end ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
local rule print-help-module-section ( |
|
module |
|
section |
|
: section-head |
|
section-description * |
|
) |
|
{ |
|
if $($(module).$(section)) |
|
{ |
|
print.section $(section-head) $(section-description) ; |
|
print.list-start ; |
|
for local item in [ sequence.insertion-sort $($(module).$(section)) ] |
|
{ |
|
local show = ; |
|
if ! $($(module).$(item).is-local) |
|
{ |
|
show = yes ; |
|
} |
|
if $(.option.show-locals) |
|
{ |
|
show = yes ; |
|
} |
|
if $(show) |
|
{ |
|
print.list-item $(item): $($(module).$(item).brief) ; |
|
} |
|
} |
|
print.list-end ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
local rule print-help-all ( |
|
ignored |
|
) |
|
{ |
|
print.section "Modules" |
|
"These are all the known modules. Use --help <module> to get more" |
|
"detailed information." |
|
; |
|
if $(documented-modules) |
|
{ |
|
print.list-start ; |
|
for local module-name in [ sequence.insertion-sort $(documented-modules) ] |
|
{ |
|
|
|
print.list-item $(module-name): $($(module-name).brief) ; |
|
} |
|
print.list-end ; |
|
} |
|
|
|
if $(documented-modules) && $(.option.detailed) |
|
{ |
|
for local module-name in [ sequence.insertion-sort $(documented-modules) ] |
|
{ |
|
|
|
print-help-module $(module-name) ; |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
local rule print-help-module ( |
|
module-name |
|
) |
|
{ |
|
|
|
print.section "Module '$(module-name)'" $($(module-name).docs) ; |
|
|
|
|
|
print-help-module-section $(module-name) classes : "Module '$(module-name)' classes" |
|
Use --help $(module-name).<class-name> to get more information. ; |
|
|
|
|
|
print-help-module-section $(module-name) rules : "Module '$(module-name)' rules" |
|
Use --help $(module-name).<rule-name> to get more information. ; |
|
|
|
|
|
print-help-module-section $(module-name) variables : "Module '$(module-name)' variables" |
|
Use --help $(module-name).<variable-name> to get more information. ; |
|
|
|
|
|
if $(.option.detailed) |
|
{ |
|
print-help-classes $(module-name) ; |
|
print-help-rules $(module-name) ; |
|
print-help-variables $(module-name) ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule print-help-rules ( |
|
module-name |
|
: name * |
|
) |
|
{ |
|
name ?= $($(module-name).rules) ; |
|
if [ set.intersection $(name) : $($(module-name).rules) $($(module-name).class-rules) ] |
|
{ |
|
|
|
for local rule-name in [ sequence.insertion-sort $(name) ] |
|
{ |
|
if $(.option.show-locals) || ! $($(module-name).$(rule-name).is-local) |
|
{ |
|
local signature = $($(module-name).$(rule-name).signature:J=" ") ; |
|
signature ?= "" ; |
|
print.section "Rule '$(module-name).$(rule-name) ( $(signature) )'" |
|
$($(module-name).$(rule-name).docs) ; |
|
if $($(module-name).$(rule-name).args) |
|
{ |
|
print.list-start ; |
|
for local arg-name in $($(module-name).$(rule-name).args) |
|
{ |
|
print.list-item $(arg-name): $($(module-name).$(rule-name).args.$(arg-name).docs) ; |
|
} |
|
print.list-end ; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule print-help-classes ( |
|
module-name |
|
: name * |
|
) |
|
{ |
|
name ?= $($(module-name).classes) ; |
|
if [ set.intersection $(name) : $($(module-name).classes) ] |
|
{ |
|
|
|
for local class-name in [ sequence.insertion-sort $(name) ] |
|
{ |
|
if $(.option.show-locals) || ! $($(module-name).$(class-name).is-local) |
|
{ |
|
local signature = $($(module-name).$(class-name).signature:J=" ") ; |
|
signature ?= "" ; |
|
print.section "Class '$(module-name).$(class-name) ( $(signature) )'" |
|
$($(module-name).$(class-name).docs) |
|
"Inherits from '"$($(module-name).$(class-name).super-name)"'." ; |
|
if $($(module-name).$(class-name).args) |
|
{ |
|
print.list-start ; |
|
for local arg-name in $($(module-name).$(class-name).args) |
|
{ |
|
print.list-item $(arg-name): $($(module-name).$(class-name).args.$(arg-name).docs) ; |
|
} |
|
print.list-end ; |
|
} |
|
} |
|
|
|
|
|
print-help-module-section $(module-name) $(class-name).class-rules : "Class '$(module-name).$(class-name)' rules" |
|
Use --help $(module-name).<rule-name> to get more information. ; |
|
|
|
|
|
if $(.option.detailed) |
|
{ |
|
print-help-rules $(module-name) : $($(module-name).$(class-name).class-rules) ; |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule print-help-variables ( |
|
module-name ? |
|
: name * |
|
) |
|
{ |
|
name ?= $($(module-name).variables) ; |
|
if [ set.intersection $(name) : $($(module-name).variables) ] |
|
{ |
|
|
|
for local variable-name in [ sequence.insertion-sort $(name) ] |
|
{ |
|
print.section "Variable '$(module-name).$(variable-name)'" $($(module-name).$(variable-name).docs) ; |
|
if $($(module-name).$(variable-name).default) || |
|
$($(module-name).$(variable-name).initial) |
|
{ |
|
print.list-start ; |
|
if $($(module-name).$(variable-name).default) |
|
{ |
|
print.list-item "default value:" '$($(module-name).$(variable-name).default:J=" ")' ; |
|
} |
|
if $($(module-name).$(variable-name).initial) |
|
{ |
|
print.list-item "initial value:" '$($(module-name).$(variable-name).initial:J=" ")' ; |
|
} |
|
print.list-end ; |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule print-help-project ( |
|
unused ? |
|
: jamfile * |
|
) |
|
{ |
|
if $(jamfile<$(jamfile)>.docs) |
|
{ |
|
|
|
print.section "Project-specific help" |
|
Project has jamfile at $(jamfile) ; |
|
|
|
print.lines $(jamfile<$(jamfile)>.docs) "" ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule print-help-config ( |
|
unused ? |
|
: type |
|
config-file |
|
) |
|
{ |
|
if $(jamfile<$(config-file)>.docs) |
|
{ |
|
|
|
print.section "Configuration help" |
|
Configuration file at $(config-file) ; |
|
|
|
print.lines $(jamfile<$(config-file)>.docs) "" ; |
|
} |
|
} |
|
|
|
|
|
ws = " " ; |
|
|
|
|
|
|
|
local rule extract-comment ( |
|
var |
|
) |
|
{ |
|
local comment = ; |
|
local line = $($(var)[1]) ; |
|
local l = [ MATCH "^[$(ws)]*(#)(.*)$" : $(line) ] ; |
|
while $(l[1]) && $($(var)) |
|
{ |
|
if $(l[2]) { comment += [ MATCH "^[$(ws)]?(.*)$" : $(l[2]) ] ; } |
|
else { comment += "" ; } |
|
$(var) = $($(var)[2-]) ; |
|
line = $($(var)[1]) ; |
|
l = [ MATCH "^[$(ws)]*(#)(.*)$" : $(line) ] ; |
|
} |
|
return $(comment) ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule extract-syntax ( |
|
var |
|
) |
|
{ |
|
local syntax = ; |
|
local line = $($(var)[1]) ; |
|
while ! $(syntax) && ! [ MATCH "^[$(ws)]*(#)" : $(line) ] && $($(var)) |
|
{ |
|
local m = [ MATCH "^[$(ws)]*(.*)$" : $(line) ] ; |
|
if $(m) |
|
{ |
|
syntax = $(m) ; |
|
} |
|
$(var) = $($(var)[2-]) ; |
|
line = $($(var)[1]) ; |
|
} |
|
return $(syntax) ; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
local rule extract-token ( |
|
var |
|
) |
|
{ |
|
local parts = ; |
|
while ! $(parts) |
|
{ |
|
parts = [ MATCH "^[$(ws)]*([^$(ws)]+)[$(ws)]*(.*)" : $($(var)[1]) ] ; |
|
if ! $(parts) |
|
{ |
|
$(var) = $($(var)[2-]) ; |
|
} |
|
} |
|
local token = ; |
|
if [ MATCH "^(#)" : $(parts[1]) ] |
|
{ |
|
token = $(parts:J=" ") ; |
|
$(var) = $($(var)[2-]) ; |
|
} |
|
else |
|
{ |
|
token = $(parts[1]) ; |
|
$(var) = $(parts[2-]:J=" ") $($(var)[2-]) ; |
|
} |
|
return $(token) ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule scan-rule ( |
|
syntax ? |
|
: var |
|
) |
|
{ |
|
local rule-parts = |
|
[ MATCH "^[$(ws)]*(rule|local[$(ws)]*rule)[$(ws)]+([^$(ws)]+)[$(ws)]*(.*)" : $(syntax:J=" ") ] ; |
|
if $(rule-parts[1]) |
|
{ |
|
|
|
local rule-name = $(rule-parts[2]) ; |
|
if $(scope-name) |
|
{ |
|
rule-name = $(scope-name).$(rule-name) ; |
|
} |
|
local is-local = [ MATCH "^(local).*" : $(rule-parts[1]) ] ; |
|
if $(comment-block) |
|
{ |
|
set-rule-doc $(rule-name) $(module-name) $(is-local) : $(comment-block) ; |
|
} |
|
|
|
$(var) = $(rule-parts[3-]) $($(var)) ; |
|
set-rule-arguments-signature $(rule-name) $(module-name) : [ scan-rule-arguments $(var) ] ; |
|
|
|
local scope-level = [ extract-token $(var) ] ; |
|
local scope-name = $(rule-name) ; |
|
while $(scope-level) |
|
{ |
|
local comment-block = [ extract-comment $(var) ] ; |
|
local syntax-block = [ extract-syntax $(var) ] ; |
|
if [ scan-rule $(syntax-block) : $(var) ] |
|
{ |
|
} |
|
else if [ MATCH "^(\\{)" : $(syntax-block) ] |
|
{ |
|
scope-level += "{" ; |
|
} |
|
else if [ MATCH "^[^\\}]*([\\}])[$(ws)]*$" : $(syntax-block) ] |
|
{ |
|
scope-level = $(scope-level[2-]) ; |
|
} |
|
} |
|
|
|
return true ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule scan-rule-arguments ( |
|
var |
|
) |
|
{ |
|
local arg-syntax = ; |
|
local token = [ extract-token $(var) ] ; |
|
while $(token) != "(" && $(token) != "{" |
|
{ |
|
token = [ extract-token $(var) ] ; |
|
} |
|
if $(token) != "{" |
|
{ |
|
token = [ extract-token $(var) ] ; |
|
} |
|
local arg-signature = ; |
|
while $(token) != ")" && $(token) != "{" |
|
{ |
|
local arg-name = ; |
|
local arg-qualifier = " " ; |
|
local arg-doc = ; |
|
if $(token) = ":" |
|
{ |
|
arg-signature += $(token) ; |
|
token = [ extract-token $(var) ] ; |
|
} |
|
arg-name = $(token) ; |
|
arg-signature += $(token) ; |
|
token = [ extract-token $(var) ] ; |
|
if [ MATCH "^([\\*\\+\\?])" : $(token) ] |
|
{ |
|
arg-qualifier = $(token) ; |
|
arg-signature += $(token) ; |
|
token = [ extract-token $(var) ] ; |
|
} |
|
if $(token) = ":" |
|
{ |
|
arg-signature += $(token) ; |
|
token = [ extract-token $(var) ] ; |
|
} |
|
if [ MATCH "^(#)" : $(token) ] |
|
{ |
|
$(var) = $(token) $($(var)) ; |
|
arg-doc = [ extract-comment $(var) ] ; |
|
token = [ extract-token $(var) ] ; |
|
} |
|
set-argument-doc $(arg-name) $(arg-qualifier) $(rule-name) $(module-name) : $(arg-doc) ; |
|
} |
|
while $(token) != "{" |
|
{ |
|
token = [ extract-token $(var) ] ; |
|
} |
|
$(var) = "{" $($(var)) ; |
|
arg-signature ?= "" ; |
|
return $(arg-signature) ; |
|
} |
|
|
|
|
|
|
|
|
|
local rule scan-variable ( |
|
syntax ? |
|
: var |
|
) |
|
{ |
|
|
|
local var-parts = |
|
[ MATCH "^[$(ws)]*([^$(ws)]+)[$(ws)]+([\\?\\=]*)[$(ws)]+([^\\;]*)\\;" : $(syntax) ] ; |
|
if $(var-parts) |
|
{ |
|
local value = [ MATCH "^(.*)[ ]$" : $(var-parts[3-]:J=" ") ] ; |
|
local default-value = "" ; |
|
local initial-valie = "" ; |
|
if $(var-parts[2]) = "?=" |
|
{ |
|
default-value = $(value) ; |
|
default-value ?= "(empty)" ; |
|
} |
|
else |
|
{ |
|
initial-value = $(value) ; |
|
initial-value ?= "(empty)" ; |
|
} |
|
if $(comment-block) |
|
{ |
|
set-variable-doc $(var-parts[1]) $(default-value) $(initial-value) $(module-name) : $(comment-block) ; |
|
} |
|
return true ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
local rule scan-class ( |
|
syntax ? |
|
) |
|
{ |
|
|
|
local class-parts = |
|
[ MATCH "^[$(ws)]*([^$(ws)]+)[$(ws)]+([^$(ws)]+)[$(ws)]+:*[$(ws)]*([^$(ws);]*)" : $(syntax) ] ; |
|
if $(class-parts[1]) = "class" || $(class-parts[1]) = "class.class" |
|
{ |
|
set-class-doc $(class-parts[2]) $(module-name) : $(class-parts[3]) ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rule scan-module ( |
|
target |
|
: text * |
|
: action * |
|
) |
|
{ |
|
if $(.option.debug) { ECHO "HELP:" scanning module target '$(target)' ; } |
|
local module-name = $(target:B) ; |
|
local module-documented = ; |
|
local comment-block = ; |
|
local syntax-block = ; |
|
|
|
|
|
text += "}" ; |
|
while $(text) |
|
{ |
|
comment-block = [ extract-comment text ] ; |
|
syntax-block = [ extract-syntax text ] ; |
|
if $(.option.debug) |
|
{ |
|
ECHO "HELP:" comment block; '$(comment-block)' ; |
|
ECHO "HELP:" syntax block; '$(syntax-block)' ; |
|
} |
|
if [ scan-rule $(syntax-block) : text ] { } |
|
else if [ scan-variable $(syntax-block) : text ] { } |
|
else if [ scan-class $(syntax-block) ] { } |
|
else if [ MATCH .*([cC]opyright).* : $(comment-block:J=" ") ] |
|
{ |
|
|
|
set-module-copyright $(module-name) : $(comment-block) ; |
|
} |
|
else if $(action[1]) in "print-help-project" "print-help-config" |
|
&& ! $(jamfile<$(target)>.docs) |
|
{ |
|
|
|
jamfile<$(target)>.docs = $(comment-block) ; |
|
} |
|
else if ! $(module-documented) |
|
{ |
|
|
|
set-module-doc $(module-name) : $(comment-block) ; |
|
module-documented = true ; |
|
} |
|
} |
|
if $(action) |
|
{ |
|
$(action[1]) $(module-name) : $(action[2-]) ; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
IMPORT $(__name__) : scan-module : : doc.scan-module ; |
|
|
|
|
|
|
|
|
|
|
|
local rule read-file ( |
|
file |
|
) |
|
{ |
|
file = [ path.native [ path.root [ path.make $(file) ] [ path.pwd ] ] ] ; |
|
if ! $(.file<$(file)>.lines) |
|
{ |
|
local content ; |
|
switch [ modules.peek : OS ] |
|
{ |
|
case NT : |
|
content = [ SHELL "TYPE \"$(file)\"" ] ; |
|
|
|
case * : |
|
content = [ SHELL "cat \"$(file)\"" ] ; |
|
} |
|
local lines ; |
|
local nl = " |
|
" ; |
|
local << = "([^$(nl)]*)[$(nl)](.*)" ; |
|
local line+ = [ MATCH "$(<<)" : "$(content)" ] ; |
|
while $(line+) |
|
{ |
|
lines += $(line+[1]) ; |
|
line+ = [ MATCH "$(<<)" : "$(line+[2])" ] ; |
|
} |
|
.file<$(file)>.lines = $(lines) ; |
|
} |
|
return $(.file<$(file)>.lines) ; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
local rule do-scan ( |
|
modules + |
|
: action * |
|
) |
|
{ |
|
if $(help-output) = text |
|
{ |
|
print.output $(help-output-file).txt plain ; |
|
ALWAYS $(help-output-file).txt ; |
|
DEPENDS all : $(help-output-file).txt ; |
|
} |
|
if $(help-output) = html |
|
{ |
|
print.output $(help-output-file).html html ; |
|
ALWAYS $(help-output-file).html ; |
|
DEPENDS all : $(help-output-file).html ; |
|
} |
|
for local module-file in $(modules[1--2]) |
|
{ |
|
scan-module $(module-file) : [ read-file $(module-file) ] ; |
|
} |
|
scan-module $(modules[-1]) : [ read-file $(modules[-1]) ] : $(action) ; |
|
} |
|
|