14318 lines
718 KiB
HTML
14318 lines
718 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="generator" content="Asciidoctor 1.5.8">
|
||
<meta name="author" content="René Ferdinand Rivera Morell, Vladimir Prus, Steven Watanabe">
|
||
<meta name="copyright" content="Copyright 2018-2021 René Ferdinand Rivera Morell; Copyright 2006, 2014 Vladimir Prus">
|
||
<title>B2 User Manual</title>
|
||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
|
||
<style>
|
||
/* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
|
||
/* Uncomment @import statement below to use as custom stylesheet */
|
||
/*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/
|
||
article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
|
||
audio,canvas,video{display:inline-block}
|
||
audio:not([controls]){display:none;height:0}
|
||
script{display:none!important}
|
||
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
|
||
a{background:transparent}
|
||
a:focus{outline:thin dotted}
|
||
a:active,a:hover{outline:0}
|
||
h1{font-size:2em;margin:.67em 0}
|
||
abbr[title]{border-bottom:1px dotted}
|
||
b,strong{font-weight:bold}
|
||
dfn{font-style:italic}
|
||
hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
|
||
mark{background:#ff0;color:#000}
|
||
code,kbd,pre,samp{font-family:monospace;font-size:1em}
|
||
pre{white-space:pre-wrap}
|
||
q{quotes:"\201C" "\201D" "\2018" "\2019"}
|
||
small{font-size:80%}
|
||
sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
|
||
sup{top:-.5em}
|
||
sub{bottom:-.25em}
|
||
img{border:0}
|
||
svg:not(:root){overflow:hidden}
|
||
figure{margin:0}
|
||
fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
|
||
legend{border:0;padding:0}
|
||
button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
|
||
button,input{line-height:normal}
|
||
button,select{text-transform:none}
|
||
button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
|
||
button[disabled],html input[disabled]{cursor:default}
|
||
input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
|
||
button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
|
||
textarea{overflow:auto;vertical-align:top}
|
||
table{border-collapse:collapse;border-spacing:0}
|
||
*,*::before,*::after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
|
||
html,body{font-size:100%}
|
||
body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
|
||
a:hover{cursor:pointer}
|
||
img,object,embed{max-width:100%;height:auto}
|
||
object,embed{height:100%}
|
||
img{-ms-interpolation-mode:bicubic}
|
||
.left{float:left!important}
|
||
.right{float:right!important}
|
||
.text-left{text-align:left!important}
|
||
.text-right{text-align:right!important}
|
||
.text-center{text-align:center!important}
|
||
.text-justify{text-align:justify!important}
|
||
.hide{display:none}
|
||
img,object,svg{display:inline-block;vertical-align:middle}
|
||
textarea{height:auto;min-height:50px}
|
||
select{width:100%}
|
||
.center{margin-left:auto;margin-right:auto}
|
||
.stretch{width:100%}
|
||
.subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
|
||
div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
|
||
a{color:#2156a5;text-decoration:underline;line-height:inherit}
|
||
a:hover,a:focus{color:#1d4b8f}
|
||
a img{border:none}
|
||
p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
|
||
p aside{font-size:.875em;line-height:1.35;font-style:italic}
|
||
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
|
||
h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
|
||
h1{font-size:2.125em}
|
||
h2{font-size:1.6875em}
|
||
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
|
||
h4,h5{font-size:1.125em}
|
||
h6{font-size:1em}
|
||
hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
|
||
em,i{font-style:italic;line-height:inherit}
|
||
strong,b{font-weight:bold;line-height:inherit}
|
||
small{font-size:60%;line-height:inherit}
|
||
code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
|
||
ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
|
||
ul,ol{margin-left:1.5em}
|
||
ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
|
||
ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
|
||
ul.square{list-style-type:square}
|
||
ul.circle{list-style-type:circle}
|
||
ul.disc{list-style-type:disc}
|
||
ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
|
||
dl dt{margin-bottom:.3125em;font-weight:bold}
|
||
dl dd{margin-bottom:1.25em}
|
||
abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
|
||
abbr{text-transform:none}
|
||
blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
|
||
blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
|
||
blockquote cite::before{content:"\2014 \0020"}
|
||
blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
|
||
blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
|
||
@media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
|
||
h1{font-size:2.75em}
|
||
h2{font-size:2.3125em}
|
||
h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
|
||
h4{font-size:1.4375em}}
|
||
table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
|
||
table thead,table tfoot{background:#f7f8f7}
|
||
table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
|
||
table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
|
||
table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
|
||
table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
|
||
h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
|
||
h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
|
||
.clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
|
||
.clearfix::after,.float-group::after{clear:both}
|
||
*:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word}
|
||
*:not(pre)>code.nobreak{word-wrap:normal}
|
||
*:not(pre)>code.nowrap{white-space:nowrap}
|
||
pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
|
||
em em{font-style:normal}
|
||
strong strong{font-weight:400}
|
||
.keyseq{color:rgba(51,51,51,.8)}
|
||
kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
|
||
.keyseq kbd:first-child{margin-left:0}
|
||
.keyseq kbd:last-child{margin-right:0}
|
||
.menuseq,.menuref{color:#000}
|
||
.menuseq b:not(.caret),.menuref{font-weight:inherit}
|
||
.menuseq{word-spacing:-.02em}
|
||
.menuseq b.caret{font-size:1.25em;line-height:.8}
|
||
.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
|
||
b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
|
||
b.button::before{content:"[";padding:0 3px 0 2px}
|
||
b.button::after{content:"]";padding:0 2px 0 3px}
|
||
p a>code:hover{color:rgba(0,0,0,.9)}
|
||
#header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
|
||
#header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
|
||
#header::after,#content::after,#footnotes::after,#footer::after{clear:both}
|
||
#content{margin-top:1.25em}
|
||
#content::before{content:none}
|
||
#header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
|
||
#header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
|
||
#header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
|
||
#header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
|
||
#header .details span:first-child{margin-left:-.125em}
|
||
#header .details span.email a{color:rgba(0,0,0,.85)}
|
||
#header .details br{display:none}
|
||
#header .details br+span::before{content:"\00a0\2013\00a0"}
|
||
#header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
|
||
#header .details br+span#revremark::before{content:"\00a0|\00a0"}
|
||
#header #revnumber{text-transform:capitalize}
|
||
#header #revnumber::after{content:"\00a0"}
|
||
#content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
|
||
#toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
|
||
#toc>ul{margin-left:.125em}
|
||
#toc ul.sectlevel0>li>a{font-style:italic}
|
||
#toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
|
||
#toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
|
||
#toc li{line-height:1.3334;margin-top:.3334em}
|
||
#toc a{text-decoration:none}
|
||
#toc a:active{text-decoration:underline}
|
||
#toctitle{color:#7a2518;font-size:1.2em}
|
||
@media screen and (min-width:768px){#toctitle{font-size:1.375em}
|
||
body.toc2{padding-left:15em;padding-right:0}
|
||
#toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
|
||
#toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
|
||
#toc.toc2>ul{font-size:.9em;margin-bottom:0}
|
||
#toc.toc2 ul ul{margin-left:0;padding-left:1em}
|
||
#toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
|
||
body.toc2.toc-right{padding-left:0;padding-right:15em}
|
||
body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
|
||
@media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
|
||
#toc.toc2{width:20em}
|
||
#toc.toc2 #toctitle{font-size:1.375em}
|
||
#toc.toc2>ul{font-size:.95em}
|
||
#toc.toc2 ul ul{padding-left:1.25em}
|
||
body.toc2.toc-right{padding-left:0;padding-right:20em}}
|
||
#content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
|
||
#content #toc>:first-child{margin-top:0}
|
||
#content #toc>:last-child{margin-bottom:0}
|
||
#footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
|
||
#footer-text{color:rgba(255,255,255,.8);line-height:1.44}
|
||
#content{margin-bottom:.625em}
|
||
.sect1{padding-bottom:.625em}
|
||
@media screen and (min-width:768px){#content{margin-bottom:1.25em}
|
||
.sect1{padding-bottom:1.25em}}
|
||
.sect1:last-child{padding-bottom:0}
|
||
.sect1+.sect1{border-top:1px solid #e7e7e9}
|
||
#content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
|
||
#content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
|
||
#content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
|
||
#content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
|
||
#content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
|
||
.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
|
||
.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
|
||
table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
|
||
.paragraph.lead>p,#preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
|
||
table.tableblock #preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:inherit}
|
||
.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
|
||
.admonitionblock>table td.icon{text-align:center;width:80px}
|
||
.admonitionblock>table td.icon img{max-width:none}
|
||
.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
|
||
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6)}
|
||
.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
|
||
.exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
|
||
.exampleblock>.content>:first-child{margin-top:0}
|
||
.exampleblock>.content>:last-child{margin-bottom:0}
|
||
.sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
|
||
.sidebarblock>:first-child{margin-top:0}
|
||
.sidebarblock>:last-child{margin-bottom:0}
|
||
.sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
|
||
.exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
|
||
.literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
|
||
.sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
|
||
.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;overflow-x:auto;padding:1em;font-size:.8125em}
|
||
@media screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}
|
||
@media screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}
|
||
.literalblock pre.nowrap,.literalblock pre.nowrap pre,.listingblock pre.nowrap,.listingblock pre.nowrap pre{white-space:pre;word-wrap:normal}
|
||
.literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
|
||
.listingblock pre.highlightjs{padding:0}
|
||
.listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
|
||
.listingblock pre.prettyprint{border-width:0}
|
||
.listingblock>.content{position:relative}
|
||
.listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
|
||
.listingblock:hover code[data-lang]::before{display:block}
|
||
.listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:#999}
|
||
.listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
|
||
table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
|
||
table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45}
|
||
table.pyhltable td.code{padding-left:.75em;padding-right:0}
|
||
pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #dddddf}
|
||
pre.pygments .lineno{display:inline-block;margin-right:.25em}
|
||
table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
|
||
.quoteblock{margin:0 1em 1.25em 1.5em;display:table}
|
||
.quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
|
||
.quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
|
||
.quoteblock blockquote{margin:0;padding:0;border:0}
|
||
.quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
|
||
.quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
|
||
.quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
|
||
.verseblock{margin:0 1em 1.25em}
|
||
.verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
|
||
.verseblock pre strong{font-weight:400}
|
||
.verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
|
||
.quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
|
||
.quoteblock .attribution br,.verseblock .attribution br{display:none}
|
||
.quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
|
||
.quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
|
||
.quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
|
||
.quoteblock.abstract{margin:0 1em 1.25em;display:block}
|
||
.quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
|
||
.quoteblock.excerpt,.quoteblock .quoteblock{margin:0 0 1.25em;padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
|
||
.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
|
||
.quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;text-align:left;margin-right:0}
|
||
table.tableblock{max-width:100%;border-collapse:separate}
|
||
p.tableblock:last-child{margin-bottom:0}
|
||
td.tableblock>.content{margin-bottom:-1.25em}
|
||
table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
|
||
table.grid-all>thead>tr>.tableblock,table.grid-all>tbody>tr>.tableblock{border-width:0 1px 1px 0}
|
||
table.grid-all>tfoot>tr>.tableblock{border-width:1px 1px 0 0}
|
||
table.grid-cols>*>tr>.tableblock{border-width:0 1px 0 0}
|
||
table.grid-rows>thead>tr>.tableblock,table.grid-rows>tbody>tr>.tableblock{border-width:0 0 1px}
|
||
table.grid-rows>tfoot>tr>.tableblock{border-width:1px 0 0}
|
||
table.grid-all>*>tr>.tableblock:last-child,table.grid-cols>*>tr>.tableblock:last-child{border-right-width:0}
|
||
table.grid-all>tbody>tr:last-child>.tableblock,table.grid-all>thead:last-child>tr>.tableblock,table.grid-rows>tbody>tr:last-child>.tableblock,table.grid-rows>thead:last-child>tr>.tableblock{border-bottom-width:0}
|
||
table.frame-all{border-width:1px}
|
||
table.frame-sides{border-width:0 1px}
|
||
table.frame-topbot,table.frame-ends{border-width:1px 0}
|
||
table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd){background:#f8f8f7}
|
||
table.stripes-none tr,table.stripes-odd tr:nth-of-type(even){background:none}
|
||
th.halign-left,td.halign-left{text-align:left}
|
||
th.halign-right,td.halign-right{text-align:right}
|
||
th.halign-center,td.halign-center{text-align:center}
|
||
th.valign-top,td.valign-top{vertical-align:top}
|
||
th.valign-bottom,td.valign-bottom{vertical-align:bottom}
|
||
th.valign-middle,td.valign-middle{vertical-align:middle}
|
||
table thead th,table tfoot th{font-weight:bold}
|
||
tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
|
||
tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
|
||
p.tableblock>code:only-child{background:none;padding:0}
|
||
p.tableblock{font-size:1em}
|
||
td>div.verse{white-space:pre}
|
||
ol{margin-left:1.75em}
|
||
ul li ol{margin-left:1.5em}
|
||
dl dd{margin-left:1.125em}
|
||
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
|
||
ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
|
||
ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
|
||
ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
|
||
ul.unstyled,ol.unstyled{margin-left:0}
|
||
ul.checklist{margin-left:.625em}
|
||
ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
|
||
ul.checklist li>p:first-child>input[type="checkbox"]:first-child{margin-right:.25em}
|
||
ul.inline{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
|
||
ul.inline>li{margin-left:1.25em}
|
||
.unstyled dl dt{font-weight:400;font-style:normal}
|
||
ol.arabic{list-style-type:decimal}
|
||
ol.decimal{list-style-type:decimal-leading-zero}
|
||
ol.loweralpha{list-style-type:lower-alpha}
|
||
ol.upperalpha{list-style-type:upper-alpha}
|
||
ol.lowerroman{list-style-type:lower-roman}
|
||
ol.upperroman{list-style-type:upper-roman}
|
||
ol.lowergreek{list-style-type:lower-greek}
|
||
.hdlist>table,.colist>table{border:0;background:none}
|
||
.hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
|
||
td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
|
||
td.hdlist1{font-weight:bold;padding-bottom:1.25em}
|
||
.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
|
||
.colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
|
||
.colist td:not([class]):first-child img{max-width:none}
|
||
.colist td:not([class]):last-child{padding:.25em 0}
|
||
.thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
|
||
.imageblock.left{margin:.25em .625em 1.25em 0}
|
||
.imageblock.right{margin:.25em 0 1.25em .625em}
|
||
.imageblock>.title{margin-bottom:0}
|
||
.imageblock.thumb,.imageblock.th{border-width:6px}
|
||
.imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
|
||
.image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
|
||
.image.left{margin-right:.625em}
|
||
.image.right{margin-left:.625em}
|
||
a.image{text-decoration:none;display:inline-block}
|
||
a.image object{pointer-events:none}
|
||
sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
|
||
sup.footnote a,sup.footnoteref a{text-decoration:none}
|
||
sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
|
||
#footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
|
||
#footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
|
||
#footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
|
||
#footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
|
||
#footnotes .footnote:last-of-type{margin-bottom:0}
|
||
#content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
|
||
.gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
|
||
.gist .file-data>table td.line-data{width:99%}
|
||
div.unbreakable{page-break-inside:avoid}
|
||
.big{font-size:larger}
|
||
.small{font-size:smaller}
|
||
.underline{text-decoration:underline}
|
||
.overline{text-decoration:overline}
|
||
.line-through{text-decoration:line-through}
|
||
.aqua{color:#00bfbf}
|
||
.aqua-background{background-color:#00fafa}
|
||
.black{color:#000}
|
||
.black-background{background-color:#000}
|
||
.blue{color:#0000bf}
|
||
.blue-background{background-color:#0000fa}
|
||
.fuchsia{color:#bf00bf}
|
||
.fuchsia-background{background-color:#fa00fa}
|
||
.gray{color:#606060}
|
||
.gray-background{background-color:#7d7d7d}
|
||
.green{color:#006000}
|
||
.green-background{background-color:#007d00}
|
||
.lime{color:#00bf00}
|
||
.lime-background{background-color:#00fa00}
|
||
.maroon{color:#600000}
|
||
.maroon-background{background-color:#7d0000}
|
||
.navy{color:#000060}
|
||
.navy-background{background-color:#00007d}
|
||
.olive{color:#606000}
|
||
.olive-background{background-color:#7d7d00}
|
||
.purple{color:#600060}
|
||
.purple-background{background-color:#7d007d}
|
||
.red{color:#bf0000}
|
||
.red-background{background-color:#fa0000}
|
||
.silver{color:#909090}
|
||
.silver-background{background-color:#bcbcbc}
|
||
.teal{color:#006060}
|
||
.teal-background{background-color:#007d7d}
|
||
.white{color:#bfbfbf}
|
||
.white-background{background-color:#fafafa}
|
||
.yellow{color:#bfbf00}
|
||
.yellow-background{background-color:#fafa00}
|
||
span.icon>.fa{cursor:default}
|
||
a span.icon>.fa{cursor:inherit}
|
||
.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
|
||
.admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
|
||
.admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
|
||
.admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
|
||
.admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
|
||
.admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
|
||
.conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
|
||
.conum[data-value] *{color:#fff!important}
|
||
.conum[data-value]+b{display:none}
|
||
.conum[data-value]::after{content:attr(data-value)}
|
||
pre .conum[data-value]{position:relative;top:-.125em}
|
||
b.conum *{color:inherit!important}
|
||
.conum:not([data-value]):empty{display:none}
|
||
dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
|
||
h1,h2,p,td.content,span.alt{letter-spacing:-.01em}
|
||
p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
|
||
p,blockquote,dt,td.content,span.alt{font-size:1.0625rem}
|
||
p{margin-bottom:1.25rem}
|
||
.sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
|
||
.exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
|
||
.print-only{display:none!important}
|
||
@page{margin:1.25cm .75cm}
|
||
@media print{*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
|
||
html{font-size:80%}
|
||
a{color:inherit!important;text-decoration:underline!important}
|
||
a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
|
||
a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
|
||
abbr[title]::after{content:" (" attr(title) ")"}
|
||
pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
|
||
thead{display:table-header-group}
|
||
svg{max-width:100%}
|
||
p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
|
||
h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
|
||
#toc,.sidebarblock,.exampleblock>.content{background:none!important}
|
||
#toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
|
||
body.book #header{text-align:center}
|
||
body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
|
||
body.book #header .details{border:0!important;display:block;padding:0!important}
|
||
body.book #header .details span:first-child{margin-left:0!important}
|
||
body.book #header .details br{display:block}
|
||
body.book #header .details br+span::before{content:none!important}
|
||
body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
|
||
body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
|
||
.listingblock code[data-lang]::before{display:block}
|
||
#footer{padding:0 .9375em}
|
||
.hide-on-print{display:none!important}
|
||
.print-only{display:block!important}
|
||
.hide-for-print{display:none!important}
|
||
.show-for-print{display:inherit!important}}
|
||
@media print,amzn-kf8{#header>h1:first-child{margin-top:1.25rem}
|
||
.sect1{padding:0!important}
|
||
.sect1+.sect1{border:0}
|
||
#footer{background:none}
|
||
#footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
|
||
@media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
|
||
</style>
|
||
<style>
|
||
.listingblock .pygments .hll { background-color: #ffffcc }
|
||
.listingblock .pygments, .listingblock .pygments code { background: #f0f0f0; }
|
||
.listingblock .pygments .tok-c { color: #60a0b0; font-style: italic } /* Comment */
|
||
.listingblock .pygments .tok-err { border: 1px solid #FF0000 } /* Error */
|
||
.listingblock .pygments .tok-k { color: #007020; font-weight: bold } /* Keyword */
|
||
.listingblock .pygments .tok-o { color: #666666 } /* Operator */
|
||
.listingblock .pygments .tok-ch { color: #60a0b0; font-style: italic } /* Comment.Hashbang */
|
||
.listingblock .pygments .tok-cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */
|
||
.listingblock .pygments .tok-cp { color: #007020 } /* Comment.Preproc */
|
||
.listingblock .pygments .tok-cpf { color: #60a0b0; font-style: italic } /* Comment.PreprocFile */
|
||
.listingblock .pygments .tok-c1 { color: #60a0b0; font-style: italic } /* Comment.Single */
|
||
.listingblock .pygments .tok-cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */
|
||
.listingblock .pygments .tok-gd { color: #A00000 } /* Generic.Deleted */
|
||
.listingblock .pygments .tok-ge { font-style: italic } /* Generic.Emph */
|
||
.listingblock .pygments .tok-gr { color: #FF0000 } /* Generic.Error */
|
||
.listingblock .pygments .tok-gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
||
.listingblock .pygments .tok-gi { color: #00A000 } /* Generic.Inserted */
|
||
.listingblock .pygments .tok-go { color: #888888 } /* Generic.Output */
|
||
.listingblock .pygments .tok-gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
|
||
.listingblock .pygments .tok-gs { font-weight: bold } /* Generic.Strong */
|
||
.listingblock .pygments .tok-gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
||
.listingblock .pygments .tok-gt { color: #0044DD } /* Generic.Traceback */
|
||
.listingblock .pygments .tok-kc { color: #007020; font-weight: bold } /* Keyword.Constant */
|
||
.listingblock .pygments .tok-kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
|
||
.listingblock .pygments .tok-kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
|
||
.listingblock .pygments .tok-kp { color: #007020 } /* Keyword.Pseudo */
|
||
.listingblock .pygments .tok-kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
|
||
.listingblock .pygments .tok-kt { color: #902000 } /* Keyword.Type */
|
||
.listingblock .pygments .tok-m { color: #40a070 } /* Literal.Number */
|
||
.listingblock .pygments .tok-s { color: #4070a0 } /* Literal.String */
|
||
.listingblock .pygments .tok-na { color: #4070a0 } /* Name.Attribute */
|
||
.listingblock .pygments .tok-nb { color: #007020 } /* Name.Builtin */
|
||
.listingblock .pygments .tok-nc { color: #0e84b5; font-weight: bold } /* Name.Class */
|
||
.listingblock .pygments .tok-no { color: #60add5 } /* Name.Constant */
|
||
.listingblock .pygments .tok-nd { color: #555555; font-weight: bold } /* Name.Decorator */
|
||
.listingblock .pygments .tok-ni { color: #d55537; font-weight: bold } /* Name.Entity */
|
||
.listingblock .pygments .tok-ne { color: #007020 } /* Name.Exception */
|
||
.listingblock .pygments .tok-nf { color: #06287e } /* Name.Function */
|
||
.listingblock .pygments .tok-nl { color: #002070; font-weight: bold } /* Name.Label */
|
||
.listingblock .pygments .tok-nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
|
||
.listingblock .pygments .tok-nt { color: #062873; font-weight: bold } /* Name.Tag */
|
||
.listingblock .pygments .tok-nv { color: #bb60d5 } /* Name.Variable */
|
||
.listingblock .pygments .tok-ow { color: #007020; font-weight: bold } /* Operator.Word */
|
||
.listingblock .pygments .tok-w { color: #bbbbbb } /* Text.Whitespace */
|
||
.listingblock .pygments .tok-mb { color: #40a070 } /* Literal.Number.Bin */
|
||
.listingblock .pygments .tok-mf { color: #40a070 } /* Literal.Number.Float */
|
||
.listingblock .pygments .tok-mh { color: #40a070 } /* Literal.Number.Hex */
|
||
.listingblock .pygments .tok-mi { color: #40a070 } /* Literal.Number.Integer */
|
||
.listingblock .pygments .tok-mo { color: #40a070 } /* Literal.Number.Oct */
|
||
.listingblock .pygments .tok-sa { color: #4070a0 } /* Literal.String.Affix */
|
||
.listingblock .pygments .tok-sb { color: #4070a0 } /* Literal.String.Backtick */
|
||
.listingblock .pygments .tok-sc { color: #4070a0 } /* Literal.String.Char */
|
||
.listingblock .pygments .tok-dl { color: #4070a0 } /* Literal.String.Delimiter */
|
||
.listingblock .pygments .tok-sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
|
||
.listingblock .pygments .tok-s2 { color: #4070a0 } /* Literal.String.Double */
|
||
.listingblock .pygments .tok-se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
|
||
.listingblock .pygments .tok-sh { color: #4070a0 } /* Literal.String.Heredoc */
|
||
.listingblock .pygments .tok-si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
|
||
.listingblock .pygments .tok-sx { color: #c65d09 } /* Literal.String.Other */
|
||
.listingblock .pygments .tok-sr { color: #235388 } /* Literal.String.Regex */
|
||
.listingblock .pygments .tok-s1 { color: #4070a0 } /* Literal.String.Single */
|
||
.listingblock .pygments .tok-ss { color: #517918 } /* Literal.String.Symbol */
|
||
.listingblock .pygments .tok-bp { color: #007020 } /* Name.Builtin.Pseudo */
|
||
.listingblock .pygments .tok-fm { color: #06287e } /* Name.Function.Magic */
|
||
.listingblock .pygments .tok-vc { color: #bb60d5 } /* Name.Variable.Class */
|
||
.listingblock .pygments .tok-vg { color: #bb60d5 } /* Name.Variable.Global */
|
||
.listingblock .pygments .tok-vi { color: #bb60d5 } /* Name.Variable.Instance */
|
||
.listingblock .pygments .tok-vm { color: #bb60d5 } /* Name.Variable.Magic */
|
||
.listingblock .pygments .tok-il { color: #40a070 } /* Literal.Number.Integer.Long */
|
||
</style>
|
||
</head>
|
||
<body class="article toc2 toc-left">
|
||
<div id="header">
|
||
<h1>B2 User Manual</h1>
|
||
<div class="details">
|
||
<span id="author" class="author">René Ferdinand Rivera Morell, Vladimir Prus, Steven Watanabe</span><br>
|
||
</div>
|
||
<div id="toc" class="toc2">
|
||
<div id="toctitle">Table of Contents</div>
|
||
<ul class="sectlevel1">
|
||
<li><a href="#_introduction">1. Introduction</a></li>
|
||
<li><a href="#bbv2.installation">2. Installation</a></li>
|
||
<li><a href="#bbv2.tutorial">3. Tutorial</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#bbv2.tutorial.hello">3.1. Hello, world</a></li>
|
||
<li><a href="#bbv2.tutorial.properties">3.2. Properties</a></li>
|
||
<li><a href="#bbv2.tutorial.hierarchy">3.3. Project Hierarchies</a></li>
|
||
<li><a href="#bbv2.tutorial.libs">3.4. Dependent Targets</a></li>
|
||
<li><a href="#bbv2.tutorial.linkage">3.5. Static and shared libraries</a></li>
|
||
<li><a href="#bbv2.tutorial.conditions">3.6. Conditions and alternatives</a></li>
|
||
<li><a href="#bbv2.tutorial.prebuilt">3.7. Prebuilt targets</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#bbv2.overview">4. Overview</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#bbv2.overview.concepts">4.1. Concepts</a></li>
|
||
<li><a href="#bbv2.overview.jam_language">4.2. Boost.Jam Language</a></li>
|
||
<li><a href="#bbv2.overview.configuration">4.3. Configuration</a></li>
|
||
<li><a href="#bbv2.overview.invocation">4.4. Invocation</a></li>
|
||
<li><a href="#bbv2.overview.targets">4.5. Declaring Targets</a></li>
|
||
<li><a href="#bbv2.overview.projects">4.6. Projects</a></li>
|
||
<li><a href="#bbv2.overview.build_process">4.7. The Build Process</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#bbv2.tasks">5. Common tasks</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#bbv2.tasks.programs">5.1. Programs</a></li>
|
||
<li><a href="#bbv2.tasks.libraries">5.2. Libraries</a></li>
|
||
<li><a href="#bbv2.tasks.alias">5.3. Alias</a></li>
|
||
<li><a href="#bbv2.tasks.installing">5.4. Installing</a></li>
|
||
<li><a href="#bbv2.builtins.testing">5.5. Testing</a></li>
|
||
<li><a href="#bbv2.builtins.raw">5.6. Custom commands</a></li>
|
||
<li><a href="#bbv2.reference.precompiled_headers">5.7. Precompiled Headers</a></li>
|
||
<li><a href="#bbv2.reference.generated_headers">5.8. Generated headers</a></li>
|
||
<li><a href="#bbv2.tasks.crosscompile">5.9. Cross-compilation</a></li>
|
||
<li><a href="#bbv2.tasks.packagemanagers">5.10. Package Managers</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#bbv2.reference">6. Reference</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#bbv2.reference.general">6.1. General information</a></li>
|
||
<li><a href="#bbv2.reference.rules">6.2. Builtin rules</a></li>
|
||
<li><a href="#bbv2.overview.builtins.features">6.3. Builtin features</a></li>
|
||
<li><a href="#bbv2.reference.tools">6.4. Builtin tools</a></li>
|
||
<li><a href="#bbv2.reference.modules">6.5. Builtin modules</a></li>
|
||
<li><a href="#bbv2.reference.class">6.6. Builtin classes</a></li>
|
||
<li><a href="#bbv2.reference.buildprocess">6.7. Build process</a></li>
|
||
<li><a href="#bbv2.reference.definitions">6.8. Definitions</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#bbv2.util">7. Utilities</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#bbv2.util.debugger">7.1. Debugger</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#bbv2.extender">8. Extender Manual</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#bbv2.extender.intro">8.1. Introduction</a></li>
|
||
<li><a href="#bbv2.extender.example">8.2. Example: 1-to-1 generator</a></li>
|
||
<li><a href="#bbv2.extending.targets">8.3. Target types</a></li>
|
||
<li><a href="#bbv2.extending.scanners">8.4. Scanners</a></li>
|
||
<li><a href="#bbv2.extending.tools">8.5. Tools and generators</a></li>
|
||
<li><a href="#bbv2.extending.features">8.6. Features</a></li>
|
||
<li><a href="#bbv2.extending.rules">8.7. Main target rules</a></li>
|
||
<li><a href="#bbv2.extending.toolset_modules">8.8. Toolset modules</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#bbv2.faq">9. Frequently Asked Questions</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#bbv2.faq.featurevalue">9.1. How do I get the current value of feature in Jamfile?</a></li>
|
||
<li><a href="#bbv2.faq.duplicate">9.2. I am getting a "Duplicate name of actual target" error. What does that mean?</a></li>
|
||
<li><a href="#bbv2.faq.envar">9.3. Accessing environment variables</a></li>
|
||
<li><a href="#bbv2.faq.proporder">9.4. How to control properties order?</a></li>
|
||
<li><a href="#bbv2.faq.liborder">9.5. How to control the library linking order on Unix?</a></li>
|
||
<li><a href="#bbv2.faq.external">9.6. Can I get capture external program output using a Boost.Jam variable?</a></li>
|
||
<li><a href="#bbv2.faq.projectroot">9.7. How to get the project root (a.k.a. Jamroot) location?</a></li>
|
||
<li><a href="#bbv2.faq.flags">9.8. How to change compilation flags for one file?</a></li>
|
||
<li><a href="#bbv2.faq.dll-path">9.9. Why are the <code>dll-path</code> and <code>hardcode-dll-paths</code> properties useful?</a></li>
|
||
<li><a href="#bbv2.recipes.site-config">9.10. Targets in site-config.jam</a></li>
|
||
<li><a href="#bbv2.faq.header-only-libraries">9.11. Header-only libraries</a></li>
|
||
<li><a href="#bbv2.faq.names">9.12. What is the difference between B2, <code>b2</code>, <code>bjam</code> and Perforce Jam?</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#_extra_tools">10. Extra Tools</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#_documentation_tools_2">10.1. Documentation Tools</a></li>
|
||
<li><a href="#_miscellaneous_tools">10.2. Miscellaneous Tools</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#_examples">11. Examples</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#_introduction_2">11.1. Introduction</a></li>
|
||
<li><a href="#_hello">11.2. Hello</a></li>
|
||
<li><a href="#_sanitizers">11.3. Sanitizers</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#bbv2.jam">12. Boost.Jam Documentation</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#jam.building">12.1. Building B2</a></li>
|
||
<li><a href="#jam.language">12.2. Language</a></li>
|
||
<li><a href="#jam.miscellaneous">12.3. Miscellaneous</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#b2.history">13. History</a>
|
||
<ul class="sectlevel2">
|
||
<li><a href="#_version_4_4_1">13.1. Version 4.4.1</a></li>
|
||
<li><a href="#_version_4_4_0">13.2. Version 4.4.0</a></li>
|
||
<li><a href="#_version_4_3_0">13.3. Version 4.3.0</a></li>
|
||
<li><a href="#_version_4_2_0">13.4. Version 4.2.0</a></li>
|
||
<li><a href="#_version_4_1_0">13.5. Version 4.1.0</a></li>
|
||
<li><a href="#_version_4_0_1">13.6. Version 4.0.1</a></li>
|
||
<li><a href="#_version_4_0_0">13.7. Version 4.0.0</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div id="content">
|
||
<div class="sect1">
|
||
<h2 id="_introduction"><a class="anchor" href="#_introduction"></a>1. Introduction</h2>
|
||
<div class="sectionbody">
|
||
<style>
|
||
.admonitionblock .icon .title {
|
||
font-size: 2.5em;
|
||
text-shadow: 1px 1px 2px rgba(0, 0, 0, .5);
|
||
}
|
||
.caution .icon .title {
|
||
color: rgba(192, 51, 0, 1);
|
||
}
|
||
.important .icon .title {
|
||
color: rgba(192, 0, 0, 1);
|
||
}
|
||
.note .icon .title {
|
||
color: rgba(26, 64, 128, 1);
|
||
}
|
||
.tip .icon .title {
|
||
color: rgba(255, 192, 0, 1);
|
||
}
|
||
.warning .icon .title {
|
||
color: rgba(192, 102, 0, 1);
|
||
}
|
||
p,blockquote,dt,td.content,span.alt {
|
||
font-size: 1.1rem
|
||
}
|
||
h1, h2, h3, h4, h5, h6 {
|
||
font-weight: bold;
|
||
}
|
||
h1 {
|
||
font-size: 2.25em;
|
||
}
|
||
h2 {
|
||
font-size: 1.5em;
|
||
}
|
||
h3,#toctitle,.sidebarblock>.content>.title {
|
||
font-size: 1.3em;
|
||
}
|
||
h4, h5 {
|
||
font-size: 1.2em;
|
||
}
|
||
h6 {
|
||
font-size: 1.1em;
|
||
}
|
||
</style>
|
||
<div class="paragraph">
|
||
<p>Want to learn about B2 features? Start with the
|
||
<a href="#bbv2.tutorial">tutorial</a> and continue with the <a href="#bbv2.overview">overview</a>.
|
||
When you’re ready to try B2 in practice, go to the
|
||
<a href="#bbv2.installation">installation</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Building a project with B2? See the <a href="#bbv2.installation">installation</a>
|
||
and then read the <a href="#bbv2.overview.invocation">overview</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Setting up B2 on your project? Take a look at the
|
||
<a href="#bbv2.overview">overview</a> and <a href="#bbv2.extender">extender manual</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If there’s anything you find unclear in this documentation, report the
|
||
problem directly in the <a href="https://github.com/boostorg/build/issues">issue
|
||
tracker</a>. For more general questions, please post them to our mailing
|
||
list (<a href="http://boost.org/more/mailing_lists.htm#jamboost" class="bare">http://boost.org/more/mailing_lists.htm#jamboost</a>).</p>
|
||
</div>
|
||
<div class="sidebarblock">
|
||
<div class="content">
|
||
<div class="paragraph">
|
||
<p>Copyright 2018-2021 René Ferdinand Rivera Morell;
|
||
Copyright 2006, 2014 Vladimir Prus.
|
||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||
file <code>LICENSE.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" class="bare">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- toc disabled -->
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.installation"><a class="anchor" href="#bbv2.installation"></a>2. Installation</h2>
|
||
<div class="sectionbody">
|
||
<div class="paragraph">
|
||
<p>To install B2 from an official release or a nightly build, as
|
||
available on the <a href="http://boost.org/boost-build2">official web site</a>,
|
||
follow these steps:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Unpack the release. On the command line, go to the root of the
|
||
unpacked tree.</p>
|
||
</li>
|
||
<li>
|
||
<p>Run either <code>.\bootstrap.bat</code> (on Windows), or <code>./bootstrap.sh</code> (on
|
||
other operating systems).</p>
|
||
</li>
|
||
<li>
|
||
<p>Run</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>$ ./b2 install --prefix<span class="tok-o">=</span>PREFIX</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>where PREFIX is a directory where you want B2 to be installed.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>Optionally, add <code>PREFIX/bin</code> to your PATH environment variable.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you are not using a B2 package, but rather the version
|
||
bundled with the Boost C++ Libraries, the above commands should be run
|
||
in the <code>tools/build</code> directory.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Now that B2 is installed, you can try some of the examples.
|
||
Copy <code>PREFIX/share/boost-build/examples/hello</code> to a different directory,
|
||
then change to that directory and run:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>$ PREFIX/bin/b2</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A simple executable should be built.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.tutorial"><a class="anchor" href="#bbv2.tutorial"></a>3. Tutorial</h2>
|
||
<div class="sectionbody">
|
||
<div class="paragraph">
|
||
<p>This section will guide you though the most basic features of
|
||
B2. We will start with the “Hello, world” example, learn how to
|
||
use libraries, and finish with testing and installing features.</p>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tutorial.hello"><a class="anchor" href="#bbv2.tutorial.hello"></a>3.1. Hello, world</h3>
|
||
<div class="paragraph">
|
||
<p>The simplest project that B2 can construct is stored in
|
||
<code>example/hello/</code> directory. The project is described by a file called
|
||
<code>Jamfile</code> that contains:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Even with this simple setup, you can do some interesting things. First
|
||
of all, just invoking <code>b2</code> will build the <code>hello</code> executable by compiling
|
||
and linking <code>hello.cpp</code>. By default, the debug variant is built. Now, to
|
||
build the release variant of <code>hello</code>, invoke</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 release</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that the debug and release variants are created in different
|
||
directories, so you can switch between variants or even build multiple
|
||
variants at once, without any unnecessary recompilation. Let us extend
|
||
the example by adding another line to our project’s <code>Jamfile</code>:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello2<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Now let us build both the debug and release variants of our project
|
||
again:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 debug release</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that two variants of <code>hello2</code> are linked. Since we have already
|
||
built both variants of <code>hello</code>, hello.cpp will not be recompiled;
|
||
instead the existing object files will just be linked into the
|
||
corresponding variants of <code>hello2</code>. Now let us remove all the built
|
||
products:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 --clean debug release</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It is also possible to build or clean specific targets. The following
|
||
two commands, respectively, build or clean only the debug version of
|
||
<code>hello2</code>.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 hello2
|
||
b2 --clean hello2</code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tutorial.properties"><a class="anchor" href="#bbv2.tutorial.properties"></a>3.2. Properties</h3>
|
||
<div class="paragraph">
|
||
<p>To represent aspects of target configuration such as debug and release
|
||
variants, or single- and multi-threaded builds portably, B2
|
||
uses <em>features</em> with associated <em>values</em>. For example, the <code>debug-symbols</code>
|
||
feature can have a value of <code>on</code> or <code>off</code>. A <em>property</em> is just a
|
||
(feature, value) pair. When a user initiates a build, B2
|
||
automatically translates the requested properties into appropriate
|
||
command-line flags for invoking toolset components like compilers and
|
||
linkers.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are many built-in features that can be combined to produce
|
||
arbitrary build configurations. The following command builds the
|
||
project’s <code>release</code> variant with inlining disabled and debug symbols
|
||
enabled:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 release <span class="tok-nv">inlining</span><span class="tok-o">=</span>off debug-symbols<span class="tok-o">=</span>on</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Properties on the command-line are specified with the syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>feature-name=feature-value</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>release</code> and <code>debug</code> that we have seen in <code>b2</code> invocations are just
|
||
a shorthand way to specify values of the <code>variant</code> feature. For example,
|
||
the command above could also have been written this way:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">variant</span><span class="tok-o">=</span>release <span class="tok-nv">inlining</span><span class="tok-o">=</span>off debug-symbols<span class="tok-o">=</span>on</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>variant</code> is so commonly-used that it has been given special status as
|
||
an <em>implicit</em> feature—B2 will deduce its identity just from the
|
||
name of one of its values.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A complete description of features can be found in
|
||
<a href="#bbv2.reference.features">the section called “Features and properties”</a>.</p>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.tutorial.properties.requirements"><a class="anchor" href="#bbv2.tutorial.properties.requirements"></a>3.2.1. Build Requests and Target Requirements</h4>
|
||
<div class="paragraph">
|
||
<p>The set of properties specified on the command line constitutes a <em>build
|
||
request</em>—a description of the desired properties for building the
|
||
requested targets (or, if no targets were explicitly requested, the
|
||
project in the current directory). The <em>actual</em> properties used for
|
||
building targets are typically a combination of the build request and
|
||
properties derived from the project’s <code>Jamfile</code> (and its other Jamfiles,
|
||
as described in
|
||
<a href="#bbv2.tutorial.hierarchy">the section called “Project Hierarchies”</a>).
|
||
For example, the locations of `#include`d header files are normally not
|
||
specified on the command-line, but described in Jamfiles as <em>target
|
||
requirements</em> and automatically combined with the build request for those
|
||
targets. Multi-threaded compilation is another example of a typical
|
||
target requirement. The Jamfile fragment below illustrates how these
|
||
requirements might be specified.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>boost<span class="tok-w"> </span><span class="tok-na"><threading></span>multi<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When <code>hello</code> is built, the two requirements specified above will always
|
||
be present. If the build request given on the <code>b2</code> command-line
|
||
explicitly contradicts a target’s requirements, the target requirements
|
||
usually override (or, in the case of “free” features like
|
||
<code><include></code>, <sup class="footnote">[<a id="_footnoteref_1" class="footnote" href="#_footnotedef_1" title="View footnote.">1</a>]</sup>
|
||
augment) the build request.</p>
|
||
</div>
|
||
<div class="admonitionblock tip">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">☀</div>
|
||
</td>
|
||
<td class="content">
|
||
The value of the <code><include></code> feature is relative to the location of
|
||
<code>Jamfile</code> where it is used.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.tutorial.properties.project_attributes"><a class="anchor" href="#bbv2.tutorial.properties.project_attributes"></a>3.2.2. Project Attributes</h4>
|
||
<div class="paragraph">
|
||
<p>If we want the same requirements for our other target, <code>hello2</code>, we
|
||
could simply duplicate them. However, as projects grow, that approach
|
||
leads to a great deal of repeated boilerplate in Jamfiles. Fortunately,
|
||
there’s a better way. Each project can specify a set of <em>attributes</em>,
|
||
including requirements:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"> </span><span class="tok-na"><include></span>/home/ghost/Work/boost<span class="tok-w"> </span><span class="tok-na"><threading></span>multi<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>hello2<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The effect would be as if we specified the same requirement for both
|
||
<code>hello</code> and <code>hello2</code>.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tutorial.hierarchy"><a class="anchor" href="#bbv2.tutorial.hierarchy"></a>3.3. Project Hierarchies</h3>
|
||
<div class="paragraph">
|
||
<p>So far we have only considered examples with one project, with one
|
||
user-written <code>Jamfile</code> file. A typical large codebase would
|
||
be composed of many projects organized into a tree. The top of the tree
|
||
is called the <em>project root</em>. Every subproject is defined by a file called
|
||
<code>Jamfile</code> in a descendant directory of the project root. The parent
|
||
project of a subproject is defined by the nearest Jamfile
|
||
file in an ancestor directory. For example, in the following directory
|
||
layout:</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>top/
|
||
|
|
||
+-- Jamfile
|
||
|
|
||
+-- app/
|
||
| |
|
||
| +-- Jamfile
|
||
| `-- app.cpp
|
||
|
|
||
`-- util/
|
||
|
|
||
+-- foo/
|
||
. |
|
||
. +-- Jamfile
|
||
. `-- bar.cpp</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>the project root is <code>top/</code>. The projects in <code>top/app/</code> and
|
||
<code>top/util/foo/</code> are immediate children of the root project.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
When we refer to a “Jamfile,” set in normal type, we mean a file called
|
||
either <code>Jamfile</code> or <code>Jamroot</code>. When we need to be more specific, the
|
||
filename will be set as “<code>Jamfile</code>” or “<code>Jamroot</code>.”
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Projects inherit all attributes (such as requirements) from their
|
||
parents. Inherited requirements are combined with any requirements
|
||
specified by the subproject. For example, if <code>top/Jamfile</code> has</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-na"><include></span>/home/ghost/local<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>in its requirements, then all of its sub-projects will have it in their
|
||
requirements, too. Of course, any project can add include paths to those
|
||
specified by its parents. <sup class="footnote">[<a id="_footnoteref_2" class="footnote" href="#_footnotedef_2" title="View footnote.">2</a>]</sup> More
|
||
details can be found in <a href="#bbv2.overview.projects">the section called “Projects”</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Invoking <code>b2</code> without explicitly specifying any targets on the command
|
||
line builds the project rooted in the current directory. Building a
|
||
project does not automatically cause its sub-projects to be built unless
|
||
the parent project’s Jamfile explicitly requests it. In our example,
|
||
<code>top/Jamfile</code> might contain:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">build-project</span><span class="tok-w"> </span>app<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>which would cause the project in <code>top/app/</code> to be built whenever the
|
||
project in <code>top/</code> is built. However, targets in <code>top/util/foo/</code> will be
|
||
built only if they are needed by targets in <code>top/</code> or <code>top/app/</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tutorial.libs"><a class="anchor" href="#bbv2.tutorial.libs"></a>3.4. Dependent Targets</h3>
|
||
<div class="paragraph">
|
||
<p>When building a target <code>X</code> that depends on first building another target
|
||
<code>Y</code> (such as a library that must be linked with X), <code>Y</code> is called a
|
||
<em>dependency</em> of <code>X</code> and <code>X</code> is termed a <em>dependent</em> of <code>Y</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To get a feeling of target dependencies, let’s continue the above
|
||
example and see how <code>top/app/Jamfile</code> can use libraries from
|
||
<code>top/util/foo</code>. If <code>top/util/foo/Jamfile</code> contains</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>bar<span class="tok-w"> </span>:<span class="tok-w"> </span>bar.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>then to use this library in <code>top/app/Jamfile</code>, we can write:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>app<span class="tok-w"> </span>:<span class="tok-w"> </span>app.cpp<span class="tok-w"> </span>../util/foo//bar<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>While <code>app.cpp</code> refers to a regular source file, <code>../util/foo//bar</code> is a
|
||
reference to another target: a library <code>bar</code> declared in the Jamfile at
|
||
<code>../util/foo</code>.</p>
|
||
</div>
|
||
<div class="admonitionblock tip">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">☀</div>
|
||
</td>
|
||
<td class="content">
|
||
Some other build system have special syntax for listing dependent
|
||
libraries, for example <code>LIBS</code> variable. In B2, you just add the
|
||
library to the list of sources.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Suppose we build <code>app</code> with:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 app <span class="tok-nv">optimization</span><span class="tok-o">=</span>full <span class="tok-nv">define</span><span class="tok-o">=</span>USE_ASM</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Which properties will be used to build <code>foo</code>? The answer is that some
|
||
features are <em>propagated</em> — B2 attempts to use dependencies with
|
||
the same value of propagated features. The <code><optimization></code> feature is
|
||
propagated, so both <code>app</code> and <code>foo</code> will be compiled with full
|
||
optimization. But <code><define></code> is not propagated: its value will be added
|
||
as-is to the compiler flags for <code>a.cpp</code>, but won’t affect <code>foo</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Let’s improve this project further. The library probably has some
|
||
headers that must be used when compiling <code>app.cpp</code>. We could manually
|
||
add the necessary <code>#include</code> paths to the <code>app</code> requirements as values of
|
||
the <code><include></code> feature, but then this work will be repeated for all
|
||
programs that use <code>foo</code>. A better solution is to modify
|
||
<code>util/foo/Jamfile</code> in this way:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>usage-requirements<span class="tok-w"> </span><span class="tok-na"><include></span>.<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>foo<span class="tok-w"> </span>:<span class="tok-w"> </span>foo.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Usage requirements are applied not to the target being declared but to
|
||
its dependents. In this case, <code><include>.</code> will be applied to all
|
||
targets that directly depend on <code>foo</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Another improvement is using symbolic identifiers to refer to the
|
||
library, as opposed to <code>Jamfile</code> location. In a large project, a library
|
||
can be used by many targets, and if they all use <code>Jamfile</code> location, a change
|
||
in directory organization entails much work.
|
||
The solution is to use project ids—symbolic names not tied to directory
|
||
layout. First, we need to assign a project id by adding this code to
|
||
<code>Jamfile</code>:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">use-project</span><span class="tok-w"> </span>/library-example/foo<span class="tok-w"> </span>:<span class="tok-w"> </span>util/foo<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Second, we modify <code>app/Jamfile</code> to use the project id:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>app<span class="tok-w"> </span>:<span class="tok-w"> </span>app.cpp<span class="tok-w"> </span>/library-example/foo//bar<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>/library-example/foo//bar</code> syntax is used to refer to the target
|
||
<code>bar</code> in the project with id <code>/library-example/foo</code>. We’ve achieved our
|
||
goal—if the library is moved to a different directory, only <code>top/Jamfile</code>
|
||
must be modified. Note that project ids are global—two Jamfiles
|
||
are not allowed to assign the same project id to different directories.</p>
|
||
</div>
|
||
<div class="admonitionblock tip">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">☀</div>
|
||
</td>
|
||
<td class="content">
|
||
<div class="paragraph">
|
||
<p>If you want all applications in some project to link to a certain
|
||
library, you can avoid having to specify directly the sources of every
|
||
target by using the <code><library></code> property. For example, if
|
||
<code>/boost/filesystem//fs</code> should be linked to all applications in your
|
||
project, you can add <code><library>/boost/filesystem//fs</code> to the project’s
|
||
requirements, like this:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"> </span><span class="tok-na"><library></span>/boost/filesystem//fs<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tutorial.linkage"><a class="anchor" href="#bbv2.tutorial.linkage"></a>3.5. Static and shared libraries</h3>
|
||
<div class="paragraph">
|
||
<p>Libraries can be either <em>static</em>, which means they are included in
|
||
executable files that use them, or <em>shared</em> (a.k.a. <em>dynamic</em>), which
|
||
are only referred to from executables, and must be available at run
|
||
time. B2 can create and use both kinds.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The kind of library produced from a <code>lib</code> target is determined by the
|
||
value of the <code>link</code> feature. Default value is <code>shared</code>, and to build a
|
||
static library, the value should be <code>static</code>. You can request a static
|
||
build either on the command line:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">link</span><span class="tok-o">=</span>static</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>or in the library’s requirements:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>l<span class="tok-w"> </span>:<span class="tok-w"> </span>l.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We can also use the <code><link></code> property to express linking requirements on
|
||
a per-target basis. For example, if a particular executable can be
|
||
correctly built only with the static version of a library, we can
|
||
qualify the executable’s <a href="#bbv2.reference.targets.references">target
|
||
reference</a> to the library as follows:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>important<span class="tok-w"> </span>:<span class="tok-w"> </span>main.cpp<span class="tok-w"> </span>helpers/<span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>No matter what arguments are specified on the <code>b2</code> command line,
|
||
<code>important</code> will only be linked with the static version of <code>helpers</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Specifying properties in target references is especially useful if you
|
||
use a library defined in some other project (one you can’t change) but
|
||
you still want static (or dynamic) linking to that library in all cases.
|
||
If that library is used by many targets, you <em>could</em> use target
|
||
references everywhere:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>e1<span class="tok-w"> </span>:<span class="tok-w"> </span>e1.cpp<span class="tok-w"> </span>/other_project//bar/<span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>e10<span class="tok-w"> </span>:<span class="tok-w"> </span>e10.cpp<span class="tok-w"> </span>/other_project//bar/<span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>but that’s far from being convenient. A better approach is to introduce
|
||
a level of indirection. Create a local <code>alias</code> target that refers to the
|
||
static (or dynamic) version of <code>foo</code>:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">alias</span><span class="tok-w"> </span>foo<span class="tok-w"> </span>:<span class="tok-w"> </span>/other_project//bar/<span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>e1<span class="tok-w"> </span>:<span class="tok-w"> </span>e1.cpp<span class="tok-w"> </span>foo<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>e10<span class="tok-w"> </span>:<span class="tok-w"> </span>e10.cpp<span class="tok-w"> </span>foo<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <a href="#bbv2.tasks.alias">alias</a> rule is specifically used to rename a
|
||
reference to a target and possibly change the properties.</p>
|
||
</div>
|
||
<div class="admonitionblock tip">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">☀</div>
|
||
</td>
|
||
<td class="content">
|
||
<div class="paragraph">
|
||
<p>When one library uses another, you put the second library in the source
|
||
list of the first. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>utils<span class="tok-w"> </span>:<span class="tok-w"> </span>utils.cpp<span class="tok-w"> </span>/boost/filesystem//fs<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>core<span class="tok-w"> </span>:<span class="tok-w"> </span>core.cpp<span class="tok-w"> </span>utils<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>app<span class="tok-w"> </span>:<span class="tok-w"> </span>app.cpp<span class="tok-w"> </span>core<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This works no matter what kind of linking is used. When <code>core</code> is built as a
|
||
shared library, links <code>utils</code> directly into it. Static libraries can’t link
|
||
to other libraries, so when <code>core</code> is built as a static library, its
|
||
dependency on <code>utils</code> is passed along to <code>core’s dependents, causing `app</code>
|
||
to be linked with both <code>core</code> and <code>utils</code>.</p>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
(Note for non-UNIX system). Typically, shared libraries must be
|
||
installed to a directory in the dynamic linker’s search path. Otherwise,
|
||
applications that use shared libraries can’t be started. On Windows, the
|
||
dynamic linker’s search path is given by the <code>PATH</code> environment variable.
|
||
This restriction is lifted when you use B2 testing
|
||
facilities—the <code>PATH</code> variable will be automatically adjusted before
|
||
running the executable.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tutorial.conditions"><a class="anchor" href="#bbv2.tutorial.conditions"></a>3.6. Conditions and alternatives</h3>
|
||
<div class="paragraph">
|
||
<p>Sometimes, particular relationships need to be maintained among a
|
||
target’s build properties. For example, you might want to set specific
|
||
<code>#define</code> when a library is built as shared, or when a target’s
|
||
<code>release</code> variant is built. This can be achieved using <em>conditional
|
||
requirements</em>.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>network<span class="tok-w"> </span>:<span class="tok-w"> </span>network.cpp<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><link></span>shared:<span class="tok-na"><define></span>NETWORK_LIB_SHARED<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><variant></span>release:<span class="tok-na"><define></span>EXTRA_FAST<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In the example above, whenever <code>network</code> is built with <code><link>shared</code>,
|
||
<code><define>NETWORK_LIB_SHARED</code> will be in its properties, too. Also, whenever
|
||
its release variant is built, <code><define>EXTRA_FAST</code> will appear in its
|
||
properties.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Sometimes the ways a target is built are so different that describing
|
||
them using conditional requirements would be hard. For example, imagine
|
||
that a library actually uses different source files depending on the
|
||
toolset used to build it. We can express this situation using target
|
||
<em>alternatives</em>:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>demangler<span class="tok-w"> </span>:<span class="tok-w"> </span>dummy_demangler.cpp<span class="tok-w"> </span>;<span class="tok-w"> </span># <b class="conum">(1)</b>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>demangler<span class="tok-w"> </span>:<span class="tok-w"> </span>demangler_gcc.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>gcc<span class="tok-w"> </span>;<span class="tok-w"> </span># <b class="conum">(2)</b>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>demangler<span class="tok-w"> </span>:<span class="tok-w"> </span>demangler_msvc.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>msvc<span class="tok-w"> </span>;<span class="tok-w"> </span># <b class="conum">(3)</b></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When building <code>demangler</code>, B2 will compare requirements for
|
||
each alternative with build properties to find the best match. For
|
||
example, when building with <code><toolset>gcc</code> alternative <strong>(2)</strong>, will be
|
||
selected, and when building with <code><toolset>msvc</code> alternative <strong>(3)</strong> will be
|
||
selected. In all other cases, the most generic alternative <strong>(1)</strong> will be
|
||
built.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tutorial.prebuilt"><a class="anchor" href="#bbv2.tutorial.prebuilt"></a>3.7. Prebuilt targets</h3>
|
||
<div class="paragraph">
|
||
<p>To link to libraries whose build instructions aren’t given in a Jamfile,
|
||
you need to create <code>lib</code> targets with an appropriate <code>file</code> property.
|
||
Target alternatives can be used to associate multiple library files with
|
||
a single conceptual target. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-c1"># util/lib2/Jamfile</span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>lib2<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><file></span>lib2_release.a<span class="tok-w"> </span><span class="tok-na"><variant></span>release<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>lib2<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><file></span>lib2_debug.a<span class="tok-w"> </span><span class="tok-na"><variant></span>debug<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This example defines two alternatives for <code>lib2</code>, and for each one names
|
||
a prebuilt file. Naturally, there are no sources. Instead, the <code><file></code>
|
||
feature is used to specify the file name.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Once a prebuilt target has been declared, it can be used just like any
|
||
other target:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>app<span class="tok-w"> </span>:<span class="tok-w"> </span>app.cpp<span class="tok-w"> </span>../util/lib2//lib2<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>As with any target, the alternative selected depends on the properties
|
||
propagated from <code>lib2’s dependents. If we build the release and debug
|
||
versions of `app</code> it will be linked with <code>lib2_release.a</code> and
|
||
<code>lib2_debug.a</code>, respectively.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>System libraries — those that are automatically found by the toolset by
|
||
searching through some set of predetermined paths — should be declared
|
||
almost like regular ones:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>pythonlib<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>python22<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We again don’t specify any sources, but give a <code>name</code> that should be
|
||
passed to the compiler. If the gcc toolset were used to link an
|
||
executable target to <code>pythonlib</code>, <code>-lpython22</code> would appear in the
|
||
command line (other compilers may use different options).</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We can also specify where the toolset should look for the library:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>pythonlib<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>python22<span class="tok-w"> </span><span class="tok-na"><search></span>/opt/lib<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>And, of course, target alternatives can be used in the usual way:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>pythonlib<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>python22<span class="tok-w"> </span><span class="tok-na"><variant></span>release<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>pythonlib<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>python22_d<span class="tok-w"> </span><span class="tok-na"><variant></span>debug<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A more advanced use of prebuilt targets is described in
|
||
<a href="#bbv2.recipes.site-config">the section called “Targets in
|
||
site-config.jam”</a>.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.overview"><a class="anchor" href="#bbv2.overview"></a>4. Overview</h2>
|
||
<div class="sectionbody">
|
||
<div class="paragraph">
|
||
<p>This section will provide the information necessary to create your own
|
||
projects using B2. The information provided here is relatively
|
||
high-level, and the <a href="#bbv2.reference">Reference</a> as well as the on-line
|
||
help system must be used to obtain low-level documentation (see
|
||
<a href="#bbv2.overview.invocation.options.help"><code>--help</code></a>).</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>B2 has two parts — a build engine with its own interpreted
|
||
language, and B2 itself, implemented in that language. The
|
||
chain of events when you type <code>b2</code> on the command line is as follows:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>The B2 executable tries to find B2 modules and
|
||
loads the top-level module. The exact process is described in
|
||
<a href="#bbv2.reference.init">the section called “Initialization”</a></p>
|
||
</li>
|
||
<li>
|
||
<p>The top-level module loads user-defined configuration files,
|
||
<code>user-config.jam</code> and <code>site-config.jam</code>, which define available
|
||
toolsets.</p>
|
||
</li>
|
||
<li>
|
||
<p>The Jamfile in the current directory is read. That in turn might
|
||
cause reading of further Jamfiles. As a result, a tree of projects is
|
||
created, with targets inside projects.</p>
|
||
</li>
|
||
<li>
|
||
<p>Finally, using the build request specified on the command line,
|
||
B2 decides which targets should be built and how. That
|
||
information is passed back to Boost.Jam, which takes care of actually
|
||
running the scheduled build action commands.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>So, to be able to successfully use B2, you need to know only
|
||
four things:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><a href="#bbv2.overview.configuration">How to configure B2</a></p>
|
||
</li>
|
||
<li>
|
||
<p><a href="#bbv2.overview.targets">How to declare targets in Jamfiles</a></p>
|
||
</li>
|
||
<li>
|
||
<p><a href="#bbv2.overview.build_process">How the build process works</a></p>
|
||
</li>
|
||
<li>
|
||
<p>Some Basics about the Boost.Jam language. See
|
||
<a href="#bbv2.overview.jam_language">the section called “Boost.Jam Language”</a>.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.overview.concepts"><a class="anchor" href="#bbv2.overview.concepts"></a>4.1. Concepts</h3>
|
||
<div class="paragraph">
|
||
<p>B2 has a few unique concepts that are introduced in this
|
||
section. The best way to explain the concepts is by comparison with more
|
||
classical build tools.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When using any flavor of make, you directly specify <em>targets</em> and
|
||
commands that are used to create them from other target. The below
|
||
example creates <code>a.o</code> from <code>a.c</code> using a hardcoded compiler invocation
|
||
command.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="make"><span></span><span class="tok-nf">a.o</span><span class="tok-o">:</span> <span class="tok-n">a</span>.<span class="tok-n">c</span>
|
||
g++ -o a.o -g a.c</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This is a rather low-level description mechanism and it’s hard to adjust
|
||
commands, options, and sets of created targets depending on the compiler
|
||
and operating system used.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To improve portability, most modern build system provide a set of
|
||
higher-level functions that can be used in build description files.
|
||
Consider this example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="cmake"><span></span><span class="tok-nb">add_program</span> <span class="tok-p">(</span><span class="tok-s2">"a"</span><span class="tok-s">,</span> <span class="tok-s2">"a.c"</span><span class="tok-p">)</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This is a function call that creates the targets necessary to create an
|
||
executable file from the source file <code>a.c</code>. Depending on configured
|
||
properties, different command lines may be used. However, <code>add_program</code>
|
||
is higher-level, but rather thin level. All targets are created
|
||
immediately when the build description is parsed, which makes it
|
||
impossible to perform multi-variant builds. Often, change in any build
|
||
property requires a complete reconfiguration of the build tree.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In order to support true multi-variant builds, B2 introduces the
|
||
concept of a metatarget definition main target metatarget
|
||
<em>metatarget</em> — an object that is created when the build description is
|
||
parsed and can be called later with specific build properties to
|
||
generate actual targets.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Consider an example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When this declaration is parsed, B2 creates a metatarget, but
|
||
does not yet decide what files must be created, or what commands must be
|
||
used. After all build files are parsed, B2 considers the
|
||
properties requested on the command line. Supposed you have invoked
|
||
B2 with:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">toolset</span><span class="tok-o">=</span>gcc <span class="tok-nv">toolset</span><span class="tok-o">=</span>msvc</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In that case, the metatarget will be called twice, once with
|
||
<code>toolset=gcc</code> and once with <code>toolset=msvc</code>. Both invocations will
|
||
produce concrete targets, that will have different extensions and use
|
||
different command lines.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Another key concept is <em>build property</em>. A build
|
||
property is a variable that affects the build process. It can be
|
||
specified on the command line, and is passed when calling a metatarget.
|
||
While all build tools have a similar mechanism, B2 differs by
|
||
requiring that all build properties are declared in advance, and
|
||
providing a large set of properties with portable semantics.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The final concept is <em>property propagation</em>.
|
||
B2 does not require that every metatarget is called with the
|
||
same properties. Instead, the "top-level" metatargets are called with
|
||
the properties specified on the command line. Each metatarget can elect
|
||
to augment or override some properties (in particular, using the
|
||
requirements mechanism, see
|
||
<a href="#bbv2.overview.targets.requirements">the section called “Requirements”</a>).
|
||
Then, the dependency metatargets are called with the modified properties and
|
||
produce concrete targets that are then used in the build process. Of
|
||
course, dependency metatargets maybe in turn modify build properties and
|
||
have dependencies of their own.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For a more in-depth treatment of the requirements and concepts, you may
|
||
refer to <a href="http://syrcose.ispras.ru/2009/files/04_paper.pdf">SYRCoSE 2009
|
||
B2 article</a>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.overview.jam_language"><a class="anchor" href="#bbv2.overview.jam_language"></a>4.2. Boost.Jam Language</h3>
|
||
<div class="paragraph">
|
||
<p>This section will describe the basics of the Boost.Jam language—just
|
||
enough for writing Jamfiles. For more information, please see the
|
||
<a href="#bbv2.jam">Boost.Jam</a> documentation.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><a href="#bbv2.jam">Boost.Jam</a> has an interpreted, procedural language. On
|
||
the lowest level, a <a href="#bbv2.jam">Boost.Jam</a> program consists of
|
||
variables and <em>rules</em> (the Jam term for functions). They are grouped
|
||
into modules—there is one global module and a number of named modules.
|
||
Besides that, a <a href="#bbv2.jam">Boost.Jam</a> program contains classes and
|
||
class instances.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Syntactically, a <a href="#bbv2.jam">Boost.Jam</a> program consists of two kinds
|
||
of elements—keywords (which have a special meaning to
|
||
<a href="#bbv2.jam">Boost.Jam</a>) and literals. Consider this code:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>a<span class="tok-w"> </span>=<span class="tok-w"> </span>b<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>which assigns the value <code>b</code> to the variable <code>a</code>. Here, <code>=</code> and <code>;</code> are
|
||
keywords, while <code>a</code> and <code>b</code> are literals.</p>
|
||
</div>
|
||
<div class="admonitionblock warning">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">⚠</div>
|
||
</td>
|
||
<td class="content">
|
||
All syntax elements, even keywords, must be separated by spaces. For
|
||
example, omitting the space character before <code>;</code> will lead to a syntax
|
||
error.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you want to use a literal value that is the same as some keyword, the
|
||
value can be quoted:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>a<span class="tok-w"> </span>=<span class="tok-w"> </span>"="<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>All variables in <a href="#bbv2.jam">Boost.Jam</a> have the same type—list of
|
||
strings. To define a variable one assigns a value to it, like in the
|
||
previous example. An undefined variable is the same as a variable with
|
||
an empty value. Variables can be accessed using the <code>$(variable)</code>
|
||
syntax. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>a<span class="tok-w"> </span>=<span class="tok-w"> </span><span class="tok-si">$(b)</span><span class="tok-w"> </span><span class="tok-si">$(c)</span><span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Rules are defined by specifying the rule name, the parameter names, and
|
||
the allowed value list size for each parameter.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">example</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">parameter1</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">parameter2</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">parameter3</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">parameter4</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-c1"># rule body</span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When this rule is called, the list passed as the first argument must
|
||
have exactly one value. The list passed as the second argument can
|
||
either have one value of be empty. The two remaining arguments can be
|
||
arbitrarily long, but the third argument may not be empty.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The overview of <a href="#bbv2.jam">Boost.Jam</a> language statements is given
|
||
below:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>helper<span class="tok-w"> </span>1<span class="tok-w"> </span>:<span class="tok-w"> </span>2<span class="tok-w"> </span>:<span class="tok-w"> </span>3<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
x<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>helper<span class="tok-w"> </span>1<span class="tok-w"> </span>:<span class="tok-w"> </span>2<span class="tok-w"> </span>:<span class="tok-w"> </span>3<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This code calls the named rule with the specified arguments. When the
|
||
result of the call must be used inside some expression, you need to add
|
||
brackets around the call, like shown on the second line.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">if</span><span class="tok-w"> </span>cond<span class="tok-w"> </span>{<span class="tok-w"> </span>statements<span class="tok-w"> </span>}<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-k">else</span><span class="tok-w"> </span>{<span class="tok-w"> </span>statements<span class="tok-w"> </span>}<span class="tok-w"> </span>]<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This is a regular if-statement. The condition is composed of:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Literals (true if at least one string is not empty)</p>
|
||
</li>
|
||
<li>
|
||
<p>Comparisons: <code>a operator b</code> where <em>operator</em> is one of <code>=</code>, <code>!=</code>, <code><</code>,
|
||
<code>></code>, <code>⇐</code> or <code>>=</code>. The comparison is done pairwise between each string
|
||
in the left and the right arguments.</p>
|
||
</li>
|
||
<li>
|
||
<p>Logical operations: <code>! a</code>, <code>a && b</code>, <code>a || b</code></p>
|
||
</li>
|
||
<li>
|
||
<p>Grouping: <code>( cond )</code></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">for</span><span class="tok-w"> </span>var<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span>list<span class="tok-w"> </span>{<span class="tok-w"> </span>statements<span class="tok-w"> </span>}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Executes statements for each element in list, setting the variable <code>var</code>
|
||
to the element value.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">while</span><span class="tok-w"> </span>cond<span class="tok-w"> </span>{<span class="tok-w"> </span>statements<span class="tok-w"> </span>}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Repeatedly execute statements while cond remains true upon entry.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">return</span><span class="tok-w"> </span>values<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement should be used only inside a rule and returns <code>values</code> to
|
||
the caller of the rule.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span><span class="tok-k">module</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">import</span><span class="tok-w"> </span><span class="tok-k">module</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">;</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The first form imports the specified module. All rules from that module
|
||
are made available using the qualified name: <code>module.rule</code>. The second form
|
||
imports the specified rules only, and they can be called using unqualified
|
||
names.</p>
|
||
</div>
|
||
<div id="bbv2.overview.jam_language.actions" class="paragraph">
|
||
<p>Sometimes, you need to specify the actual command lines to be used when
|
||
creating targets. In the jam language, you use named actions to do this.
|
||
For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">actions</span><span class="tok-w"> </span><span class="tok-nf">create-file-from-another</span><span class="tok-w"></span>
|
||
{<span class="tok-sh"></span>
|
||
<span class="tok-sh"> create-file-from-another </span><span class="tok-si">$(<)</span><span class="tok-sh"> </span><span class="tok-si">$(>)</span><span class="tok-sh"></span>
|
||
<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This specifies a named action called <code>create-file-from-another</code>. The text
|
||
inside braces is the command to invoke. The <code>$(<)</code> variable will be expanded
|
||
to a list of generated files, and the <code>$(>)</code> variable will be expanded to a
|
||
list of source files.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To adjust the command line flexibly, you can define a rule with the same
|
||
name as the action and taking three parameters — targets, sources and
|
||
properties. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">create-file-from-another</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">properties</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-na"><variant></span>debug<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(properties)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>OPTIONS<span class="tok-w"> </span><span class="tok-k">on</span><span class="tok-w"> </span><span class="tok-si">$(targets)</span><span class="tok-w"> </span>=<span class="tok-w"> </span>--debug<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
}<span class="tok-w"></span>
|
||
<span class="tok-k">actions</span><span class="tok-w"> </span><span class="tok-nf">create-file-from-another</span><span class="tok-w"></span>
|
||
{<span class="tok-sh"></span>
|
||
<span class="tok-sh"> create-file-from-another </span><span class="tok-si">$(OPTIONS)</span><span class="tok-sh"> </span><span class="tok-si">$(<)</span><span class="tok-sh"> </span><span class="tok-si">$(>)</span><span class="tok-sh"></span>
|
||
<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In this example, the rule checks if a certain build property is
|
||
specified. If so, it sets the variable <code>OPTIONS</code> that is then used
|
||
inside the action. Note that the variables set "on a target" will be
|
||
visible only inside actions building that target, not globally. Were
|
||
they set globally, using variable named <code>OPTIONS</code> in two unrelated
|
||
actions would be impossible.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>More details can be found in the Jam reference,
|
||
<a href="#jam.language.rules">the section called “Rules”</a>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.overview.configuration"><a class="anchor" href="#bbv2.overview.configuration"></a>4.3. Configuration</h3>
|
||
<div class="paragraph">
|
||
<p>On startup, B2 searches and reads three configuration files:
|
||
<code>site-config.jam</code>, <code>user-config.jam</code>, and <code>project-config.jam</code>. The
|
||
first one is usually installed and maintained by a system administrator,
|
||
and the second is for the user to modify. You can edit the one in the
|
||
top-level directory of your B2 installation or create a copy in
|
||
your home directory and edit the copy. The third is used for project
|
||
specific configuration. The following table explains where the files are
|
||
searched.</p>
|
||
</div>
|
||
<table class="tableblock frame-all grid-all stretch">
|
||
<caption class="title">Table 1. Search paths for configuration files</caption>
|
||
<colgroup>
|
||
<col style="width: 25%;">
|
||
<col style="width: 25%;">
|
||
<col style="width: 25%;">
|
||
<col style="width: 25%;">
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-top"></th>
|
||
<th class="tableblock halign-center valign-top">site-config.jam</th>
|
||
<th class="tableblock halign-center valign-top">user-config.jam</th>
|
||
<th class="tableblock halign-center valign-top">project-config.jam</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-middle"><p class="tableblock">Linux</p></th>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p><code>/etc</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>$HOME</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>$BOOST_BUILD_PATH</code></p>
|
||
</div></div></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p><code>$HOME</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>$BOOST_BUILD_PATH</code></p>
|
||
</div></div></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p><code>.</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>..</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>../..</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>…​</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-middle"><p class="tableblock">Windows</p></th>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p><code>%SystemRoot%</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>%HOMEDRIVE%%HOMEPATH%</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>%HOME%</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>%BOOST_BUILD_PATH%</code></p>
|
||
</div></div></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p><code>%HOMEDRIVE%%HOMEPATH%</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>%HOME%</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>%BOOST_BUILD_PATH%</code></p>
|
||
</div></div></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p><code>.</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>..</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>../..</code></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>…​</p>
|
||
</div></div></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="paragraph">
|
||
<p>Any of these files may also be overridden
|
||
<a href="#bbv2.reference.init.options.config">on the command line</a>.</p>
|
||
</div>
|
||
<div class="admonitionblock tip">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">☀</div>
|
||
</td>
|
||
<td class="content">
|
||
You can use the <code>--debug-configuration</code> option to find which
|
||
configuration files are actually loaded.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Usually, <code>user-config.jam</code> just defines the available compilers and
|
||
other tools (see <a href="#bbv2.recipes.site-config">the section called “Targets
|
||
in site-config.jam”</a> for more advanced usage). A tool is configured using
|
||
the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>tool-name<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>using</code> rule is given the name of tool, and will make that tool
|
||
available to B2. For example,</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will make the <a href="http://gcc.gnu.org">GCC</a> compiler available.</p>
|
||
</div>
|
||
<div class="admonitionblock tip">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">☀</div>
|
||
</td>
|
||
<td class="content">
|
||
You can put <code>using <tool> ;</code> with no other argument in a Jamfile
|
||
that needs the <code>tool</code>, provided that the <code>tool</code> supports this usage.
|
||
In all other cases, the <code>using</code> rule should be in a configuration file.
|
||
The general principle is that descriptions in Jamfile should be
|
||
maintained as portable while configuration files are system specific.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>All the supported tools are documented in
|
||
<a href="#bbv2.reference.tools">the section called “Builtin tools”</a>, including the
|
||
specific options they take. Some general notes that apply to most C++
|
||
compilers are below.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For all the C++ compiler toolsets that B2 supports
|
||
out-of-the-box, the list of parameters to <code>using</code> is the same:
|
||
<code>toolset-name</code>, <code>version</code>, <code>invocation-command</code>, and <code>options</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you have a single compiler, and the compiler executable</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>has its “usual name” and is in the <code>PATH</code>, or</p>
|
||
</li>
|
||
<li>
|
||
<p>was installed in a standard “installation directory”, or</p>
|
||
</li>
|
||
<li>
|
||
<p>can be found using a global system like the Windows registry.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>it can be configured by simply:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>tool-name<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the compiler is installed in a custom directory, you should provide
|
||
the command that invokes the compiler, for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-3.2<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>msvc<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>"Z:/Programs/Microsoft<span class="tok-w"> </span>Visual<span class="tok-w"> </span>Studio/vc98/bin/cl"<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Some B2 toolsets will use that path to take additional actions
|
||
required before invoking the compiler, such as calling vendor-supplied
|
||
scripts to set up its required environment variables. When the compiler
|
||
executables for C and C++ are different, the path to the C++ compiler
|
||
executable must be specified. The command can be any command allowed by
|
||
the operating system. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>msvc<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-nb">echo</span><span class="tok-w"> </span>Compiling<span class="tok-w"> </span>&&<span class="tok-w"> </span>foo/bar/baz/cl<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will work.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To configure several versions of a toolset, simply invoke the <code>using</code>
|
||
rule multiple times:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>3.3<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>3.4<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-3.4<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>3.2<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-3.2<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>5<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>clang<span class="tok-w"> </span>:<span class="tok-w"> </span>3.9<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>msvc<span class="tok-w"> </span>:<span class="tok-w"> </span>14.0<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that in the first call to <code>using</code>, the compiler found in the <code>PATH</code>
|
||
will be used, and there is no need to explicitly specify the command.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Many of toolsets have an <code>options</code> parameter to fine-tune the
|
||
configuration. All of B2’s standard compiler toolsets accept
|
||
four options <code>cflags</code>, <code>cxxflags</code>, <code>compileflags</code> and <code>linkflags</code> as
|
||
<code>options</code> specifying flags that will be always passed to the
|
||
corresponding tools. There must not be a space between the tag for the
|
||
option name and the value. Values of the <code>cflags</code> feature are passed
|
||
directly to the C compiler, values of the <code>cxxflags</code> feature are passed
|
||
directly to the C++ compiler, and values of the <code>compileflags</code> feature
|
||
are passed to both. For example, to configure a <code>gcc</code> toolset so that it
|
||
always generates 64-bit code you could write:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>3.4<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><compileflags></span>-m64<span class="tok-w"> </span><span class="tok-na"><linkflags></span>-m64<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If multiple of the same type of options are needed, they can be
|
||
concatenated with quotes or have multiple instances of the option tag.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>5<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><cxxflags></span>"-std=c++14<span class="tok-w"> </span>-O2"<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>clang<span class="tok-w"> </span>:<span class="tok-w"> </span>3.9<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><cxxflags></span>-std=c++14<span class="tok-w"> </span><span class="tok-na"><cxxflags></span>-O2<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Multiple variations of the same tool can be used for most tools. These
|
||
are delineated by the version passed in. Because the dash '-' cannot be
|
||
used here, the convention has become to use the tilde '~' to delineate
|
||
variations.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>5<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-5<span class="tok-w"> </span>:<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># default is C++ 98</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>5~c++03<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-5<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><cxxflags></span>-std=c++03<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># C++ 03</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>5~gnu03<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-5<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><cxxflags></span>-std=gnu++03<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># C++ 03 with GNU</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>5~c++11<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-5<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><cxxflags></span>-std=c++11<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># C++ 11</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>5~c++14<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-5<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><cxxflags></span>-std=c++14<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># C++ 14</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>These are then used as normal toolsets:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">toolset</span><span class="tok-o">=</span>gcc-5 stage
|
||
b2 <span class="tok-nv">toolset</span><span class="tok-o">=</span>gcc-5~c++14 stage</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="admonitionblock warning">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">⚠</div>
|
||
</td>
|
||
<td class="content">
|
||
Although the syntax used to specify toolset options is very similar
|
||
to syntax used to specify requirements in Jamfiles, the toolset options are
|
||
not the same as features. Don’t try to specify a feature value in
|
||
toolset initialization.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.overview.invocation"><a class="anchor" href="#bbv2.overview.invocation"></a>4.4. Invocation</h3>
|
||
<div class="paragraph">
|
||
<p>To invoke B2, type <code>b2</code> on the command line. Three kinds of
|
||
command-line tokens are accepted, in any order:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1">options</dt>
|
||
<dd>
|
||
<p>Options start with either one or two dashes. The standard options are
|
||
listed below, and each project may add additional options</p>
|
||
</dd>
|
||
<dt class="hdlist1">properties</dt>
|
||
<dd>
|
||
<p>Properties specify details of what you want to build (e.g. debug or
|
||
release variant). Syntactically, all command line tokens with an equal
|
||
sign in them are considered to specify properties. In the simplest
|
||
form, a property looks like <code>feature=value</code></p>
|
||
</dd>
|
||
<dt class="hdlist1">target</dt>
|
||
<dd>
|
||
<p>All tokens that are neither options nor properties specify what
|
||
targets to build. The available targets entirely depend on the project
|
||
you are building.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.overview.invocation.examples"><a class="anchor" href="#bbv2.overview.invocation.examples"></a>4.4.1. Examples</h4>
|
||
<div class="paragraph">
|
||
<p>To build all targets defined in the Jamfile in the current directory
|
||
with the default properties, run:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To build specific targets, specify them on the command line:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 lib1 subproject//lib2</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To request a certain value for some property, add <code>property=value</code> to the
|
||
command line:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">toolset</span><span class="tok-o">=</span>gcc <span class="tok-nv">variant</span><span class="tok-o">=</span>debug <span class="tok-nv">optimization</span><span class="tok-o">=</span>space</code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.overview.invocation.options"><a class="anchor" href="#bbv2.overview.invocation.options"></a>4.4.2. Options</h4>
|
||
<div class="paragraph">
|
||
<p>B2 recognizes the following command line options.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><a id="bbv2.overview.invocation.options.help"></a><code>--help</code></dt>
|
||
<dd>
|
||
<p>Invokes the online help system. This prints general information on how
|
||
to use the help system with additional --help* options.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--clean</code></dt>
|
||
<dd>
|
||
<p>Cleans all targets in the current directory and in any sub-projects.
|
||
Note that unlike the <code>clean</code> target in make, you can use <code>--clean</code>
|
||
together with target names to clean specific targets.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--clean-all</code></dt>
|
||
<dd>
|
||
<p>Cleans all targets, no matter where they are defined. In particular,
|
||
it will clean targets in parent Jamfiles, and targets defined under
|
||
other project roots.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--build-dir</code></dt>
|
||
<dd>
|
||
<p>Changes the build directories for all project roots being built. When
|
||
this option is specified, all Jamroot files must declare a project
|
||
name. The build directory for the project root will be computed by
|
||
concatenating the value of the <code>--build-dir</code> option, the project name
|
||
specified in Jamroot, and the build dir specified in Jamroot (or
|
||
<code>bin</code>, if none is specified).
|
||
The option is primarily useful when building from read-only media,
|
||
when you can’t modify Jamroot.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--abbreviate-paths</code></dt>
|
||
<dd>
|
||
<p>Compresses target paths by abbreviating each component. This option is
|
||
useful to keep paths from becoming longer than the filesystem
|
||
supports. See also <a href="#bbv2.reference.buildprocess.targetpath">the
|
||
section called “Target Paths”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--hash</code></dt>
|
||
<dd>
|
||
<p>Compresses target paths using an MD5 hash. This option is useful to
|
||
keep paths from becoming longer than the filesystem supports. This
|
||
option produces shorter paths than <code>--abbreviate-paths</code> does, but at the
|
||
cost of making them less understandable. See also
|
||
<a href="#bbv2.reference.buildprocess.targetpath">the section called “Target
|
||
Paths”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--version</code></dt>
|
||
<dd>
|
||
<p>Prints information on the B2 and Boost.Jam versions.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-a</code></dt>
|
||
<dd>
|
||
<p>Causes all files to be rebuilt.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-n</code></dt>
|
||
<dd>
|
||
<p>Do not execute the commands, only print them.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-q</code></dt>
|
||
<dd>
|
||
<p>Stop at the first error, as opposed to continuing to build targets
|
||
that don’t depend on the failed ones.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-j N</code></dt>
|
||
<dd>
|
||
<p>Run up to N commands in parallel. Default number of jobs is the number
|
||
of detected available CPU threads. Note: There are circumstances when that
|
||
default can be larger than the allocated cpu resources, for instance in some
|
||
virtualized container installs.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--config=filename</code><a id="bbv2.reference.init.options.config"></a></dt>
|
||
<dd>
|
||
<p>Override all <a href="#bbv2.overview.configuration">configuration files</a></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--site-config=filename</code></dt>
|
||
<dd>
|
||
<p>Override the default <a href="#bbv2.overview.configuration">site-config.jam</a></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--user-config=filename</code></dt>
|
||
<dd>
|
||
<p>Override the default <a href="#bbv2.overview.configuration">user-config.jam</a></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--project-config=filename</code></dt>
|
||
<dd>
|
||
<p>Override the default <a href="#bbv2.overview.configuration">project-config.jam</a></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--debug-configuration</code></dt>
|
||
<dd>
|
||
<p>Produces debug information about the loading of B2 and
|
||
toolset files.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--debug-building</code></dt>
|
||
<dd>
|
||
<p>Prints what targets are being built and with what properties.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--debug-generators</code></dt>
|
||
<dd>
|
||
<p>Produces debug output from the generator search process. Useful for
|
||
debugging custom generators.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-d0</code></dt>
|
||
<dd>
|
||
<p>Suppress all informational messages.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-d N</code></dt>
|
||
<dd>
|
||
<p>Enable cumulative debugging levels from 1 to n. Values are:
|
||
+</p>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Show the actions taken for building targets, as they are executed
|
||
(the default).</p>
|
||
</li>
|
||
<li>
|
||
<p>Show "quiet" actions and display all action text, as they are
|
||
executed.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show dependency analysis, and target/source timestamps/paths.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show arguments and timing of shell invocations.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show rule invocations and variable expansions.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show directory/header file/archive scans, and attempts at binding
|
||
to targets.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show variable settings.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show variable fetches, variable expansions, and evaluation of
|
||
'"if"' expressions.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show variable manipulation, scanner tokens, and memory usage.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show profile information for rules, both timing and memory.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show parsing progress of Jamfiles.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show graph of target dependencies.</p>
|
||
</li>
|
||
<li>
|
||
<p>Show change target status (fate).</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-d +N</code></dt>
|
||
<dd>
|
||
<p>Enable debugging level <code>N</code>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-o file</code></dt>
|
||
<dd>
|
||
<p>Write the updating actions to the specified file instead of running
|
||
them.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>-s var=value</code></dt>
|
||
<dd>
|
||
<p>Set the variable <code>var</code> to <code>value</code> in the global scope of the jam language
|
||
interpreter, overriding variables imported from the environment.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.overview.invocation.properties"><a class="anchor" href="#bbv2.overview.invocation.properties"></a>4.4.3. Properties</h4>
|
||
<div class="paragraph">
|
||
<p>In the simplest case, the build is performed with a single set of
|
||
properties, that you specify on the command line with elements in the
|
||
form <code>feature=value</code>. The complete list of features can be found in
|
||
<a href="#bbv2.overview.builtins.features">the section called “Builtin features”</a>.
|
||
The most common features are summarized below.</p>
|
||
</div>
|
||
<table class="tableblock frame-all grid-all stretch">
|
||
<colgroup>
|
||
<col style="width: 33.3333%;">
|
||
<col style="width: 33.3333%;">
|
||
<col style="width: 33.3334%;">
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-top">Feature</th>
|
||
<th class="tableblock halign-left valign-top">Allowed values</th>
|
||
<th class="tableblock halign-left valign-top">Notes</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">variant</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">debug,release</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">link</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">shared,static</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Determines if B2 creates shared or static libraries</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">threading</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">single,multi</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Cause the produced binaries to be thread-safe. This requires proper support
|
||
in the source code itself.</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">address-model</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">32,64</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Explicitly request either 32-bit or 64-bit code
|
||
generation. This typically requires that your compiler is appropriately
|
||
configured. Please refer to
|
||
<a href="#bbv2.reference.tools.compilers">the section called “C++ Compilers”</a>
|
||
and your compiler documentation in case of problems.</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">toolset</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">(Depends on configuration)</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>The C++ compiler to use. See
|
||
<a href="#bbv2.reference.tools.compilers">the section called “C++ Compilers”</a>
|
||
for a detailed list.</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">include</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">(Arbitrary string)</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Additional include paths for C and C++ compilers.</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">define</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">(Arbitrary string)</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Additional macro definitions for C and C++ compilers. The string should be
|
||
either <code>SYMBOL</code> or <code>SYMBOL=VALUE</code></p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">cxxflags</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">(Arbitrary string)</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Custom options to pass to the C++ compiler.</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">cflags</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">(Arbitrary string)</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Custom options to pass to the C compiler.</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">linkflags</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">(Arbitrary string)</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Custom options to pass to the C++ linker.</p>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">runtime-link</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">shared,static</p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Determines if shared or static version of C and C++ runtimes should be used.</p>
|
||
</div></div></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="paragraph">
|
||
<p>If you have more than one version of a given C++ toolset (e.g.
|
||
configured in <code>user-config.jam</code>, or autodetected, as happens with msvc),
|
||
you can request the specific version by passing <code>toolset-version</code> as the
|
||
value of the <code>toolset</code> feature, for example <code>toolset=msvc-8.0</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If a feature has a fixed set of values it can be specified more than
|
||
once on the command line. In which case, everything will be built
|
||
several times — once for each specified value of a feature. For
|
||
example, if you use</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">link</span><span class="tok-o">=</span>static <span class="tok-nv">link</span><span class="tok-o">=</span>shared <span class="tok-nv">threading</span><span class="tok-o">=</span>single <span class="tok-nv">threading</span><span class="tok-o">=</span>multi</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Then a total of 4 builds will be performed. For convenience, instead of
|
||
specifying all requested values of a feature in separate command line
|
||
elements, you can separate the values with commas, for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">link</span><span class="tok-o">=</span>static,shared <span class="tok-nv">threading</span><span class="tok-o">=</span>single,multi</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The comma has this special meaning only if the feature has a fixed set
|
||
of values, so</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">include</span><span class="tok-o">=</span>static,shared</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>is not treated specially.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Multiple features may be grouped by using a forwards slash.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 gcc/link<span class="tok-o">=</span>shared msvc/link<span class="tok-o">=</span>static,shared</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This will build 3 different variants, altogether.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.overview.invocation.targets"><a class="anchor" href="#bbv2.overview.invocation.targets"></a>4.4.4. Targets</h4>
|
||
<div class="paragraph">
|
||
<p>All command line elements that are neither options nor properties are
|
||
the names of the targets to build. See <a href="#bbv2.reference.ids">the section
|
||
called “Target identifiers and references”</a>. If no target is specified, the
|
||
project in the current directory is built.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.overview.targets"><a class="anchor" href="#bbv2.overview.targets"></a>4.5. Declaring Targets</h3>
|
||
<div id="bbv2.overview.targets.main" class="paragraph">
|
||
<p>A Main target is a user-defined named entity that can be built, for
|
||
example an executable file. Declaring a main target is usually done
|
||
using one of the main target rules described in
|
||
<a href="#bbv2.reference.rules">the section called “Builtin rules”</a>. The user can
|
||
also declare custom main target rules as shown in
|
||
<a href="#bbv2.extending.rules">the section called “Main target rules”</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><a id="bbv2.main-target-rule-syntax"></a>
|
||
Most main target rules in B2 have the same common signature:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">rule-name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">main-target-name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">default-build</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">usage-requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>main-target-name</code> is the name used to request the target on command
|
||
line and to use it from other main targets. A main target name may
|
||
contain alphanumeric characters, dashes (‘<code>-</code>’), and underscores
|
||
(‘<code>_</code>’).</p>
|
||
</li>
|
||
<li>
|
||
<p><code>sources</code> is the list of source files and other main targets that must
|
||
be combined.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>requirements</code> is the list of properties that must always be present
|
||
when this main target is built.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>default-build</code> is the list of properties that will be used unless
|
||
some other value of the same feature is already specified, e.g. on the
|
||
command line or by propagation from a dependent target.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>usage-requirements</code> is the list of properties that will be propagated
|
||
to all main targets that use this one, i.e. to all its dependents.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Some main target rules have a different list of parameters as explicitly
|
||
stated in their documentation.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The actual requirements for a target are obtained by refining the
|
||
requirements of the project where the target is declared with the
|
||
explicitly specified requirements. The same is true for
|
||
usage-requirements. More details can be found in
|
||
<a href="#bbv2.reference.variants.proprefine">the section called “Property refinement”</a>.</p>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_name"><a class="anchor" href="#_name"></a>4.5.1. Name</h4>
|
||
<div class="paragraph">
|
||
<p>The name of main target has two purposes. First, it’s used to refer to
|
||
this target from other targets and from command line. Second, it’s used
|
||
to compute the names of the generated files. Typically, filenames are
|
||
obtained from main target name by appending system-dependent suffixes
|
||
and prefixes.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The name of a main target can contain alphanumeric characters, dashes,
|
||
underscores and dots. The entire name is significant when resolving
|
||
references from other targets. For determining filenames, only the part
|
||
before the first dot is taken. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">obj</span><span class="tok-w"> </span>test.release<span class="tok-w"> </span>:<span class="tok-w"> </span>test.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><variant></span>release<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">obj</span><span class="tok-w"> </span>test.debug<span class="tok-w"> </span>:<span class="tok-w"> </span>test.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><variant></span>debug<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will generate two files named <code>test.obj</code> (in two different directories),
|
||
not two files named <code>test.release.obj</code> and <code>test.debug.obj</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_sources"><a class="anchor" href="#_sources"></a>4.5.2. Sources</h4>
|
||
<div class="paragraph">
|
||
<p>The list of sources specifies what should be processed to get the
|
||
resulting targets. Most of the time, it’s just a list of files.
|
||
Sometimes, you’ll want to automatically construct the list of source
|
||
files rather than having to spell it out manually, in which case you can
|
||
use the <a href="#bbv2.reference.rules.glob">glob</a> rule. Here are two
|
||
examples:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>;<span class="tok-w"> </span><b class="conum">(1)</b>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">glob</span><span class="tok-w"> </span>*.cpp<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"> </span><b class="conum">(2)</b></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="colist arabic">
|
||
<ol>
|
||
<li>
|
||
<p><code>a.cpp</code> is the only source file</p>
|
||
</li>
|
||
<li>
|
||
<p>all <code>.cpp</code> files in this directory are sources</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Unless you specify a file with an absolute path, the name is considered
|
||
relative to the source directory — which is typically the directory
|
||
where the Jamfile is located, but can be changed as described in
|
||
<a href="#bbv2.overview.projects.attributes.projectrule">the section called “Projects”</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The list of sources can also refer to other main targets. Targets in the
|
||
same project can be referred to by name, while targets in other projects
|
||
must be qualified with a directory or a symbolic project name. The
|
||
directory/project name is separated from the target name by a double
|
||
forward slash. There is no special syntax to distinguish the directory
|
||
name from the project name—the part before the double slash is first
|
||
looked up as project name, and then as directory name. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>helper<span class="tok-w"> </span>:<span class="tok-w"> </span>helper.cpp<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>helper<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>b.cpp<span class="tok-w"> </span>..//utils<span class="tok-w"> </span>;<span class="tok-w"> </span><b class="conum">(1)</b>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>c<span class="tok-w"> </span>:<span class="tok-w"> </span>c.cpp<span class="tok-w"> </span>/boost/program_options//program_options<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="colist arabic">
|
||
<ol>
|
||
<li>
|
||
<p>Since all project ids start with slash, “..” is a directory name.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The first exe uses the library defined in the same project. The second
|
||
one uses some target (most likely a library) defined by a Jamfile one
|
||
level higher. Finally, the third target uses a <a href="http://boost.org">C++
|
||
Boost</a> library, referring to it using its absolute symbolic name. More
|
||
information about target references can be found in
|
||
<a href="#bbv2.tutorial.libs">the section called “Dependent Targets”</a> and
|
||
<a href="#bbv2.reference.ids">the section called “Target identifiers and references”</a>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.overview.targets.requirements"><a class="anchor" href="#bbv2.overview.targets.requirements"></a>4.5.3. Requirements</h4>
|
||
<div class="paragraph">
|
||
<p>Requirements are the properties that should always be present when
|
||
building a target. Typically, they are includes and defines:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/opt/boost<span class="tok-w"> </span><span class="tok-na"><define></span>MY_DEBUG<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are a number of other features, listed in
|
||
<a href="#bbv2.overview.builtins.features">the section called “Builtin features”</a>.
|
||
For example if a library can only be built statically, or a file can’t be
|
||
compiled with optimization due to a compiler bug, one can use.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>util<span class="tok-w"> </span>:<span class="tok-w"> </span>util.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">obj</span><span class="tok-w"> </span>main<span class="tok-w"> </span>:<span class="tok-w"> </span>main.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><optimization></span>off<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><a id="bbv2.overview.targets.requirements.conditional"></a>Sometimes, particular
|
||
relationships need to be
|
||
maintained among a target’s build properties. This can be achieved with
|
||
<em>conditional requirements</em>. For example, you might want to set specific
|
||
<code>#defines</code> when a library is built as shared, or when a target’s
|
||
<code>release</code> variant is built in release mode.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>network<span class="tok-w"> </span>:<span class="tok-w"> </span>network.cpp<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><link></span>shared:<span class="tok-na"><define></span>NETWORK_LIB_SHARED<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><variant></span>release:<span class="tok-na"><define></span>EXTRA_FAST<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In the example above, whenever <code>network</code> is built with <code><link>shared</code>,
|
||
<code><define>NETWORK_LIB_SHARED</code> will be in its properties, too.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>You can use several properties in the condition, for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>network<span class="tok-w"> </span>:<span class="tok-w"> </span>network.cpp<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>gcc,<span class="tok-na"><optimization></span>speed:<span class="tok-na"><define></span>USE_INLINE_ASSEMBLER<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A more powerful variant of conditional requirements
|
||
is <em>indirect conditional</em> requirements. You can provide a rule that will
|
||
be called with the current build properties and can compute additional
|
||
properties to be added. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>network<span class="tok-w"> </span>:<span class="tok-w"> </span>network.cpp<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><conditional></span>@my-rule<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">my-rule</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">properties</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>result<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-na"><toolset></span>gcc<span class="tok-w"> </span><span class="tok-na"><optimization></span>speed<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(properties)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>result<span class="tok-w"> </span>+=<span class="tok-w"> </span><span class="tok-na"><define></span>USE_INLINE_ASSEMBLER<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-si">$(result)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This example is equivalent to the previous one, but for complex cases,
|
||
indirect conditional requirements can be easier to write and understand.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Requirements explicitly specified for a target are usually combined with
|
||
the requirements specified for the containing project. You can cause a
|
||
target to completely ignore a specific project requirement using the
|
||
syntax by adding a minus sign before the property, for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>main<span class="tok-w"> </span>:<span class="tok-w"> </span>main.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span>-<span class="tok-na"><define></span>UNNECESSARY_DEFINE<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This syntax is the only way to ignore free properties, such as defines,
|
||
from a parent. It can be also useful for ordinary properties. Consider
|
||
this example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"> </span>test<span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"> </span><span class="tok-na"><threading></span>multi<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>test1<span class="tok-w"> </span>:<span class="tok-w"> </span>test1.cpp<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>test2<span class="tok-w"> </span>:<span class="tok-w"> </span>test2.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><threading></span>single<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>test3<span class="tok-w"> </span>:<span class="tok-w"> </span>test3.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span>-<span class="tok-na"><threading></span>multi<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Here, <code>test1</code> inherits the project requirements and will always be built
|
||
in multi-threaded mode. The <code>test2</code> target <em>overrides</em> the project’s
|
||
requirements and will always be built in single-threaded mode. In
|
||
contrast, the <code>test3</code> target <em>removes</em> a property from the project
|
||
requirements and will be built either in single-threaded or
|
||
multi-threaded mode depending on which variant is requested by the user.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that the removal of requirements is completely textual: you need to
|
||
specify exactly the same property to remove it.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_default_build"><a class="anchor" href="#_default_build"></a>4.5.4. Default Build</h4>
|
||
<div class="paragraph">
|
||
<p>The <code>default-build</code> parameter is a set of properties to be used if the
|
||
build request does not otherwise specify a value for features in the
|
||
set. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><threading></span>multi<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>would build a multi-threaded target unless the user explicitly requests
|
||
a single-threaded version. The difference between the requirements and
|
||
the default-build is that the requirements cannot be overridden in any
|
||
way.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_additional_information"><a class="anchor" href="#_additional_information"></a>4.5.5. Additional Information</h4>
|
||
<div class="paragraph">
|
||
<p>The ways a target is built can be so different that describing them
|
||
using conditional requirements would be hard. For example, imagine that
|
||
a library actually uses different source files depending on the toolset
|
||
used to build it. We can express this situation using <em>target alternatives</em>:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>demangler<span class="tok-w"> </span>:<span class="tok-w"> </span>dummy_demangler.cpp<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># alternative 1</span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>demangler<span class="tok-w"> </span>:<span class="tok-w"> </span>demangler_gcc.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>gcc<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># alternative 2</span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>demangler<span class="tok-w"> </span>:<span class="tok-w"> </span>demangler_msvc.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>msvc<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># alternative 3</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In the example above, when built with <code>gcc</code> or <code>msvc</code>, <code>demangler</code> will
|
||
use a source file specific to the toolset. Otherwise, it will use a
|
||
generic source file, <code>dummy_demangler.cpp</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It is possible to declare a target inline, i.e. the "sources" parameter
|
||
may include calls to other main rules. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">obj</span><span class="tok-w"> </span>helpers<span class="tok-w"> </span>:<span class="tok-w"> </span>helpers.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><optimization></span>off<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Will cause "helpers.cpp" to be always compiled without optimization.
|
||
When referring to an inline main target, its declared name must be
|
||
prefixed by its parent target’s name and two dots. In the example above,
|
||
to build only helpers, one should run <code>b2 hello..helpers</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When no target is requested on the command line, all targets in the
|
||
current project will be built. If a target should be built only by
|
||
explicit request, this can be expressed by the
|
||
<a href="#bbv2.reference.rules.explicit">explicit</a> rule:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">explicit</span><span class="tok-w"> </span>install_programs<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.overview.projects"><a class="anchor" href="#bbv2.overview.projects"></a>4.6. Projects</h3>
|
||
<div class="paragraph">
|
||
<p>As mentioned before, targets are grouped into projects, and each Jamfile
|
||
is a separate project. Projects are useful because they allow us to
|
||
group related targets together, define properties common to all those
|
||
targets, and assign a symbolic name to the project that can be used in
|
||
referring to its targets.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Projects are named using the <code>project</code> rule, which has the following
|
||
syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"> </span>id<span class="tok-w"> </span>:<span class="tok-w"> </span>attributes<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Here, <em>attributes</em> is a sequence of rule arguments, each of which begins
|
||
with an attribute-name and is followed by any number of build
|
||
properties. The list of attribute names along with its handling is also
|
||
shown in the table below. For example, it is possible to write:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"> </span>tennis<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"> </span><span class="tok-na"><threading></span>multi<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>default-build<span class="tok-w"> </span>release<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The possible attributes are listed below.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><em>Project id</em> is a short way to denote a project, as opposed to the
|
||
Jamfile’s pathname. It is a hierarchical path, unrelated to filesystem,
|
||
such as "boost/thread". <a href="#bbv2.reference.ids">Target references</a> make
|
||
use of project ids to specify a target.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><em>Source location</em> specifies the directory where sources for the project
|
||
are located.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><em>Project requirements</em> are requirements that apply to all the targets in
|
||
the projects as well as all sub-projects.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><em>Default build</em> is the build request that should be used when no build
|
||
request is specified explicitly.</p>
|
||
</div>
|
||
<div id="bbv2.overview.projects.attributes.projectrule" class="paragraph">
|
||
<p>The default values for those attributes are given in the table below.</p>
|
||
</div>
|
||
<table class="tableblock frame-all grid-all stretch">
|
||
<colgroup>
|
||
<col style="width: 25%;">
|
||
<col style="width: 25%;">
|
||
<col style="width: 25%;">
|
||
<col style="width: 25%;">
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-top">Attribute</th>
|
||
<th class="tableblock halign-left valign-top">Name</th>
|
||
<th class="tableblock halign-left valign-top">Default value</th>
|
||
<th class="tableblock halign-left valign-top">Handling by the <code>project</code> rule</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Project id</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">none</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">none</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Assigned from the first parameter of the
|
||
'project' rule. It is assumed to denote absolute project id.</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Source location</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>source-location</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">The location of jamfile for the
|
||
project</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Sets to the passed value</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Requirements</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>requirements</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">The parent’s requirements</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">The parent’s
|
||
requirements are refined with the passed requirement and the result is
|
||
used as the project requirements.</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Default build</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>default-build</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">none</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Sets to the passed value</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Build directory</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>build-dir</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Empty if the parent has no build
|
||
directory set. Otherwise, the parent’s build directory with the relative
|
||
path from parent to the current project appended to it.</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Sets to the
|
||
passed value, interpreted as relative to the project’s location.</p></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="paragraph">
|
||
<p>Besides defining projects and main targets, Jamfiles often invoke
|
||
various utility rules. For the full list of rules that can be directly
|
||
used in Jamfile see
|
||
<a href="#bbv2.reference.rules">the section called “Builtin rules”</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Each subproject inherits attributes, constants and rules from its parent
|
||
project, which is defined by the nearest Jamfile in an ancestor
|
||
directory above the subproject. The top-level project is declared in a
|
||
file called <code>Jamroot</code>, or <code>Jamfile</code>. When loading a project,
|
||
B2 looks for either <code>Jamroot</code> or <code>Jamfile</code>. They are handled
|
||
identically, except that if the file is called <code>Jamroot</code>, the search for
|
||
a parent project is not performed. A <code>Jamfile</code> without a parent project
|
||
is also considered the top-level project.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Even when building in a subproject directory, parent project files are
|
||
always loaded before those of their sub-projects, so that every
|
||
definition made in a parent project is always available to its children.
|
||
The loading order of any other projects is unspecified. Even if one
|
||
project refers to another via the <code>use-project</code> or a target reference,
|
||
no specific order should be assumed.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
Giving the root project the special name “<code>Jamroot</code>” ensures that
|
||
B2 won’t misinterpret a directory above it as the project root
|
||
just because the directory contains a Jamfile.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.overview.build_process"><a class="anchor" href="#bbv2.overview.build_process"></a>4.7. The Build Process</h3>
|
||
<div class="paragraph">
|
||
<p>When you’ve described your targets, you want B2 to run the
|
||
right tools and create the needed targets. This section will describe
|
||
two things: how you specify what to build, and how the main targets are
|
||
actually constructed.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The most important thing to note is that in B2, unlike other
|
||
build tools, the targets you declare do not correspond to specific
|
||
files. What you declare in a Jamfile is more like a “metatarget.”
|
||
Depending on the properties you specify on the command line, each
|
||
metatarget will produce a set of real targets corresponding to the
|
||
requested properties. It is quite possible that the same metatarget is
|
||
built several times with different properties, producing different
|
||
files.</p>
|
||
</div>
|
||
<div class="admonitionblock tip">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">☀</div>
|
||
</td>
|
||
<td class="content">
|
||
This means that for B2, you cannot directly obtain a build
|
||
variant from a Jamfile. There could be several variants requested by the
|
||
user, and each target can be built with different properties.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.overview.build_request"><a class="anchor" href="#bbv2.overview.build_request"></a>4.7.1. Build Request</h4>
|
||
<div class="paragraph">
|
||
<p>The command line specifies which targets to build and with which
|
||
properties. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 app1 lib1//lib1 <span class="tok-nv">toolset</span><span class="tok-o">=</span>gcc <span class="tok-nv">variant</span><span class="tok-o">=</span>debug <span class="tok-nv">optimization</span><span class="tok-o">=</span>full</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>would build two targets, "app1" and "lib1//lib1" with the specified
|
||
properties. You can refer to any targets, using
|
||
<a href="#bbv2.reference.ids">target id</a> and specify arbitrary properties.
|
||
Some of the properties are very common, and for them the name of the
|
||
property can be omitted. For example, the above can be written as:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 app1 lib1//lib1 gcc debug <span class="tok-nv">optimization</span><span class="tok-o">=</span>full</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The complete syntax, which has some additional shortcuts, is described
|
||
in <a href="#bbv2.overview.invocation">the section called “Invocation”</a>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_building_a_main_target"><a class="anchor" href="#_building_a_main_target"></a>4.7.2. Building a main target</h4>
|
||
<div class="paragraph">
|
||
<p>When you request, directly or indirectly, a build of a main target with
|
||
specific requirements, the following steps are done. Some brief
|
||
explanation is provided, and more details are given in
|
||
<a href="#bbv2.reference.buildprocess">the section called “Build process”</a>.</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Applying default build. If the default-build property of a target
|
||
specifies a value of a feature that is not present in the build request,
|
||
that value is added.</p>
|
||
</li>
|
||
<li>
|
||
<p>Selecting the main target alternative to use. For each alternative
|
||
we look how many properties are present both in alternative’s
|
||
requirements, and in build request. The alternative with largest number
|
||
of matching properties is selected.</p>
|
||
</li>
|
||
<li>
|
||
<p>Determining "common" properties. The build request is
|
||
<a href="#bbv2.reference.variants.proprefine">refined</a> with target’s
|
||
requirements. The conditional properties in requirements are handled as
|
||
well. Finally, default values of features are added.</p>
|
||
</li>
|
||
<li>
|
||
<p>Building targets referred by the sources list and dependency
|
||
properties. The list of sources and the properties can refer to other
|
||
target using <a href="#bbv2.reference.ids">target references</a>. For each
|
||
reference, we take all
|
||
<a href="#bbv2.reference.features.attributes.propagated">propagated</a>
|
||
properties, refine them by explicit properties specified in the target
|
||
reference, and pass the resulting properties as build request to the
|
||
other target.</p>
|
||
</li>
|
||
<li>
|
||
<p>Adding the usage requirements produced when building dependencies to
|
||
the "common" properties. When dependencies are built in the previous
|
||
step, they return both the set of created "real" targets, and usage
|
||
requirements. The usage requirements are added to the common properties
|
||
and the resulting property set will be used for building the current
|
||
target.</p>
|
||
</li>
|
||
<li>
|
||
<p>Building the target using generators. To convert the sources to the
|
||
desired type, B2 uses "generators" — objects that correspond
|
||
to tools like compilers and linkers. Each generator declares what type
|
||
of targets it can produce and what type of sources it requires. Using
|
||
this information, B2 determines which generators must be run to
|
||
produce a specific target from specific sources. When generators are
|
||
run, they return the "real" targets.</p>
|
||
</li>
|
||
<li>
|
||
<p>Computing the usage requirements to be returned. The conditional
|
||
properties in usage requirements are expanded and the result is
|
||
returned.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_building_a_project"><a class="anchor" href="#_building_a_project"></a>4.7.3. Building a Project</h4>
|
||
<div class="paragraph">
|
||
<p>Often, a user builds a complete project, not just one main target. In
|
||
fact, invoking <code>b2</code> without arguments builds the project defined in the
|
||
current directory.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When a project is built, the build request is passed without
|
||
modification to all main targets in that project. It’s is possible to
|
||
prevent implicit building of a target in a project with the <code>explicit</code>
|
||
rule:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">explicit</span><span class="tok-w"> </span>hello_test<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>would cause the <code>hello_test</code> target to be built only if explicitly
|
||
requested by the user or by some other target.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The Jamfile for a project can include a number of <code>build-project</code> rule
|
||
calls that specify additional projects to be built.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.tasks"><a class="anchor" href="#bbv2.tasks"></a>5. Common tasks</h2>
|
||
<div class="sectionbody">
|
||
<div class="paragraph">
|
||
<p>This section describes main targets types that B2 supports
|
||
out-of-the-box. Unless otherwise noted, all mentioned main target rules
|
||
have the common signature, described in
|
||
<a href="#bbv2.overview.targets">the section called “Declaring Targets”</a>.</p>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tasks.programs"><a class="anchor" href="#bbv2.tasks.programs"></a>5.1. Programs</h3>
|
||
<div class="paragraph">
|
||
<p>Programs are created using the <code>exe</code> rule, which follows the
|
||
<a href="#bbv2.main-target-rule-syntax">common syntax</a>. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>some_library.lib<span class="tok-w"> </span>/some_project//library<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><threading></span>multi<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This will create an executable file from the sources—​in this case,
|
||
one C++ file, one library file present in the same directory, and
|
||
another library that is created by B2. Generally, sources can
|
||
include C and C++ files, object files and libraries. B2 will
|
||
automatically try to convert targets of other types.</p>
|
||
</div>
|
||
<div class="admonitionblock tip">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">☀</div>
|
||
</td>
|
||
<td class="content">
|
||
On Windows, if an application uses shared libraries, and both the
|
||
application and the libraries are built using B2, it is not
|
||
possible to immediately run the application, because the <code>PATH</code> environment
|
||
variable should include the path to the libraries. It means you have to either
|
||
add the paths manually, or have the build place the application and the
|
||
libraries into the same directory. See
|
||
<a href="#bbv2.tasks.installing">the section called “Installing”</a>.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tasks.libraries"><a class="anchor" href="#bbv2.tasks.libraries"></a>5.2. Libraries</h3>
|
||
<div class="paragraph">
|
||
<p>Library targets are created using the <code>lib</code> rule, which follows the
|
||
<a href="#bbv2.main-target-rule-syntax">common syntax</a>. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>helpers<span class="tok-w"> </span>:<span class="tok-w"> </span>helpers.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This will define a library target named <code>helpers</code> built from the
|
||
<code>helpers.cpp</code> source file. It can be either a static library or a shared
|
||
library, depending on the value of the
|
||
<a href="#bbv2.builtin.features.link"><code><link></code></a> feature.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Library targets can represent:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Libraries that should be built from source, as in the example above.</p>
|
||
</li>
|
||
<li>
|
||
<p>Prebuilt libraries which already exist on the system. Such libraries
|
||
can be searched for by the tools using them (typically with the linker’s
|
||
<code>-l</code> option) or their paths can be known in advance by the build system.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The syntax for prebuilt libraries is given below:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>z<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>z<span class="tok-w"> </span><span class="tok-na"><search></span>/home/ghost<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>compress<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><file></span>/opt/libs/compress.a<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>name</code> property specifies the name of the library without the
|
||
standard prefixes and suffixes. For example, depending on the system,
|
||
<code>z</code> could refer to a file called <code>z.so</code>, <code>libz.a</code>, or <code>z.lib</code>, etc. The
|
||
<code>search</code> feature specifies paths in which to search for the library in
|
||
addition to the default compiler paths. <code>search</code> can be specified
|
||
several times or it can be omitted, in which case only the default
|
||
compiler paths will be searched. The <code>file</code> property specifies the file
|
||
location.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The difference between using the <code>file</code> feature and using a combination
|
||
of the <code>name</code> and <code>search</code> features is that <code>file</code> is more precise.</p>
|
||
</div>
|
||
<div class="admonitionblock warning">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">⚠</div>
|
||
</td>
|
||
<td class="content">
|
||
<div class="paragraph">
|
||
<p>The value of the <code>search</code> feature is just added to the linker search
|
||
path. When linking to multiple libraries, the paths specified by
|
||
<code>search</code> are combined without regard to which <code>lib</code> target each path
|
||
came from. Thus, given</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>a<span class="tok-w"> </span><span class="tok-na"><search></span>/pool/release<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>b<span class="tok-w"> </span><span class="tok-na"><search></span>/pool/debug<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If /pool/release/a.so, /pool/release/b.so, /pool/debug/a.so, and
|
||
/pool/release/b.so all exist, the linker will probably take both <code>a</code> and
|
||
<code>b</code> from the same directory, instead of finding <code>a</code> in /pool/release and
|
||
<code>b</code> in /pool/debug. If you need to distinguish between multiple
|
||
libraries with the same name, it’s safer to use <code>file</code>.</p>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For convenience, the following syntax is allowed:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>z<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>gui<span class="tok-w"> </span>db<span class="tok-w"> </span>aux<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>which has exactly the same effect as:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>z<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>z<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>gui<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>gui<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>db<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>db<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>aux<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>aux<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When a library references another library you should put that other
|
||
library in its list of sources. This will do the right thing in all
|
||
cases. For portability, you should specify library dependencies even for
|
||
searched and prebuilt libraries, otherwise, static linking on Unix will
|
||
not work. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>z<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>png<span class="tok-w"> </span>:<span class="tok-w"> </span>z<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>png<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
<div class="paragraph">
|
||
<p>When a library has a shared library as a source, or a static library has
|
||
another static library as a source then any target linking to the first
|
||
library with automatically link to its source library as well.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>On the other hand, when a shared library has a static library as a
|
||
source then the first library will be built so that it completely
|
||
includes the second one.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you do not want a shared library to include all the libraries
|
||
specified in its sources (especially statically linked ones), you would
|
||
need to use the following:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><use></span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><library></span>b<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This specifies that library <code>a</code> uses library <code>b</code>, and causes all
|
||
executables that link to <code>a</code> to link to <code>b</code> also. In this case, even for
|
||
shared linking, the <code>a</code> library will not refer to <code>b</code>.</p>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><a href="#bbv2.overview.targets">Usage requirements</a> are often very useful
|
||
for defining library targets. For example, imagine that you want you
|
||
build a <code>helpers</code> library and its interface is described in its
|
||
<code>helpers.hpp</code> header file located in the same directory as the
|
||
<code>helpers.cpp</code> source file. Then you could add the following to the
|
||
Jamfile located in that same directory:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>helpers<span class="tok-w"> </span>:<span class="tok-w"> </span>helpers.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>.<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>which would automatically add the directory where the target has been
|
||
defined (and where the library’s header file is located) to the
|
||
compiler’s include path for all targets using the <code>helpers</code> library.
|
||
This feature greatly simplifies Jamfiles.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tasks.alias"><a class="anchor" href="#bbv2.tasks.alias"></a>5.3. Alias</h3>
|
||
<div class="paragraph">
|
||
<p>The <code>alias</code> rule gives an alternative name to a group of targets. For
|
||
example, to give the name <code>core</code> to a group of three other targets with
|
||
the following code:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">alias</span><span class="tok-w"> </span>core<span class="tok-w"> </span>:<span class="tok-w"> </span>im<span class="tok-w"> </span>reader<span class="tok-w"> </span>writer<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Using <code>core</code> on the command line, or in the source list of any other
|
||
target is the same as explicitly using <code>im</code>, <code>reader</code>, and <code>writer</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Another use of the <code>alias</code> rule is to change build properties. For
|
||
example, if you want to link statically to the Boost Threads
|
||
library, you can write the following:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">alias</span><span class="tok-w"> </span>threads<span class="tok-w"> </span>:<span class="tok-w"> </span>/boost/thread//boost_thread<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>and use only the <code>threads</code> alias in your Jamfiles.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>You can also specify usage requirements for the <code>alias</code> target. If you
|
||
write the following:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">alias</span><span class="tok-w"> </span>header_only_library<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/include/header_only_library<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>then using <code>header_only_library</code> in sources will only add an include
|
||
path. Also note that when an alias has sources, their usage requirements
|
||
are propagated as well. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>library1<span class="tok-w"> </span>:<span class="tok-w"> </span>library1.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/library/include1<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>library2<span class="tok-w"> </span>:<span class="tok-w"> </span>library2.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/library/include2<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">alias</span><span class="tok-w"> </span>static_libraries<span class="tok-w"> </span>:<span class="tok-w"> </span>library1<span class="tok-w"> </span>library2<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>main<span class="tok-w"> </span>:<span class="tok-w"> </span>main.cpp<span class="tok-w"> </span>static_libraries<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will compile <code>main.cpp</code> with additional includes required for using the
|
||
specified static libraries.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tasks.installing"><a class="anchor" href="#bbv2.tasks.installing"></a>5.4. Installing</h3>
|
||
<div class="paragraph">
|
||
<p>This section describes various ways to install built targets and
|
||
arbitrary files.</p>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_basic_install"><a class="anchor" href="#_basic_install"></a>5.4.1. Basic install</h4>
|
||
<div class="paragraph">
|
||
<p>For installing a built target you should use the <code>install</code> rule, which
|
||
follows the <a href="#bbv2.main-target-rule-syntax">common syntax</a>. For
|
||
example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">install</span><span class="tok-w"> </span>dist<span class="tok-w"> </span>:<span class="tok-w"> </span>hello<span class="tok-w"> </span>helpers<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will cause the targets <code>hello</code> and <code>helpers</code> to be moved to the <code>dist</code>
|
||
directory, relative to the Jamfile’s directory. The directory can be
|
||
changed using the <code>location</code> property:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">install</span><span class="tok-w"> </span>dist<span class="tok-w"> </span>:<span class="tok-w"> </span>hello<span class="tok-w"> </span>helpers<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><location></span>/usr/bin<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>While you can achieve the same effect by changing the target name to
|
||
<code>/usr/bin</code>, using the <code>location</code> property is better as it allows you to
|
||
use a mnemonic target name.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>location</code> property is especially handy when the location is not
|
||
fixed, but depends on the build variant or environment variables:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">install</span><span class="tok-w"> </span>dist<span class="tok-w"> </span>:<span class="tok-w"> </span>hello<span class="tok-w"> </span>helpers<span class="tok-w"> </span>:<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><variant></span>release:<span class="tok-na"><location></span>dist/release<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><variant></span>debug:<span class="tok-na"><location></span>dist/debug<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">install</span><span class="tok-w"> </span>dist2<span class="tok-w"> </span>:<span class="tok-w"> </span>hello<span class="tok-w"> </span>helpers<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><location></span><span class="tok-si">$(DIST)</span><span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>See also <a href="#bbv2.reference.variants.propcond">conditional properties</a>
|
||
and <a href="#bbv2.faq.envar">environment variables</a></p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_installing_with_all_dependencies"><a class="anchor" href="#_installing_with_all_dependencies"></a>5.4.2. Installing with all dependencies</h4>
|
||
<div class="paragraph">
|
||
<p>Specifying the names of all libraries to install can be boring. The
|
||
<code>install</code> allows you to specify only the top-level executable targets to
|
||
install, and automatically install all dependencies:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">install</span><span class="tok-w"> </span>dist<span class="tok-w"> </span>:<span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><install-dependencies></span>on<span class="tok-w"> </span><span class="tok-na"><install-type></span>EXE<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><install-type></span>LIB<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will find all targets that <code>hello</code> depends on, and install all of those
|
||
which are either executables or libraries. More specifically, for each
|
||
target, other targets that were specified as sources or as dependency
|
||
properties, will be recursively found. One exception is that targets
|
||
referred with the <a href="#bbv2.builtin.features.use"><code>use</code></a> feature are not
|
||
considered, as that feature is typically used to refer to header-only
|
||
libraries. If the set of target types is specified, only targets of that
|
||
type will be installed, otherwise, all found target will be installed.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_preserving_directory_hierarchy"><a class="anchor" href="#_preserving_directory_hierarchy"></a>5.4.3. Preserving Directory Hierarchy</h4>
|
||
<div class="paragraph">
|
||
<p>By default, the <code>install</code> rule will strip paths from its sources. So, if
|
||
sources include <code>a/b/c.hpp</code>, the <code>a/b</code> part will be ignored. To make the
|
||
<code>install</code> rule preserve the directory hierarchy you need to use the
|
||
<code><install-source-root></code> feature to specify the root of the hierarchy you
|
||
are installing. Relative paths from that root will be preserved. For
|
||
example, if you write:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">install</span><span class="tok-w"> </span>headers<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>a/b/c.h<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><location></span>/tmp<span class="tok-w"> </span><span class="tok-na"><install-source-root></span>a<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>the a file named <code>/tmp/b/c.h</code> will be created.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <a href="#bbv2.reference.glob-tree"><code>glob-tree</code></a> rule can be used to find
|
||
all files below a given directory, making it easy to install an entire
|
||
directory tree.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_installing_into_several_directories"><a class="anchor" href="#_installing_into_several_directories"></a>5.4.4. Installing into Several Directories</h4>
|
||
<div class="paragraph">
|
||
<p>The <a href="#bbv2.tasks.alias"><code>alias</code></a> rule can be used when targets need
|
||
to be installed into several directories:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">alias</span><span class="tok-w"> </span><span class="tok-nb">install</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-nb">install</span>-bin<span class="tok-w"> </span><span class="tok-nb">install</span>-lib<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">install</span><span class="tok-w"> </span><span class="tok-nb">install</span>-bin<span class="tok-w"> </span>:<span class="tok-w"> </span>applications<span class="tok-w"> </span>:<span class="tok-w"> </span>/usr/bin<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">install</span><span class="tok-w"> </span><span class="tok-nb">install</span>-lib<span class="tok-w"> </span>:<span class="tok-w"> </span>helper<span class="tok-w"> </span>:<span class="tok-w"> </span>/usr/lib<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Because the <code>install</code> rule just copies targets, most free features
|
||
<sup class="footnote">[<a id="_footnoteref_3" class="footnote" href="#_footnotedef_3" title="View footnote.">3</a>]</sup>
|
||
have no effect when used in requirements of the <code>install</code> rule. The only two
|
||
that matter are
|
||
<a href="#bbv2.builtin.features.dependency"><code>dependency</code></a> and, on Unix,
|
||
<a href="#bbv2.builtin.features.dll-path"><code>dll-path</code></a>.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
(Unix specific) On Unix, executables built using B2 typically
|
||
contain the list of paths to all used shared libraries. For installing,
|
||
this is not desired, so B2 relinks the executable with an empty
|
||
list of paths. You can also specify additional paths for installed
|
||
executables using the <code>dll-path</code> feature.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.builtins.testing"><a class="anchor" href="#bbv2.builtins.testing"></a>5.5. Testing</h3>
|
||
<div class="paragraph">
|
||
<p>B2 has convenient support for running unit tests. The simplest
|
||
way is the <code>unit-test</code> rule, which follows the
|
||
<a href="#bbv2.main-target-rule-syntax">common syntax</a>. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">unit-test</span><span class="tok-w"> </span>helpers_test<span class="tok-w"> </span>:<span class="tok-w"> </span>helpers_test.cpp<span class="tok-w"> </span>helpers<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>unit-test</code> rule behaves like the <a href="#bbv2.tasks.programs">exe</a>
|
||
rule, but after the executable is created it is also run. If the
|
||
executable returns an error code, the build system will also return an
|
||
error and will try running the executable on the next invocation until
|
||
it runs successfully. This behavior ensures that you can not miss a
|
||
unit test failure.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are few specialized testing rules, listed below:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">compile</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target-name</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">compile-fail</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target-name</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">link</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target-name</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">link-fail</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target-name</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>They are given a list of sources and requirements. If the target name is
|
||
not provided, the name of the first source file is used instead. The
|
||
<code>compile*</code> tests try to compile the passed source. The <code>link*</code> rules try
|
||
to compile and link an application from all the passed sources. The
|
||
<code>compile</code> and <code>link</code> rules expect that compilation/linking succeeds. The
|
||
<code>compile-fail</code> and <code>link-fail</code> rules expect that the
|
||
compilation/linking fails.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are two specialized rules for running executables, which are more
|
||
powerful than the <code>unit-test</code> rule. The <code>run</code> rule has the following
|
||
signature:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">run</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">args</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">input-files</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target-name</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">default-build</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The rule builds application from the provided sources and runs it,
|
||
passing <code>args</code> and <code>input-files</code> as command-line arguments. The <code>args</code>
|
||
parameter is passed verbatim and the values of the <code>input-files</code>
|
||
parameter are treated as paths relative to containing Jamfile, and are
|
||
adjusted if <code>b2</code> is invoked from a different directory. The <code>run-fail</code>
|
||
rule is identical to the <code>run</code> rule, except that it expects that the run
|
||
fails.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>All rules described in this section, if executed successfully, create a
|
||
special manifest file to indicate that the test passed. For the
|
||
<code>unit-test</code> rule the files is named <code>target-name.passed</code> and for the other
|
||
rules it is called <code>target-name.test</code>. The <code>run*</code> rules also capture all
|
||
output from the program, and store it in a file named <code>target-name.output</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the <code>preserve-test-targets</code> feature has the
|
||
value <code>off</code>, then <code>run</code> and the <code>run-fail</code> rules will remove the
|
||
executable after running it. This somewhat decreases disk space
|
||
requirements for continuous testing environments. The default value of
|
||
<code>preserve-test-targets</code> feature is <code>on</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It is possible to print the list of all test targets (except for
|
||
<code>unit-test</code>) declared in your project, by passing the <code>--dump-tests</code>
|
||
command-line option. The output will consist of lines of the form:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>boost-test(test-type)<span class="tok-w"> </span>path<span class="tok-w"> </span>:<span class="tok-w"> </span>sources<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It is possible to process the list of tests, B2 output and the
|
||
presence/absence of the <code>*.test</code> files created when test passes into
|
||
human-readable status table of tests. Such processing utilities are not
|
||
included in B2.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following features adjust behavior of the testing metatargets.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>testing.arg</code></dt>
|
||
<dd>
|
||
<p>Defines an argument to be passed to the target when it is executed
|
||
before the list of input files.</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">unit-test</span><span class="tok-w"> </span>helpers_test<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>helpers_test.cpp<span class="tok-w"> </span>helpers<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><testing.arg></span>"--foo<span class="tok-w"> </span>bar"<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>testing.input-file</code></dt>
|
||
<dd>
|
||
<p>Specifies a file to be passed to the executable on the command line
|
||
after the arguments. All files must be specified in alphabetical order
|
||
due to constraints in the current implementation.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>testing.launcher</code></dt>
|
||
<dd>
|
||
<p>By default, the executable is run directly. Sometimes, it is desirable
|
||
to run the executable using some helper command. You should use this
|
||
property to specify the name of the helper command. For example, if
|
||
you write:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">unit-test</span><span class="tok-w"> </span>helpers_test<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>helpers_test.cpp<span class="tok-w"> </span>helpers<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><testing.launcher></span>valgrind<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The command used to run the executable will be:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>valgrind bin/<span class="tok-nv">$toolset</span>/debug/helpers_test</code></pre>
|
||
</div>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>test-info</code></dt>
|
||
<dd>
|
||
<p>A description of the test. This is displayed as part of the
|
||
<code>--dump-tests</code> command-line option.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.builtins.raw"><a class="anchor" href="#bbv2.builtins.raw"></a>5.6. Custom commands</h3>
|
||
<div class="paragraph">
|
||
<p>For most main target rules, B2 automatically figures out the
|
||
commands to run. When you want to use new file types or support new
|
||
tools, one approach is to extend B2 to support them smoothly,
|
||
as documented in <a href="#bbv2.extender">Extender Manual</a>. However, if the new
|
||
tool is only used in a single place, it might be easier just to specify the
|
||
commands to run explicitly.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Three main target rules can be used for that. The <code>make</code> rule allows you to
|
||
construct a single file from any number of source file, by running a command
|
||
you specify. The <code>notfile</code> rule allows you to run an arbitrary command,
|
||
without creating any files. And finally, the <code>generate</code> rule allows you to
|
||
describe a transformation using B2’s virtual targets. This is
|
||
higher-level than the file names that the <code>make</code> rule operates with and
|
||
allows you to create more than one target, create differently named targets
|
||
depending on properties, or use more than one tool.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>make</code> rule is used when you want to create one file from a number
|
||
of sources using some specific command. The <code>notfile</code> is used to
|
||
unconditionally run a command.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Suppose you want to create the file <code>file.out</code> from the file <code>file.in</code>
|
||
by running the command <code>in2out</code>. Here is how you would do this in B2:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">make</span><span class="tok-w"> </span>file.out<span class="tok-w"> </span>:<span class="tok-w"> </span>file.in<span class="tok-w"> </span>:<span class="tok-w"> </span>@in2out<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">actions</span><span class="tok-w"> </span><span class="tok-nf">in2out</span><span class="tok-w"></span>
|
||
{<span class="tok-sh"></span>
|
||
<span class="tok-sh"> in2out </span><span class="tok-si">$(<)</span><span class="tok-sh"> </span><span class="tok-si">$(>)</span><span class="tok-sh"></span>
|
||
<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you run <code>b2</code> and <code>file.out</code> does not exist, B2 will run the
|
||
<code>in2out</code> command to create that file. For more details on specifying
|
||
actions, see
|
||
<a href="#bbv2.overview.jam_language.actions">the section called “Boost.Jam Language”</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It could be that you just want to run some command unconditionally, and
|
||
that command does not create any specific files. For that you can use
|
||
the <code>notfile</code> rule. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">notfile</span><span class="tok-w"> </span>echo_something<span class="tok-w"> </span>:<span class="tok-w"> </span>@echo<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">actions</span><span class="tok-w"> </span><span class="tok-nf">echo</span><span class="tok-w"></span>
|
||
{<span class="tok-sh"></span>
|
||
<span class="tok-sh"> echo "something"</span>
|
||
<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The only difference from the <code>make</code> rule is that the name of the target
|
||
is not considered a name of a file, so B2 will unconditionally
|
||
run the action.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>generate</code> rule is used when you want to express transformations
|
||
using B2’s virtual targets, as opposed to just filenames. The
|
||
<code>generate</code> rule has the standard main target rule signature, but you are
|
||
required to specify the <code>generating-rule</code> property. The value of the
|
||
property should be in the form <code>@<em>rule-name</em></code>, the named rule should have the
|
||
following signature:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">generating-rule</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">project</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>and will be called with an instance of the <code>project-target</code> class, the
|
||
name of the main target, an instance of the <code>property-set</code> class
|
||
containing build properties, and the list of instances of the
|
||
<code>virtual-target</code> class corresponding to sources. The rule must return a
|
||
list of <code>virtual-target</code> instances. The interface of the
|
||
<code>virtual-target</code> class can be learned by looking at the
|
||
<code>build/virtual-target.jam</code> file. The <code>generate</code> example contained in the
|
||
B2 distribution illustrates how the <code>generate</code> rule can be
|
||
used.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.precompiled_headers"><a class="anchor" href="#bbv2.reference.precompiled_headers"></a>5.7. Precompiled Headers</h3>
|
||
<div class="paragraph">
|
||
<p>Precompiled headers is a mechanism to speed up compilation by creating a
|
||
partially processed version of some header files, and then using that
|
||
version during compilations rather then repeatedly parsing the original
|
||
headers. B2 supports precompiled headers with gcc and msvc
|
||
toolsets.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To use precompiled headers, follow the following steps:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Create a header that includes headers used by your project that you
|
||
want precompiled. It is better to include only headers that are
|
||
sufficiently stable — like headers from the compiler and external
|
||
libraries. Please wrap the header in <code>#ifdef BOOST_BUILD_PCH_ENABLED</code>, so
|
||
that the potentially expensive inclusion of headers is not done when PCH is
|
||
not enabled. Include the new header at the top of your source files.</p>
|
||
</li>
|
||
<li>
|
||
<p>Declare a new B2 target for the precompiled header and add
|
||
that precompiled header to the sources of the target whose compilation
|
||
you want to speed up:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>cpp-pch<span class="tok-w"> </span>pch<span class="tok-w"> </span>:<span class="tok-w"> </span>pch.hpp<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>main<span class="tok-w"> </span>:<span class="tok-w"> </span>main.cpp<span class="tok-w"> </span>pch<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>You can use the <code>c-pch</code> rule if you want to use the precompiled header
|
||
in C programs.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>pch</code> example in B2 distribution can be used as reference.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Please note the following:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>The inclusion of the precompiled header must be the first thing in a
|
||
source file, before any code or preprocessor directives.</p>
|
||
</li>
|
||
<li>
|
||
<p>The build properties used to compile the source files and the
|
||
precompiled header must be the same. Consider using project requirements
|
||
to assure this.</p>
|
||
</li>
|
||
<li>
|
||
<p>Precompiled headers must be used purely as a way to improve
|
||
compilation time, not to save the number of <code>#include</code> statements. If a
|
||
source file needs to include some header, explicitly include it in the
|
||
source file, even if the same header is included from the precompiled
|
||
header. This makes sure that your project will build even if precompiled
|
||
headers are not supported.</p>
|
||
</li>
|
||
<li>
|
||
<p>Prior to version 4.2, the gcc compiler did not allow anonymous
|
||
namespaces in precompiled headers, which limits their utility. See the
|
||
<a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29085">bug report</a> for
|
||
details.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.generated_headers"><a class="anchor" href="#bbv2.reference.generated_headers"></a>5.8. Generated headers</h3>
|
||
<div class="paragraph">
|
||
<p>Usually, B2 handles implicit dependencies completely
|
||
automatically. For example, for C++ files, all <code>#include</code> statements are
|
||
found and handled. The only aspect where user help might be needed is
|
||
implicit dependency on generated files.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>By default, B2 handles such dependencies within one main
|
||
target. For example, assume that main target "app" has two sources,
|
||
"app.cpp" and "parser.y". The latter source is converted into "parser.c"
|
||
and "parser.h". Then, if "app.cpp" includes "parser.h", B2 will
|
||
detect this dependency. Moreover, since "parser.h" will be generated
|
||
into a build directory, the path to that directory will automatically be
|
||
added to the include path.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Making this mechanism work across main target boundaries is possible,
|
||
but imposes certain overhead. For that reason, if there is implicit
|
||
dependency on files from other main targets, the <code><implicit-dependency></code>
|
||
feature must be used, for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>parser<span class="tok-w"> </span>:<span class="tok-w"> </span>parser.y<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>app<span class="tok-w"> </span>:<span class="tok-w"> </span>app.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><implicit-dependency></span>parser<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The above example tells the build system that when scanning all sources
|
||
of "app" for implicit-dependencies, it should consider targets from
|
||
"parser" as potential dependencies.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tasks.crosscompile"><a class="anchor" href="#bbv2.tasks.crosscompile"></a>5.9. Cross-compilation</h3>
|
||
<div class="paragraph">
|
||
<p>B2 supports cross compilation with the gcc and msvc toolsets.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When using gcc, you first need to specify your cross compiler in
|
||
<code>user-config.jam</code> (see
|
||
<a href="#bbv2.overview.configuration">the section called “Configuration”</a>), for
|
||
example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>arm<span class="tok-w"> </span>:<span class="tok-w"> </span>arm-none-linux-gnueabi-g++<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>After that, if the host and target os are the same, for example Linux,
|
||
you can just request that this compiler version be used:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>b2 <span class="tok-nv">toolset</span><span class="tok-o">=</span>gcc-arm</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you want to target a different operating system from the host, you
|
||
need to additionally specify the value for the <code>target-os</code> feature, for
|
||
example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="bat"><span></span># On windows box
|
||
b2 toolset=gcc-arm target-os=linux
|
||
# On Linux box
|
||
b2 toolset=gcc-mingw target-os=windows</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For the complete list of allowed operating system names, please see the
|
||
documentation for <a href="#bbv2.builtin.features.target-os">target-os
|
||
feature</a>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When using the msvc compiler, it’s only possible to cross-compile to a
|
||
64-bit system on a 32-bit host. Please see
|
||
<a href="#bbv2.reference.tools.compiler.msvc.64">the section called “64-bit support”</a>
|
||
for details.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.tasks.packagemanagers"><a class="anchor" href="#bbv2.tasks.packagemanagers"></a>5.10. Package Managers</h3>
|
||
<div class="paragraph">
|
||
<p>B2 support automatic, or manual, loading of generated build files
|
||
from package managers. For example using the Conan package manager which
|
||
generates <code>conanbuildinfo.jam</code> files B2 will load that files automatically
|
||
when it loads the project at the same location. The included file can
|
||
define targets and other project declarations in the context of the
|
||
project it’s being loaded into. Control over what package manager file
|
||
is loaded can be controlled with (in order of priority):</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>With the <code>use-packages</code> rule.</p>
|
||
</li>
|
||
<li>
|
||
<p>Command line argument <code>--use-package-manager=X</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p>Environment variable <code>PACKAGE_MANAGER_BUILD_INFO</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p>Built-in detection of the file. Currently this includes: "conan".</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><strong><code>use-packages</code> rule:</strong></p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">use-packages</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name-or-glob-pattern</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>use-packages</code> rule allows one to specify in the projects themselves kind
|
||
of package definitions to use either as the ones for a built-in package
|
||
manager support. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>use-packages<span class="tok-w"> </span>conan<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Or to specify a <code>glob</code> pattern to find the file with the definitions. For
|
||
instance:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>use-packages<span class="tok-w"> </span>"packages.jam"<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><strong><code>--use-package-manager</code> command line option:</strong></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>--use-package-manager=NAME</code> command line option allows one to
|
||
non-intrusively specify per invocation which of the built-in package manager
|
||
types to use.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><strong><code>PACKAGE_MANAGER_BUILD_INFO</code> variable:</strong></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>PACKAGE_MANAGER_BUILD_INFO</code> variable, which is taken from the environment
|
||
or defined with the <code>-sX=Y</code> option, specifies a <code>glob</code> pattern to use to find
|
||
the package definitions.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><strong>Built-in detection:</strong></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are a number of built-in <code>glob</code> patterns to support popular package
|
||
managers. Currently the supported ones are:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Conan (<code>conan</code>): currently supports the
|
||
<a href="https://bintray.com/bfgroup/public-conan/b2gen%3Abfgroup"><code>b2gen</code></a>
|
||
generator.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.reference"><a class="anchor" href="#bbv2.reference"></a>6. Reference</h2>
|
||
<div class="sectionbody">
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.general"><a class="anchor" href="#bbv2.reference.general"></a>6.1. General information</h3>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.init"><a class="anchor" href="#bbv2.reference.init"></a>6.1.1. Initialization</h4>
|
||
<div class="paragraph">
|
||
<p>Immediately upon starting, the B2 engine (<strong><code>b2</code></strong>) loads the Jam
|
||
code that implements the build system. To do this, it searches for a
|
||
file called <code>boost-build.jam</code>, first in the invocation directory, then
|
||
in its parent and so forth up to the filesystem root, and finally in the
|
||
directories specified by the environment variable BOOST_BUILD_PATH. On
|
||
Unix BOOST_BUILD_PATH defaults to <code>/usr/share/boost-build</code>. When
|
||
found, the file is interpreted, and should specify the build system
|
||
location by calling the boost-build rule:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">boost-build</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">location</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If location is a relative path, it is treated as relative to the
|
||
directory of <code>boost-build.jam</code>. The directory specified by that location
|
||
and the directories in BOOST_BUILD_PATH are then searched for a file
|
||
called <code>bootstrap.jam</code>, which is expected to bootstrap the build system.
|
||
This arrangement allows the build system to work without any
|
||
command-line or environment variable settings. For example, if the build
|
||
system files were located in a directory "build-system/" at your project
|
||
root, you might place a <code>boost-build.jam</code> at the project root
|
||
containing:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>boost-build<span class="tok-w"> </span>build-system<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In this case, running <strong><code>b2</code></strong> anywhere in the project tree will
|
||
automatically find the build system.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The default <code>bootstrap.jam</code>, after loading some standard definitions,
|
||
loads both <code>site-config.jam</code> and <code>user-config.jam</code>.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.rules"><a class="anchor" href="#bbv2.reference.rules"></a>6.2. Builtin rules</h3>
|
||
<div class="paragraph">
|
||
<p>This section contains the list of all rules that can be used in
|
||
Jamfile — both rules that define new targets and auxiliary rules.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.exe"></a><code>exe</code></dt>
|
||
<dd>
|
||
<p>Creates an executable file. See
|
||
<a href="#bbv2.tasks.programs">the section called “Programs”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.lib"></a><code>lib</code></dt>
|
||
<dd>
|
||
<p>Creates an library file. See
|
||
<a href="#bbv2.tasks.libraries">the section called “Libraries”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.install"></a><code>install</code></dt>
|
||
<dd>
|
||
<p>Installs built targets and other files. See
|
||
<a href="#bbv2.tasks.installing">the section called “Installing”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.alias"></a><code>alias</code></dt>
|
||
<dd>
|
||
<p>Creates an alias for other targets. See
|
||
<a href="#bbv2.tasks.alias">the section called “Alias”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.unit-test"></a><code>unit-test</code></dt>
|
||
<dd>
|
||
<p>Creates an executable that will be automatically run. See
|
||
<a href="#bbv2.builtins.testing">the section called “Testing”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.test"></a><code>compile</code>; <code>compile-fail</code>; <code>link</code>; <code>link-fail</code>; <code>run</code>; <code>run-fail</code></dt>
|
||
<dd>
|
||
<p>Specialized rules for testing. See
|
||
<a href="#bbv2.builtins.testing">the section called “Testing”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.check-target-builds"></a><code>check-target-builds</code></dt>
|
||
<dd>
|
||
<p>The <code>check-target-builds</code> allows you to conditionally use different
|
||
properties depending on whether some metatarget builds, or not. This
|
||
is similar to functionality of configure script in <code>autotools</code> projects.
|
||
The function signature is:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule check-target-builds ( target message ? : true-properties * : false-properties * )</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This function can only be used when passing requirements or usage
|
||
requirements to a metatarget rule. For example, to make an application
|
||
link to a library if it’s available, one has use the following:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>exe app : app.cpp : [ check-target-builds has_foo "System has foo" : <library>foo : <define>FOO_MISSING=1 ] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For another example, the alias rule can be used to consolidate
|
||
configuration choices and make them available to other metatargets,
|
||
like so:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>alias foobar : : : : [ check-target-builds has_foo "System has foo" : <library>foo : <library>bar ] ;</pre>
|
||
</div>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.obj"></a><code>obj</code></dt>
|
||
<dd>
|
||
<p>Creates an object file. Useful when a single source file must be
|
||
compiled with special properties.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.preprocessed"></a><code>preprocessed</code></dt>
|
||
<dd>
|
||
<p>Creates an preprocessed source file. The arguments follow the
|
||
<a href="#bbv2.main-target-rule-syntax">common syntax</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.glob"></a><code>glob</code></dt>
|
||
<dd>
|
||
<p>The <code>glob</code> rule takes a list shell pattern and returns the list of
|
||
files in the project’s source directory that match the pattern. For
|
||
example:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>lib tools : [ glob *.cpp ] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It is possible to also pass a second argument—the list of exclude
|
||
patterns. The result will then include the list of files matching any
|
||
of include patterns, and not matching any of the exclude patterns. For
|
||
example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>lib tools : [ glob *.cpp : file_to_exclude.cpp bad*.cpp ] ;</pre>
|
||
</div>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.glob-tree"></a><code>glob-tree</code></dt>
|
||
<dd>
|
||
<p>The <code>glob-tree</code> is similar to the <code>glob</code> except that it operates
|
||
recursively from the directory of the containing Jamfile. For example:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>ECHO [ glob-tree *.cpp : .svn ] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will print the names of all C++ files in your project. The <code>.svn</code>
|
||
exclude pattern prevents the <code>glob-tree</code> rule from entering
|
||
administrative directories of the Subversion version control system.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.project"></a><code>project</code></dt>
|
||
<dd>
|
||
<p>Declares project id and attributes, including project requirements.
|
||
See <a href="#bbv2.overview.projects">the section called “Projects”</a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.use-project"></a><code>use-project</code></dt>
|
||
<dd>
|
||
<p>Assigns a symbolic project ID to a project at a given path. This rule
|
||
must be better documented!</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.explicit"></a><code>explicit</code></dt>
|
||
<dd>
|
||
<p>The <code>explicit</code> rule takes a single parameter—​a list of target names.
|
||
The named targets will be marked explicit, and will be built only if
|
||
they are explicitly requested on the command line, or if their
|
||
dependents are built. Compare this to ordinary targets, that are built
|
||
implicitly when their containing project is built.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.always"></a><code>always</code></dt>
|
||
<dd>
|
||
<p>The <code>always</code> function takes a single parameter—a list of metatarget
|
||
names. The targets produced by the named metatargets will be
|
||
always considered out of date. Consider this example:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>exe hello : hello.cpp ;
|
||
exe bye : bye.cpp ;
|
||
always hello ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If a build of <code>hello</code> is requested, then it will always be recompiled. Note that
|
||
if a build of <code>hello</code> is not requested, for example you specify just
|
||
<code>bye</code> on the command line, <code>hello</code> will not be recompiled.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.constant"></a><code>constant</code></dt>
|
||
<dd>
|
||
<p>Sets project-wide constant. Takes two parameters: variable name and a
|
||
value and makes the specified variable name accessible in this Jamfile
|
||
and any child Jamfiles. For example:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>constant VERSION : 1.34.0 ;</pre>
|
||
</div>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.path-constant"></a><code>path-constant</code></dt>
|
||
<dd>
|
||
<p>Same as <code>constant</code> except that the value is treated as path relative
|
||
to Jamfile location. For example, if <code>b2</code> is invoked in the current
|
||
directory, and Jamfile in <code>helper</code> subdirectory has:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>path-constant DATA : data/a.txt ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>then the variable <code>DATA</code> will be set to <code>helper/data/a.txt</code>, and if
|
||
<strong><code>b2</code></strong> is invoked from the <code>helper</code> directory, then the variable <code>DATA</code>
|
||
will be set to <code>data/a.txt</code>.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.build-project"></a><code>build-project</code></dt>
|
||
<dd>
|
||
<p>Cause some other project to be built. This rule takes a single
|
||
parameter—a directory name relative to the containing Jamfile. When
|
||
the containing Jamfile is built, the project located at that directory
|
||
will be built as well. At the moment, the parameter to this rule
|
||
should be a directory name. Project ID or general target references
|
||
are not allowed.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.reference.rules.test-suite"></a><code>test-suite</code></dt>
|
||
<dd>
|
||
<p>This rule is deprecated and equivalent to <code>alias</code>.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.overview.builtins.features"><a class="anchor" href="#bbv2.overview.builtins.features"></a>6.3. Builtin features</h3>
|
||
<div class="paragraph">
|
||
<p>This section documents the features that are built-in into B2.
|
||
For features with a fixed set of values, that set is provided, with the
|
||
default value listed first.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.address-model"></a><code>address-model</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>32</code>, <code>64</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies if 32-bit or 64-bit code should be generated by the compiler. Whether
|
||
this feature works depends on the used compiler, its version, how the compiler
|
||
is configured, and the values of the <code>architecture</code> <code>instruction-set</code> features.
|
||
Please see the section <a href="#bbv2.reference.tools.compilers">C++ Compilers</a> for details.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.address-sanitizer"></a><code>address-sanitizer</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>norecover</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables address sanitizer. Value <code>norecover</code> disables recovery for the
|
||
sanitizer. The feature is optional, thus no sanitizer is enabled by default.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.allow"></a><code>allow</code></dt>
|
||
<dd>
|
||
<p>This feature is used to allow specific generators to run. For example, Qt tools
|
||
can only be invoked when Qt library is used. In that case, <code><allow>qt</code> will be
|
||
in usage requirement of the library.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.architecture"></a><code>architecture</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>x86</code>, <code>ia64</code>, <code>sparc</code>, <code>power</code>, <code>mips1</code>, <code>mips2</code>,
|
||
<code>mips3</code>, <code>mips4</code>, <code>mips32</code>, <code>mips32r2</code>, <code>mips64</code>, <code>parisc</code>, <code>arm</code>,
|
||
<code>s390x</code>, <code>combined</code>, <code>combined-x86-power</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies the general processor family to generate code for.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.archiveflags"></a><code>archiveflags</code></dt>
|
||
<dd>
|
||
<p>The value of this feature is passed without modification to the archiver tool
|
||
when creating static libraries.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.asmflags"></a><code>asmflags</code></dt>
|
||
<dd>
|
||
<p>The value of this feature is passed without modification to the assembler.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.asynch-exceptions"></a><code>asynch-exceptions</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>on</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Selects whether there is support for asynchronous EH (e.g. catching SEGVs).</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.build"></a><code>build</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>no</code></p>
|
||
<div class="paragraph">
|
||
<p>Used to conditionally disable build of a target. If <code><build>no</code> is in
|
||
properties when building a target, build of that target is skipped. Combined
|
||
with conditional requirements this allows you to skip building some target in
|
||
configurations where the build is known to fail.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.cflags"></a><code>cflags</code>; <code>cxxflags</code>; <code>linkflags</code></dt>
|
||
<dd>
|
||
<p>The value of these features is passed without modification to the corresponding
|
||
tools. For <code>cflags</code> that is both the C and C++ compilers, for <code>cxxflags</code> that
|
||
is the C++ compiler, and for <code>linkflags</code> that is the linker. The features are
|
||
handy when you are trying to do something special that cannot be achieved by a
|
||
higher-level feature in B2.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.conditional"></a><code>conditional</code></dt>
|
||
<dd>
|
||
<p>Used to introduce indirect conditional requirements. The value should have the
|
||
form:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>@rulename</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>where <em>rulename</em> should be a name of a rule with the following signature:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule rulename ( properties * )</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The rule will be called for each target with its properties and should return
|
||
any additional properties. See also section <a href="#bbv2.overview.targets.requirements">Requirements</a> for an example.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.coverage"></a><code>coverage</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>on</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables code instrumentation to generate coverage data during execution.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.cxxflags"></a><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>See <a href="#bbv2.builtin.features.cflags"><code><cflags></code></a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.cxxstd"></a><code>cxxstd</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values</strong>: <code>98</code>, <code>03</code>, <code>0x</code>, <code>11</code>, <code>1y</code>, <code>14</code>, <code>1z</code>, <code>17</code>, <code>2a</code>, <code>20</code>,
|
||
<code>latest</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies the version of the C++ Standard Language to build with. All the
|
||
official versions of the standard since "98" are included. It is also possible
|
||
to specify using the experimental, work in progress, <code>latest</code> version. Some
|
||
compilers specified intermediate versions for the experimental versions leading
|
||
up to the released standard version. Those are included following the GNU
|
||
nomenclature as <code>0x</code>, <code>1y</code>, <code>1z</code>, and <code>2a</code>. Depending on the compiler <code>latest</code>
|
||
would map to one of those.</p>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
This is an <code>optional</code> feature. Hence when not specified the compiler
|
||
default behaviour is used.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
Please consult the toolset specific documentation for which <code>cxxstd</code>
|
||
is supported.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.cxxstd-dialect"></a><code>cxxstd-dialect</code></dt>
|
||
<dd>
|
||
<p><strong>Subfeature of</strong> <code>cxxstd</code></p>
|
||
<div class="paragraph">
|
||
<p><strong>Allowed values</strong>: <code>iso</code>, <code>gnu</code>, <code>ms</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Indicates if a non-standard dialect should be used. These usually have
|
||
either/or extensions or platform specific functionality. Not specifying the
|
||
dialect will default to 'iso' which will attempt to use ISO C++ Standard
|
||
conformance to the best of the compiler’s ability.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.cxxabi"></a><code>c++abi</code></dt>
|
||
<dd>
|
||
<p>Selects a specific variant of C++ ABI if the compiler supports several.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.cpp-template-depth"></a><code>c++-template-depth</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> Any positive integer.</p>
|
||
<div class="paragraph">
|
||
<p>Allows configuring a C++ compiler with the maximal template instantiation
|
||
depth parameter. Specific toolsets may or may not provide support for this
|
||
feature depending on whether their compilers provide a corresponding
|
||
command-line option.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
Due to some internal details in the current B2 implementation it
|
||
is not possible to have features whose valid values are all positive integer.
|
||
As a workaround a large set of allowed values has been defined for this feature
|
||
and, if a different one is needed, user can easily add it by calling the
|
||
feature.extend rule.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.debug-symbols"></a><code>debug-symbols</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>off</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies if produced object files, executables, and libraries should include
|
||
debug information. Typically, the value of this feature is implicitly set by
|
||
the <code>variant</code> feature, but it can be explicitly specified by the user. The most
|
||
common usage is to build release variant with debugging information.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.define"></a><code>define</code></dt>
|
||
<dd>
|
||
<p>Specifies a preprocessor symbol that should be defined on the command line.
|
||
You may either specify just the symbol, which will be defined without any
|
||
value, or both the symbol and the value, separated by equal sign.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.def-file"></a><code>def-file</code></dt>
|
||
<dd>
|
||
<p>Provides a means to specify def-file for windows DLLs.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.dependency"></a><code>dependency</code></dt>
|
||
<dd>
|
||
<p>Introduces a dependency on the target named by the value of this feature (so it
|
||
will be brought up-to-date whenever the target being declared is). The
|
||
dependency is not used in any other way.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.dll-path"></a><code>dll-path</code></dt>
|
||
<dd>
|
||
<p>Specifies an additional directory where the system should look for shared
|
||
libraries when the executable or shared library is run. This feature only
|
||
affects Unix compilers. Please see
|
||
<a href="#bbv2.faq.dll-path">Why are the <code>dll-path</code> and <code>hardcode-dll-paths</code> properties useful?</a>
|
||
in <a href="#bbv2.faq">Frequently Asked Questions</a> for details.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.embed-manifest"></a><code>embed-manifest</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>off</code>.</p>
|
||
<div class="paragraph">
|
||
<p>This feature is specific to the <code>msvc</code> toolset (see <a href="#bbv2.reference.tools.compiler.msvc">Microsoft Visual C++</a>),
|
||
and controls whether the manifest files should be embedded inside executables
|
||
and shared libraries, or placed alongside them. This feature corresponds to the
|
||
IDE option found in the project settings dialog, under Configuration Properties
|
||
→ Manifest Tool → Input and Output → Embed manifest.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.embed-manifest-file"></a><code>embed-manifest-file</code></dt>
|
||
<dd>
|
||
<p>This feature is specific to the <code>msvc</code> toolset (see <a href="#bbv2.reference.tools.compiler.msvc">Microsoft Visual C++</a>),
|
||
and controls which manifest files should be embedded inside executables and
|
||
shared libraries. This feature corresponds to the IDE option found in the
|
||
project settings dialog, under Configuration Properties → Manifest Tool →
|
||
Input and Output → Additional Manifest Files.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.embed-manifest-via"></a><code>embed-manifest-via</code></dt>
|
||
<dd>
|
||
<p>This feature is specific to the <code>msvc</code> toolset (see <a href="#bbv2.reference.tools.compiler.msvc">Microsoft Visual C++</a>),
|
||
and controls whether a manifest should be embedded via linker or manifest tool.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.exception-handling"></a><code>exception-handling</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>off</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Disables exceptions.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.extern-c-nothrow"></a><code>extern-c-nothrow</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>on</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Selects whether all <code>extern "C"</code> functions are considered <code>nothrow</code> by default.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.fflags"></a><code>fflags</code></dt>
|
||
<dd>
|
||
<p>The value of this feature is passed without modification to the tool when
|
||
compiling Fortran sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.file"></a><code>file</code></dt>
|
||
<dd>
|
||
<p>When used in requirements of a prebuilt library target this feature specifies
|
||
the path to the library file. See <a href="#bbv2.tutorial.prebuilt">Prebuilt targets</a> for examples.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.find-shared-library"></a><code>find-shared-library</code></dt>
|
||
<dd>
|
||
<p>Adds a shared library to link to. Usually <a href="#bbv2.tasks.libraries"><code>lib</code></a>
|
||
targets should be preferred over using this feature.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.find-static-library"></a><code>find-static-library</code></dt>
|
||
<dd>
|
||
<p>Adds a static library to link to. Usually <a href="#bbv2.tasks.libraries"><code>lib</code></a>
|
||
targets should be preferred over using this feature.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.flags"></a><code>flags</code></dt>
|
||
<dd>
|
||
<p>This feature is used for generic, i.e. non-language specific, flags for tools.
|
||
The value of this feature is passed without modification to the tool that will
|
||
build the target.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.hardcode-dll-paths"></a><code>hardcode-dll-paths</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>true</code>, <code>false</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Controls automatic generation of dll-path properties.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This property is specific to Unix systems. If an executable is built with
|
||
<code><hardcode-dll-paths>true</code>, the generated binary will contain the list of all
|
||
the paths to the used shared libraries. As the result, the executable can be
|
||
run without changing system paths to shared libraries or installing the
|
||
libraries to system paths. This is very convenient during development. Please
|
||
see the <a href="#bbv2.faq.dll-path">FAQ entry</a> for details. Note that on Mac OSX,
|
||
the paths are unconditionally hardcoded by the linker, and it is not possible
|
||
to disable that behavior</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.implicit-dependency"></a><code>implicit-dependency</code></dt>
|
||
<dd>
|
||
<p>Indicates that the target named by the value of this feature may produce files
|
||
that are included by the sources of the target being declared. See the section
|
||
<a href="#bbv2.reference.generated_headers">Generated headers</a> for more information.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.force-include"></a><code>force-include</code></dt>
|
||
<dd>
|
||
<p>Specifies an include path that has to be included in a way like if
|
||
<code>#include "file"</code> appeared as the first line of every target’s source file.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The include order is not guaranteed if used multiple times on a single target.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.include"></a><code>include</code></dt>
|
||
<dd>
|
||
<p>Specifies an additional include path that is to be passed to C and C++
|
||
compilers.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.inlining"></a><code>inlining</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>on</code>, <code>full</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables inlining.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.install-package"></a><code>install-package</code></dt>
|
||
<dd>
|
||
<p>Specifies the name of the package to which installed files belong. This is
|
||
used for default installation prefix on certain platforms.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.install-prefix"></a><code>install-<name></code></dt>
|
||
<dd>
|
||
<p>Specifies installation prefix for <a href="#bbv2.tasks.installing"><code>install</code></a> targets.
|
||
These named installation prefixes are registered by default:</p>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>prefix</code>: <code>C:\<package name></code> if <code><target-os>windows</code> is in the property set,
|
||
<code>/usr/local</code> otherwise</p>
|
||
</li>
|
||
<li>
|
||
<p><code>exec-prefix</code>: <code>(prefix)</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>bindir</code>: <code>(exec-prefix)/bin</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>sbindir</code>: <code>(exec-prefix)/sbin</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>libexecdir</code>: <code>(exec-prefix)/libexec</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>libdir</code>: <code>(exec-prefix)/lib</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>datarootdir</code>: <code>(prefix)/share</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>datadir</code>: <code>(datarootdir)</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>sysconfdir</code>: <code>(prefix)/etc</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>sharedstatedir</code>: <code>(prefix)/com</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>localstatedir</code>: <code>(prefix)/var</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>runstatedir</code>: <code>(localstatedir)/run</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>includedir</code>: <code>(prefix)/include</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>oldincludedir</code>: <code>/usr/include</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>docdir</code>: <code>(datarootdir)/doc/<package name></code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>infodir</code>: <code>(datarootdir)/info</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>htmldir</code>: <code>(docdir)</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>dvidir</code> : <code>(docdir)</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>pdfdir</code> : <code>(docdir)</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>psdir</code> : <code>(docdir)</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>lispdir</code>: <code>(datarootdir)/emacs/site-lisp</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>localedir</code>: <code>(datarootdir)/locale</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>mandir</code>: <code>(datarootdir)/man</code></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If more are necessary, they could be added with
|
||
<a href="#bbv2.reference.modules.stage.add-install-dir"><code>stage.add-install-dir</code></a>.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.instruction-set"></a><code>instruction-set</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> depends on the used toolset.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies for which specific instruction set the code should be generated. The
|
||
code in general might not run on processors with older/different instruction
|
||
sets.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>While B2 allows a large set of possible values for this features,
|
||
whether a given value works depends on which compiler you use. Please see
|
||
the section <a href="#bbv2.reference.tools.compilers">C++ Compilers</a> for details.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.library"></a><code>library</code></dt>
|
||
<dd>
|
||
<p>This feature is almost equivalent to the
|
||
<a href="#bbv2.builtin.features.library"><code><source></code></a> feature, except that it takes
|
||
effect only for linking. When you want to link all targets in a Jamfile to
|
||
certain library, the <code><library></code> feature is preferred over <code><source>X</code> — the
|
||
latter will add the library to all targets, even those that have nothing to do
|
||
with libraries.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.library-path"></a><code>library-path</code></dt>
|
||
<dd>
|
||
<p>Adds to the list of directories which will be used by the linker to search for
|
||
libraries.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.leak-sanitizer"></a><code>leak-sanitizer</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>norecover</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables leak sanitizer. Value <code>norecover</code> disables recovery for the
|
||
sanitizer. The feature is optional, thus no sanitizer is enabled by default.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.link"></a><code>link</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>shared</code>, <code>static</code></p>
|
||
<div class="paragraph">
|
||
<p>Controls how libraries are built.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.linkflags"></a><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>See <a href="#bbv2.builtin.features.cflags"><code><cflags></code></a>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.local-visibility"></a><code>local-visibility</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>global</code>, <code>protected</code>, <code>hidden</code>.</p>
|
||
<div class="paragraph">
|
||
<p>This feature has the same effect as the
|
||
<a href="#bbv2.builtin.features.visibility"><code>visibility</code></a> feature but is intended
|
||
to be used by targets that require a particular symbol visibility. Unlike the
|
||
<code>visibility</code> feature, <code>local-visibility</code> is not inherited by the target
|
||
dependencies and only affects the target to which it is applied.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>local-visibility</code> feature supports the same values with the same meaning
|
||
as the <code>visibility</code> feature. By default, if <code>local-visibility</code> is not specified
|
||
for a target, the value of the <code>visibility</code> feature is used.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.location"></a><code>location</code></dt>
|
||
<dd>
|
||
<p>Specifies the build directory for a target. The feature is used primarily with
|
||
<a href="#bbv2.tasks.installing"><code><install></code></a> rule.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.location-prefix"></a><code>location-prefix</code></dt>
|
||
<dd>
|
||
<p>Sets the build directory for a target as the project’s build directory prefixed
|
||
with the value of this feature. See section <a href="#bbv2.reference.buildprocess.targetpath">Target Paths</a> for an example.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.mflags"></a><code>mflags</code></dt>
|
||
<dd>
|
||
<p>The value of this feature is passed without modification to the tool when
|
||
compiling Objective C sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.mmflags"></a><code>mmflags</code></dt>
|
||
<dd>
|
||
<p>The value of this feature is passed without modification to the tool when
|
||
compiling Objective C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.name"></a><code>name</code></dt>
|
||
<dd>
|
||
<p>When used in requirements of a prebuilt library target this feature specifies
|
||
the name of the library (the name of the library file without any
|
||
platform-specific suffixes or prefixes). See <a href="#bbv2.tutorial.prebuilt">Prebuilt targets</a> for examples.</p>
|
||
<div class="paragraph">
|
||
<p>When used in requirements of an <code><install></code> target it specifies the name of the
|
||
target file.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.optimization"></a><code>optimization</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>speed</code>, <code>space</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables optimization. <code>speed</code> optimizes for faster code, <code>space</code> optimizes for
|
||
smaller binary.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.profiling"></a><code>profiling</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>on</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables generation of extra code to write profile information.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.relevant"></a><code>relevant</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> the name of any feature.</p>
|
||
<div class="paragraph">
|
||
<p>Indicates which other features are relevant for a given target. It is usually
|
||
not necessary to manage it explicitly, as B2 can deduce it in most
|
||
cases. Features which are not relevant will not affect target paths, and will
|
||
not cause conflicts.</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>A feature will be considered relevant if any of the following are true</p>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>It is referenced by <code>toolset.flags</code> or <code>toolset.uses-features</code></p>
|
||
</li>
|
||
<li>
|
||
<p>It is used by the requirements of a generator</p>
|
||
</li>
|
||
<li>
|
||
<p>It is a sub-feature of a relevant feature</p>
|
||
</li>
|
||
<li>
|
||
<p>It has a sub-feature which is relevant</p>
|
||
</li>
|
||
<li>
|
||
<p>It is a composite feature, and any composed feature is relevant</p>
|
||
</li>
|
||
<li>
|
||
<p>It affects target alternative selection for a main target</p>
|
||
</li>
|
||
<li>
|
||
<p>It is a propagated feature and is relevant for any dependency</p>
|
||
</li>
|
||
<li>
|
||
<p>It is relevant for any dependency created by the same main target</p>
|
||
</li>
|
||
<li>
|
||
<p>It is used in the condition of a conditional property and the corresponding
|
||
value is relevant</p>
|
||
</li>
|
||
<li>
|
||
<p>It is explicitly named as relevant</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>Relevant features cannot be automatically deduced in the following cases:</p>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Indirect conditionals. Solution: return properties of the form
|
||
<code><relevant>result-feature:<relevant>condition-feature</code></p>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
This isn’t really a conditional, although for most purposes it functions
|
||
like one. In particular, it does not support multiple comma-separated elements
|
||
in the condition, and it does work correctly even in contexts where conditional
|
||
properties are not allowed
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>Action rules that read properties. Solution: add toolset.uses-features to
|
||
tell B2 that the feature is actually used.</p>
|
||
</li>
|
||
<li>
|
||
<p>Generators and targets that manipulate property-sets directly. Solution:
|
||
set <relevant> manually.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.rtti"></a><code>rtti</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>off</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Disables run-time type information.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.runtime-debugging"></a><code>runtime-debugging</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>off</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies whether produced object files, executables, and libraries should
|
||
include behavior useful only for debugging, such as asserts. Typically, the
|
||
value of this feature is implicitly set by the <code>variant</code> feature, but it can be
|
||
explicitly specified by the user. The most common usage is to build release
|
||
variant with debugging output.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.runtime-link"></a><code>runtime-link</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>shared</code>, <code>static</code></p>
|
||
<div class="paragraph">
|
||
<p>Controls if a static or shared C/C++ runtime should be used. There are some
|
||
restrictions how this feature can be used, for example on some compilers an
|
||
application using static runtime should not use shared libraries at all, and on
|
||
some compilers, mixing static and shared runtime requires extreme care. Check
|
||
your compiler documentation for more details.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.search"></a><code>search</code></dt>
|
||
<dd>
|
||
<p>When used in requirements of a prebuilt library target this feature adds to the
|
||
list of directories to search for the library file. See <a href="#bbv2.tutorial.prebuilt">Prebuilt targets</a>
|
||
for examples.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.source"></a><code>source</code></dt>
|
||
<dd>
|
||
<p>The <code><source>X</code> property has the same effect on building a target as putting X
|
||
in the list of sources. It is useful when you want to add the same source to
|
||
all targets in the project (you can put <code><source></code> in requirements) or to
|
||
conditionally include a source (using conditional requirements, see
|
||
the section <a href="#bbv2.tutorial.conditions">Conditions and alternatives</a>. See also the
|
||
<a href="#bbv2.builtin.features.library"><code><library></code></a> feature.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.staging-prefix"></a><code>staging-prefix</code></dt>
|
||
<dd>
|
||
<p>Specifies staging prefix for <a href="#bbv2.tasks.installing"><code>install</code></a> targets.
|
||
If present, it will be used instead of the path to named directory <code>prefix</code>.
|
||
Example:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"> </span><span class="tok-na"><install-prefix></span>x/y/z<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">install</span><span class="tok-w"> </span>a1<span class="tok-w"> </span>:<span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><location></span>(bindir)<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># installs into x/y/z/bin</span>
|
||
<span class="tok-nb">install</span><span class="tok-w"> </span>a2<span class="tok-w"> </span>:<span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><location></span>(bindir)<span class="tok-w"> </span><span class="tok-na"><staging-prefix></span>q<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># installs into q/bin</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The feature is useful when you cannot (or don’t want to) put build artfiacts
|
||
into their intented locations during the build (such as when cross-compiling),
|
||
but still need to communicate those intended locations to the build system,
|
||
e.g. to generate configuration files.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.stdlib"></a><code>stdlib</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values</strong>: <code>native</code>, <code>gnu</code>, <code>gnu11</code>, <code>libc++</code>, <code>sun-stlport</code>, <code>apache</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies C++ standard library to link to and in some cases the library ABI to
|
||
use:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>native</code></dt>
|
||
<dd>
|
||
<p>Use compiler’s default.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>gnu</code></dt>
|
||
<dd>
|
||
<p>Use GNU Standard Library (a.k.a. libstdc++) with the old ABI.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>gnu11</code></dt>
|
||
<dd>
|
||
<p>Use GNU Standard Library with the new ABI.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>libc++</code></dt>
|
||
<dd>
|
||
<p>Use LLVM libc++.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>sun-stlport</code></dt>
|
||
<dd>
|
||
<p>Use the STLport implementation of the standard library
|
||
provided with the Solaris Studio compiler.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>apache</code></dt>
|
||
<dd>
|
||
<p>Use the Apache stdcxx version 4 C++ standard library provided with
|
||
the Solaris Studio compiler.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.strip"></a><code>strip</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>on</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Controls whether the binary should be stripped — that is have everything not
|
||
necessary to running removed.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
This feature will show up in target paths of everything, not just
|
||
binaries.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.suppress-import-lib"></a><code>suppress-import-lib</code></dt>
|
||
<dd>
|
||
<p>Suppresses creation of import library by the linker.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.tag"></a><code>tag</code></dt>
|
||
<dd>
|
||
<p>Used to customize the name of the generated files. The value should have the
|
||
form:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>@rulename</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>where <em>rulename</em> should be a name of a rule with the following signature:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule tag ( name : type ? : property-set )</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The rule will be called for each target with the default name computed by
|
||
B2, the type of the target, and property set. The rule can either
|
||
return a string that must be used as the name of the target, or an empty
|
||
string, in which case the default name will be used.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Most typical use of the <code>tag</code> feature is to encode build properties, or library
|
||
version in library target names. You should take care to return non-empty
|
||
string from the tag rule only for types you care about — otherwise, you might
|
||
end up modifying names of object files, generated header file and other targets
|
||
for which changing names does not make sense.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.target-os"></a><code>target-os</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>aix</code>, <code>android</code>, <code>appletv</code>, <code>bsd</code>, <code>cygwin</code>, <code>darwin</code>,
|
||
<code>freebsd</code>, <code>haiku</code>, <code>hpux</code>, <code>iphone</code>, <code>linux</code>, <code>netbsd</code>, <code>openbsd</code>, <code>osf</code>,
|
||
<code>qnx</code>, <code>qnxnto</code>, <code>sgi</code>, <code>solaris</code>, <code>unix</code>, <code>unixware</code>, <code>windows</code>, <code>vms</code>,
|
||
<code>vxworks</code>, <code>freertos</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies the operating system for which the code is to be generated. The
|
||
compiler you used should be the compiler for that operating system. This option
|
||
causes B2 to use naming conventions suitable for that operating
|
||
system, and adjust build process accordingly. For example, with gcc, it
|
||
controls if import libraries are produced for shared libraries or not.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>See the section <a href="#bbv2.tasks.crosscompile">Cross-compilation</a> for details of cross-compilation.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.threading"></a><code>threading</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>single</code>, <code>multi</code></p>
|
||
<div class="paragraph">
|
||
<p>Controls if the project should be built in multi-threaded mode. This feature
|
||
does not necessary change code generation in the compiler, but it causes the
|
||
compiler to link to additional or different runtime libraries, and define
|
||
additional preprocessor symbols (for example, <code>_MT</code> on Windows and <code>_REENTRANT</code>
|
||
on Linux). How those symbols affect the compiled code depends on the code
|
||
itself.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.thread-sanitizer"></a><code>thread-sanitizer</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>norecover</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables thread sanitizer. Value <code>norecover</code> disables recovery for the
|
||
sanitizer. The feature is optional, thus no sanitizer is enabled by default.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.toolset"></a><code>toolset</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> any of the toolset modules.</p>
|
||
<div class="paragraph">
|
||
<p>Selects the toolset that will be used to build binary targets. The full list of
|
||
toolset modules is in the <a href="#bbv2.reference.tools">Builtin tools</a> section.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.undef"></a><code>undef</code></dt>
|
||
<dd>
|
||
<p>Specifies a preprocessor symbol to undefine.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.undefined-sanitizer"></a><code>undefined-sanitizer</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>norecover</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables undefined behavior sanitizer. Value <code>norecover</code> disables recovery for
|
||
the sanitizer. The feature is optional, thus no sanitizer is enabled by
|
||
default.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.use"></a><code>use</code></dt>
|
||
<dd>
|
||
<p>Introduces a dependency on the target named by the value of this feature (so it
|
||
will be brought up-to-date whenever the target being declared is), and adds its
|
||
usage requirements to the build properties of the target being declared. The
|
||
dependency is not used in any other way. The primary use case is when you want
|
||
the usage requirements (such as <code>#include</code> paths) of some library to be
|
||
applied, but do not want to link to it.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.user-interface"></a><code>user-interface</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>console</code>, <code>gui</code>, <code>wince</code>, <code>native</code>, <code>auto</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies the environment for the executable which affects the entry point
|
||
symbol (or entry point function) that the linker will select. This feature is
|
||
Windows-specific.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>console</code></dt>
|
||
<dd>
|
||
<p>console application.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>gui</code></dt>
|
||
<dd>
|
||
<p>application does not require a console (it is supposed to create its
|
||
own windows.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>wince</code></dt>
|
||
<dd>
|
||
<p>application is intended to run on a device that has a version of the
|
||
Windows CE kernel.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>native</code></dt>
|
||
<dd>
|
||
<p>application runs without a subsystem environment.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>auto</code></dt>
|
||
<dd>
|
||
<p>application runs in the POSIX subsystem in Windows.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.variant"></a><code>variant</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>debug</code>, <code>release</code>, <code>profile</code>.</p>
|
||
<div class="paragraph">
|
||
<p>A feature combining several low-level features, making it easy to
|
||
request common build configurations.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The value <code>debug</code> expands to</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre><optimization>off <debug-symbols>on <inlining>off <runtime-debugging>on</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The value <code>release</code> expands to</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre><optimization>speed <debug-symbols>off <inlining>full <runtime-debugging>off</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The value <code>profile</code> expands to the same as <code>release</code>, plus:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre><profiling>on <debug-symbols>on</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Users can define their own build variants using the <code>variant</code> rule
|
||
from the <code>common</code> module.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
Runtime debugging is on in debug builds to suit the expectations of
|
||
people used to various IDEs.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.vectorize"></a><code>vectorize</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>on</code>, <code>full</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables vectorization.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.version"></a><code>version</code></dt>
|
||
<dd>
|
||
<p>This feature isn’t used by any of the builtin tools, but can be used, for
|
||
example, to adjust target’s name via <a href="#bbv2.builtin.features.tag"><code><tag></code></a>
|
||
feature.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.visibility"></a><code>visibility</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>global</code>, <code>protected</code>, <code>hidden</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Specifies the default symbol visibility in compiled binaries. Not all values
|
||
are supported on all platforms and on some platforms (for example, Windows)
|
||
symbol visibility is not supported at all.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The supported values have the following meaning:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>global</code></dt>
|
||
<dd>
|
||
<p>a.k.a. "default" in gcc documentation. Global symbols are
|
||
considered public, they are exported from shared libraries and can be
|
||
redefined by another shared library or executable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>protected</code></dt>
|
||
<dd>
|
||
<p>a.k.a. "symbolic". Protected symbols are exported from shared
|
||
ibraries but cannot be redefined by another shared library or executable.
|
||
This mode is not supported on some platforms, for example OS X.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>hidden</code></dt>
|
||
<dd>
|
||
<p>Hidden symbols are not exported from shared libraries and cannot
|
||
be redefined by a different shared library or executable loaded in a process.
|
||
In this mode, public symbols have to be explicitly marked in the source code
|
||
to be exported from shared libraries. This is the recommended mode.</p>
|
||
<div class="paragraph">
|
||
<p>By default compiler default visibility mode is used (no compiler flags are
|
||
added).</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
In Boost super-project Jamroot file this property is set to the default
|
||
value of <code>hidden</code>. This means that Boost libraries are built with hidden
|
||
visibility by default, unless the user overrides it with a different
|
||
<code>visibility</code> or a library sets a different <code>local-visibility</code> (see below).
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.warnings"></a><code>warnings</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>, <code>all</code>, <code>extra</code>, <code>pedantic</code>, <code>off</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Controls the warning level of compilers.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>on</code></dt>
|
||
<dd>
|
||
<p>enable default/"reasonable" warning level.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>all</code></dt>
|
||
<dd>
|
||
<p>enable most warnings.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>extra</code></dt>
|
||
<dd>
|
||
<p>enable extra, possibly conflicting, warnings.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>pedantic</code></dt>
|
||
<dd>
|
||
<p>enable likely inconsequential, and conflicting, warnings.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>off</code></dt>
|
||
<dd>
|
||
<p>disable all warnings.</p>
|
||
<div class="paragraph">
|
||
<p>Default value is <code>all</code>.</p>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.warnings-as-errors"></a><code>warnings-as-errors</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>off</code>, <code>on</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Makes it possible to treat warnings as errors and abort compilation on a
|
||
warning.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.translate-path"></a><code>translate-path</code></dt>
|
||
<dd>
|
||
<p>Used to introduce custom path feature translation. The value should have the
|
||
form:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>@rulename</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>where <em>rulename</em> should be a name of a rule with the following signature:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule rulename ( feature value : properties * : project-id : project-location )</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The rule is called for each target with the <code>feature</code> of a path property,
|
||
the path property value, target properties, the target project ID, and
|
||
the target project location. It should return the translated path value.
|
||
Or return nothing if it doesn’t do path translation. Leaving it do the
|
||
default path translation.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.lto"></a><code>lto</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>on</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Enables link time optimizations (also known as interprocedural optimizations or
|
||
whole-program optimizations). Currently supported toolsets are <a href="#bbv2.reference.tools.compiler.gcc">GNU C++</a>,
|
||
clang and <a href="#bbv2.reference.tools.compiler.msvc">Microsoft Visual C++</a>. The feature is optional.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.lto-mode"></a><code>lto-mode</code></dt>
|
||
<dd>
|
||
<p><strong>Subfeature of</strong> <code>lto</code></p>
|
||
<div class="paragraph">
|
||
<p><strong>Allowed values:</strong> <code>full</code>, <code>thin</code>, <code>fat</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Specifies the type of LTO to use.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>full</code></dt>
|
||
<dd>
|
||
<p>Use the monolithic LTO: on linking all input is merged into a single
|
||
module.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>thin</code></dt>
|
||
<dd>
|
||
<p>Use clang’s ThinLTO: each compiled file contains a summary of the
|
||
module, these summaries are merged into a single index. This allows to avoid
|
||
merging all modules together, which greatly reduces linking time.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>fat</code></dt>
|
||
<dd>
|
||
<p>Produce gcc’s fat LTO objects: compiled files contain both the
|
||
intermidiate language suitable for LTO and object code suitable for regular
|
||
linking.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><a id="bbv2.builtin.features.response-file"></a><code>response-file</code></dt>
|
||
<dd>
|
||
<p><strong>Allowed values:</strong> <code>auto</code>, <code>file</code>, <code>contents</code>.</p>
|
||
<div class="paragraph">
|
||
<p>Controls whether a response file is used, or not, during the build of the
|
||
applicable target. For <code>file</code> a response file is created and the filename
|
||
replaced in the action. For <code>contents</code> the contents (<code>:E=</code>) is replaced
|
||
in the action and no response file is created. For <code>auto</code> either a response
|
||
file is created, or the contents replaced, based on the length of the
|
||
contents such that if the contents fits within the limits of the command
|
||
execution line length limits the contents is replaced. Otherwise a
|
||
response file is created and the filename is replaced in the actions.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Supported for <code>clang-linux</code> and <code>msvc</code> toolsets.</p>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.tools"><a class="anchor" href="#bbv2.reference.tools"></a>6.4. Builtin tools</h3>
|
||
<div class="paragraph">
|
||
<p>B2 comes with support for a large number of C++ compilers, and
|
||
other tools. This section documents how to use those tools.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Before using any tool, you must declare your intention, and possibly
|
||
specify additional information about the tool’s configuration. This is
|
||
done by calling the <code>using</code> rule, typically in your <code>user-config.jam</code>,
|
||
for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>additional parameters can be passed just like for other rules, for
|
||
example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>gcc<span class="tok-w"> </span>:<span class="tok-w"> </span>4.0<span class="tok-w"> </span>:<span class="tok-w"> </span>g++-4.0<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The options that can be passed to each tool are documented in the
|
||
subsequent sections.</p>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.tools.compilers"><a class="anchor" href="#bbv2.reference.tools.compilers"></a>6.4.1. C++ Compilers</h4>
|
||
<div class="paragraph">
|
||
<p>This section lists all B2 modules that support C++ compilers
|
||
and documents how each one can be initialized. The name of support
|
||
module for compiler is also the value for the <code>toolset</code> feature that can
|
||
be used to explicitly request that compiler.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.acc"><a class="anchor" href="#bbv2.reference.tools.compiler.acc"></a>HP aC++ compiler</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>acc</code> module supports the
|
||
<a href="http://h21007.www2.hp.com/dspp/tech/tech_TechSoftwareDetailPage_IDX/1,1703,1740,00.html">HP
|
||
aC++ compiler</a> for the HP-UX operating system.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using acc : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the command is not specified, the <code>aCC</code> binary will be searched in
|
||
PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.borland"><a class="anchor" href="#bbv2.reference.tools.compiler.borland"></a>Borland C++ Compiler</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>borland</code> module supports the 32-bit command line C compilers
|
||
running on Microsoft Windows. This is the bcc32 executable for all
|
||
versions of Borland C and C Builder, as well as the command line
|
||
compatible compiler bcc32c on later versions of C Builder.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using borland : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the command is not specified, Boost.Build will search for a binary
|
||
named <code>bcc32</code> in PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>user-interface</code></dt>
|
||
<dd>
|
||
<p>Specifies the user interface for applications. Valid choices are <code>console</code>
|
||
for a console applicatiuon and <code>gui</code> for a Windows application.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.como"><a class="anchor" href="#bbv2.reference.tools.compiler.como"></a>Comeau C/C++ Compiler</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>como-linux</code> and the <code>como-win</code> modules supports the
|
||
<a href="http://www.comeaucomputing.com/">Comeau C/C++ Compiler</a> on Linux and
|
||
Windows respectively.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using como : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the command is not specified, B2 will search for a binary
|
||
named <code>como</code> in PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Before using the Windows version of the compiler, you need to setup
|
||
necessary environment variables per compiler’s documentation. In
|
||
particular, the COMO_XXX_INCLUDE variable should be set, where XXX
|
||
corresponds to the used backend C compiler.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.cw"><a class="anchor" href="#bbv2.reference.tools.compiler.cw"></a>Code Warrior</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>cw</code> module support CodeWarrior compiler, originally produced by
|
||
Metrowerks and presently developed by Freescale. B2 supports
|
||
only the versions of the compiler that target x86 processors. All such
|
||
versions were released by Metrowerks before acquisition and are not sold
|
||
any longer. The last version known to work is 9.4.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using cw : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the command is not specified, B2 will search for a binary
|
||
named <code>mwcc</code> in default installation paths and in PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>setup</code></dt>
|
||
<dd>
|
||
<p>The command that sets up environment variables prior to invoking the
|
||
compiler. If not specified, <code>cwenv.bat</code> alongside the compiler binary
|
||
will be used.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compiler</code></dt>
|
||
<dd>
|
||
<p>The command that compiles C and C++ sources. If not specified, <code>mwcc</code>
|
||
will be used. The command will be invoked after the setup script was
|
||
executed and adjusted the PATH variable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linker</code></dt>
|
||
<dd>
|
||
<p>The command that links executables and dynamic libraries. If not
|
||
specified, <code>mwld</code> will be used. The command will be invoked after the
|
||
setup script was executed and adjusted the PATH variable.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.dmc"><a class="anchor" href="#bbv2.reference.tools.compiler.dmc"></a>Digital Mars C/C++ Compiler</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>dmc</code> module supports the <a href="http://www.digitalmars.com/">Digital Mars
|
||
C++ compiler.</a></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using dmc : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the command is not specified, B2 will search for a binary
|
||
named <code>dmc</code> in PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.gcc"><a class="anchor" href="#bbv2.reference.tools.compiler.gcc"></a>GNU C++</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>gcc</code> module supports the <a href="http://gcc.gnu.org">GNU C++ compiler</a> on
|
||
Linux, a number of Unix-like system including SunOS and on Windows
|
||
(either <a href="http://www.cygwin.com">Cygwin</a> or <a href="http://www.mingw.org">MinGW</a>).</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>gcc</code> module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using gcc : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the version is not explicitly specified, it will be automatically
|
||
detected by running the compiler with the <code>-v</code> option. If the command is
|
||
not specified, the <code>g++</code> binary will be searched in PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>root</code></dt>
|
||
<dd>
|
||
<p>Specifies root directory of the compiler installation. This option is
|
||
necessary only if it is not possible to detect this information from the
|
||
compiler command—​for example if the specified compiler command is a user
|
||
script.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>archiver</code></dt>
|
||
<dd>
|
||
<p>Specifies the archiver command that is used to produce static
|
||
libraries. Normally, it is autodetected using gcc <code>-print-prog-name</code>
|
||
option or defaulted to <code>ar</code>, but in some cases you might want to
|
||
override it, for example to explicitly use a system version instead of
|
||
one included with gcc.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>ranlib</code></dt>
|
||
<dd>
|
||
<p>Specifies the ranlib command that is used to generated symbol table
|
||
for static libraries. Normally, it is autodetected using gcc
|
||
<code>-print-prog-name</code> option or defaulted to <code>ranlib</code>, but in some cases
|
||
you might want to override it, for example to explicitly use a system
|
||
version instead of one included with gcc.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>rc</code></dt>
|
||
<dd>
|
||
<p>Specifies the resource compiler command that will be used with the
|
||
version of gcc that is being configured. This setting makes sense only
|
||
for Windows and only if you plan to use resource files. By default
|
||
<code>windres</code> will be used.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>rc-type</code></dt>
|
||
<dd>
|
||
<p>Specifies the type of resource compiler. The value can be either
|
||
<code>windres</code> for msvc resource compiler, or <code>rc</code> for borland’s resource
|
||
compiler.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In order to compile 64-bit applications, you have to specify
|
||
<code>address-model=64</code>, and the <code>instruction-set</code> feature should refer to a 64
|
||
bit processor. Currently, those include <code>nocona</code>, <code>opteron</code>, <code>athlon64</code> and
|
||
<code>athlon-fx</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.hp_cxx"><a class="anchor" href="#bbv2.reference.tools.compiler.hp_cxx"></a>HP C++ Compiler for Tru64 Unix</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>hp_cxx</code> modules supports the
|
||
<a href="http://h30097.www3.hp.com/cplus/?jumpid=reg_R1002_USEN">HP C++ Compiler</a>
|
||
for Tru64 Unix.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using hp_cxx : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the command is not specified, B2 will search for a binary
|
||
named <code>hp_cxx</code> in PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.intel"><a class="anchor" href="#bbv2.reference.tools.compiler.intel"></a>Intel C++</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>intel-*</code> modules support the Intel C++ command-line compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using intel : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If compiler command is not specified, then B2 will look in PATH
|
||
for an executable <code>icpc</code> (on Linux), or <code>icl.exe</code> (on Windows).</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>root</code></dt>
|
||
<dd>
|
||
<p>For the Linux version, specifies the root directory of the compiler installation.
|
||
This option is necessary only if it is not possible to detect this information
|
||
from the compiler command — for example if the specified compiler command is
|
||
a user script. For the Windows version, specifies the directory of the
|
||
<code>iclvars.bat</code> file, for versions prior to 21 ( or 2021 ), or of the <code>setvars.bat</code>,
|
||
for versions from 21 ( or 2021 ) on up, for configuring the compiler.
|
||
Specifying the <code>root</code> option without specifying the compiler command allows the
|
||
end-user not to have to worry about whether they are compiling 32-bit or 64-bit code,
|
||
as the toolset will automatically configure the compiler for the appropriate address
|
||
model and compiler command using the <code>iclvars.bat</code> or <code>setvars.bat</code> batch file.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.msvc"><a class="anchor" href="#bbv2.reference.tools.compiler.msvc"></a>Microsoft Visual C++</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>msvc</code> module supports the
|
||
<a href="http://msdn.microsoft.com/visualc/">Microsoft Visual C++</a> command-line
|
||
tools on Microsoft Windows. The supported products and versions of
|
||
command line tools are listed below:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Visual Studio 2019-14.2</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio 2017—14.1</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio 2015—14.0</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio 2013—12.0</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio 2012—11.0</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio 2010—10.0</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio 2008—9.0</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio 2005—8.0</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio .NET 2003—7.1</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio .NET—7.0</p>
|
||
</li>
|
||
<li>
|
||
<p>Visual Studio 6.0, Service Pack 5—​6.5</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The user would then call the boost build executable with the toolset set
|
||
equal to <code>msvc-[version number]</code> for example to build with Visual Studio
|
||
2019 one could run:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>.\b2 toolset=msvc-14.2 target</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>msvc</code> module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using msvc : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the version is not explicitly specified, the most recent version
|
||
found in the registry will be used instead. If the special value <code>all</code>
|
||
is passed as the version, all versions found in the registry will be
|
||
configured. If a version is specified, but the command is not, the
|
||
compiler binary will be searched in standard installation paths for that
|
||
version, followed by PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The compiler command should be specified using forward slashes, and
|
||
quoted.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>assembler</code></dt>
|
||
<dd>
|
||
<p>The command that compiles assembler sources. If not specified, <code>ml</code>
|
||
will be used. The command will be invoked after the setup script was
|
||
executed and adjusted the PATH variable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compiler</code></dt>
|
||
<dd>
|
||
<p>The command that compiles C and C++ sources. If not specified, <code>cl</code>
|
||
will be used. The command will be invoked after the setup script was
|
||
executed and adjusted the PATH variable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compiler-filter</code></dt>
|
||
<dd>
|
||
<p>Command through which to pipe the output of running the compiler. For
|
||
example to pass the output to STLfilt.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>idl-compiler</code></dt>
|
||
<dd>
|
||
<p>The command that compiles Microsoft COM interface definition files. If
|
||
not specified, <code>midl</code> will be used. The command will be invoked after
|
||
the setup script was executed and adjusted the PATH variable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linker</code></dt>
|
||
<dd>
|
||
<p>The command that links executables and dynamic libraries. If not
|
||
specified, <code>link</code> will be used. The command will be invoked after the
|
||
setup script was executed and adjusted the PATH variable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>mc-compiler</code></dt>
|
||
<dd>
|
||
<p>The command that compiles Microsoft message catalog files. If not
|
||
specified, <code>mc</code> will be used. The command will be invoked after the
|
||
setup script was executed and adjusted the PATH variable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>resource-compiler</code></dt>
|
||
<dd>
|
||
<p>The command that compiles resource files. If not specified, <code>rc</code> will
|
||
be used. The command will be invoked after the setup script was
|
||
executed and adjusted the PATH variable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>setup</code></dt>
|
||
<dd>
|
||
<p>The filename of the global environment setup script to run before
|
||
invoking any of the tools defined in this toolset. Will not be used in
|
||
case a target platform specific script has been explicitly specified
|
||
for the current target platform. Used setup script will be passed the
|
||
target platform identifier (x86, x86_amd64, x86_ia64, amd64 or ia64)
|
||
as a parameter. If not specified a default script is chosen based on
|
||
the used compiler binary, e.g. <code>vcvars32.bat</code> or <code>vsvars32.bat</code>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>setup-amd64</code>; <code>setup-i386</code>; <code>setup-ia64</code></dt>
|
||
<dd>
|
||
<p>The filename of the target platform specific environment setup script
|
||
to run before invoking any of the tools defined in this toolset. If
|
||
not specified the global environment setup script is used.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="bbv2.reference.tools.compiler.msvc.64"><a class="anchor" href="#bbv2.reference.tools.compiler.msvc.64"></a>64-bit support</h6>
|
||
<div class="paragraph">
|
||
<p>Starting with version 8.0, Microsoft Visual Studio can generate binaries
|
||
for 64-bit processor, both 64-bit flavours of x86 (codenamed
|
||
AMD64/EM64T), and Itanium (codenamed IA64). In addition, compilers that
|
||
are itself run in 64-bit mode, for better performance, are provided. The
|
||
complete list of compiler configurations are as follows (we abbreviate
|
||
AMD64/EM64T to just AMD64):</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>32-bit x86 host, 32-bit x86 target</p>
|
||
</li>
|
||
<li>
|
||
<p>32-bit x86 host, 64-bit AMD64 target</p>
|
||
</li>
|
||
<li>
|
||
<p>32-bit x86 host, 64-bit IA64 target</p>
|
||
</li>
|
||
<li>
|
||
<p>64-bit AMD64 host, 64-bit AMD64 target</p>
|
||
</li>
|
||
<li>
|
||
<p>64-bit IA64 host, 64-bit IA64 target</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The 32-bit host compilers can be always used, even on 64-bit Windows. On
|
||
the contrary, 64-bit host compilers require both 64-bit host processor
|
||
and 64-bit Windows, but can be faster. By default, only 32-bit host,
|
||
32-bit target compiler is installed, and additional compilers need to be
|
||
installed explicitly.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To use 64-bit compilation you should:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Configure you compiler as usual. If you provide a path to the
|
||
compiler explicitly, provide the path to the 32-bit compiler. If you try
|
||
to specify the path to any of 64-bit compilers, configuration will not
|
||
work.</p>
|
||
</li>
|
||
<li>
|
||
<p>When compiling, use <code>address-model=64</code>, to generate AMD64 code.</p>
|
||
</li>
|
||
<li>
|
||
<p>To generate IA64 code, use <code>architecture=ia64</code></p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The (AMD64 host, AMD64 target) compiler will be used automatically when
|
||
you are generating AMD64 code and are running 64-bit Windows on AMD64.
|
||
The (IA64 host, IA64 target) compiler will never be used, since nobody
|
||
has an IA64 machine to test.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It is believed that AMD64 and EM64T targets are essentially compatible.
|
||
The compiler options <code>/favor:AMD64</code> and <code>/favor:EM64T</code>, which are
|
||
accepted only by AMD64 targeting compilers, cause the generated code to
|
||
be tuned to a specific flavor of 64-bit x86. B2 will make use
|
||
of those options depending on the value of the`instruction-set` feature.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="bbv2.reference.tools.compiler.msvc.winrt"><a class="anchor" href="#bbv2.reference.tools.compiler.msvc.winrt"></a>Windows Runtime support</h6>
|
||
<div class="paragraph">
|
||
<p>Starting with version 11.0, Microsoft Visual Studio can produce binaries
|
||
for Windows Store and Phone in addition to traditional Win32 desktop. To
|
||
specify which Windows API set to target, use the <code>windows-api</code> feature.
|
||
Available options are <code>desktop</code>, <code>store</code>, or <code>phone</code>. If not specified,
|
||
<code>desktop</code> will be used.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When using <code>store</code> or <code>phone</code> the specified toolset determines what
|
||
Windows version is targeted. The following options are available:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Windows 8.0: toolset=msvc-11.0 windows-api=store</p>
|
||
</li>
|
||
<li>
|
||
<p>Windows 8.1: toolset=msvc-12.0 windows-api=store</p>
|
||
</li>
|
||
<li>
|
||
<p>Windows Phone 8.0: toolset=msvc-11.0 windows-api=phone</p>
|
||
</li>
|
||
<li>
|
||
<p>Windows Phone 8.1: toolset=msvc-12.0 windows-api=phone</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example use the following to build for Windows Store 8.1 with the
|
||
ARM architecture:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>.\b2 toolset=msvc-12.0 windows-api=store architecture=arm</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that when targeting Windows Phone 8.1, version 12.0 didn’t include
|
||
the vcvars phone setup scripts. They can be separately downloaded from
|
||
<a href="http://blogs.msdn.com/b/vcblog/archive/2014/07/18/using-boost-libraries-in-windows-store-and-phone-applications.aspx">here</a>.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.sun"><a class="anchor" href="#bbv2.reference.tools.compiler.sun"></a>Sun Studio</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>sun</code> module supports the
|
||
<a href="http://developers.sun.com/sunstudio/index.jsp">Sun Studio</a> C++ compilers
|
||
for the Solaris OS.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using sun : [version] : [c++-compile-command] : [compiler options] ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This statement may be repeated several times, if you want to configure
|
||
several versions of the compiler.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the command is not specified, B2 will search for a binary
|
||
named <code>CC</code> in <code>/opt/SUNWspro/bin</code> and in PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When using this compiler on complex C code, such as the
|
||
http://boost.org[Boost C library], it is recommended to specify the
|
||
following options when initializing the <code>sun</code> module:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>-library=stlport4 -features=tmplife -features=tmplrefstatic</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>See the <a href="http://blogs.sun.com/sga/entry/command_line_options">Sun C++
|
||
Frontend Tales</a> for details.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>cflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cxxflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling C++
|
||
sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>compileflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional compiler flags that will be used when compiling both C
|
||
and C++ sources.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>linkflags</code></dt>
|
||
<dd>
|
||
<p>Specifies additional command line options that will be passed to the linker.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Starting with Sun Studio 12, you can create 64-bit applications by using
|
||
the <code>address-model=64</code> property.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.compiler.vacpp"><a class="anchor" href="#bbv2.reference.tools.compiler.vacpp"></a>IBM Visual Age</h5>
|
||
<div class="paragraph">
|
||
<p>The <code>vacpp</code> module supports the <a href="http://www.ibm.com/software/ad/vacpp">IBM
|
||
Visual Age</a> C++ Compiler, for the AIX operating system. Versions 7.1 and
|
||
8.0 are known to work.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module is initialized using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using vacpp ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The module does not accept any initialization options. The compiler
|
||
should be installed in the <code>/usr/vacpp/bin</code> directory.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Later versions of Visual Age are known as XL C/C++. They were not tested
|
||
with the the <code>vacpp</code> module.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_third_party_libraries"><a class="anchor" href="#_third_party_libraries"></a>6.4.2. Third-party libraries</h4>
|
||
<div class="paragraph">
|
||
<p>B2 provides special support for some third-party C++ libraries,
|
||
documented below.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.libraries.stlport"><a class="anchor" href="#bbv2.reference.tools.libraries.stlport"></a>STLport library</h5>
|
||
<div class="paragraph">
|
||
<p>The <a href="http://stlport.org">STLport</a> library is an alternative implementation
|
||
of C++ runtime library. B2 supports using that library on
|
||
Windows platform. Linux is hampered by different naming of libraries in
|
||
each STLport version and is not officially supported.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Before using STLport, you need to configure it in <code>user-config.jam</code>
|
||
using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>stlport<span class="tok-w"> </span>:<span class="tok-w"> </span>version<span class="tok-w"> </span>:<span class="tok-w"> </span>header-path<span class="tok-w"> </span>:<span class="tok-w"> </span>library-path<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Where version is the version of STLport, for example <code>5.1.4</code>, headers is
|
||
the location where STLport headers can be found, and libraries is the
|
||
location where STLport libraries can be found. The version should always
|
||
be provided, and the library path should be provided if you’re using
|
||
STLport’s implementation of <code>iostreams</code>. Note that STLport 5.* always uses
|
||
its own <code>iostream</code> implementation, so the library path is required.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When STLport is configured, you can build with STLport by requesting
|
||
<code>stdlib=stlport</code> on the command line.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.libraries.zlib"><a class="anchor" href="#bbv2.reference.tools.libraries.zlib"></a>zlib</h5>
|
||
<div class="paragraph">
|
||
<p>Provides support for the <a href="http://www.zlib.net">zlib</a> library. zlib can be
|
||
configured either to use precompiled binaries or to build the library
|
||
from source.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>zlib can be initialized using the following syntax</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>zlib<span class="tok-w"> </span>:<span class="tok-w"> </span>version<span class="tok-w"> </span>:<span class="tok-w"> </span>options<span class="tok-w"> </span>:<span class="tok-w"> </span>condition<span class="tok-w"> </span>:<span class="tok-w"> </span>is-default<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Options for using a prebuilt library:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>search</code></dt>
|
||
<dd>
|
||
<p>The directory containing the zlib binaries.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>name</code></dt>
|
||
<dd>
|
||
<p>Overrides the default library name.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>include</code></dt>
|
||
<dd>
|
||
<p>The directory containing the zlib headers.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If none of these options is specified, then the environmental variables
|
||
ZLIB_LIBRARY_PATH, ZLIB_NAME, and ZLIB_INCLUDE will be used instead.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Options for building zlib from source:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>source</code></dt>
|
||
<dd>
|
||
<p>The zlib source directory. Defaults to the environmental variable
|
||
ZLIB_SOURCE.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>tag</code></dt>
|
||
<dd>
|
||
<p>Sets the <a href="#bbv2.builtin.features.tag">tag</a> property to adjust the
|
||
file name of the library. Ignored when using precompiled binaries.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>build-name</code></dt>
|
||
<dd>
|
||
<p>The base name to use for the compiled library. Ignored when using
|
||
precompiled binaries.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Examples:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-c1"># Find zlib in the default system location</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>zlib<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># Build zlib from source</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>zlib<span class="tok-w"> </span>:<span class="tok-w"> </span>1.2.7<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><source></span>/home/steven/zlib-1.2.7<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># Find zlib in /usr/local</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>zlib<span class="tok-w"> </span>:<span class="tok-w"> </span>1.2.7<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span><span class="tok-na"><search></span>/usr/local/lib<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># Build zlib from source for msvc and find</span>
|
||
<span class="tok-c1"># prebuilt binaries for gcc.</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>zlib<span class="tok-w"> </span>:<span class="tok-w"> </span>1.2.7<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><source></span>C:/Devel/src/zlib-1.2.7<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>msvc<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>zlib<span class="tok-w"> </span>:<span class="tok-w"> </span>1.2.7<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>gcc<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.libraries.bzip2"><a class="anchor" href="#bbv2.reference.tools.libraries.bzip2"></a>bzip2</h5>
|
||
<div class="paragraph">
|
||
<p>Provides support for the <a href="http://www.bzip.org">bzip2</a> library. bzip2 can
|
||
be configured either to use precompiled binaries or to build the library
|
||
from source.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>bzip2 can be initialized using the following syntax</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>bzip2<span class="tok-w"> </span>:<span class="tok-w"> </span>version<span class="tok-w"> </span>:<span class="tok-w"> </span>options<span class="tok-w"> </span>:<span class="tok-w"> </span>condition<span class="tok-w"> </span>:<span class="tok-w"> </span>is-default<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Options for using a prebuilt library:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>search</code></dt>
|
||
<dd>
|
||
<p>The directory containing the bzip2 binaries.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>name</code></dt>
|
||
<dd>
|
||
<p>Overrides the default library name.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>include</code></dt>
|
||
<dd>
|
||
<p>The directory containing the bzip2 headers.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If none of these options is specified, then the environmental variables
|
||
BZIP2_LIBRARY_PATH, BZIP2_NAME, and BZIP2_INCLUDE will be used instead.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Options for building bzip2 from source:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>source</code></dt>
|
||
<dd>
|
||
<p>The bzip2 source directory. Defaults to the environmental variable
|
||
BZIP2_SOURCE.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>tag</code></dt>
|
||
<dd>
|
||
<p>Sets the <a href="#bbv2.builtin.features.tag">tag</a> property to adjust the
|
||
file name of the library. Ignored when using precompiled binaries.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>build-name</code></dt>
|
||
<dd>
|
||
<p>The base name to use for the compiled library. Ignored when using
|
||
precompiled binaries.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Examples:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-c1"># Find bzip in the default system location</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>bzip2<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># Build bzip from source</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>bzip2<span class="tok-w"> </span>:<span class="tok-w"> </span>1.0.6<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><source></span>/home/sergey/src/bzip2-1.0.6<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># Find bzip in /usr/local</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>bzip2<span class="tok-w"> </span>:<span class="tok-w"> </span>1.0.6<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span><span class="tok-na"><search></span>/usr/local/lib<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># Build bzip from source for msvc and find</span>
|
||
<span class="tok-c1"># prebuilt binaries for gcc.</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>bzip2<span class="tok-w"> </span>:<span class="tok-w"> </span>1.0.6<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><source></span>C:/Devel/src/bzip2-1.0.6<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>msvc<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>bzip2<span class="tok-w"> </span>:<span class="tok-w"> </span>1.0.6<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>gcc<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.libraries.python"><a class="anchor" href="#bbv2.reference.tools.libraries.python"></a>Python</h5>
|
||
<div class="paragraph">
|
||
<p>Provides support for the <a href="http://www.python.org">python</a> language
|
||
environment to be linked in as a library.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>python can be initialized using the following syntax</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>python<span class="tok-w"> </span>:<span class="tok-w"> </span>[version]<span class="tok-w"> </span>:<span class="tok-w"> </span>[command-or-prefix]<span class="tok-w"> </span>:<span class="tok-w"> </span>[includes]<span class="tok-w"> </span>:<span class="tok-w"> </span>[libraries]<span class="tok-w"> </span>:<span class="tok-w"> </span>[conditions]<span class="tok-w"> </span>:<span class="tok-w"> </span>[extension-suffix]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Options for using python:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>version</code></dt>
|
||
<dd>
|
||
<p>The version of Python to use. Should be in Major.Minor format, for example
|
||
2.3. Do not include the sub-minor version.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>command-or-prefix</code></dt>
|
||
<dd>
|
||
<p>Preferably, a command that invokes a Python interpreter. Alternatively, the
|
||
installation prefix for Python libraries and includes. If empty, will be
|
||
guessed from the version, the platform’s installation patterns, and the
|
||
python executables that can be found in PATH.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>includes</code></dt>
|
||
<dd>
|
||
<p>the include path to Python headers. If empty, will be guessed.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>libraries</code></dt>
|
||
<dd>
|
||
<p>the path to Python library binaries. If empty, will be guessed. On
|
||
MacOS/Darwin, you can also pass the path of the Python framework.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>conditions</code></dt>
|
||
<dd>
|
||
<p>if specified, should be a set of properties that are matched against the
|
||
build configuration when B2 selects a Python configuration to use.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>extension-suffix</code></dt>
|
||
<dd>
|
||
<p>A string to append to the name of extension modules before the true filename
|
||
extension. Ordinarily we would just compute this based on the value of the
|
||
<code><python-debugging></code> feature. However ubuntu’s <code>python-dbg</code> package uses the
|
||
windows convention of appending _d to debug-build extension modules. We have
|
||
no way of detecting ubuntu, or of probing python for the "_d" requirement,
|
||
and if you configure and build python using <code>--with-pydebug</code>, you’ll be using
|
||
the standard *nix convention. Defaults to "" (or "_d" when targeting windows
|
||
and <python-debugging> is set).</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Examples:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-c1"># Find python in the default system location</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>python<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># 2.7</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>python<span class="tok-w"> </span>:<span class="tok-w"> </span>2.7<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># 3.5</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>python<span class="tok-w"> </span>:<span class="tok-w"> </span>3.5<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-c1"># On ubuntu 16.04</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>python<span class="tok-w"></span>
|
||
:<span class="tok-w"> </span>2.7<span class="tok-w"> </span><span class="tok-c1"># version</span>
|
||
:<span class="tok-w"> </span><span class="tok-c1"># Interpreter/path to dir</span>
|
||
:<span class="tok-w"> </span>/usr/include/python2.7<span class="tok-w"> </span><span class="tok-c1"># includes</span>
|
||
:<span class="tok-w"> </span>/usr/lib/x86_64-linux-gnu<span class="tok-w"> </span><span class="tok-c1"># libs</span>
|
||
:<span class="tok-w"> </span><span class="tok-c1"># conditions</span>
|
||
;<span class="tok-w"></span>
|
||
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>python<span class="tok-w"></span>
|
||
:<span class="tok-w"> </span>3.5<span class="tok-w"> </span><span class="tok-c1"># version</span>
|
||
:<span class="tok-w"> </span><span class="tok-c1"># Interpreter/path to dir</span>
|
||
:<span class="tok-w"> </span>/usr/include/python3.5<span class="tok-w"> </span><span class="tok-c1"># includes</span>
|
||
:<span class="tok-w"> </span>/usr/lib/x86_64-linux-gnu<span class="tok-w"> </span><span class="tok-c1"># libs</span>
|
||
:<span class="tok-w"> </span><span class="tok-c1"># conditions</span>
|
||
;<span class="tok-w"></span>
|
||
|
||
<span class="tok-c1"># On windows</span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>python<span class="tok-w"></span>
|
||
:<span class="tok-w"> </span>2.7<span class="tok-w"> </span><span class="tok-c1"># version</span>
|
||
:<span class="tok-w"> </span>C:\\Python27-32\\python.exe<span class="tok-w"> </span><span class="tok-c1"># Interperter/path to dir</span>
|
||
:<span class="tok-w"> </span>C:\\Python27-32\\include<span class="tok-w"> </span><span class="tok-c1"># includes</span>
|
||
:<span class="tok-w"> </span>C:\\Python27-32\\libs<span class="tok-w"> </span><span class="tok-c1"># libs</span>
|
||
:<span class="tok-w"> </span><span class="tok-na"><address-model></span>32<span class="tok-w"> </span><span class="tok-na"><address-model></span><span class="tok-w"> </span><span class="tok-c1"># conditions - both 32 and unspecified</span>
|
||
;<span class="tok-w"></span>
|
||
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>python<span class="tok-w"></span>
|
||
:<span class="tok-w"> </span>2.7<span class="tok-w"> </span><span class="tok-c1"># version</span>
|
||
:<span class="tok-w"> </span>C:\\Python27-64\\python.exe<span class="tok-w"> </span><span class="tok-c1"># Interperter/path to dir</span>
|
||
:<span class="tok-w"> </span>C:\\Python27-64\\include<span class="tok-w"> </span><span class="tok-c1"># includes</span>
|
||
:<span class="tok-w"> </span>C:\\Python27-64\\libs<span class="tok-w"> </span><span class="tok-c1"># libs</span>
|
||
:<span class="tok-w"> </span><span class="tok-na"><address-model></span>64<span class="tok-w"> </span><span class="tok-c1"># conditions</span>
|
||
;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_documentation_tools"><a class="anchor" href="#_documentation_tools"></a>6.4.3. Documentation tools</h4>
|
||
<div class="paragraph">
|
||
<p>B2 support for the Boost documentation tools is documented
|
||
below.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.doc.xsltproc"><a class="anchor" href="#bbv2.reference.tools.doc.xsltproc"></a>xsltproc</h5>
|
||
<div class="paragraph">
|
||
<p>To use xsltproc, you first need to configure it using the following
|
||
syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>xsltproc<span class="tok-w"> </span>:<span class="tok-w"> </span>xsltproc<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Where xsltproc is the xsltproc executable. If xsltproc is not specified,
|
||
and the variable XSLTPROC is set, the value of XSLTPROC will be used.
|
||
Otherwise, xsltproc will be searched for in PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>xsl:param</code></dt>
|
||
<dd>
|
||
<p>Values should have the form name=value</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>xsl:path</code></dt>
|
||
<dd>
|
||
<p>Sets an additional search path for xi:include elements.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>catalog</code></dt>
|
||
<dd>
|
||
<p>A catalog file used to rewrite remote URL’s to a local copy.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The xsltproc module provides the following rules. Note that these
|
||
operate on jam targets and are intended to be used by another toolset,
|
||
such as boostbook, rather than directly by users.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>xslt</code></dt>
|
||
<dd>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule xslt ( target : source stylesheet : properties * )</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Runs xsltproc to create a single output file.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>xslt-dir</code></dt>
|
||
<dd>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule xslt-dir ( target : source stylesheet : properties * : dirname )</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Runs xsltproc to create multiple outputs in a directory. <code>dirname</code> is
|
||
unused, but exists for historical reasons. The output directory is
|
||
determined from the target.</p>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.doc.boostbook"><a class="anchor" href="#bbv2.reference.tools.doc.boostbook"></a>boostbook</h5>
|
||
<div class="paragraph">
|
||
<p>To use boostbook, you first need to configure it using the following
|
||
syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>boostbook<span class="tok-w"> </span>:<span class="tok-w"> </span>docbook-xsl-dir<span class="tok-w"> </span>:<span class="tok-w"> </span>docbook-dtd-dir<span class="tok-w"> </span>:<span class="tok-w"> </span>boostbook-dir<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>docbook-xsl-dir</code> is the DocBook XSL stylesheet directory. If not
|
||
provided, we use <code>DOCBOOK_XSL_DIR</code> from the environment (if available) or
|
||
look in standard locations. Otherwise, we let the XML processor load the
|
||
stylesheets remotely.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>docbook-dtd-dir</code> is the DocBook DTD directory. If not provided, we use
|
||
<code>DOCBOOK_DTD_DIR</code> From the environment (if available) or look in standard
|
||
locations. Otherwise, we let the XML processor load the DTD remotely.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>boostbook-dir</code> is the BoostBook directory with the DTD and XSL sub-dirs.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The boostbook module depends on xsltproc. For pdf or ps output, it also
|
||
depends on fop.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>format</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p><strong>Allowed values:</strong> <code>html</code>, <code>xhtml</code>, <code>htmlhelp</code>, <code>onehtml</code>, <code>man</code>,
|
||
<code>pdf</code>, <code>ps</code>, <code>docbook</code>, <code>fo</code>, <code>tests</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>format</code> feature determines the type of output produced by the
|
||
boostbook rule.</p>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The boostbook module defines a rule for creating a target following the
|
||
common syntax.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>boostbook</code></dt>
|
||
<dd>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule boostbook ( target-name : sources * : requirements * : default-build * )</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Creates a boostbook target.</p>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.doc.doxygen"><a class="anchor" href="#bbv2.reference.tools.doc.doxygen"></a>doxygen</h5>
|
||
<div class="paragraph">
|
||
<p>To use doxygen, you first need to configure it using the following
|
||
syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>doxygen<span class="tok-w"> </span>:<span class="tok-w"> </span>name<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>name</code> is the doxygen command. If it is not specified, it will be found in
|
||
the PATH.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The doxygen module depends on the boostbook module when generating
|
||
BoostBook XML.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The following options can be provided, using
|
||
<em>`<option-name>option-value syntax`</em>:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>doxygen:param</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>All the values of <code>doxygen:param</code> are added to the <code>doxyfile</code>.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>prefix</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Specifies the common prefix of all headers when generating BoostBook
|
||
XML. Everything before this will be stripped off.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>reftitle</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Specifies the title of the library-reference section, when generating
|
||
BoostBook XML.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>doxygen:xml-imagedir</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>When generating BoostBook XML, specifies the directory in which to
|
||
place the images generated from LaTex formulae.</p>
|
||
</div>
|
||
<div class="admonitionblock warning">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">⚠</div>
|
||
</td>
|
||
<td class="content">
|
||
The path is interpreted relative to the current working directory,
|
||
not relative to the Jamfile. This is necessary to match the behavior of
|
||
BoostBook.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The doxygen module defines a rule for creating a target following the
|
||
common syntax.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>doxygen</code></dt>
|
||
<dd>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule doxygen ( target : sources * : requirements * : default-build * : usage-requirements * )</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Creates a doxygen target. If the target name ends with .html, then
|
||
this will generate an html directory. Otherwise it will generate
|
||
BoostBook XML.</p>
|
||
</div>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.doc.quickbook"><a class="anchor" href="#bbv2.reference.tools.doc.quickbook"></a>quickbook</h5>
|
||
<div class="paragraph">
|
||
<p>The quickbook module provides a generator to convert from Quickbook to
|
||
BoostBook XML.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To use quickbook, you first need to configure it using the following
|
||
syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>quickbook<span class="tok-w"> </span>:<span class="tok-w"> </span>command<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>command</code> is the quickbook executable. If it is not specified, B2
|
||
will compile it from source. If it is unable to find the source it will
|
||
search for a quickbook executable in PATH.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="bbv2.reference.tools.doc.fop"><a class="anchor" href="#bbv2.reference.tools.doc.fop"></a>fop</h5>
|
||
<div class="paragraph">
|
||
<p>The fop module provides generators to convert from XSL formatting
|
||
objects to Postscript and PDF.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To use fop, you first need to configure it using the following syntax:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>fop<span class="tok-w"> </span>:<span class="tok-w"> </span>fop-command<span class="tok-w"> </span>:<span class="tok-w"> </span>java-home<span class="tok-w"> </span>:<span class="tok-w"> </span>java<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>fop-command</code> is the command to run fop. If it is not specified,
|
||
B2 will search for it in PATH and FOP_HOME.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Either <code>java-home</code> or <code>java</code> can be used to specify where to find java.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.modules"><a class="anchor" href="#bbv2.reference.modules"></a>6.5. Builtin modules</h3>
|
||
<div class="paragraph">
|
||
<p>This section describes the modules that are provided by B2. The
|
||
import rule allows rules from one module to be used in another module or
|
||
Jamfile.</p>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.modules.modules"><a class="anchor" href="#bbv2.reference.modules.modules"></a>6.5.1. modules</h4>
|
||
<div class="paragraph">
|
||
<p>The <code>modules</code> module defines basic functionality for handling modules.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A module defines a number of rules that can be used in other modules.
|
||
Modules can contain code at the top level to initialize the module. This
|
||
code is executed the first time the module is loaded.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
A Jamfile is a special kind of module which is managed by the build
|
||
system. Although they cannot be loaded directly by users, the other
|
||
features of modules are still useful for Jamfiles.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Each module has its own namespaces for variables and rules. If two
|
||
modules A and B both use a variable named X, each one gets its own copy
|
||
of X. They won’t interfere with each other in any way. Similarly,
|
||
importing rules into one module has no effect on any other module.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Every module has two special variables. <code>$(<em>file</em>)</code> contains the name
|
||
of the file that the module was loaded from and <code>$(<em>name</em>)</code> contains
|
||
the name of the module.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
<code>$(<em>file</em>)</code> does not contain the full path to the file. If you need
|
||
this, use <code>modules.binding</code>.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>rule binding ( module-name )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the filesystem binding of the given module.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example, a module can get its own location with:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>me<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>modules.binding<span class="tok-w"> </span><span class="tok-si">$(__name__)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule poke ( module-name ? : variables + : value * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Sets the module-local value of a variable.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example, to set a variable in the global module:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>modules.poke<span class="tok-w"> </span>:<span class="tok-w"> </span>ZLIB_INCLUDE<span class="tok-w"> </span>:<span class="tok-w"> </span>/usr/local/include<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule peek ( module-name ? : variables + )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the module-local value of a variable.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example, to read a variable from the global module:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">local</span><span class="tok-w"> </span>ZLIB_INCLUDE<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>modules.peek<span class="tok-w"> </span>:<span class="tok-w"> </span>ZLIB_INCLUDE<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule call-in ( module-name ? : rule-name args * : * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Call the given rule locally in the given module. Use this for rules
|
||
accepting rule names as arguments, so that the passed rule may be
|
||
invoked in the context of the rule’s caller (for example, if the rule
|
||
accesses module globals or is a local rule).</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
rules called this way may accept at most 8 parameters.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">filter</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">f</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">values</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>m<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">CALLER_MODULE</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>result<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span>v<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(values)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span>[<span class="tok-w"> </span>modules.call-in<span class="tok-w"> </span><span class="tok-si">$(m)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(f)</span><span class="tok-w"> </span><span class="tok-si">$(v)</span><span class="tok-w"> </span>]<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>result<span class="tok-w"> </span>+=<span class="tok-w"> </span><span class="tok-si">$(v)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span>result<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule load ( module-name : filename ? : search * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Load the indicated module if it is not already loaded.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>module-name</code></dt>
|
||
<dd>
|
||
<p>Name of module to load.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>filename</code></dt>
|
||
<dd>
|
||
<p>(partial) path to file; Defaults to <code>$(module-name).jam</code></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>search</code></dt>
|
||
<dd>
|
||
<p>Directories in which to search for filename. Defaults to
|
||
<code>$(BOOST_BUILD_PATH)</code>.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule import ( module-names + : rules-opt * : rename-opt * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Load the indicated module and import rule names into the current module.
|
||
Any members of <code>rules-opt</code> will be available without qualification in
|
||
the caller’s module. Any members of <code>rename-opt</code> will be taken as the
|
||
names of the rules in the caller’s module, in place of the names they
|
||
have in the imported module. If <code>rules-opt = '*'</code>, all rules from the
|
||
indicated module are imported into the caller’s module. If <code>rename-opt</code>
|
||
is supplied, it must have the same number of elements as <code>rules-opt</code>.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
The <code>import</code> rule is available without qualification in all modules.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Examples:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span>path<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">import</span><span class="tok-w"> </span>path<span class="tok-w"> </span>:<span class="tok-w"> </span>*<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">import</span><span class="tok-w"> </span>path<span class="tok-w"> </span>:<span class="tok-w"> </span>join<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">import</span><span class="tok-w"> </span>path<span class="tok-w"> </span>:<span class="tok-w"> </span>native<span class="tok-w"> </span><span class="tok-nb">make</span><span class="tok-w"> </span>:<span class="tok-w"> </span>native-path<span class="tok-w"> </span><span class="tok-nb">make</span>-path<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule clone-rules ( source-module target-module )</code></p>
|
||
<div class="paragraph">
|
||
<p>Define exported copies in <code>$(target-module)</code> of all rules exported from
|
||
<code>$(source-module)</code>. Also make them available in the global module with
|
||
qualification, so that it is just as though the rules were defined
|
||
originally in <code>$(target-module)</code>.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.modules.path"><a class="anchor" href="#bbv2.reference.modules.path"></a>6.5.2. path</h4>
|
||
<div class="paragraph">
|
||
<p>Performs various path manipulations. Paths are always in a 'normalized'
|
||
representation. In it, a path may be either:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>'.'</code>, or</p>
|
||
</li>
|
||
<li>
|
||
<p><code>['/'] [ ( '..' '/' )* (token '/')* token ]</code></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In plain english, a path can be rooted, <code>'..'</code> elements are allowed only
|
||
at the beginning, and it never ends in slash, except for the path
|
||
consisting of slash only.</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.make"></a> <code>rule make ( native )</code></p>
|
||
<div class="paragraph">
|
||
<p>Converts the native path into normalized form.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.native"></a> <code>rule native ( path )</code></p>
|
||
<div class="paragraph">
|
||
<p>Builds the native representation of the path.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.is-rooted"></a> <code>rule is-rooted ( path )</code></p>
|
||
<div class="paragraph">
|
||
<p>Tests if a path is rooted.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.has-parent"></a> <code>rule has-parent ( path )</code></p>
|
||
<div class="paragraph">
|
||
<p>Tests if a path has a parent.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.basename"></a> <code>rule basename ( path )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the path without any directory components.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.parent"></a> <code>rule parent ( path )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the parent directory of the path. If no parent exists, an error
|
||
is issued.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.reverse"></a> <code>rule reverse ( path )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns <code>path2</code> such that <code>[ join path path2 ] = "."</code>. The path may not
|
||
contain <code>".."</code> element or be rooted.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.join"></a> <code>rule join ( elements + )</code></p>
|
||
<div class="paragraph">
|
||
<p>Concatenates the passed path elements. Generates an error if any element
|
||
other than the first one is rooted. Skips any empty or undefined path
|
||
elements.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.root"></a> <code>rule root ( path root )</code></p>
|
||
<div class="paragraph">
|
||
<p>If <code>path</code> is relative, it is rooted at <code>root</code>. Otherwise, it is
|
||
unchanged.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.pwd"></a> <code>rule pwd ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the current working directory.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.glob"></a> <code>rule glob ( dirs * : patterns + : exclude-patterns * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the list of files matching the given pattern in the specified
|
||
directory. Both directories and patterns are supplied as portable paths.
|
||
Each pattern should be a non-absolute path, and can’t contain "." or
|
||
".." elements. Each slash separated element of a pattern can contain the
|
||
following special characters:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>'?' matches any character</p>
|
||
</li>
|
||
<li>
|
||
<p>'*' matches an arbitrary number of characters</p>
|
||
<div class="paragraph">
|
||
<p>A file <code>$(d)/e1/e2/e3</code> (where 'd' is in <code>$(dirs)</code>) matches the pattern
|
||
p1/p2/p3 if and only if e1 matches p1, e2 matches p2 and so on. For
|
||
example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>[<span class="tok-w"> </span><span class="tok-nb">glob</span><span class="tok-w"> </span>.<span class="tok-w"> </span>:<span class="tok-w"> </span>*.cpp<span class="tok-w"> </span>]<span class="tok-w"></span>
|
||
[<span class="tok-w"> </span><span class="tok-nb">glob</span><span class="tok-w"> </span>.<span class="tok-w"> </span>:<span class="tok-w"> </span>*/build/Jamfile<span class="tok-w"> </span>]<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.glob-tree"></a> <code>rule glob-tree ( roots * : patterns + : exclude-patterns * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Recursive version of <a href="#bbv2.reference.modules.path.glob">glob</a>.
|
||
Builds the glob of files while also searching in the subdirectories of
|
||
the given roots. An optional set of exclusion patterns will filter out
|
||
the matching entries from the result. The exclusions also apply to the
|
||
subdirectory scanning, such that directories that match the exclusion
|
||
patterns will not be searched.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.exists"></a> <code>rule exists ( file )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns true if the specified file exists.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.all-parents"></a> <code>rule all-parents ( path : upper_limit ? : cwd ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Find out the absolute name of path and return the list of all the
|
||
parents, starting with the immediate one. Parents are returned as
|
||
relative names. If <code>upper_limit</code> is specified, directories above it will
|
||
be pruned.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.glob-in-parents"></a> <code>rule glob-in-parents ( dir : patterns + : upper-limit ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Search for <code>patterns</code> in parent directories of <code>dir</code>, up to and
|
||
including <code>upper_limit</code>, if it is specified, or till the filesystem root
|
||
otherwise.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.relative"></a> <code>rule relative ( child parent : no-error ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Assuming <code>child</code> is a subdirectory of <code>parent</code>, return the relative path
|
||
from <code>parent</code> to <code>child</code>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.relative-to"></a> <code>rule relative-to ( path1 path2 )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the minimal path to path2 that is relative path1.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.programs-path"></a> <code>rule programs-path ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the list of paths which are used by the operating system for
|
||
looking up programs.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.path.makedirs"></a> <code>rule makedirs ( path )</code></p>
|
||
<div class="paragraph">
|
||
<p>Creates a directory and all parent directories that do not already
|
||
exist.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.modules.regex"><a class="anchor" href="#bbv2.reference.modules.regex"></a>6.5.3. regex</h4>
|
||
<div class="paragraph">
|
||
<p>Contains rules for string processing using regular expressions.</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>"x*"</code> matches the pattern <code>"x"</code> zero or more times.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>"x+"</code> matches <code>"x"</code> one or more times.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>"x?"</code> matches <code>"x"</code> zero or one time.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>"[abcd]"</code> matches any of the characters, <code>"a"</code>, <code>"b"</code>, <code>"c"</code>, and
|
||
<code>"d"</code>. A character range such as <code>"[a-z]"</code> matches any character between
|
||
<code>"a"</code> and <code>"z"</code>. <code>"[^abc]"</code> matches any character which is not <code>"a"</code>,
|
||
<code>"b"</code>, or <code>"c"</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>"x|y"</code> matches either pattern <code>"x"</code> or pattern <code>"y"</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>(x)</code> matches <code>"x"</code> and captures it.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>"^"</code> matches the beginning of the string.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>"$"</code> matches the end of the string.</p>
|
||
</li>
|
||
<li>
|
||
<p>"\<" matches the beginning of a word.</p>
|
||
</li>
|
||
<li>
|
||
<p>"\>" matches the end of a word.</p>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.regex.split"></a> <code>rule split ( string separator )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns a list of the following substrings:</p>
|
||
</div>
|
||
<div class="olist loweralpha">
|
||
<ol class="loweralpha" type="a">
|
||
<li>
|
||
<p>from beginning till the first occurrence of <code>separator</code> or till the
|
||
end,</p>
|
||
</li>
|
||
<li>
|
||
<p>between each occurrence of <code>separator</code> and the next occurrence,</p>
|
||
</li>
|
||
<li>
|
||
<p>from the last occurrence of <code>separator</code> till the end.</p>
|
||
<div class="paragraph">
|
||
<p>If no separator is present, the result will contain only one element.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.regex.split-list"></a> <code>rule split-list ( list * : separator )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the concatenated results of applying
|
||
<a href="#bbv2.reference.modules.regex.split">regex.split</a> to every element
|
||
of the list using the separator pattern.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.regex.match"></a> <code>rule match ( pattern : string : indices * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Match <code>string</code> against <code>pattern</code>, and return the elements indicated by
|
||
<code>indices</code>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.regex.transform"></a> <code>rule transform ( list * : pattern : indices * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Matches all elements of <code>list</code> against the <code>pattern</code> and returns a list
|
||
of elements indicated by <code>indices</code> of all successful matches. If
|
||
<code>indices</code> is omitted returns a list of first parenthesized groups of all
|
||
successful matches.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.regex.escape"></a> <code>rule escape ( string : symbols : escape-symbol )</code></p>
|
||
<div class="paragraph">
|
||
<p>Escapes all of the characters in <code>symbols</code> using the escape symbol
|
||
<code>escape-symbol</code> for the given string, and returns the escaped string.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.regex.replace"></a> <code>rule replace ( string match replacement )</code></p>
|
||
<div class="paragraph">
|
||
<p>Replaces occurrences of a match string in a given string and returns the
|
||
new string. The match string can be a regex expression.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.regex.replace-list"></a> <code>rule replace-list ( list * : match : replacement )</code></p>
|
||
<div class="paragraph">
|
||
<p>Replaces occurrences of a match string in a given list of strings and
|
||
returns a list of new strings. The match string can be a regex
|
||
expression.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>See also: <a href="#jam.language.rules.builtins.utility._match__">MATCH</a></p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.modules.sequence"><a class="anchor" href="#bbv2.reference.modules.sequence"></a>6.5.4. sequence</h4>
|
||
<div class="paragraph">
|
||
<p>Various useful list functions. Note that algorithms in this module
|
||
execute largely in the caller’s module namespace, so that local rules
|
||
can be used as function objects. Also note that most predicates can be
|
||
multi-element lists. In that case, all but the first element are
|
||
prepended to the first argument which is passed to the rule named by the
|
||
first element.</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>rule filter ( predicate + : sequence * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Return the elements <code>e</code> of <code>$(sequence)</code> for which <code>[ $(predicate) e ]</code>
|
||
has a non-null value.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule transform ( function + : sequence * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Return a new sequence consisting of <code>[ $(function) $(e) ]</code> for each
|
||
element <code>e</code> of <code>$(sequence)</code>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule reverse ( s * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the elements of <code>s</code> in reverse order.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule insertion-sort ( s * : ordered * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Insertion-sort <code>s</code> using the BinaryPredicate <code>ordered</code>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule merge ( s1 * : s2 * : ordered * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Merge two ordered sequences using the BinaryPredicate <code>ordered</code>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule join ( s * : joint ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Join the elements of <code>s</code> into one long string. If <code>joint</code> is supplied,
|
||
it is used as a separator.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule length ( s * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Find the length of any sequence.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule unique ( list * : stable ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Removes duplicates from <code>list</code>. If <code>stable</code> is passed, then the order of
|
||
the elements will be unchanged.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule max-element ( elements + : ordered ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the maximum number in <code>elements</code>. Uses <code>ordered</code> for comparisons
|
||
or <code>numbers.less</code> if none is provided.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule select-highest-ranked ( elements * : ranks * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns all of <code>elements</code> for which the corresponding element in the
|
||
parallel list <code>rank</code> is equal to the maximum value in <code>rank</code>.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.modules.stage"><a class="anchor" href="#bbv2.reference.modules.stage"></a>6.5.5. stage</h4>
|
||
<div class="paragraph">
|
||
<p>This module defines the <code>install</code> rule, used to copy a set of targets to a
|
||
single location.</p>
|
||
</div>
|
||
<div id="bbv2.reference.modules.stage.add-install-dir" class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>rule add-install-dir ( name : suffix ? : parent ? : options * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Defines a named installation directory.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example, <code>add-install-dir foo : bar : baz ;</code> creates feature
|
||
<a href="#bbv2.builtin.features.install-prefix"><code><install-foo></code></a> and adds support for
|
||
named directory <code>(foo)</code> to <code>install</code> rule. The rule will try to use the value
|
||
of <code><install-foo></code> property if present, otherwise will fallback to <code>(baz)/bar</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Arguments:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>name</code>: the name of the directory.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>suffix</code>: the path suffix appended to the parent named directory.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>parent</code>: the optional name of parent named directory.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>options</code>: special options that modify treatment of the directory.
|
||
Allowed options:</p>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>package-suffix</code>: append the package name to the default value. For example:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>add-install-dir<span class="tok-w"> </span>foo<span class="tok-w"> </span>:<span class="tok-w"> </span>bar<span class="tok-w"> </span>:<span class="tok-w"> </span>baz<span class="tok-w"> </span>:<span class="tok-w"> </span>package-suffix<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">install</span><span class="tok-w"> </span>(foo)<span class="tok-w"> </span>:<span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><install-package></span>xyz<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>installs <code>a</code> into <code>(baz)/bar/xyz</code>.</p>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule install-dir-names ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns names of all registered installation directories.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule get-dir ( name : property-set : package-name : flags * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the path to a named installation directory. For a given <code>name=xyz</code> the
|
||
rule uses the value of <code><install-xyz></code> property if it is present in
|
||
<code>property-set</code>. Otherwise it tries to construct the default value of the path
|
||
recursively getting the path to <code>name</code>'s registered base named directory and
|
||
relative path. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>stage.add-install-dir<span class="tok-w"> </span>foo<span class="tok-w"> </span>:<span class="tok-w"> </span>bar<span class="tok-w"> </span>:<span class="tok-w"> </span>baz<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-k">local</span><span class="tok-w"> </span>ps<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>property-set.create<span class="tok-w"> </span><span class="tok-na"><install-foo></span>x/y/z<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">echo</span><span class="tok-w"> </span>[<span class="tok-w"> </span>stage.get-dir<span class="tok-w"> </span>foo<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(ps)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(__name__)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># outputs x/y/z</span>
|
||
|
||
ps<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>property-set.create<span class="tok-w"> </span><span class="tok-na"><install-baz></span>a/b/c/d<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">echo</span><span class="tok-w"> </span>[<span class="tok-w"> </span>stage.get-dir<span class="tok-w"> </span>foo<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(ps)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(__name__)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># outputs a/b/c/d/bar</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The argument <code>package-name</code> is used to construct the path for named directories
|
||
that were registered with <code>package-suffix</code> option and also to construct
|
||
<code>install-prefix</code> when targeting Windows.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Available <code>flags</code>:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>staged</code>: take <a href="#bbv2.builtin.features.staging-prefix"><code>staging-prefix</code></a> into
|
||
account.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>relative</code>: return the path to <code>name</code> relative to its base directory.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule get-package-name ( property-set : project-module ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the package name that will be used for <code>install</code> targets when
|
||
constructing installation location. The rule uses the value of
|
||
<a href="#bbv2.builtin.features.install-package"><code><install-package></code></a> property if it’s
|
||
present in <code>property-set</code>. Otherwise it deduces the package name using
|
||
<code>project-module</code>'s attributes. It traverses the project hierarchy up to the
|
||
root searching for the first project with an id. If none is found, the base
|
||
name of the root project’s location is used. If <code>project-module</code> is empty, the
|
||
caller module is used (this allows invoking just <code>[ get-package-name $(ps) ]</code>
|
||
in project jam files).</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.modules.type"><a class="anchor" href="#bbv2.reference.modules.type"></a>6.5.6. type</h4>
|
||
<div class="paragraph">
|
||
<p>Deals with target type declaration and defines target class which
|
||
supports typed targets.</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.register"></a> <code>rule register ( type : suffixes * : base-type ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Registers a target type, possible derived from a <code>base-type</code>. Providing
|
||
a list of suffixes here is a shortcut for separately calling the
|
||
<a href="#bbv2.reference.modules.type.register-suffixes">register-suffixes</a>
|
||
rule with the given suffixes and the
|
||
<a href="#bbv2.reference.modules.type.set-generated-target-suffix">set-generated-target-suffix</a>
|
||
rule with the first given suffix.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.register-suffixes"></a> <code>rule register-suffixes ( suffixes + : type )</code></p>
|
||
<div class="paragraph">
|
||
<p>Specifies that files with suffix from <code>suffixes</code> be recognized as
|
||
targets of type <code>type</code>. Issues an error if a different type is already
|
||
specified for any of the suffixes.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.registered"></a> <code>rule registered ( type )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns true iff type has been registered.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.validate"></a> <code>rule validate ( type )</code></p>
|
||
<div class="paragraph">
|
||
<p>Issues an error if <code>type</code> is unknown.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.set-scanner"></a> <code>rule set-scanner ( type : scanner )</code></p>
|
||
<div class="paragraph">
|
||
<p>Sets a scanner class that will be used for this type.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.get-scanner"></a> <code>rule get-scanner ( type : property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns a scanner instance appropriate to <code>type</code> and <code>property-set</code>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.base"></a> <code>rule base ( type )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns a base type for the given type or nothing in case the given type
|
||
is not derived.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.all-bases"></a> <code>rule all-bases ( type )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the given type and all of its base types in order of their
|
||
distance from type.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.all-derived"></a> <code>rule all-derived ( type )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the given type and all of its derived types in order of their
|
||
distance from type.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.is-derived"></a> <code>rule is-derived ( type base )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns true if <code>type</code> is equal to <code>base</code> or has <code>base</code> as its direct or
|
||
indirect base.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.set-generated-target-suffix"></a> <code>rule set-generated-target-suffix ( type : properties * : suffix )</code></p>
|
||
<div class="paragraph">
|
||
<p>Sets a file suffix to be used when generating a target of <code>type</code> with
|
||
the specified properties. Can be called with no properties if no suffix
|
||
has already been specified for the <code>type</code>. The <code>suffix</code> parameter can be
|
||
an empty string (<code>""</code>) to indicate that no suffix should be used.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that this does not cause files with <code>suffix</code> to be automatically
|
||
recognized as being of <code>type</code>. Two different types can use the same
|
||
suffix for their generated files but only one type can be auto-detected
|
||
for a file with that suffix. User should explicitly specify which one
|
||
using the
|
||
<a href="#bbv2.reference.modules.type.register-suffixes">register-suffixes</a>
|
||
rule.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.change-generated-target-suffix"></a> <code>rule change-generated-target-suffix ( type : properties * : suffix )</code></p>
|
||
<div class="paragraph">
|
||
<p>Change the suffix previously registered for this type/properties
|
||
combination. If suffix is not yet specified, sets it.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.generated-target-suffix"></a> <code>rule generated-target-suffix ( type : property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the suffix used when generating a file of <code>type</code> with the given
|
||
properties.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.set-generated-target-prefix"></a> <code>rule set-generated-target-prefix ( type : properties * : prefix )</code></p>
|
||
<div class="paragraph">
|
||
<p>Sets a target prefix that should be used when generating targets of
|
||
<code>type</code> with the specified properties. Can be called with empty
|
||
properties if no prefix for <code>type</code> has been specified yet.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>prefix</code> parameter can be empty string (<code>""</code>) to indicate that no
|
||
prefix should be used.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Usage example: library names use the <code>"lib"</code> prefix on unix.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.change-generated-target-prefix"></a> <code>rule change-generated-target-prefix ( type : properties * : prefix )</code></p>
|
||
<div class="paragraph">
|
||
<p>Change the prefix previously registered for this type/properties
|
||
combination. If prefix is not yet specified, sets it.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.generated-target-prefix"></a> <code>rule generated-target-prefix ( type : property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the prefix used when generating a file of <code>type</code> with the given
|
||
properties.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.modules.type.type"></a> <code>rule type ( filename )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns file type given its name. If there are several dots in filename,
|
||
tries each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and
|
||
"so" will be tried.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.class"><a class="anchor" href="#bbv2.reference.class"></a>6.6. Builtin classes</h3>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.class.abstract-target"><a class="anchor" href="#bbv2.reference.class.abstract-target"></a>6.6.1. Class abstract-target</h4>
|
||
<div class="paragraph">
|
||
<p>Base class for all abstract targets.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">abstract-target</span><span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">__init__</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">project</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">project</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">location</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">full-name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">generate</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Classes derived from
|
||
<a href="#bbv2.reference.class.abstract-target">abstract-target</a>:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>project-target</p>
|
||
</li>
|
||
<li>
|
||
<p>main-target</p>
|
||
</li>
|
||
<li>
|
||
<p>basic-target</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="openblock">
|
||
<div class="content">
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>rule <em>init</em> ( name : project )</code></p>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>name</code></dt>
|
||
<dd>
|
||
<p>The name of the target in the Jamfile.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>project</code></dt>
|
||
<dd>
|
||
<p>The <a href="#bbv2.reference.class.project-target">project</a> to which this
|
||
target belongs.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule name ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the name of this target.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule project ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the <a href="#bbv2.reference.class.project-target">project</a> for this
|
||
target.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule location ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the location where the target was declared.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule full-name ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns a user-readable name for this target.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.class.abstract-target.generate"></a> <code>rule generate ( property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Generates virtual targets for this abstract target using the specified
|
||
properties, unless a different value of some feature is required by the
|
||
target. This is an abstract method which must be overridden by derived
|
||
classes.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>On success, returns:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>a property-set with the usage requirements to be applied to dependents</p>
|
||
</li>
|
||
<li>
|
||
<p>a list of produced virtual targets, which may be empty.</p>
|
||
<div class="paragraph">
|
||
<p>If <code>property-set</code> is empty, performs the default build of this target,
|
||
in a way specific to the derived class.</p>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.class.project-target"><a class="anchor" href="#bbv2.reference.class.project-target"></a>6.6.2. Class project-target</h4>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">project-target</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nc">abstract-target</span><span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">generate</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">build-dir</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">main-target</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">has-main-target</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">find</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">id</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">no-error</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
|
||
<span class="tok-w"> </span><span class="tok-c1"># Methods inherited from abstract-target</span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">project</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">location</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">full-name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This class has the following responsibilities:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Maintaining a list of main targets in this project and building them.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="openblock">
|
||
<div class="content">
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><a id="bbv2.reference.class.project-target.generate"></a> <code>rule generate ( property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Overrides
|
||
<a href="#bbv2.reference.class.abstract-target.generate">abstract-target.generate</a>.
|
||
Generates virtual targets for all the targets contained in this project.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>On success, returns:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>a property-set with the usage requirements to be applied to dependents</p>
|
||
</li>
|
||
<li>
|
||
<p>a list of produced virtual targets, which may be empty.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule build-dir ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the root build directory of the project.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule main-target ( name )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns a <a href="#bbv2.reference.class.main-target">main-target</a> class
|
||
instance corresponding to <code>name</code>. Can only be called after the project
|
||
has been fully loaded.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule has-main-target ( name )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns whether a <a href="#bbv2.reference.class.main-target">main-target</a>
|
||
with the specified name exists. Can only be called after the project has
|
||
been fully loaded.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule find ( id : no-error ? )</code></p>
|
||
<div class="paragraph">
|
||
<p>Find and return the target with the specified id, treated relative to
|
||
self. Id may specify either a target or a file name with the target
|
||
taking priority. May report an error or return nothing if the target is
|
||
not found depending on the <code>no-error</code> parameter.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.class.main-target"><a class="anchor" href="#bbv2.reference.class.main-target"></a>6.6.3. Class main-target</h4>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">main-target</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nc">abstract-target</span><span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">generate</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
|
||
<span class="tok-w"> </span><span class="tok-c1"># Methods inherited from abstract-target</span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">project</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">location</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">full-name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A <a href="#bbv2.reference.class.main-target">main-target</a> represents a named
|
||
top-level target in a Jamfile.</p>
|
||
</div>
|
||
<div class="openblock">
|
||
<div class="content">
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><a id="bbv2.reference.class.main-target.generate"></a> <code>rule generate ( property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Overrides
|
||
<a href="#bbv2.reference.class.abstract-target.generate">abstract-target.generate</a>.
|
||
Select an alternative for this main target, by finding all alternatives
|
||
whose requirements are satisfied by <code>property-set</code> and picking the one
|
||
with the longest requirements set. Returns the result of calling
|
||
<a href="#bbv2.reference.class.basic-target.generate">generate</a> on that
|
||
alternative.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>On success, returns:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>a property-set with the usage requirements to be applied to dependents</p>
|
||
</li>
|
||
<li>
|
||
<p>a list of produced virtual targets, which may be empty.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.class.basic-target"><a class="anchor" href="#bbv2.reference.class.basic-target"></a>6.6.4. Class basic-target</h4>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">basic-target</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nc">abstract-target</span><span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">__init__</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">project</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">default-build</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">usage-requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">generate</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">construct</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">source-targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
|
||
<span class="tok-w"> </span><span class="tok-c1"># Methods inherited from abstract-target</span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">project</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">location</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">full-name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Implements the most standard way of constructing main target alternative
|
||
from sources. Allows sources to be either files or other main targets
|
||
and handles generation of those dependency targets.</p>
|
||
</div>
|
||
<div class="openblock">
|
||
<div class="content">
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>rule <em>init</em> ( name : project : sources * : requirements * : default-build * : usage-requirements * )</code></p>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>name</code></dt>
|
||
<dd>
|
||
<p>The name of the target</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>project</code></dt>
|
||
<dd>
|
||
<p>The <a href="#bbv2.reference.class.project-target">project</a> in which the
|
||
target is declared.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.class.basic-target.generate"></a> <code>rule generate ( property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Overrides
|
||
<a href="#bbv2.reference.class.abstract-target.generate">abstract-target.generate</a>.
|
||
Determines final build properties, generates sources, and calls
|
||
<a href="#bbv2.reference.class.basic-target.construct">construct</a>. This
|
||
method should not be overridden.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>On success, returns:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>a property-set with the usage requirements to be applied to dependents</p>
|
||
</li>
|
||
<li>
|
||
<p>a list of produced virtual targets, which may be empty.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.class.basic-target.construct"></a> <code>rule construct ( name : source-targets * : property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Constructs virtual targets for this abstract target. Returns a
|
||
usage-requirements property-set and a list of virtual targets. Should be
|
||
overridden in derived classes.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.class.typed-target"><a class="anchor" href="#bbv2.reference.class.typed-target"></a>6.6.5. Class typed-target</h4>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">typed-target</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nc">basic-target</span><span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">__init__</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">project</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">type</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">default-build</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">usage-requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">type</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">construct</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">source-targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
|
||
<span class="tok-w"> </span><span class="tok-c1"># Methods inherited from abstract-target</span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">project</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">location</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">full-name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
|
||
<span class="tok-w"> </span><span class="tok-c1"># Methods inherited from basic-target</span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">generate</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><a href="#bbv2.reference.class.typed-target">typed-target</a> is the most common
|
||
kind of target alternative. Rules for creating typed targets are defined
|
||
automatically for each type.</p>
|
||
</div>
|
||
<div class="openblock">
|
||
<div class="content">
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>rule <em>init</em> ( name : project : type : sources * : requirements * : default-build * : usage-requirements * )</code></p>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>name</code></dt>
|
||
<dd>
|
||
<p>The name of the target</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>project</code></dt>
|
||
<dd>
|
||
<p>The <a href="#bbv2.reference.class.project-target">project</a> in which the
|
||
target is declared.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>type</code></dt>
|
||
<dd>
|
||
<p>The <a href="#bbv2.reference.modules.type">type</a> of the target.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule type ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the <a href="#bbv2.reference.modules.type">type</a> of the target.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule construct ( name : source-targets * : property-set )</code></p>
|
||
<div class="paragraph">
|
||
<p>Implements
|
||
<a href="#bbv2.reference.class.basic-target.construct">basic-target.construct</a>.
|
||
Attempts to create a target of the correct type using generators
|
||
appropriate for the given
|
||
<a href="#bbv2.reference.class.property-set">property-set</a>. Returns a
|
||
<a href="#bbv2.reference.class.property-set">property-set</a> containing the
|
||
usage requirements and a list of virtual targets.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
This function is invoked automatically by
|
||
<a href="#bbv2.reference.class.basic-target.generate">basic-target.generate</a>
|
||
and should not be called directly by users.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.class.property-set"><a class="anchor" href="#bbv2.reference.class.property-set"></a>6.6.6. Class property-set</h4>
|
||
<div class="paragraph">
|
||
<p>Class for storing a set of properties.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">property-set</span><span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">raw</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">str</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">propagated</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">add</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">ps</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">add-raw</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">properties</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">refine</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">ps</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">get</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">feature</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There is 1<→1 correspondence between identity and value. No two
|
||
instances of the class are equal. To maintain this property, the
|
||
'property-set.create' rule should be used to create new instances.
|
||
Instances are immutable.</p>
|
||
</div>
|
||
<div class="openblock">
|
||
<div class="content">
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>rule raw ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns a Jam list of the stored properties.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule str ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns the string representation of the stored properties.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule propagated ( )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns a <a href="#bbv2.reference.class.property-set">property-set</a>
|
||
containing all the
|
||
<a href="#bbv2.reference.features.attributes.propagated">propagated</a>
|
||
properties in this
|
||
<a href="#bbv2.reference.class.property-set">property-set</a>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.class.property-set.add"></a> <code>rule add ( ps )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns a new <a href="#bbv2.reference.class.property-set">property-set</a>
|
||
containing the union of the properties in this
|
||
<a href="#bbv2.reference.class.property-set">property-set</a> and in <code>ps</code>.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
If <code>ps</code> contains non-free properties that should override the values in
|
||
this object, use <a href="#bbv2.reference.class.property-set.refine">refine</a>
|
||
instead.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule add-raw ( properties * )</code></p>
|
||
<div class="paragraph">
|
||
<p>Link <a href="#bbv2.reference.class.property-set.add">add</a>, except that it
|
||
takes a list of properties instead of a
|
||
<a href="#bbv2.reference.class.property-set">property-set</a>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.class.property-set.refine"></a> <code>rule refine ( ps )</code></p>
|
||
<div class="paragraph">
|
||
<p>Refines properties by overriding any non-free and non-conditional
|
||
properties for which a different value is specified in <code>ps</code>. Returns the
|
||
resulting <a href="#bbv2.reference.class.property-set">property-set</a>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><code>rule get ( feature )</code></p>
|
||
<div class="paragraph">
|
||
<p>Returns all the values of <code>feature</code>.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.buildprocess"><a class="anchor" href="#bbv2.reference.buildprocess"></a>6.7. Build process</h3>
|
||
<div class="paragraph">
|
||
<p>The general overview of the build process was given in the
|
||
<a href="#bbv2.overview.build_process">user documentation</a>. This section
|
||
provides additional details, and some specific rules.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To recap, building a target with specific properties includes the
|
||
following steps:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>applying the default build,</p>
|
||
</li>
|
||
<li>
|
||
<p>selecting the main target alternative to use,</p>
|
||
</li>
|
||
<li>
|
||
<p>determining the "common" properties,</p>
|
||
</li>
|
||
<li>
|
||
<p>building targets referred by the the sources list and dependency
|
||
properties,</p>
|
||
</li>
|
||
<li>
|
||
<p>adding the usage requirements produced when building dependencies to
|
||
the "common" properties,</p>
|
||
</li>
|
||
<li>
|
||
<p>building the target using generators,</p>
|
||
</li>
|
||
<li>
|
||
<p>computing the usage requirements to be returned.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.buildprocess.alternatives"><a class="anchor" href="#bbv2.reference.buildprocess.alternatives"></a>6.7.1. Alternative selection</h4>
|
||
<div class="paragraph">
|
||
<p>When a target has several alternatives, one of them must be selected.
|
||
The process is as follows:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>For each alternative, its <em>condition</em> is defined as the set of
|
||
<a href="#bbv2.reference.features.attributes.base">base properties</a> in its
|
||
requirements. <a href="#bbv2.reference.variants.propcond">Conditional
|
||
properties</a> are excluded.</p>
|
||
</li>
|
||
<li>
|
||
<p>An alternative is viable only if all properties in its condition are
|
||
present in the build request.</p>
|
||
</li>
|
||
<li>
|
||
<p>If there’s only one viable alternative, it’s chosen. Otherwise, an
|
||
attempt is made to find the best alternative. An alternative a is better
|
||
than another alternative b, if the set of properties in b’s condition is
|
||
a strict subset of the set of properties of a’s condition. If one viable
|
||
alternative is better than all the others, it’s selected. Otherwise, an
|
||
error is reported.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.buildprocess.common"><a class="anchor" href="#bbv2.reference.buildprocess.common"></a>6.7.2. Determining common properties</h4>
|
||
<div class="paragraph">
|
||
<p>"Common" properties is a somewhat artificial term. This is the
|
||
intermediate property set from which both the build request for
|
||
dependencies and the properties for building the target are derived.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Since the default build and alternatives are already handled, we have
|
||
only two inputs: the build request and the requirements. Here are the
|
||
rules about common properties.</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Non-free features can have only one value</p>
|
||
</li>
|
||
<li>
|
||
<p>A non-conditional property in the requirements is always present in
|
||
common properties.</p>
|
||
</li>
|
||
<li>
|
||
<p>A property in the build request is present in common properties,
|
||
unless it is overridden by a property in the requirements.</p>
|
||
</li>
|
||
<li>
|
||
<p>If either the build request, or the requirements (non-conditional or
|
||
conditional) include an expandable property (either composite, or with a
|
||
specified sub-feature value), the behavior is equivalent to explicitly
|
||
adding all the expanded properties to the build request or the
|
||
requirements respectively.</p>
|
||
</li>
|
||
<li>
|
||
<p>If the requirements include a
|
||
<a href="#bbv2.reference.variants.propcond">conditional property</a>, and the
|
||
condition of this property is true in the context of common properties,
|
||
then the conditional property should be in common properties as well.</p>
|
||
</li>
|
||
<li>
|
||
<p>If no value for a feature is given by other rules here, it has
|
||
default value in common properties.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>These rules are declarative. They don’t specify how to compute the
|
||
common properties. However, they provide enough information for the
|
||
user. The important point is the handling of conditional requirements.
|
||
The condition can be satisfied either by a property in the build
|
||
request, by non-conditional requirements, or even by another conditional
|
||
property. For example, the following example works as expected:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>gcc:<span class="tok-na"><variant></span>release<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><variant></span>release:<span class="tok-na"><define></span>FOO<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.buildprocess.targetpath"><a class="anchor" href="#bbv2.reference.buildprocess.targetpath"></a>6.7.3. Target Paths</h4>
|
||
<div class="paragraph">
|
||
<p>Several factors determine the location of a concrete file target. All
|
||
files in a project are built under the directory bin unless this is
|
||
overridden by the build-dir project attribute. Under bin is a path that
|
||
depends on the properties used to build each target. This path is
|
||
uniquely determined by all non-free, non-incidental properties. For
|
||
example, given a property set containing: <code><toolset>gcc</code>
|
||
<code><toolset-gcc:version>4.6.1</code> <code><variant>debug</code> <code><warnings>all</code> <code><define>_DEBUG</code>
|
||
<code><include>/usr/local/include</code> <code><link>static</code>, the path will be
|
||
<code>gcc-4.6.1/debug/link-static</code>. <code><warnings></code> is an incidental feature and
|
||
<code><define></code> and <code><include></code> are free features, so they do not affect the path.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Sometimes the paths produced by B2 can become excessively long.
|
||
There are a couple of command line options that can help with this.
|
||
<code>--abbreviate-paths</code> reduces each element to no more than five characters.
|
||
For example, <code>link-static</code> becomes <code>lnk-sttc</code>. The <code>--hash</code> option reduces the
|
||
path to a single directory using an MD5 hash.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are two features that affect the build directory. The <code><location></code>
|
||
feature completely overrides the default build directory. For example,</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><location></span>.<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>builds all the files produced by <code>a</code> in the directory of the Jamfile.
|
||
This is generally discouraged, as it precludes variant builds.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <location-prefix> feature adds a prefix to the path, under the
|
||
project’s build directory. For example,</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><location-prefix></span>subdir<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will create the files for <code>a</code> in <code>bin/subdir/gcc-4.6.1/debug</code></p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.reference.definitions"><a class="anchor" href="#bbv2.reference.definitions"></a>6.8. Definitions</h3>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.features"><a class="anchor" href="#bbv2.reference.features"></a>6.8.1. Features and properties</h4>
|
||
<div class="paragraph">
|
||
<p>A <em>feature</em> is a normalized (toolset-independent) aspect of a build
|
||
configuration, such as whether inlining is enabled. Feature names may
|
||
not contain the ‘>’ character.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Each feature in a build configuration has one or more associated
|
||
<em>value</em>s. Feature values for non-free features may not contain the
|
||
punctuation characters of pointy bracket (‘<code><</code>’), colon (‘<code>:</code>’ ),
|
||
equal sign (‘<code>=</code>’) and dashes (‘<code>-</code>’). Feature values for free
|
||
features may not contain the pointy bracket (‘<code><</code>’) character.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A <em>property</em> is a (feature,value) pair, expressed as <feature>value.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A <em>subfeature</em> is a feature that only exists in the presence of its
|
||
parent feature, and whose identity can be derived (in the context of its
|
||
parent) from its value. A subfeature’s parent can never be another
|
||
subfeature. Thus, features and their subfeatures form a two-level
|
||
hierarchy.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A <em>value-string</em> for a feature <strong>F</strong> is a string of the form
|
||
<code>value-subvalue1-subvalue2</code>…​<code>-subvalueN</code>, where <code>value</code> is a legal
|
||
value for <strong>F</strong> and <code>subvalue1</code>…​<code>subvalueN</code> are legal values of some of
|
||
<strong>F</strong>'s subfeatures separated with dashes (‘<code>-</code>’).
|
||
For example, the properties <code><toolset>gcc <toolset-version>3.0.1</code> can
|
||
be expressed more concisely using a value-string, as <code><toolset>gcc-3.0.1</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A <em>property set</em> is a set of properties (i.e. a collection without
|
||
duplicates), for instance: <code><toolset>gcc <runtime-link>static</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A <em>property path</em> is a property set whose elements have been joined into
|
||
a single string separated by slashes. A property path representation of
|
||
the previous example would be <code><toolset>gcc/<runtime-link>static</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A <em>build specification</em> is a property set that fully describes the set
|
||
of features used to build a target.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.features.validity"><a class="anchor" href="#bbv2.reference.features.validity"></a>6.8.2. Property Validity</h4>
|
||
<div class="paragraph">
|
||
<p>For <a href="#bbv2.reference.features.attributes.free">free</a> features, all
|
||
values are valid. For all other features, the valid values are
|
||
explicitly specified, and the build system will report an error for the
|
||
use of an invalid feature-value. Subproperty validity may be restricted
|
||
so that certain values are valid only in the presence of certain other
|
||
subproperties. For example, it is possible to specify that the
|
||
<code><gcc-target>mingw</code> property is only valid in the presence of
|
||
<code><gcc-version>2.95.2</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.features.attributes"><a class="anchor" href="#bbv2.reference.features.attributes"></a>6.8.3. Feature Attributes</h4>
|
||
<div class="paragraph">
|
||
<p>Each feature has a collection of zero or more of the following
|
||
attributes. Feature attributes are low-level descriptions of how the
|
||
build system should interpret a feature’s values when they appear in a
|
||
build request. We also refer to the attributes of properties, so that an
|
||
<em>incidental</em> property, for example, is one whose feature has the
|
||
<em>incidental</em> attribute.</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.incidental"></a> <em>incidental</em></p>
|
||
<div class="paragraph">
|
||
<p>Incidental features are assumed not to affect build products at all. As
|
||
a consequence, the build system may use the same file for targets whose
|
||
build specification differs only in incidental features. A feature that
|
||
controls a compiler’s warning level is one example of a likely
|
||
incidental feature.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Non-incidental features are assumed to affect build products, so the
|
||
files for targets whose build specification differs in non-incidental
|
||
features are placed in different directories as described in
|
||
<a href="#bbv2.reference.buildprocess.targetpath">Target Paths</a>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.propagated"></a> <em>propagated</em></p>
|
||
<div class="paragraph">
|
||
<p>Features of this kind are propagated to dependencies. That is, if a
|
||
<a href="#bbv2.overview.targets.main">main target</a> is built using a
|
||
propagated property, the build systems attempts to use the same property
|
||
when building any of its dependencies as part of that main target. For
|
||
instance, when an optimized executable is requested, one usually wants
|
||
it to be linked with optimized libraries. Thus, the <code><optimization></code>
|
||
feature is propagated.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.free"></a> <em>free</em></p>
|
||
<div class="paragraph">
|
||
<p>Most features have a finite set of allowed values, and can only take on
|
||
a single value from that set in a given build specification. Free
|
||
features, on the other hand, can have several values at a time and each
|
||
value can be an arbitrary string. For example, it is possible to have
|
||
several preprocessor symbols defined simultaneously:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre><define>NDEBUG=1 <define>HAS_CONFIG_H=1</pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.optional"></a> <em>optional</em></p>
|
||
<div class="paragraph">
|
||
<p>An optional feature is a feature that is not required to appear in a
|
||
build specification. Every non-optional non-free feature has a default
|
||
value that is used when a value for the feature is not otherwise
|
||
specified, either in a target’s requirements or in the user’s build
|
||
request. [A feature’s default value is given by the first value listed
|
||
in the feature’s declaration. — move this elsewhere - dwa]</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.symmetric"></a> <em>symmetric</em></p>
|
||
<div class="paragraph">
|
||
<p>Normally a feature only generates a sub-variant directory when its value
|
||
differs from its default value, leading to an asymmetric sub-variant
|
||
directory structure for certain values of the feature. A symmetric
|
||
feature always generates a corresponding sub-variant directory.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.path"></a> <em>path</em></p>
|
||
<div class="paragraph">
|
||
<p>The value of a path feature specifies a path. The path is treated as
|
||
relative to the directory of Jamfile where path feature is used and is
|
||
translated appropriately by the build system when the build is invoked
|
||
from a different directory</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.implicit"></a> <em>implicit</em></p>
|
||
<div class="paragraph">
|
||
<p>Values of implicit features alone identify the feature. For example, a
|
||
user is not required to write "<toolset>gcc", but can simply write
|
||
"gcc". Implicit feature names also don’t appear in variant paths,
|
||
although the values do. Thus: bin/gcc/…​ as opposed to
|
||
bin/toolset-gcc/…​. There should typically be only a few such features,
|
||
to avoid possible name clashes.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.composite"></a> <em>composite</em></p>
|
||
<div class="paragraph">
|
||
<p>Composite features actually correspond to groups of properties. For
|
||
example, a build variant is a composite feature. When generating targets
|
||
from a set of build properties, composite features are recursively
|
||
expanded and <em>added</em> to the build property set, so rules can find them
|
||
if necessary. Non-composite non-free features override components of
|
||
composite features in a build property set.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p><a id="bbv2.reference.features.attributes.dependency"></a> <em>dependency</em></p>
|
||
<div class="paragraph">
|
||
<p>The value of a dependency feature is a target reference. When used for
|
||
building of a main target, the value of dependency feature is treated as
|
||
additional dependency.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example, dependency features allow to state that library A depends
|
||
on library B. As the result, whenever an application will link to A, it
|
||
will also link to B. Specifying B as dependency of A is different from
|
||
adding B to the sources of A.</p>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div id="bbv2.reference.features.attributes.base" class="paragraph">
|
||
<p>Features that are neither free nor incidental are called <em>base</em>
|
||
features.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.features.declaration"><a class="anchor" href="#bbv2.reference.features.declaration"></a>6.8.4. Feature Declaration</h4>
|
||
<div class="paragraph">
|
||
<p>The low-level feature declaration interface is the <code>feature</code> rule from
|
||
the <code>feature</code> module:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">feature</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">allowed-values</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">attributes</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A feature’s allowed-values may be extended with the <code>feature.extend</code>
|
||
rule.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.variants.proprefine"><a class="anchor" href="#bbv2.reference.variants.proprefine"></a>6.8.5. Property refinement</h4>
|
||
<div class="paragraph">
|
||
<p>When a target with certain properties is requested, and that target
|
||
requires some set of properties, it is needed to find the set of
|
||
properties to use for building. This process is called <em>property
|
||
refinement</em> and is performed by these rules</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Each property in the required set is added to the original property
|
||
set</p>
|
||
</li>
|
||
<li>
|
||
<p>If the original property set includes property with a different
|
||
value of non free feature, that property is removed.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.variants.propcond"><a class="anchor" href="#bbv2.reference.variants.propcond"></a>6.8.6. Conditional properties</h4>
|
||
<div class="paragraph">
|
||
<p>Sometime it’s desirable to apply certain requirements only for a
|
||
specific combination of other properties. For example, one of compilers
|
||
that you use issues a pointless warning that you want to suppress by
|
||
passing a command line option to it. You would not want to pass that
|
||
option to other compilers. Conditional properties allow you to do just
|
||
that. Their syntax is:</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>property ( "," property ) * ":" property</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example, the problem above would be solved by:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>yfc:<span class="tok-na"><cxxflags></span>-disable-pointless-warning<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The syntax also allows several properties in the condition, for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><os></span>NT,<span class="tok-na"><toolset></span>gcc:<span class="tok-na"><link></span>static<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.reference.ids"><a class="anchor" href="#bbv2.reference.ids"></a>6.8.7. Target identifiers and references</h4>
|
||
<div class="paragraph">
|
||
<p><em>Target identifier</em> is used to denote a target. The syntax is:</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>target-id -> (target-name | file-name | project-id | directory-name)
|
||
| (project-id | directory-name) "//" target-name
|
||
project-id -> path
|
||
target-name -> path
|
||
file-name -> path
|
||
directory-name -> path</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This grammar allows some elements to be recognized as either</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>name of target declared in current Jamfile (note that target names may
|
||
include slash).</p>
|
||
</li>
|
||
<li>
|
||
<p>a regular file, denoted by absolute name or name relative to project’s
|
||
sources location.</p>
|
||
</li>
|
||
<li>
|
||
<p>project id (at this point, all project ids start with slash).</p>
|
||
</li>
|
||
<li>
|
||
<p>the directory of another project, denoted by absolute name or name
|
||
relative to the current project’s location.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To determine the real meaning the possible interpretations are checked
|
||
in this order. For example, valid target ids might be:</p>
|
||
</div>
|
||
<table class="tableblock frame-all grid-all stretch">
|
||
<colgroup>
|
||
<col style="width: 50%;">
|
||
<col style="width: 50%;">
|
||
</colgroup>
|
||
<tbody>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>a</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">target in current project</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>lib/b.cpp</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">regular file</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>/boost/thread</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">project "/boost/thread"</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>/home/ghost/build/lr_library//parser</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">target in specific project</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>../boost_1_61_0</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">project in specific directory</p></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="paragraph">
|
||
<p><strong>Rationale:</strong>Target is separated from project by special separator (not
|
||
just slash), because:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>It emphasis that projects and targets are different things.</p>
|
||
</li>
|
||
<li>
|
||
<p>It allows to have main target names with slashes.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div id="bbv2.reference.targets.references" class="paragraph">
|
||
<p><em>Target reference</em> is used to specify a source target, and may
|
||
additionally specify desired properties for that target. It has this
|
||
syntax:</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>target-reference -> target-id [ "/" requested-properties ]
|
||
requested-properties -> property-path</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example,</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>compiler<span class="tok-w"> </span>:<span class="tok-w"> </span>compiler.cpp<span class="tok-w"> </span>libs/cmdline/<span class="tok-na"><optimization></span>space<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>would cause the version of <code>cmdline</code> library, optimized for space, to be
|
||
linked in even if the <code>compiler</code> executable is build with optimization
|
||
for speed.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.util"><a class="anchor" href="#bbv2.util"></a>7. Utilities</h2>
|
||
<div class="sectionbody">
|
||
<div class="sect2">
|
||
<h3 id="bbv2.util.debugger"><a class="anchor" href="#bbv2.util.debugger"></a>7.1. Debugger</h3>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.util.debugger.overview"><a class="anchor" href="#bbv2.util.debugger.overview"></a>7.1.1. Overview</h4>
|
||
<div class="paragraph">
|
||
<p>B2 comes with a debugger for Jamfiles. To run the debugger,
|
||
start B2 with <code>b2 -dconsole</code>.</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>$ b2 -dconsole
|
||
(b2db) break gcc.init
|
||
Breakpoint 1 set at gcc.init
|
||
(b2db) run
|
||
Starting program: /usr/bin/b2
|
||
Breakpoint 1, gcc.init ( ) at /usr/share/boost-build/tools/gcc.jam:74
|
||
74 local tool-command = ;
|
||
(b2db) quit</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.util.debugger.running"><a class="anchor" href="#bbv2.util.debugger.running"></a>7.1.2. Running the Program</h4>
|
||
<div class="paragraph">
|
||
<p>The <code>run</code> command is used to start a new <code>b2</code> subprocess for debugging.
|
||
The arguments to <code>run</code> are passed on the command line. If a child
|
||
process is already running, it will be terminated before the new child
|
||
is launched.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When the program is paused <code>continue</code> will resume execution. The <code>step</code>
|
||
command will advance the program by a single statement, stopping on
|
||
entry to another function or return from the current function. <code>next</code> is
|
||
like <code>step</code> except that it skips over function calls. <code>finish</code> executes
|
||
until the current function returns.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>kill</code> command terminates the current child immediately.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.util.debugger.break"><a class="anchor" href="#bbv2.util.debugger.break"></a>7.1.3. Breakpoints</h4>
|
||
<div class="paragraph">
|
||
<p>Breakpoints are set using the <code>break</code> command. The location of the
|
||
breakpoint can be specified as either the name of a function (including
|
||
the module name) or or a file name and line number of the form
|
||
<code>file:line</code>. When a breakpoint is created it is given a unique id which
|
||
is used to identify it for other commands.</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>(b2db) break Jamfile:10
|
||
Breakpoint 1 set at Jamfile:10
|
||
(b2db) break msvc.init
|
||
Breakpoint 2 set at msvc.init</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A breakpoint can be temporarily disabled using the <code>disable</code> command.
|
||
While a breakpoint is disabled, the child will not stop when it is hit.
|
||
A disabled breakpoint can be activated again with <code>enable</code>.</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>(b2db) disable 1
|
||
(b2db) enable 1</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Breakpoints can be removed permanently with <code>delete</code> or <code>clear</code>. The
|
||
difference between them is that <code>delete</code> takes the breakpoint id while
|
||
<code>clear</code> takes the location of the breakpoint as originally specified to
|
||
break.</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>(b2db) clear Jamfile:10
|
||
Deleted breakpoint 1
|
||
(b2db) delete 2</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.util.debugger.stack"><a class="anchor" href="#bbv2.util.debugger.stack"></a>7.1.4. Examining the Stack</h4>
|
||
<div class="paragraph">
|
||
<p>The <code>backtrace</code> command will print a summary of every frame on the
|
||
stack.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>print</code> command can be used to show the value of an expression.</p>
|
||
</div>
|
||
<div class="literalblock">
|
||
<div class="content">
|
||
<pre>(b2db) print [ modules.peek : ARGV ]
|
||
/usr/bin/b2 toolset=msvc install
|
||
(b2db) print $(__file__)
|
||
Jamfile.jam</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.util.debugger.misc"><a class="anchor" href="#bbv2.util.debugger.misc"></a>7.1.5. Miscellaneous Commands</h4>
|
||
<div class="paragraph">
|
||
<p><code>quit</code> exits the debugger. <code>help</code> describes the available commands.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.extender"><a class="anchor" href="#bbv2.extender"></a>8. Extender Manual</h2>
|
||
<div class="sectionbody">
|
||
<div class="sect2">
|
||
<h3 id="bbv2.extender.intro"><a class="anchor" href="#bbv2.extender.intro"></a>8.1. Introduction</h3>
|
||
<div class="paragraph">
|
||
<p>This section explains how to extend B2 to accommodate your local
|
||
requirements — primarily to add support for non-standard tools you
|
||
have. Before we start, be sure you have read and understood the concept
|
||
of metatarget, <a href="#bbv2.overview.concepts">Concepts</a>, which is critical to
|
||
understanding the remaining material.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The current version of B2 has three levels of targets, listed
|
||
below.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1">metatarget</dt>
|
||
<dd>
|
||
<p>Object that is created from declarations in Jamfiles. May be called
|
||
with a set of properties to produce concrete targets.</p>
|
||
</dd>
|
||
<dt class="hdlist1">concrete target</dt>
|
||
<dd>
|
||
<p>Object that corresponds to a file or an action.</p>
|
||
</dd>
|
||
<dt class="hdlist1">jam target</dt>
|
||
<dd>
|
||
<p>Low-level concrete target that is specific to Boost.Jam build engine.
|
||
Essentially a string — most often a name of file.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In most cases, you will only have to deal with concrete targets and the
|
||
process that creates concrete targets from metatargets. Extending
|
||
metatarget level is rarely required. The jam targets are typically only
|
||
used inside the command line patterns.</p>
|
||
</div>
|
||
<div class="admonitionblock warning">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">⚠</div>
|
||
</td>
|
||
<td class="content">
|
||
All of the Boost.Jam target-related builtin functions, like
|
||
<code>DEPENDS</code> or <code>ALWAYS</code> operate on jam targets. Applying them to metatargets or
|
||
concrete targets has no effect.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.extender.overview.metatargets"><a class="anchor" href="#bbv2.extender.overview.metatargets"></a>8.1.1. Metatargets</h4>
|
||
<div class="paragraph">
|
||
<p>Metatarget is an object that records information specified in Jamfile,
|
||
such as metatarget kind, name, sources and properties, and can be called
|
||
with specific properties to generate concrete targets. At the code level
|
||
it is represented by an instance of class derived from
|
||
<a href="#bbv2.reference.class.abstract-target">abstract-target</a>.
|
||
<sup class="footnote">[<a id="_footnoteref_4" class="footnote" href="#_footnotedef_4" title="View footnote.">4</a>]</sup></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <a href="#bbv2.reference.class.abstract-target.generate">generate</a> method
|
||
takes the build properties (as an instance of the
|
||
<a href="#bbv2.reference.class.property-set">property-set</a> class) and returns
|
||
a list containing:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>As front element — Usage-requirements from this invocation (an
|
||
instance of <a href="#bbv2.reference.class.property-set">property-set</a>)</p>
|
||
</li>
|
||
<li>
|
||
<p>As subsequent elements — created concrete targets ( instances of the
|
||
<code>virtual-target</code> class.)</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It’s possible to lookup a metatarget by target-id using the
|
||
<code>targets.resolve-reference</code> function, and the
|
||
<code>targets.generate-from-reference</code> function can both lookup and generate
|
||
a metatarget.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <a href="#bbv2.reference.class.abstract-target">abstract-target</a> class
|
||
has three immediate derived classes:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><a href="#bbv2.reference.class.project-target">project-target</a> that
|
||
corresponds to a project and is not intended for further subclassing.
|
||
The <a href="#bbv2.reference.class.project-target.generate">generate</a> method
|
||
of this class builds all targets in the project that are not marked as
|
||
explicit.</p>
|
||
</li>
|
||
<li>
|
||
<p><a href="#bbv2.reference.class.main-target">main-target</a> corresponds to a
|
||
target in a project and contains one or more target alternatives. This
|
||
class also should not be subclassed. The
|
||
<a href="#bbv2.reference.class.main-target.generate">generate</a> method of this
|
||
class selects an alternative to build, and calls the
|
||
<a href="#bbv2.reference.class.basic-target.generate">generate</a> method of
|
||
that alternative.</p>
|
||
</li>
|
||
<li>
|
||
<p><a href="#bbv2.reference.class.basic-target">basic-target</a> corresponds to a
|
||
specific target alternative. This is base class, with a number of
|
||
derived classes. The
|
||
<a href="#bbv2.reference.class.basic-target.generate">generate</a> method
|
||
processes the target requirements and requested build properties to
|
||
determine final properties for the target, builds all sources, and
|
||
finally calls the abstract
|
||
<a href="#bbv2.reference.class.basic-target.construct">construct</a> method with
|
||
the list of source virtual targets, and the final properties.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The instances of the
|
||
<a href="#bbv2.reference.class.project-target">project-target</a> and
|
||
<a href="#bbv2.reference.class.main-target">main-target</a> classes are created
|
||
implicitly — when loading a new Jamfiles, or when a new target
|
||
alternative with as-yet unknown name is created. The instances of the
|
||
classes derived from
|
||
<a href="#bbv2.reference.class.basic-target">basic-target</a> are typically
|
||
created when Jamfile calls a metatarget rule, such as such as <code>exe</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It it permissible to create a custom class derived from
|
||
<a href="#bbv2.reference.class.basic-target">basic-target</a> and create new
|
||
metatarget rule that creates instance of such target. However, in the
|
||
majority of cases, a specific subclass of
|
||
<a href="#bbv2.reference.class.basic-target">basic-target</a> — <a href="#bbv2.reference.class.typed-target">typed-target</a> is used. That
|
||
class is associated with a type and relays to generators to construct
|
||
concrete targets of that type. This process will be explained below.
|
||
When a new type is declared, a new metatarget rule is automatically
|
||
defined. That rule creates new instance of type-target, associated with
|
||
that type.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.extender.overview.targets"><a class="anchor" href="#bbv2.extender.overview.targets"></a>8.1.2. Concrete targets</h4>
|
||
<div class="paragraph">
|
||
<p>Concrete targets are represented by instance of classes derived from
|
||
<code>virtual-target</code>. The most commonly used subclass is <code>file-target</code>. A
|
||
file target is associated with an action that creates it —  an
|
||
instance of the <code>action</code> class. The action, in turn, hold a list of
|
||
source targets. It also holds the
|
||
<a href="#bbv2.reference.class.property-set">property-set</a> instance with the
|
||
build properties that should be used for the action.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Here’s an example of creating a target from another target, <code>source</code></p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">local</span><span class="tok-w"> </span>a<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>new<span class="tok-w"> </span>action<span class="tok-w"> </span><span class="tok-si">$(source)</span><span class="tok-w"> </span>:<span class="tok-w"> </span>common.copy<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(property-set)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">local</span><span class="tok-w"> </span>t<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>new<span class="tok-w"> </span>file-target<span class="tok-w"> </span><span class="tok-si">$(name)</span><span class="tok-w"> </span>:<span class="tok-w"> </span>CPP<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(project)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(a)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The first line creates an instance of the <code>action</code> class. The first
|
||
parameter is the list of sources. The second parameter is the name a
|
||
jam-level <a href="#bbv2.overview.jam_language.actions">action</a>. The third
|
||
parameter is the property-set applying to this action. The second line
|
||
creates a target. We specify a name, a type and a project. We also pass
|
||
the action object created earlier. If the action creates several
|
||
targets, we can repeat the second line several times.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In some cases, code that creates concrete targets may be invoked more
|
||
than once with the same properties. Returning two different instances of
|
||
<code>file-target</code> that correspond to the same file clearly will result in
|
||
problems. Therefore, whenever returning targets you should pass them via
|
||
the <code>virtual-target.register</code> function, besides allowing B2 to
|
||
track which virtual targets got created for each metatarget, this will
|
||
also replace targets with previously created identical ones, as
|
||
necessary.<sup class="footnote">[<a id="_footnoteref_5" class="footnote" href="#_footnotedef_5" title="View footnote.">5</a>]</sup> Here are a couple of examples:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">return</span><span class="tok-w"> </span>[<span class="tok-w"> </span>virtual-target.register<span class="tok-w"> </span><span class="tok-si">$(t)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">return</span><span class="tok-w"> </span>[<span class="tok-w"> </span>sequence.transform<span class="tok-w"> </span>virtual-target.register<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(targets)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="bbv2.extender.overview.generators"><a class="anchor" href="#bbv2.extender.overview.generators"></a>8.1.3. Generators</h4>
|
||
<div class="paragraph">
|
||
<p>In theory, every kind of metatarget in B2 (like <code>exe</code>, <code>lib</code> or
|
||
<code>obj</code>) could be implemented by writing a new metatarget class that,
|
||
independently of the other code, figures what files to produce and what
|
||
commands to use. However, that would be rather inflexible. For example,
|
||
adding support for a new compiler would require editing several
|
||
metatargets.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In practice, most files have specific types, and most tools consume and
|
||
produce files of specific type. To take advantage of this fact,
|
||
B2 defines concept of target type and generators generators,
|
||
and has special metatarget class
|
||
<a href="#bbv2.reference.class.typed-target">typed-target</a>. Target type is
|
||
merely an identifier. It is associated with a set of file extensions
|
||
that correspond to that type. Generator is an abstraction of a tool. It
|
||
advertises the types it produces and, if called with a set of input
|
||
target, tries to construct output targets of the advertised types.
|
||
Finally, <a href="#bbv2.reference.class.typed-target">typed-target</a> is
|
||
associated with specific target type, and relays the generator (or
|
||
generators) for that type.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A generator is an instance of a class derived from <code>generator</code>. The
|
||
<code>generator</code> class itself is suitable for common cases. You can define
|
||
derived classes for custom scenarios.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.extender.example"><a class="anchor" href="#bbv2.extender.example"></a>8.2. Example: 1-to-1 generator</h3>
|
||
<div class="paragraph">
|
||
<p>Say you’re writing an application that generates C++ code. If you ever
|
||
did this, you know that it’s not nice. Embedding large portions of C++
|
||
code in string literals is very awkward. A much better solution is:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Write the template of the code to be generated, leaving placeholders
|
||
at the points that will change</p>
|
||
</li>
|
||
<li>
|
||
<p>Access the template in your application and replace placeholders
|
||
with appropriate text.</p>
|
||
</li>
|
||
<li>
|
||
<p>Write the result.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It’s quite easy to achieve. You write special verbatim files that are
|
||
just C++, except that the very first line of the file contains the name
|
||
of a variable that should be generated. A simple tool is created that
|
||
takes a verbatim file and creates a cpp file with a single <code>char*</code>
|
||
variable whose name is taken from the first line of the verbatim file
|
||
and whose value is the file’s properly quoted content.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Let’s see what B2 can do.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>First off, B2 has no idea about "verbatim files". So, you must
|
||
register a new target type. The following code does it:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span>type<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
type.register<span class="tok-w"> </span>VERBATIM<span class="tok-w"> </span>:<span class="tok-w"> </span>verbatim<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The first parameter to
|
||
<a href="#bbv2.reference.modules.type.register">type.register</a> gives the name
|
||
of the declared type. By convention, it’s uppercase. The second
|
||
parameter is the suffix for files of this type. So, if B2 sees
|
||
<code>code.verbatim</code> in a list of sources, it knows that it’s of type
|
||
<code>VERBATIM</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Next, you tell B2 that the verbatim files can be transformed
|
||
into C++ files in one build step. A generator is a template for a build
|
||
step that transforms targets of one type (or set of types) into another.
|
||
Our generator will be called <code>verbatim.inline-file</code>; it transforms
|
||
<code>VERBATIM</code> files into <code>CPP</code> files:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span>generators<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
generators.register-standard<span class="tok-w"> </span>verbatim.inline-file<span class="tok-w"> </span>:<span class="tok-w"> </span>VERBATIM<span class="tok-w"> </span>:<span class="tok-w"> </span>CPP<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Lastly, you have to inform B2 about the shell commands used to
|
||
make that transformation. That’s done with an <code>actions</code> declaration.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">actions</span><span class="tok-w"> </span><span class="tok-nf">inline-file</span><span class="tok-w"></span>
|
||
{<span class="tok-sh"></span>
|
||
<span class="tok-sh"> "./inline-file.py" </span><span class="tok-si">$(<)</span><span class="tok-sh"> </span><span class="tok-si">$(>)</span><span class="tok-sh"></span>
|
||
<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Now, we’re ready to tie it all together. Put all the code above in file
|
||
<code>verbatim.jam</code>, add <code>import verbatim ;</code> to <code>Jamroot.jam</code>, and it’s
|
||
possible to write the following in your Jamfile:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>codegen<span class="tok-w"> </span>:<span class="tok-w"> </span>codegen.cpp<span class="tok-w"> </span>class_template.verbatim<span class="tok-w"> </span>usage.verbatim<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The listed verbatim files will be automatically converted into C++
|
||
source files, compiled and then linked to the <code>codegen</code> executable.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In subsequent sections, we will extend this example, and review all the
|
||
mechanisms in detail. The complete code is available in the
|
||
<code>example/customization</code> directory.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.extending.targets"><a class="anchor" href="#bbv2.extending.targets"></a>8.3. Target types</h3>
|
||
<div class="paragraph">
|
||
<p>The first thing we did in the <a href="#bbv2.extender.intro">introduction</a>
|
||
was declaring a new target type:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span>type<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
type.register<span class="tok-w"> </span>VERBATIM<span class="tok-w"> </span>:<span class="tok-w"> </span>verbatim<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The type is the most important property of a target. B2 can
|
||
automatically generate necessary build actions only because you specify
|
||
the desired type (using the different main target rules), and because
|
||
B2 can guess the type of sources from their extensions.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The first two parameters for the <code>type.register</code> rule are the name of
|
||
new type and the list of extensions associated with it. A file with an
|
||
extension from the list will have the given target type. In the case
|
||
where a target of the declared type is generated from other sources, the
|
||
first specified extension will be used.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Sometimes you want to change the suffix used for generated targets
|
||
depending on build properties, such as toolset. For example, some
|
||
compiler uses extension <code>elf</code> for executable files. You can use the
|
||
<code>type.set-generated-target-suffix</code> rule:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>type.set-generated-target-suffix<span class="tok-w"> </span>EXE<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><toolset></span>elf<span class="tok-w"> </span>:<span class="tok-w"> </span>elf<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A new target type can be inherited from an existing one.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>type.register<span class="tok-w"> </span>PLUGIN<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>SHARED_LIB<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The above code defines a new type derived from <code>SHARED_LIB</code>. Initially,
|
||
the new type inherits all the properties of the base type - in
|
||
particular generators and suffix. Typically, you’ll change the new type
|
||
in some way. For example, using <code>type.set-generated-target-suffix</code> you
|
||
can set the suffix for the new type. Or you can write a special
|
||
generator for the new type. For example, it can generate additional
|
||
meta-information for the plugin. In either way, the <code>PLUGIN</code> type can be
|
||
used whenever <code>SHARED_LIB</code> can. For example, you can directly link
|
||
plugins to an application.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A type can be defined as "main", in which case B2 will
|
||
automatically declare a main target rule for building targets of that
|
||
type. More details can be found
|
||
<a href="#bbv2.extending.rules.main-type">later</a>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.extending.scanners"><a class="anchor" href="#bbv2.extending.scanners"></a>8.4. Scanners</h3>
|
||
<div class="paragraph">
|
||
<p>Sometimes, a file can refer to other files via some include system. To
|
||
make B2 track dependencies between included files, you need to
|
||
provide a scanner. The primary limitation is that only one scanner can
|
||
be assigned to a target type.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>First, we need to declare a new class for the scanner:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">verbatim-scanner</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nc">common-scanner</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">pattern</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span>"//###include[<span class="tok-w"> </span>]*\"([^\"]*)\""<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>All the complex logic is in the <code>common-scanner</code> class, and you only
|
||
need to override the method that returns the regular expression to be
|
||
used for scanning. The parentheses in the regular expression indicate
|
||
which part of the string is the name of the included file. Only the
|
||
first parenthesized group in the regular expression will be recognized;
|
||
if you can’t express everything you want that way, you can return
|
||
multiple regular expressions, each of which contains a parenthesized
|
||
group to be matched.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>After that, we need to register our scanner class:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>scanner.register<span class="tok-w"> </span>verbatim-scanner<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-k">include</span><span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The value of the second parameter, in this case <code>include</code>, specifies the
|
||
properties that contain the list of paths that should be searched for
|
||
the included files.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Finally, we assign the new scanner to the <code>VERBATIM</code> target type:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>type.set-scanner<span class="tok-w"> </span>VERBATIM<span class="tok-w"> </span>:<span class="tok-w"> </span>verbatim-scanner<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>That’s enough for scanning include dependencies.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.extending.tools"><a class="anchor" href="#bbv2.extending.tools"></a>8.5. Tools and generators</h3>
|
||
<div class="paragraph">
|
||
<p>This section will describe how B2 can be extended to support
|
||
new tools.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For each additional tool, a B2 object called generator must be
|
||
created. That object has specific types of targets that it accepts and
|
||
produces. Using that information, B2 is able to automatically
|
||
invoke the generator. For example, if you declare a generator that takes
|
||
a target of the type <code>D</code> and produces a target of the type <code>OBJ</code>, when
|
||
placing a file with extension <code>.d</code> in a list of sources will cause
|
||
B2 to invoke your generator, and then to link the resulting
|
||
object file into an application. (Of course, this requires that you
|
||
specify that the <code>.d</code> extension corresponds to the <code>D</code> type.)</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Each generator should be an instance of a class derived from the
|
||
<code>generator</code> class. In the simplest case, you don’t need to create a
|
||
derived class, but simply create an instance of the <code>generator</code> class.
|
||
Let’s review the example we’ve seen in the
|
||
<a href="#bbv2.extender.intro">introduction</a>.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span>generators<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
generators.register-standard<span class="tok-w"> </span>verbatim.inline-file<span class="tok-w"> </span>:<span class="tok-w"> </span>VERBATIM<span class="tok-w"> </span>:<span class="tok-w"> </span>CPP<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">actions</span><span class="tok-w"> </span><span class="tok-nf">inline-file</span><span class="tok-w"></span>
|
||
{<span class="tok-sh"></span>
|
||
<span class="tok-sh"> "./inline-file.py" </span><span class="tok-si">$(<)</span><span class="tok-sh"> </span><span class="tok-si">$(>)</span><span class="tok-sh"></span>
|
||
<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We declare a standard generator, specifying its id, the source type and
|
||
the target type. When invoked, the generator will create a target of
|
||
type <code>CPP</code> with a source target of type <code>VERBATIM</code> as the only source.
|
||
But what command will be used to actually generate the file? In
|
||
B2, actions are specified using named "actions" blocks and the
|
||
name of the action block should be specified when creating targets. By
|
||
convention, generators use the same name of the action block as their
|
||
own id. So, in above example, the "inline-file" actions block will be
|
||
used to convert the source into the target.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are two primary kinds of generators: standard and composing, which
|
||
are registered with the <code>generators.register-standard</code> and the
|
||
<code>generators.register-composing</code> rules, respectively. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>generators.register-standard<span class="tok-w"> </span>verbatim.inline-file<span class="tok-w"> </span>:<span class="tok-w"> </span>VERBATIM<span class="tok-w"> </span>:<span class="tok-w"> </span>CPP<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
generators.register-composing<span class="tok-w"> </span>mex.mex<span class="tok-w"> </span>:<span class="tok-w"> </span>CPP<span class="tok-w"> </span>LIB<span class="tok-w"> </span>:<span class="tok-w"> </span>MEX<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The first (standard) generator takes a <em>single</em> source of type
|
||
<code>VERBATIM</code> and produces a result. The second (composing) generator takes
|
||
any number of sources, which can have either the <code>CPP</code> or the <code>LIB</code>
|
||
type. Composing generators are typically used for generating top-level
|
||
target type. For example, the first generator invoked when building an
|
||
<code>exe</code> target is a composing generator corresponding to the proper
|
||
linker.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>You should also know about two specific functions for registering
|
||
generators: <code>generators.register-c-compiler</code> and
|
||
<code>generators.register-linker</code>. The first sets up header dependency
|
||
scanning for C files, and the seconds handles various complexities like
|
||
searched libraries. For that reason, you should always use those
|
||
functions when adding support for compilers and linkers.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>(Need a note about UNIX)</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><strong>Custom generator classes</strong></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The standard generators allows you to specify source and target types,
|
||
an action, and a set of flags. If you need anything more complex, you
|
||
need to create a new generator class with your own logic. Then, you have
|
||
to create an instance of that class and register it. Here’s an example
|
||
how you can create your own generator class:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">custom-generator</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nc">generator</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">__init__</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>generator.__init__<span class="tok-w"> </span><span class="tok-si">$(1)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(2)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(3)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(4)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(5)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(6)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(7)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(8)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(9)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
|
||
}<span class="tok-w"></span>
|
||
|
||
generators.register<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>[<span class="tok-w"> </span>new<span class="tok-w"> </span>custom-generator<span class="tok-w"> </span>verbatim.inline-file<span class="tok-w"> </span>:<span class="tok-w"> </span>VERBATIM<span class="tok-w"> </span>:<span class="tok-w"> </span>CPP<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This generator will work exactly like the <code>verbatim.inline-file</code>
|
||
generator we’ve defined above, but it’s possible to customize the
|
||
behavior by overriding methods of the <code>generator</code> class.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are two methods of interest. The <code>run</code> method is responsible for
|
||
the overall process - it takes a number of source targets, converts them
|
||
to the right types, and creates the result. The <code>generated-targets</code>
|
||
method is called when all sources are converted to the right types to
|
||
actually create the result.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>generated-targets</code> method can be overridden when you want to add
|
||
additional properties to the generated targets or use additional
|
||
sources. For a real-life example, suppose you have a program analysis
|
||
tool that should be given a name of executable and the list of all
|
||
sources. Naturally, you don’t want to list all source files manually.
|
||
Here’s how the <code>generated-targets</code> method can find the list of sources
|
||
automatically:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">itrace-generator</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nc">generator</span><span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
...<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">generated-targets</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">project</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>leaves<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>temp<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>virtual-target.traverse<span class="tok-w"> </span><span class="tok-si">$(sources[1])</span><span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-k">include</span>-sources<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>t<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(temp)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span>!<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-si">$(t)</span>.action<span class="tok-w"> </span>]<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>leaves<span class="tok-w"> </span>+=<span class="tok-w"> </span><span class="tok-si">$(t)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span>[<span class="tok-w"> </span>generator.generated-targets<span class="tok-w"> </span><span class="tok-si">$(sources)</span><span class="tok-w"> </span><span class="tok-si">$(leafs)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(property-set)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(project)</span><span class="tok-w"> </span><span class="tok-si">$(name)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
}<span class="tok-w"></span>
|
||
generators.register<span class="tok-w"> </span>[<span class="tok-w"> </span>new<span class="tok-w"> </span>itrace-generator<span class="tok-w"> </span>nm.itrace<span class="tok-w"> </span>:<span class="tok-w"> </span>EXE<span class="tok-w"> </span>:<span class="tok-w"> </span>ITRACE<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>generated-targets</code> method will be called with a single source
|
||
target of type <code>EXE</code>. The call to <code>virtual-target.traverse</code> will return
|
||
all targets the executable depends on, and we further find files that
|
||
are not produced from anything. The found targets are added to the
|
||
sources.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>run</code> method can be overridden to completely customize the way the
|
||
generator works. In particular, the conversion of sources to the desired
|
||
types can be completely customized. Here’s another real example. Tests
|
||
for the Boost Python library usually consist of two parts: a Python
|
||
program and a C++ file. The C++ file is compiled to Python extension
|
||
that is loaded by the Python program. But in the likely case that both
|
||
files have the same name, the created Python extension must be renamed.
|
||
Otherwise, the Python program will import itself, not the extension.
|
||
Here’s how it can be done:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">run</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">project</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>python<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>s<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(sources)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-si">$(s)</span>.type<span class="tok-w"> </span>]<span class="tok-w"> </span>=<span class="tok-w"> </span>PY<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>python<span class="tok-w"> </span>=<span class="tok-w"> </span><span class="tok-si">$(s)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>libs<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>s<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(sources)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span>[<span class="tok-w"> </span>type.is-derived<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-si">$(s)</span>.type<span class="tok-w"> </span>]<span class="tok-w"> </span>LIB<span class="tok-w"> </span>]<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>libs<span class="tok-w"> </span>+=<span class="tok-w"> </span><span class="tok-si">$(s)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>new-sources<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>s<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(sources)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span>[<span class="tok-w"> </span>type.is-derived<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-si">$(s)</span>.type<span class="tok-w"> </span>]<span class="tok-w"> </span>CPP<span class="tok-w"> </span>]<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>name<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-si">$(s)</span>.name<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># get the target's basename</span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-si">$(name)</span><span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-si">$(python)</span>.name<span class="tok-w"> </span>]<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>name<span class="tok-w"> </span>=<span class="tok-w"> </span><span class="tok-si">$(name)</span>_ext<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># rename the target</span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>new-sources<span class="tok-w"> </span>+=<span class="tok-w"> </span>[<span class="tok-w"> </span>generators.construct<span class="tok-w"> </span><span class="tok-si">$(project)</span><span class="tok-w"> </span><span class="tok-si">$(name)</span><span class="tok-w"> </span>:<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>PYTHON_EXTENSION<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(property-set)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(s)</span><span class="tok-w"> </span><span class="tok-si">$(libs)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
|
||
<span class="tok-w"> </span>result<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>construct-result<span class="tok-w"> </span><span class="tok-si">$(python)</span><span class="tok-w"> </span><span class="tok-si">$(new-sources)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(project)</span><span class="tok-w"> </span><span class="tok-si">$(name)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(property-set)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>First, we separate all source into python files, libraries and C++
|
||
sources. For each C++ source we create a separate Python extension by
|
||
calling <code>generators.construct</code> and passing the C++ source and the
|
||
libraries. At this point, we also change the extension’s name, if
|
||
necessary.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.extending.features"><a class="anchor" href="#bbv2.extending.features"></a>8.6. Features</h3>
|
||
<div class="paragraph">
|
||
<p>Often, we need to control the options passed the invoked tools. This is
|
||
done with features. Consider an example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-c1"># Declare a new free feature</span>
|
||
<span class="tok-nb">import</span><span class="tok-w"> </span>feature<span class="tok-w"> </span>:<span class="tok-w"> </span>feature<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
feature<span class="tok-w"> </span>verbatim-options<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span>free<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-c1"># Cause the value of the 'verbatim-options' feature to be</span>
|
||
<span class="tok-c1"># available as 'OPTIONS' variable inside verbatim.inline-file</span>
|
||
<span class="tok-nb">import</span><span class="tok-w"> </span>toolset<span class="tok-w"> </span>:<span class="tok-w"> </span>flags<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
flags<span class="tok-w"> </span>verbatim.inline-file<span class="tok-w"> </span>OPTIONS<span class="tok-w"> </span><span class="tok-na"><verbatim-options></span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-c1"># Use the "OPTIONS" variable</span>
|
||
<span class="tok-k">actions</span><span class="tok-w"> </span><span class="tok-nf">inline-file</span><span class="tok-w"></span>
|
||
{<span class="tok-sh"></span>
|
||
<span class="tok-sh"> "./inline-file.py" </span><span class="tok-si">$(OPTIONS)</span><span class="tok-sh"> </span><span class="tok-si">$(<)</span><span class="tok-sh"> </span><span class="tok-si">$(>)</span><span class="tok-sh"></span>
|
||
<span class="tok-p">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We first define a new feature. Then, the <code>flags</code> invocation says that
|
||
whenever verbatim.inline-file action is run, the value of the
|
||
<code>verbatim-options</code> feature will be added to the <code>OPTIONS</code> variable, and
|
||
can be used inside the action body. You’d need to consult online help
|
||
(--help) to find all the features of the <code>toolset.flags</code> rule.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Although you can define any set of features and interpret their values
|
||
in any way, B2 suggests the following coding standard for
|
||
designing features.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Most features should have a fixed set of values that is portable (tool
|
||
neutral) across the class of tools they are designed to work with. The
|
||
user does not have to adjust the values for a exact tool. For example,
|
||
<code><optimization>speed</code> has the same meaning for all C++ compilers and the
|
||
user does not have to worry about the exact options passed to the
|
||
compiler’s command line.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Besides such portable features there are special 'raw' features that
|
||
allow the user to pass any value to the command line parameters for a
|
||
particular tool, if so desired. For example, the <code><cxxflags></code> feature
|
||
allows you to pass any command line options to a C++ compiler. The
|
||
<code><include></code> feature allows you to pass any string preceded by <code>-I</code> and
|
||
the interpretation is tool-specific. (See <a href="#bbv2.faq.external">Can I get capture external program output using a Boost.Jam variable?</a>
|
||
for an example of very smart usage of that feature). Of course one
|
||
should always strive to use portable features, but these are still be
|
||
provided as a backdoor just to make sure B2 does not take away
|
||
any control from the user.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Using portable features is a good idea because:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>When a portable feature is given a fixed set of values, you can build
|
||
your project with two different settings of the feature and B2
|
||
will automatically use two different directories for generated files.
|
||
B2 does not try to separate targets built with different raw
|
||
options.</p>
|
||
</li>
|
||
<li>
|
||
<p>Unlike with “raw” features, you don’t need to use specific
|
||
command-line flags in your Jamfile, and it will be more likely to work
|
||
with other tools.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><strong>Steps for adding a feature</strong></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Adding a feature requires three steps:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Declaring a feature. For that, the "feature.feature" rule is used.
|
||
You have to decide on the set of
|
||
<a href="#bbv2.reference.features.attributes">feature attributes</a>:</p>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>if you want a feature value set for one target to automatically
|
||
propagate to its dependent targets then make it “propagated”.</p>
|
||
</li>
|
||
<li>
|
||
<p>if a feature does not have a fixed list of values, it must be “free.”
|
||
For example, the <code>include</code> feature is a free feature.</p>
|
||
</li>
|
||
<li>
|
||
<p>if a feature is used to refer to a path relative to the Jamfile, it
|
||
must be a “path” feature. Such features will also get their values
|
||
automatically converted to B2’s internal path representation.
|
||
For example, <code>include</code> is a path feature.</p>
|
||
</li>
|
||
<li>
|
||
<p>if feature is used to refer to some target, it must be a “dependency”
|
||
feature.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>Representing the feature value in a target-specific variable. Build
|
||
actions are command templates modified by Boost.Jam variable expansions.
|
||
The <code>toolset.flags</code> rule sets a target-specific variable to the value of
|
||
a feature.</p>
|
||
</li>
|
||
<li>
|
||
<p>Using the variable. The variable set in step 2 can be used in a
|
||
build action to form command parameters or files.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><strong>Another example</strong></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Here’s another example. Let’s see how we can make a feature that refers
|
||
to a target. For example, when linking dynamic libraries on Windows, one
|
||
sometimes needs to specify a "DEF file", telling what functions should
|
||
be exported. It would be nice to use this file like this:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><def-file></span>a.def<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Actually, this feature is already supported, but anyway…​</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>Since the feature refers to a target, it must be "dependency".</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>feature def-file : : free dependency ;</pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>One of the toolsets that cares about DEF files is msvc. The
|
||
following line should be added to it.</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>flags msvc.link DEF_FILE <def-file> ;</pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>Since the DEF_FILE variable is not used by the msvc.link action, we
|
||
need to modify it to be:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>actions link bind DEF_FILE
|
||
{
|
||
$(.LD) .... /DEF:$(DEF_FILE) ....
|
||
}</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note the <code>bind DEF_FILE</code> part. It tells B2 to translate the
|
||
internal target name in <code>DEF_FILE</code> to a corresponding filename in the
|
||
<code>link</code> action. Without it the expansion of <code>$(DEF_FILE)</code> would be a
|
||
strange symbol that is not likely to make sense for the linker.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>We are almost done, except for adding the following code to <code>msvc.jam</code>:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>rule link
|
||
{
|
||
DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ;
|
||
}</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This is a workaround for a bug in B2 engine, which will
|
||
hopefully be fixed one day.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><strong>Variants and composite features.</strong></p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Sometimes you want to create a shortcut for some set of features. For
|
||
example, <code>release</code> is a value of <code><variant></code> and is a shortcut for a set
|
||
of features.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>It is possible to define your own build variants. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>variant<span class="tok-w"> </span>crazy<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><optimization></span>speed<span class="tok-w"> </span><span class="tok-na"><inlining></span>off<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><debug-symbols></span>on<span class="tok-w"> </span><span class="tok-na"><profiling></span>on<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will define a new variant with the specified set of properties. You can
|
||
also extend an existing variant:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>variant<span class="tok-w"> </span>super_release<span class="tok-w"> </span>:<span class="tok-w"> </span>release<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><define></span>USE_ASM<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>In this case, <code>super_release</code> will expand to all properties specified by
|
||
<code>release</code>, and the additional one you’ve specified.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>You are not restricted to using the <code>variant</code> feature only. Here’s
|
||
example that defines a brand new feature:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>feature<span class="tok-w"> </span>parallelism<span class="tok-w"> </span>:<span class="tok-w"> </span>mpi<span class="tok-w"> </span>fake<span class="tok-w"> </span>none<span class="tok-w"> </span>:<span class="tok-w"> </span>composite<span class="tok-w"> </span><span class="tok-nb">link</span>-incompatible<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
feature.compose<span class="tok-w"> </span><span class="tok-na"><parallelism></span>mpi<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><library></span>/mpi//mpi/<span class="tok-na"><parallelism></span>none<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
feature.compose<span class="tok-w"> </span><span class="tok-na"><parallelism></span>fake<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><library></span>/mpi//fake/<span class="tok-na"><parallelism></span>none<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This will allow you to specify the value of feature <code>parallelism</code>, which
|
||
will expand to link to the necessary library.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.extending.rules"><a class="anchor" href="#bbv2.extending.rules"></a>8.7. Main target rules</h3>
|
||
<div class="paragraph">
|
||
<p>A main target rule (e.g “<a href="#bbv2.tasks.programs">exe</a>” Or
|
||
“<a href="#bbv2.tasks.libraries">lib</a>”) creates a top-level target. It’s
|
||
quite likely that you’ll want to declare your own and there are two ways
|
||
to do that.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><a id="bbv2.extending.rules.main-type"></a>The first way applies when your target rule
|
||
should just produce a target
|
||
of specific type. In that case, a rule is already defined for you! When
|
||
you define a new type, B2 automatically defines a corresponding
|
||
rule. The name of the rule is obtained from the name of the type, by
|
||
down-casing all letters and replacing underscores with dashes. For
|
||
example, if you create a module <code>obfuscate.jam</code> containing:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span>type<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
type.register<span class="tok-w"> </span>OBFUSCATED_CPP<span class="tok-w"> </span>:<span class="tok-w"> </span>ocpp<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-nb">import</span><span class="tok-w"> </span>generators<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
generators.register-standard<span class="tok-w"> </span>obfuscate.file<span class="tok-w"> </span>:<span class="tok-w"> </span>CPP<span class="tok-w"> </span>:<span class="tok-w"> </span>OBFUSCATED_CPP<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>and import that module, you’ll be able to use the rule "obfuscated-cpp"
|
||
in Jamfiles, which will convert source to the OBFUSCATED_CPP type.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The second way is to write a wrapper rule that calls any of the existing
|
||
rules. For example, suppose you have only one library per directory and
|
||
want all cpp files in the directory to be compiled into that library.
|
||
You can achieve this effect using:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>codegen<span class="tok-w"> </span>:<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">glob</span><span class="tok-w"> </span>*.cpp<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you want to make it even simpler, you could add the following
|
||
definition to the <code>Jamroot.jam</code> file:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">glib</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">extra-sources</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">requirements</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nb">lib</span><span class="tok-w"> </span><span class="tok-si">$(name)</span><span class="tok-w"> </span>:<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">glob</span><span class="tok-w"> </span>*.cpp<span class="tok-w"> </span>]<span class="tok-w"> </span><span class="tok-si">$(extra-sources)</span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(requirements)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>allowing you to reduce the Jamfile to just</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>glib<span class="tok-w"> </span>codegen<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that because you can associate a custom generator with a target
|
||
type, the logic of building can be rather complicated. For example, the
|
||
<code>boostbook</code> module declares a target type <code>BOOSTBOOK_MAIN</code> and a custom
|
||
generator for that type. You can use that as example if your main target
|
||
rule is non-trivial.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.extending.toolset_modules"><a class="anchor" href="#bbv2.extending.toolset_modules"></a>8.8. Toolset modules</h3>
|
||
<div class="paragraph">
|
||
<p>If your extensions will be used only on one project, they can be placed
|
||
in a separate <code>.jam</code> file and imported by your <code>Jamroot.jam</code>. If the
|
||
extensions will be used on many projects, users will thank you for a
|
||
finishing touch.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>using</code> rule provides a standard mechanism for loading and
|
||
configuring extensions. To make it work, your module should provide an
|
||
<code>init</code> rule. The rule will be called with the same parameters that were
|
||
passed to the <code>using</code> rule. The set of allowed parameters is determined
|
||
by you. For example, you can allow the user to specify paths, tool
|
||
versions, and other options.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Here are some guidelines that help to make B2 more consistent:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>The <code>init</code> rule should never fail. Even if the user provided an
|
||
incorrect path, you should emit a warning and go on. Configuration may
|
||
be shared between different machines, and wrong values on one machine
|
||
can be OK on another.</p>
|
||
</li>
|
||
<li>
|
||
<p>Prefer specifying the command to be executed to specifying the tool’s
|
||
installation path. First of all, this gives more control: it’s possible
|
||
to specify</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>/usr/bin/g++-snapshot
|
||
time g++</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>as the command. Second, while some tools have a logical "installation
|
||
root", it’s better if the user doesn’t have to remember whether a
|
||
specific tool requires a full command or a path.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>Check for multiple initialization. A user can try to initialize the
|
||
module several times. You need to check for this and decide what to do.
|
||
Typically, unless you support several versions of a tool, duplicate
|
||
initialization is a user error. If the tool’s version can be specified
|
||
during initialization, make sure the version is either always specified,
|
||
or never specified (in which case the tool is initialized only once). For
|
||
example, if you allow:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using yfc ;
|
||
using yfc : 3.3 ;
|
||
using yfc : 3.4 ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Then it’s not clear if the first initialization corresponds to version
|
||
3.3 of the tool, version 3.4 of the tool, or some other version. This
|
||
can lead to building twice with the same version.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>If possible, <code>init</code> must be callable with no parameters. In which
|
||
case, it should try to autodetect all the necessary information, for
|
||
example, by looking for a tool in PATH or in common installation
|
||
locations. Often this is possible and allows the user to simply write:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using yfc ;</pre>
|
||
</div>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>Consider using facilities in the <code>tools/common</code> module. You can take a
|
||
look at how <code>tools/gcc.jam</code> uses that module in the <code>init</code> rule.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.faq"><a class="anchor" href="#bbv2.faq"></a>9. Frequently Asked Questions</h2>
|
||
<div class="sectionbody">
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.featurevalue"><a class="anchor" href="#bbv2.faq.featurevalue"></a>9.1. How do I get the current value of feature in Jamfile?</h3>
|
||
<div class="paragraph">
|
||
<p>This is not possible, since Jamfile does not have "current" value of any
|
||
feature, be it toolset, build variant or anything else. For a single run
|
||
of B2, any given main target can be built with several property
|
||
sets. For example, user can request two build variants on the command
|
||
line. Or one library is built as shared when used from one application,
|
||
and as static when used from another. Each Jamfile is read only once so
|
||
generally there is no single value of a feature you can access in
|
||
Jamfile.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A feature has a specific value only when building a target, and there
|
||
are two ways you can use that value:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Use conditional requirements or indirect conditional requirements. See
|
||
<a href="#bbv2.overview.targets.requirements.conditional">the section called “Requirements”</a>.</p>
|
||
</li>
|
||
<li>
|
||
<p>Define a custom generator and a custom main target type. The custom
|
||
generator can do arbitrary processing or properties. See the
|
||
<a href="#bbv2.extender">extender manual</a></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.duplicate"><a class="anchor" href="#bbv2.faq.duplicate"></a>9.2. I am getting a "Duplicate name of actual target" error. What does that mean?</h3>
|
||
<div class="paragraph">
|
||
<p>The most likely case is that you are trying to compile the same file
|
||
twice, with almost the same, but differing properties. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The above snippet requires two different compilations of <code>a.cpp</code>, which
|
||
differ only in their <code>include</code> property. Since the <code>include</code> feature is
|
||
declared as <code>free</code> B2 does not create a separate build
|
||
directory for each of its values and those two builds would both produce
|
||
object files generated in the same build directory. Ignoring this and
|
||
compiling the file only once would be dangerous as different includes
|
||
could potentially cause completely different code to be compiled.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To solve this issue, you need to decide if the file should be compiled
|
||
once or twice.</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>To compile the file only once, make sure that properties are the
|
||
same for both target requests:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>or:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">alias</span><span class="tok-w"> </span>a-with-include<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a-with-include<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>a-with-include<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>or if you want the <code>includes</code> property not to affect how any other
|
||
sources added for the built <code>a</code> and <code>b</code> executables would be compiled:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">obj</span><span class="tok-w"> </span>a-obj<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a-obj<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>a-obj<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that in both of these cases the <code>include</code> property will be applied
|
||
only for building these object files and not any other sources that
|
||
might be added for targets <code>a</code> and <code>b</code>.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>To compile the file twice, you can tell B2 to compile it to
|
||
two separate object files like so:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">obj</span><span class="tok-w"> </span>a_obj<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">obj</span><span class="tok-w"> </span>b_obj<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a_obj<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>b_obj<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>or you can make the object file targets local to the main target:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">obj</span><span class="tok-w"> </span>a_obj<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>/usr/local/include<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">obj</span><span class="tok-w"> </span>a_obj<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>which will cause B2 to actually change the generated object
|
||
file names a bit for you and thus avoid any conflicts.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that in both of these cases the <code>include</code> property will be applied
|
||
only for building these object files and not any other sources that
|
||
might be added for targets <code>a</code> and <code>b</code>.</p>
|
||
</div>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A good question is why B2 can not use some of the above
|
||
approaches automatically. The problem is that such magic would only help
|
||
in half of the cases, while in the other half it would be silently doing
|
||
the wrong thing. It is simpler and safer to ask the user to clarify his
|
||
intention in such cases.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.envar"><a class="anchor" href="#bbv2.faq.envar"></a>9.3. Accessing environment variables</h3>
|
||
<div class="paragraph">
|
||
<p>Many users would like to use environment variables in Jamfiles, for
|
||
example, to control the location of external libraries. In many cases it
|
||
is better to declare those external libraries in the site-config.jam
|
||
file, as documented in the <a href="#bbv2.recipes.site-config">recipes
|
||
section</a>. However, if the users already have the environment variables
|
||
set up, it may not be convenient for them to set up their
|
||
site-config.jam files as well and using the environment variables might
|
||
be reasonable.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Boost.Jam automatically imports all environment variables into its
|
||
built-in .ENVIRON module so user can read them from there directly or by
|
||
using the helper os.environ rule. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span>os<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">local</span><span class="tok-w"> </span>unga-unga<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>os.environ<span class="tok-w"> </span>UNGA_UNGA<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">ECHO</span><span class="tok-w"> </span><span class="tok-si">$(unga-unga)</span><span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>or a bit more realistic:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">import</span><span class="tok-w"> </span>os<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">local</span><span class="tok-w"> </span>SOME_LIBRARY_PATH<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>os.environ<span class="tok-w"> </span>SOME_LIBRARY_PATH<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span><span class="tok-si">$(SOME_LIBRARY_PATH)</span><span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.proporder"><a class="anchor" href="#bbv2.faq.proporder"></a>9.4. How to control properties order?</h3>
|
||
<div class="paragraph">
|
||
<p>For internal reasons, B2 sorts all the properties
|
||
alphabetically. This means that if you write:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>b<span class="tok-w"> </span><span class="tok-na"><include></span>a<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>then the command line with first mention the <code>a</code> include directory, and
|
||
then <code>b</code>, even though they are specified in the opposite order. In most
|
||
cases, the user does not care. But sometimes the order of includes, or
|
||
other properties, is important. For such cases, a special syntax is
|
||
provided:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>a&&b<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>&&</code> symbols separate property values and specify that their order
|
||
should be preserved. You are advised to use this feature only when the
|
||
order of properties really matters and not as a convenient shortcut.
|
||
Using it everywhere might negatively affect performance.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.liborder"><a class="anchor" href="#bbv2.faq.liborder"></a>9.5. How to control the library linking order on Unix?</h3>
|
||
<div class="paragraph">
|
||
<p>On Unix-like operating systems, the order in which static libraries are
|
||
specified when invoking the linker is important, because by default, the
|
||
linker uses one pass though the libraries list. Passing the libraries in
|
||
the incorrect order will lead to a link error. Further, this behavior
|
||
is often used to make one library override symbols from another. So,
|
||
sometimes it is necessary to force specific library linking order.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>B2 tries to automatically compute the right order. The primary
|
||
rule is that if library <code>a</code> "uses" library <code>b</code>, then library <code>a</code> will
|
||
appear on the command line before library <code>b</code>. Library <code>a</code> is considered
|
||
to use <code>b</code> if <code>b</code> is present either in the <code>a</code> library’s sources or its
|
||
usage is listed in its requirements. To explicitly specify the <code>use</code>
|
||
relationship one can use the <code><use></code> feature. For example, both of the
|
||
following lines will cause <code>a</code> to appear before <code>b</code> on the command line:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>b<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><use></span>b<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The same approach works for searched libraries as well:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">lib</span><span class="tok-w"> </span>z<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>png<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><use></span>z<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">exe</span><span class="tok-w"> </span>viewer<span class="tok-w"> </span>:<span class="tok-w"> </span>viewer<span class="tok-w"> </span>png<span class="tok-w"> </span>z<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.external"><a class="anchor" href="#bbv2.faq.external"></a>9.6. Can I get capture external program output using a Boost.Jam variable?</h3>
|
||
<div class="paragraph">
|
||
<p>The <code>SHELL</code> builtin rule may be used for this purpose:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">local</span><span class="tok-w"> </span>gtk_includes<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">SHELL</span><span class="tok-w"> </span>"gtk-config<span class="tok-w"> </span>--cflags"<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.projectroot"><a class="anchor" href="#bbv2.faq.projectroot"></a>9.7. How to get the project root (a.k.a. Jamroot) location?</h3>
|
||
<div class="paragraph">
|
||
<p>You might want to use your project’s root location in your Jamfiles. To
|
||
access it just declare a path constant in your <code>Jamroot.jam</code> file using:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">path-constant</span><span class="tok-w"> </span>TOP<span class="tok-w"> </span>:<span class="tok-w"> </span>.<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>After that, the <code>TOP</code> variable can be used in every Jamfile.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.flags"><a class="anchor" href="#bbv2.faq.flags"></a>9.8. How to change compilation flags for one file?</h3>
|
||
<div class="paragraph">
|
||
<p>If one file must be compiled with special options, you need to
|
||
explicitly declare an <code>obj</code> target for that file and then use that
|
||
target in your <code>exe</code> or <code>lib</code> target:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>b<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">obj</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>b.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><optimization></span>off<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Of course you can use other properties, for example to specify specific
|
||
C/C++ compiler options:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>b<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">obj</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>b.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><cflags></span>-g<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>You can also use <a href="#bbv2.tutorial.conditions">conditional properties</a>
|
||
for finer control:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>a<span class="tok-w"> </span>:<span class="tok-w"> </span>a.cpp<span class="tok-w"> </span>b<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">obj</span><span class="tok-w"> </span>b<span class="tok-w"> </span>:<span class="tok-w"> </span>b.cpp<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><variant></span>release:<span class="tok-na"><optimization></span>off<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.dll-path"><a class="anchor" href="#bbv2.faq.dll-path"></a>9.9. Why are the <code>dll-path</code> and <code>hardcode-dll-paths</code> properties useful?</h3>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
This entry is specific to Unix systems.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Before answering the questions, let us recall a few points about shared
|
||
libraries. Shared libraries can be used by several applications, or
|
||
other libraries, without physically including the library in the
|
||
application which can greatly decrease the total application size. It is
|
||
also possible to upgrade a shared library when the application is
|
||
already installed.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>However, in order for application depending on shared libraries to be
|
||
started the OS may need to find the shared library when the application
|
||
is started. The dynamic linker will search in a system-defined list of
|
||
paths, load the library and resolve the symbols. Which means that you
|
||
should either change the system-defined list, given by the
|
||
<code>LD_LIBRARY_PATH</code> environment variable, or install the libraries to a
|
||
system location. This can be inconvenient when developing, since the
|
||
libraries are not yet ready to be installed, and cluttering system paths
|
||
may be undesirable. Luckily, on Unix there is another way.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>An executable can include a list of additional library paths, which will
|
||
be searched before system paths. This is excellent for development
|
||
because the build system knows the paths to all libraries and can
|
||
include them in the executables. That is done when the
|
||
<code>hardcode-dll-paths</code> feature has the <code>true</code> value, which is the default.
|
||
When the executables should be installed, the story is different.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Obviously, installed executable should not contain hardcoded paths to
|
||
your development tree. (The <code>install</code> rule explicitly disables the
|
||
<code>hardcode-dll-paths</code> feature for that reason.) However, you can use the
|
||
<code>dll-path</code> feature to add explicit paths manually. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">install</span><span class="tok-w"> </span>installed<span class="tok-w"> </span>:<span class="tok-w"> </span>application<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><dll-path></span>/usr/lib/snake<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><location></span>/usr/bin<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>will allow the application to find libraries placed in the
|
||
<code>/usr/lib/snake</code> directory.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you install libraries to a nonstandard location and add an explicit
|
||
path, you get more control over libraries which will be used. A library
|
||
of the same name in a system location will not be inadvertently used. If
|
||
you install libraries to a system location and do not add any paths, the
|
||
system administrator will have more control. Each library can be
|
||
individually upgraded, and all applications will use the new library.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Which approach is best depends on your situation. If the libraries are
|
||
relatively standalone and can be used by third party applications, they
|
||
should be installed in the system location. If you have lots of
|
||
libraries which can be used only by your application, it makes sense to
|
||
install them to a nonstandard directory and add an explicit path, like
|
||
the example above shows. Please also note that guidelines for different
|
||
systems differ in this respect. For example, the Debian GNU guidelines
|
||
prohibit any additional search paths while Solaris guidelines suggest
|
||
that they should always be used.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.recipes.site-config"><a class="anchor" href="#bbv2.recipes.site-config"></a>9.10. Targets in site-config.jam</h3>
|
||
<div class="paragraph">
|
||
<p>It is desirable to declare standard libraries available on a given
|
||
system. Putting target declaration in a specific project’s Jamfile is
|
||
not really good, since locations of the libraries can vary between
|
||
different development machines and then such declarations would need to
|
||
be duplicated in different projects. The solution is to declare the
|
||
targets in B2’s <code>site-config.jam</code> configuration file:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"> </span>site-config<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">lib</span><span class="tok-w"> </span>zlib<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><name></span>z<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Recall that both <code>site-config.jam</code> and <code>user-config.jam</code> are projects,
|
||
and everything you can do in a Jamfile you can do in those files as
|
||
well. So, you declare a project id and a target. Now, one can write:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>/site-config//zlib<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>in any Jamfile.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.header-only-libraries"><a class="anchor" href="#bbv2.faq.header-only-libraries"></a>9.11. Header-only libraries</h3>
|
||
<div class="paragraph">
|
||
<p>In modern C++, libraries often consist of just header files, without any
|
||
source files to compile. To use such libraries, you need to add proper
|
||
includes and possibly defines to your project. But with a large number
|
||
of external libraries it becomes problematic to remember which libraries
|
||
are header only, and which ones you have to link to. However, with
|
||
B2 a header-only library can be declared as B2 target
|
||
and all dependents can use such library without having to remember
|
||
whether it is a header-only library or not.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Header-only libraries may be declared using the <code>alias</code> rule, specifying
|
||
their include path as a part of its usage requirements, for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">alias</span><span class="tok-w"> </span>my-lib<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-c1"># no sources</span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-c1"># no build requirements</span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-c1"># no default build</span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><include></span>whatever<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The includes specified in usage requirements of <code>my-lib</code> are
|
||
automatically added to all of its dependents build properties. The
|
||
dependents need not care if <code>my-lib</code> is a header-only or not, and it is
|
||
possible to later make <code>my-lib</code> into a regular compiled library without
|
||
having to add the includes to its dependents declarations.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you already have proper usage requirements declared for a project
|
||
where a header-only library is defined, you do not need to duplicate
|
||
them for the <code>alias</code> target:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"> </span>my<span class="tok-w"> </span>:<span class="tok-w"> </span>usage-requirements<span class="tok-w"> </span><span class="tok-na"><include></span>whatever<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">alias</span><span class="tok-w"> </span>mylib<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="bbv2.faq.names"><a class="anchor" href="#bbv2.faq.names"></a>9.12. What is the difference between B2, <code>b2</code>, <code>bjam</code> and Perforce Jam?</h3>
|
||
<div class="paragraph">
|
||
<p>B2 is the name of the complete build system. The executable
|
||
that runs it is <code>b2</code>. That executable is written in C and implements
|
||
performance-critical algorithms, like traversal of dependency graph and
|
||
executing commands. It also implements an interpreted language used to
|
||
implement the rest of B2. This executable is formally called
|
||
"B2 engine".</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The B2 engine is derived from an earlier build tool called
|
||
Perforce Jam. Originally, there were just minor changes, and the
|
||
filename was <code>bjam</code>. Later on, with more and more changes, the
|
||
similarity of names became a disservice to users, and as of Boost
|
||
1.47.0, the official name of the executable was changed to <code>b2</code>. A copy
|
||
named <code>bjam</code> is still created for compatibility, but you are encouraged
|
||
to use the new name in all cases.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Perforce Jam was an important foundation, and we gratefully acknowledge
|
||
its influence, but for users today, these tools share only some basics
|
||
of the interpreted language.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="_extra_tools"><a class="anchor" href="#_extra_tools"></a>10. Extra Tools</h2>
|
||
<div class="sectionbody">
|
||
<div class="sect2">
|
||
<h3 id="_documentation_tools_2"><a class="anchor" href="#_documentation_tools_2"></a>10.1. Documentation Tools</h3>
|
||
<div class="sect3">
|
||
<h4 id="_asciidoctor"><a class="anchor" href="#_asciidoctor"></a>10.1.1. Asciidoctor</h4>
|
||
<div class="paragraph">
|
||
<p>The asciidoctor tool converts the ascidoc documentation format to various
|
||
backend formats for either viewing or further processing by documentation
|
||
tools. This tool supports the baseline asciidoctor distribution (i.e. the
|
||
Ruby based tool).</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_feature_asciidoctor_attribute"><a class="anchor" href="#_feature_asciidoctor_attribute"></a>Feature: <code>asciidoctor-attribute</code></h5>
|
||
<div class="paragraph">
|
||
<p>Defines arbitrary asciidoctor attributes. The value of the feature should be
|
||
specified with the CLI syntax for attributes.
|
||
For example to use as a target requirement:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>html<span class="tok-w"> </span>example<span class="tok-w"> </span>:<span class="tok-w"> </span>example.adoc<span class="tok-w"> </span>:<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><asciidoctor-attribute></span>idprefix=ex<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This is a <code>free</code> feature and is not <code>propagated</code>. I.e. it applies only to the
|
||
target it’s specified on.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_feature_asciidoctor_doctype"><a class="anchor" href="#_feature_asciidoctor_doctype"></a>Feature: <code>asciidoctor-doctype</code></h5>
|
||
<div class="paragraph">
|
||
<p>Specifies the <code>doctype</code> to use for generating the output format. Allowed
|
||
<code>doctype</code> values are: <code>article</code>, <code>book</code>, <code>manpage</code>, and <code>inline</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_feature_asciidoctor_backend"><a class="anchor" href="#_feature_asciidoctor_backend"></a>Feature: <code>asciidoctor-backend</code></h5>
|
||
<div class="paragraph">
|
||
<p>Specifies the <code>backend</code> to use to produce output from the source asciidoc.
|
||
This feature is automatically applied to fit the build target type. For
|
||
example, when specifying an <code>html</code> target for an <code>asciidoc</code> source:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>html<span class="tok-w"> </span>example<span class="tok-w"> </span>:<span class="tok-w"> </span>example.adoc<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The target will by default acquire the <code><asciidoctor-backend>html5</code>
|
||
requirement. The default for each target type are:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>html</code>: <code><asciidoctor-backend>html5</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>docbook</code>: <code><asciidoctor-backend>docbook45</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>man</code>: <code><asciidoctor-backend>manpage</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>pdf</code>: <code><asciidoctor-backend>pdf</code></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>To override the defaults you specify it as a requirement on the target:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>docbook<span class="tok-w"> </span>example<span class="tok-w"> </span>:<span class="tok-w"> </span>example.adoc<span class="tok-w"> </span>:<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><asciidoctor-backend></span>docbook5<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Allowed <code>backend</code> values are: <code>html5</code>, <code>docbook45</code>, <code>docbook5</code>, <code>pdf</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_initialization"><a class="anchor" href="#_initialization"></a>Initialization</h5>
|
||
<div class="paragraph">
|
||
<p>To use the <code>asciidoctor</code> tool you need to declare it in a configuration file
|
||
with the <code>using</code> rule. The initialization takes the following arguments:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>command</code>: The command, with any extra arguments, to execute.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example you could insert the following in your <code>user-config.jam</code>:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>asciidoctor<span class="tok-w"> </span>:<span class="tok-w"> </span>"/usr/local/bin/asciidoctor"<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If no <code>command</code> is given it defaults to just <code>asciidoctor</code> with assumption
|
||
that the <code>asciidoctor</code> is available in the search <code>PATH</code>.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_miscellaneous_tools"><a class="anchor" href="#_miscellaneous_tools"></a>10.2. Miscellaneous Tools</h3>
|
||
<div class="sect3">
|
||
<h4 id="_pkg_config"><a class="anchor" href="#_pkg_config"></a>10.2.1. pkg-config</h4>
|
||
<div class="paragraph">
|
||
<p>The <strong>pkg-config</strong> program is used to retrieve information about installed
|
||
libraries in the system. It retrieves information about packages from special
|
||
metadata files. These files are named after the package, and have a <code>.pc</code>
|
||
extension. The package name specified to <strong>pkg-config</strong> is defined to be the name
|
||
of the metadata file, minus the <code>.pc</code> extension.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_feature_pkg_config"><a class="anchor" href="#_feature_pkg_config"></a>Feature: <code>pkg-config</code></h5>
|
||
<div class="paragraph">
|
||
<p>Selects one of the initialized <code>pkg-config</code> configurations. This feature is
|
||
<code>propagated</code> to dependencies. Its use is dicussed in
|
||
section <a href="#pkg-config-init">[pkg-config-init]</a>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_feature_pkg_config_define"><a class="anchor" href="#_feature_pkg_config_define"></a>Feature: <code>pkg-config-define</code></h5>
|
||
<div class="paragraph">
|
||
<p>This <code>free</code> feature adds a variable assignment to pkg-config invocation. For
|
||
example,</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>pkg-config.import<span class="tok-w"> </span>mypackage<span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"> </span><span class="tok-na"><pkg-config-define></span>key=value<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>is equivalent to invoking on the comand line</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>pkg-config --define-variable<span class="tok-o">=</span><span class="tok-nv">key</span><span class="tok-o">=</span>value mypackage <span class="tok-p">;</span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_rule_import"><a class="anchor" href="#_rule_import"></a>Rule: <code>import</code></h5>
|
||
<div class="paragraph">
|
||
<p>Main target rule that imports a <strong>pkg-config</strong> package. When its consumer targets
|
||
are built, <strong>pkg-config</strong> command will be invoked with arguments that depend on
|
||
current property set. The features that have an effect are:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code><pkg-config-define></code>: adds a <code>--define-variable</code> argument;</p>
|
||
</li>
|
||
<li>
|
||
<p><code><link></code>: adds <code>--static</code> argument when <code><link>static</code>;</p>
|
||
</li>
|
||
<li>
|
||
<p><code><link></code>: adds <code>--static</code> argument when <code><link>static</code>;</p>
|
||
</li>
|
||
<li>
|
||
<p><code><name></code>: specifies package name (target name is used instead if the property
|
||
is not present);</p>
|
||
</li>
|
||
<li>
|
||
<p><code><version></code>: specifies package version range, can be used multiple times and
|
||
should be a dot-separated sequence of numbers optionally prefixed with <code>=</code>,
|
||
<code><</code>, <code>></code>, <code>⇐</code> or <code>>=</code>.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>pkg-config.import<span class="tok-w"> </span>my-package<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"> </span><span class="tok-na"><name></span>my_package<span class="tok-w"> </span><span class="tok-na"><version><4</span><span class="tok-err"> </span><span class="tok-na"><version>></span>=3.1<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_initialization_pkg_config_init"><a class="anchor" href="#_initialization_pkg_config_init"></a>Initialization [[ pkg-config-init ]]</h5>
|
||
<div class="paragraph">
|
||
<p>To use the <code>pkg-config</code> tool you need to declare it in a configuration file
|
||
with the <code>using</code> rule:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>pkg-config<span class="tok-w"> </span>:<span class="tok-w"> </span>[config]<span class="tok-w"> </span>:<span class="tok-w"> </span>[command]<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>[<span class="tok-w"> </span>options<span class="tok-w"> </span>]<span class="tok-w"> </span>...<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>config</code>: the name of initialized configuration. The name can be omitted, in
|
||
which case the configuration will become the default one.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>command</code>: the command, with any extra arguments, to execute. If no command
|
||
is given, first <code>PKG_CONFIG</code> environment variable is checked, and if its
|
||
empty the string <code>pkg-config</code> is used.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>options</code>: options that modify <code>pkg-config</code> behavior. Allowed options are:</p>
|
||
</li>
|
||
<li>
|
||
<p><code><path></code>: sets <code>PKG_CONFIG_PATH</code> environment variable;
|
||
multiple occurences are allowed.</p>
|
||
</li>
|
||
<li>
|
||
<p><code><libdir></code>: sets <code>PKG_CONFIG_LIBDIR</code> environment variable;
|
||
multiple occurences are allowed.</p>
|
||
</li>
|
||
<li>
|
||
<p><code><allow-system-cflags></code>: sets <code>PKG_CONFIG_ALLOW_SYSTEM_CFLAGS</code>
|
||
environment variable; multiple occurences are allowed.</p>
|
||
</li>
|
||
<li>
|
||
<p><code><allow-system-libs></code>: sets <code>PKG_CONFIG_ALLOW_SYSTEM_LIBS</code>
|
||
environment variable; multiple occurences are allowed.</p>
|
||
</li>
|
||
<li>
|
||
<p><code><sysroot></code>: sets <code>PKG_CONFIG_SYSROOT_DIR</code> environment variable;
|
||
multiple occurences are allowed.</p>
|
||
</li>
|
||
<li>
|
||
<p><code><variable></code>: adds a variable definition argument to command invocation;
|
||
multiple occurences are allowed.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_class_pkg_config_target"><a class="anchor" href="#_class_pkg_config_target"></a>Class <code>pkg-config-target</code></h5>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">class</span><span class="tok-w"> </span><span class="tok-nc">pkg-config-target</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nc">alias-target-class</span><span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">construct</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">sources</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">version</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">variable</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">name</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">property-set</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The class of objects returned by <code>import</code> rule. The objects themselves could be
|
||
useful in situations that require more complicated logic for consuming a
|
||
package. See <a href="#pkg-config-tips">Tips</a> for examples.</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>rule construct ( name : sources * : property-set )</code>
|
||
Overrides <code>alias-target.construct</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>rule version ( property-set )</code>
|
||
Returns the package’s version, in the context of <code>property-set</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>rule variable ( name : property-set )</code>
|
||
Returns the value of variable <code>name</code> in the package, in the context of
|
||
<code>property-set</code>.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="pkg-config-tips"><a class="anchor" href="#pkg-config-tips"></a>Tips</h5>
|
||
<div class="sect5">
|
||
<h6 id="_using_several_configurations"><a class="anchor" href="#_using_several_configurations"></a>Using several configurations</h6>
|
||
<div class="paragraph">
|
||
<p>Suppose, you have 2 collections of <code>.pc</code> files: one for platform A, and another
|
||
for platform B. You can initialize 2 configurations of <code>pkg-config</code> tool each
|
||
corresponding to specific collection:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>pkg-config<span class="tok-w"> </span>:<span class="tok-w"> </span>A<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><libdir></span>path/to/collection/A<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">using</span><span class="tok-w"> </span>pkg-config<span class="tok-w"> </span>:<span class="tok-w"> </span>B<span class="tok-w"> </span>:<span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-na"><libdir></span>path/to/collection/B<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Then, you can specify that builds for platform A should use configuration A,
|
||
while builds for B should use configuration B:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">project</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><target-os></span>A-os,<span class="tok-na"><architecture></span>A-arch:<span class="tok-na"><pkg-config></span>A<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-na"><target-os></span>B-os,<span class="tok-na"><architecture></span>B-arch:<span class="tok-na"><pkg-config></span>B<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Thanks to the fact, that <code>project-config</code>, <code>user-config</code> and <code>site-config</code>
|
||
modules are parents of jamroot module, you can put it in any of those files.o</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="_choosing_the_package_name_based_on_the_property_set"><a class="anchor" href="#_choosing_the_package_name_based_on_the_property_set"></a>Choosing the package name based on the property set</h6>
|
||
<div class="paragraph">
|
||
<p>Since a file for a package should be named after the package suffixed with
|
||
<code>.pc</code>, some projects came up with naming schemes in order to allow simultaneous
|
||
installation of several major versions or build variants. In order to pick the
|
||
specific name corresponding to the build request you can use <code><conditional></code>
|
||
property in requirements:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>pkg-config.import<span class="tok-w"> </span>mypackage<span class="tok-w"> </span>:<span class="tok-w"> </span>requirements<span class="tok-w"> </span><span class="tok-na"><conditional></span>@infer-name<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">infer-name</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">properties</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>name<span class="tok-w"> </span>=<span class="tok-w"> </span>mypackage<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>variant<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span>property.select<span class="tok-w"> </span><span class="tok-na"><variant></span><span class="tok-w"> </span>:<span class="tok-w"> </span><span class="tok-si">$(properties)</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">if</span><span class="tok-w"> </span><span class="tok-si">$(variant)</span><span class="tok-w"> </span>=<span class="tok-w"> </span>debug<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>name<span class="tok-w"> </span>+=<span class="tok-w"> </span>-d<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-na"><name></span><span class="tok-si">$(name)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>common.format-name</code> rule can be very useful in this situation.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="_modify_usage_requirements_based_on_package_version_or_variable"><a class="anchor" href="#_modify_usage_requirements_based_on_package_version_or_variable"></a>Modify usage requirements based on package version or variable</h6>
|
||
<div class="paragraph">
|
||
<p>Sometimes you need to apply some logic based on package’s version or a
|
||
variable that it defines. For that you can use <code><conditional></code> property in
|
||
usage requirements:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>mypackage =
|
||
[ pkg-config.import mypackage : usage-requirements <conditional>@define_ns
|
||
] ;
|
||
|
||
rule extra-props ( properties * )
|
||
{
|
||
local ps = [ property-set.create $(properties) ] ;
|
||
local prefix = [ $(mypackage).variable name_prefix : $(ps) ] ;
|
||
prefix += [ $(mypackage).version $(ps) ] ;
|
||
return <define>$(prefix:J=_) ;
|
||
}</pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="_sass"><a class="anchor" href="#_sass"></a>10.2.2. Sass</h4>
|
||
<div class="paragraph">
|
||
<p>This tool converts SASS and SCSS files into CSS. This tool explicitly supports
|
||
both the version written in C (sassc) and the original Ruby implementation
|
||
(scss) but other variants might also work. In addition to tool-specific
|
||
features, described in this section, the tool recognizes features <code><flags></code>
|
||
and <code><include></code>.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_feature_sass_style"><a class="anchor" href="#_feature_sass_style"></a>Feature: <code>sass-style</code></h5>
|
||
<div class="paragraph">
|
||
<p>Sets the output style. Available values are</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>nested</code>: each property is put on its own line, rules are indented based on
|
||
how deeply they are nested;</p>
|
||
</li>
|
||
<li>
|
||
<p><code>expanded</code>: each property is put on its own line, rules are not indented;</p>
|
||
</li>
|
||
<li>
|
||
<p><code>compact</code>: each rule is put on a single line, nested rules occupy adjacent
|
||
lines, while groups of unrelated rules are separated by newlines;</p>
|
||
</li>
|
||
<li>
|
||
<p><code>compressed</code>: takes minimum amount of space: all unnecessary whitespace is
|
||
removed, property values are compressed to have minimal representation.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The feature is <code>optional</code> and is not <code>propagated</code> to dependent targets. If no
|
||
style is specified, then, if property set contains property <code><optimization>on</code>,
|
||
<code>compressed</code> style is selected. Otherwise, <code>nested</code> style is selected.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_feature_sass_line_numbers"><a class="anchor" href="#_feature_sass_line_numbers"></a>Feature: <code>sass-line-numbers</code></h5>
|
||
<div class="paragraph">
|
||
<p>Enables emitting comments showing original line numbers for rules. This can be
|
||
useful for debugging a stylesheet. Available values are <code>on</code> and <code>off</code>. The
|
||
feature is <code>optional</code> and is not <code>propagated</code> to dependent targets. If no value
|
||
for this feature is specified, then one is copied from the feature
|
||
<code>debug-symbols</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="_initialization_2"><a class="anchor" href="#_initialization_2"></a>Initialization</h5>
|
||
<div class="paragraph">
|
||
<p>To use the <code>sass</code> tool you need to declare it in a configuration file with the
|
||
<code>using</code> rule. The initialization takes the following arguments:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>command</code>: the command, with any extra arguments, to execute.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For example you could insert the following in your <code>user-config.jam</code>:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">using</span><span class="tok-w"> </span>sass<span class="tok-w"> </span>:<span class="tok-w"> </span>/usr/local/bin/psass<span class="tok-w"> </span>-p2<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># Perl libsass-based version</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If no <code>command</code> is given, <code>sassc</code> is tried, after which <code>scss</code> is tried.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="_examples"><a class="anchor" href="#_examples"></a>11. Examples</h2>
|
||
<div class="sectionbody">
|
||
<div class="sect2">
|
||
<h3 id="_introduction_2"><a class="anchor" href="#_introduction_2"></a>11.1. Introduction</h3>
|
||
<div class="paragraph">
|
||
<p>Here we include a collection of simple to complex fully working examples of
|
||
using Boost Build v2 for various tasks. They show the gamut from simple
|
||
to advanced features. If you find yourself looking at the examples and not
|
||
finding something you want to see working please post to our support list
|
||
and we’ll try and come up with a solution and add it here for others to learn
|
||
from.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_hello"><a class="anchor" href="#_hello"></a>11.2. Hello</h3>
|
||
<div class="paragraph">
|
||
<p>This example shows a very basic Boost Build project set up so it compiles a
|
||
single executable from a single source file:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="title"><code>hello.cpp</code></div>
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="cpp"><span></span><span class="tok-cp">#include</span> <span class="tok-cpf"><iostream></span><span class="tok-cp"></span>
|
||
|
||
<span class="tok-kt">int</span> <span class="tok-nf">main</span><span class="tok-p">()</span>
|
||
<span class="tok-p">{</span>
|
||
<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o"><<</span> <span class="tok-s">"Hello!</span><span class="tok-se">\n</span><span class="tok-s">"</span><span class="tok-p">;</span>
|
||
<span class="tok-k">return</span> <span class="tok-mi">1</span><span class="tok-p">;</span>
|
||
<span class="tok-p">}</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Our <code>jamroot.jam</code> is minimal and only specifies one <code>exe</code> target for the
|
||
program:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="title"><code>jamroot.jam</code></div>
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>hello<span class="tok-w"> </span>:<span class="tok-w"> </span>hello.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Building the example yields:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="bash"><span></span>> <span class="tok-nb">cd</span> /example/hello
|
||
> b2
|
||
...found <span class="tok-m">8</span> targets...
|
||
...updating <span class="tok-m">4</span> targets...
|
||
common.mkdir bin/clang-darwin-4.2.1
|
||
common.mkdir bin/clang-darwin-4.2.1/debug
|
||
clang-darwin.compile.c++ bin/clang-darwin-4.2.1/debug/hello.o
|
||
clang-darwin.link bin/clang-darwin-4.2.1/debug/hello
|
||
...updated <span class="tok-m">4</span> targets...
|
||
> bin/clang-darwin-4.2.1/debug/hello
|
||
Hello!</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
The actual paths in the <code>bin</code> sub-directory will depend on your
|
||
toolset.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_sanitizers"><a class="anchor" href="#_sanitizers"></a>11.3. Sanitizers</h3>
|
||
<div class="paragraph">
|
||
<p>This example shows how to enable sanitizers when using a clang or gcc toolset</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="title"><code>main.cpp</code></div>
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="cpp"><span></span><span class="tok-kt">int</span> <span class="tok-nf">main</span><span class="tok-p">()</span>
|
||
<span class="tok-p">{</span>
|
||
<span class="tok-kt">char</span><span class="tok-o">*</span> <span class="tok-n">c</span> <span class="tok-o">=</span> <span class="tok-k">nullptr</span><span class="tok-p">;</span>
|
||
<span class="tok-n">std</span><span class="tok-o">::</span><span class="tok-n">cout</span> <span class="tok-o"><<</span> <span class="tok-s">"Hello sanitizers</span><span class="tok-se">\n</span><span class="tok-s"> "</span> <span class="tok-o"><<</span> <span class="tok-o">*</span><span class="tok-n">c</span><span class="tok-p">;</span>
|
||
<span class="tok-p">}</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Our <code>jamroot.jam</code> is minimal and only specifies one <code>exe</code> target for the
|
||
program:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="title"><code>jamroot.jam</code></div>
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">exe</span><span class="tok-w"> </span>main<span class="tok-w"> </span>:<span class="tok-w"> </span>main.cpp<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Sanitizers can be enabled by passing <code>on</code> or <code>norecover</code> to the appropriate sanitizer feature
|
||
(e.g. <code>thread-sanitizer=on</code>). The <code>norecover</code> option causes the program to terminate after
|
||
the first sanitizer issue is detected. The following example shows how to enable <code>address</code> and <code>undefined</code>
|
||
sanitizers in a simple program:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="bash"><span></span>> <span class="tok-nb">cd</span> /example/sanitizers
|
||
> b2 <span class="tok-nv">toolset</span><span class="tok-o">=</span>gcc address-sanitizer<span class="tok-o">=</span>norecover undefined-sanitizer<span class="tok-o">=</span>on
|
||
...found <span class="tok-m">10</span> targets...
|
||
...updating <span class="tok-m">7</span> targets...
|
||
gcc.compile.c++ bin/gcc-7.3.0/debug/address-sanitizer-norecover/undefined-sanitizer-on/main.o
|
||
gcc.link bin/gcc-7.3.0/debug/address-sanitizer-norecover/undefined-sanitizer-on/main
|
||
...updated <span class="tok-m">7</span> targets...</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Running the produced program may produce an output simillar to the following:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="bash"><span></span>> ./bin/gcc-7.3.0/debug/address-sanitizer-norecover/undefined-sanitizer-on/main
|
||
Hello sanitizers
|
||
main.cpp:6:43: runtime error: load of null pointer of <span class="tok-nb">type</span> <span class="tok-s1">'char'</span>
|
||
ASAN:DEADLYSIGNAL
|
||
<span class="tok-o">=================================================================</span>
|
||
<span class="tok-o">==</span><span class="tok-nv">29767</span><span class="tok-o">==</span>ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 <span class="tok-o">(</span>pc 0x55ba7988af1b bp 0x7ffdf3d76560 sp 0x7ffdf3d76530 T0<span class="tok-o">)</span>
|
||
<span class="tok-o">==</span><span class="tok-nv">29767</span><span class="tok-o">==</span>The signal is caused by a READ memory access.
|
||
<span class="tok-o">==</span><span class="tok-nv">29767</span><span class="tok-o">==</span>Hint: address points to the zero page.
|
||
<span class="tok-c1">#0 0x55ba7988af1a in main /home/damian/projects/boost/tools/build/example/sanitizers/main.cpp:6</span>
|
||
<span class="tok-c1">#1 0x7f42f2ba1b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)</span>
|
||
<span class="tok-c1">#2 0x55ba7988adb9 in _start (/home/damian/projects/boost/tools/build/example/sanitizers/bin/gcc-7.3.0/debug/address-sanitizer-norecover/undefined-sanitizer-on/main+0xdb9)</span>
|
||
|
||
AddressSanitizer can not provide additional info.
|
||
SUMMARY: AddressSanitizer: SEGV /home/damian/projects/boost/tools/build/example/sanitizers/main.cpp:6 in <span class="tok-nv">main</span>
|
||
<span class="tok-o">==</span><span class="tok-nv">29767</span><span class="tok-o">==</span>ABORTING</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
The actual paths in the <code>bin</code> sub-directory will depend on your
|
||
toolset and configuration. The presented output may vary depending on your compiler version.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="bbv2.jam"><a class="anchor" href="#bbv2.jam"></a>12. Boost.Jam Documentation</h2>
|
||
<div class="sectionbody">
|
||
<div class="quoteblock">
|
||
<blockquote>
|
||
<div class="paragraph">
|
||
<p>Jam is a make(1) replacement that makes building simple things simple and building
|
||
complicated things manageable.</p>
|
||
</div>
|
||
</blockquote>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="jam.building"><a class="anchor" href="#jam.building"></a>12.1. Building B2</h3>
|
||
<div class="paragraph">
|
||
<p>Installing <code>B2</code> after building it is simply a matter of copying the
|
||
generated executables someplace in your <code>PATH</code>. For building the
|
||
executables there are a set of <code>build</code> bootstrap scripts to accommodate
|
||
particular environments. The scripts take one optional argument, the
|
||
name of the toolset to build with. When the toolset is not given an
|
||
attempt is made to detect an available toolset and use that. The build
|
||
scripts accept these arguments:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span>build <span class="tok-o">[</span>toolset<span class="tok-o">]</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Running the scripts without arguments will give you the best chance of
|
||
success. On Windows platforms from a command console do:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="bat"><span></span><span class="tok-k">cd</span> jam source location
|
||
.\build.bat</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>On Unix type platforms do:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="shell"><span></span><span class="tok-nb">cd</span> jam <span class="tok-nb">source</span> location
|
||
sh ./build.sh</code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For the Boost.Jam source included with the Boost distribution the <em>jam
|
||
source location</em> is <code>BOOST_ROOT/tools/build/src/engine</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the scripts fail to detect an appropriate toolset to build with your
|
||
particular toolset may not be auto-detectable. In that case, you can
|
||
specify the toolset as the first argument, this assumes that the toolset
|
||
is readily available in the <code>PATH</code>.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
The toolset used to build Boost.Jam is independent of the toolsets used
|
||
for B2. Only one version of Boost.Jam is needed to use
|
||
B2.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The supported toolsets, and whether they are auto-detected, are:</p>
|
||
</div>
|
||
<table class="tableblock frame-all grid-all fit-content">
|
||
<caption class="title">Table 2. Supported Toolsets</caption>
|
||
<colgroup>
|
||
<col>
|
||
<col>
|
||
<col>
|
||
<col>
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-top">Script</th>
|
||
<th class="tableblock halign-left valign-top">Platform</th>
|
||
<th class="tableblock halign-left valign-top">Toolset</th>
|
||
<th class="tableblock halign-left valign-top">Detection and Notes</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-top"><p class="tableblock"><code>build.bat</code></p></th>
|
||
<th class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">Windows</p></th>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vc142</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Microsoft Visual Studio C++ 2019</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Uses <code>vswhere</code> utility.</p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vc141</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Microsoft Visual Studio C++ 2017</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Uses <code>vswhere</code> utility.</p>
|
||
</li>
|
||
<li>
|
||
<p>Common install location: <code>%ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\VC\</code></p>
|
||
</li>
|
||
<li>
|
||
<p>Common install location: <code>%ProgramFiles%\Microsoft Visual Studio\2017\Professional\VC\</code></p>
|
||
</li>
|
||
<li>
|
||
<p>Common install location: <code>%ProgramFiles%\Microsoft Visual Studio\2017\Community\VC\</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vc14</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Microsoft Visual Studio C++ 2015</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Env var <code>%VS140COMNTOOLS%</code></p>
|
||
</li>
|
||
<li>
|
||
<p>Common install location: <code>%ProgramFiles%\Microsoft Visual Studio 14.0\VC\</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>vc12</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Microsoft Visual Studio C++ 2013</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Env var <code>%VS120COMNTOOLS%</code></p>
|
||
</li>
|
||
<li>
|
||
<p>Common install location: <code>%ProgramFiles%\Microsoft Visual Studio 12.0\VC\</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>borland</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Embarcadero C++Builder</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>bcc32c.exe</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>intel-win32</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Intel C++ Compiler for Windows</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>icl.exe</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>mingw</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>GNU GCC as the MinGW configuration</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Common install location: <code>C:\MinGW</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>como</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Comeau Computing C/C++</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>gcc</code>,</p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">GNU GCC</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>clang</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Clang LLVM</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>gcc-nocygwin</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">GNU GCC</p></td>
|
||
</tr>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-top"><p class="tableblock"><code>build.sh</code></p></th>
|
||
<th class="tableblock halign-left valign-top" colspan="3"><p class="tableblock">Unix, Linux, Cygwin, Windows Bash, etc.</p></th>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>gcc</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>GNU GCC</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>g++</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>clang</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Clang LLVM</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>clang++</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>intel-linux</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Intel C++ (oneAPI) for Linux</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>icpx</code> in <code>PATH</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>icc</code> in <code>PATH</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>icpc</code> in <code>PATH</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>setvars.sh</code> in common install locations: <code>$HOME/intel/oneapi</code>,
|
||
<code>/opt/intel/oneapi</code>, <code>/opt/intel/inteloneapi</code></p>
|
||
</li>
|
||
<li>
|
||
<p><code>iccvars.sh</code> in common install locations: <code>/opt/intel/cc/9.0/bin</code>,
|
||
<code>/opt/intel_cc_80/bin</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>mipspro</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>SGI MIPSpro C++</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>uname</code> is "IRIX" or "IRIX64" and <code>CC</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>true64cxx</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Compaq C++ Compiler for True64 UNIX</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>uname</code> is "OSF1" and <code>cc</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>qcc</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>QNX Neutrino</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>uname</code> is "QNX" and <code>QCC</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>xlcpp</code> and <code>vacpp</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>IBM VisualAge C++</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>uname</code> is "Linux" and <code>xlC_r</code> in <code>PATH</code> (<code>xlcpp</code> or <code>vacpp</code> depending on
|
||
machine endian)</p>
|
||
</li>
|
||
<li>
|
||
<p><code>uname</code> is "AIX" and <code>xlC_r</code> in <code>PATH</code> (<code>vacpp</code>)</p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>pgi</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>PGI Compilers</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>pgc++</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>pathscale</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Pathscale C++</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>pathCC</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>como</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Comeau Computing C/C++</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>como</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>kylix</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Borland C++</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>bc++</code> in <code>PATH</code> (<code>kylix</code>)</p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>acc</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>HP-UX aCC</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>aCC</code> in <code>PATH</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>sunpro</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><div class="content"><div class="paragraph">
|
||
<p>Sun Workshop 6 C++</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Standard install location: <code>/opt/SUNWspro/bin/CC</code></p>
|
||
</li>
|
||
</ul>
|
||
</div></div></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="paragraph">
|
||
<p>The built executables are placed in the <code>src/engine</code> directory.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>build.sh</code> script supports additional invocation options used to
|
||
control the the build and custom compilers:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>build.sh [--option|--option=x] [toolset]</pre>
|
||
</div>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>--help</code></dt>
|
||
<dd>
|
||
<p>Shows some help information, including these options.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--verbose</code></dt>
|
||
<dd>
|
||
<p>Show messages about what this script is doing.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--debug</code></dt>
|
||
<dd>
|
||
<p>Builds debugging versions of the executable. The default is to build an
|
||
optimized executable.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--guess-toolset</code></dt>
|
||
<dd>
|
||
<p>Print the toolset we can detect for building. This is used by external
|
||
scripts, like the Boost Libraries main bootstrap script.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--cxx=CXX</code></dt>
|
||
<dd>
|
||
<p>The compiler exec to use instead of the detected compiler exec.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>--cxxflags=CXXFLAGS</code></dt>
|
||
<dd>
|
||
<p>The compiler flags to use in addition to the flags for the detected
|
||
compiler.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="jam.language"><a class="anchor" href="#jam.language"></a>12.2. Language</h3>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> has an interpreted, procedural language. Statements in <code>b2</code> are
|
||
rule (procedure) definitions, rule invocations, flow-of-control
|
||
structures, variable assignments, and sundry language support.</p>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.language.lexical"><a class="anchor" href="#jam.language.lexical"></a>12.2.1. Lexical Features</h4>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> treats its input files as whitespace-separated tokens, with two
|
||
exceptions: double quotes (") can enclose whitespace to embed it into a
|
||
token, and everything between the matching curly braces (\{}) in the
|
||
definition of a rule action is treated as a single string. A backslash
|
||
(\) can escape a double quote, or any single whitespace character.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> requires whitespace (blanks, tabs, or newlines) to surround all
|
||
tokens, including the colon (:) and semicolon (;) tokens.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> keywords (an mentioned in this document) are reserved and generally
|
||
must be quoted with double quotes (") to be used as arbitrary tokens,
|
||
such as variable or target names.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Comments start with the <code>#</code> character and extend until the end of line.
|
||
And block comments start with <code>#|</code> and extend until the next <code>|#</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.language.target"><a class="anchor" href="#jam.language.target"></a>12.2.2. Targets</h4>
|
||
<div class="paragraph">
|
||
<p>The essential <code>b2</code> data entity is a target. Build targets are files to
|
||
be updated. Source targets are the files used in updating built targets.
|
||
Built targets and source targets are collectively referred to as file
|
||
targets, and frequently built targets are source targets for other built
|
||
targets. Pseudo-targets are symbols representing dependencies on other
|
||
targets, but which are not themselves associated with any real file.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A file target’s identifier is generally the file’s name, which can be
|
||
absolutely rooted, relative to the directory of <code>b2`s invocation, or
|
||
simply local (no directory). Most often it is the last case, and the
|
||
actual file path is bound using the `$(SEARCH)</code> and <code>$(LOCATE)</code> special
|
||
variables. See <a href="#jam.language.variables.builtins.search">SEARCH and
|
||
LOCATE Variables</a> below. A local filename is optionally qualified with
|
||
grist, a string value used to assure uniqueness. A file target with an
|
||
identifier of the form <em>file(member)</em> is a library member (usually an
|
||
<code>ar</code>(1) archive on Unix).</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.target.binding_detection"><a class="anchor" href="#jam.language.target.binding_detection"></a>Binding Detection</h5>
|
||
<div class="paragraph">
|
||
<p>Whenever a target is bound to a location in the filesystem, Boost Jam
|
||
will look for a variable called <code>BINDRULE</code> (first "on" the target being
|
||
bound, then in the global module). If non-empty, <code>$(BINDRULE[1])</code> names
|
||
a rule which is called with the name of the target and the path it is
|
||
being bound to. The signature of the rule named by <code>$(BINDRULE[1])</code>
|
||
should match the following:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">bind-rule</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">target</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">path</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>This facility is useful for correct header file scanning, since many
|
||
compilers will search for <code>#include</code> files first in the directory
|
||
containing the file doing the <code>#include</code> directive. <code>$(BINDRULE)</code> can be
|
||
used to make a record of that directory.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.language.rules"><a class="anchor" href="#jam.language.rules"></a>12.2.3. Rules</h4>
|
||
<div class="paragraph">
|
||
<p>The basic <code>b2</code> language entity is called a rule. A rule is defined in
|
||
two parts: the procedure and the actions. The procedure is a body of jam
|
||
statements to be run when the rule is invoked; the actions are the OS
|
||
shell commands to execute when updating the built targets of the rule.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Rules can return values, which can be expanded into a list with "[
|
||
<em>rule</em> <em>args</em> …​ ]". A rule’s value is the value of its last statement,
|
||
though only the following statements have values: 'if' (value of the leg
|
||
chosen), 'switch' (value of the case chosen), set (value of the
|
||
resulting variable), and 'return' (value of its arguments).</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>b2</code> statements for defining and invoking rules are as follows:</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Define a rule’s procedure, replacing any previous definition.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">rulename</span><span class="tok-w"> </span><span class="tok-nv">{</span><span class="tok-w"> </span><span class="tok-nv">statements</span><span class="tok-w"> </span><span class="tok-nv">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Define a rule’s updating actions, replacing any previous definition.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">actions</span><span class="tok-w"> </span><span class="tok-nf">[</span><span class="tok-w"> </span><span class="tok-nv">modifiers</span><span class="tok-w"> </span><span class="tok-nv">]</span><span class="tok-w"> </span><span class="tok-nv">rulename</span><span class="tok-w"> </span>{<span class="tok-sh"> commands </span><span class="tok-p">}</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Invoke a rule.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>rulename<span class="tok-w"> </span>field1<span class="tok-w"> </span>:<span class="tok-w"> </span>field2<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>fieldN<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Invoke a rule under the influence of target’s specific variables..</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">on</span><span class="tok-w"> </span>target<span class="tok-w"> </span>rulename<span class="tok-w"> </span>field1<span class="tok-w"> </span>:<span class="tok-w"> </span>field2<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>fieldN<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Used as an argument, expands to the return value of the rule invoked.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>[<span class="tok-w"> </span>rulename<span class="tok-w"> </span>field1<span class="tok-w"> </span>:<span class="tok-w"> </span>field2<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>fieldN<span class="tok-w"> </span>]<span class="tok-w"></span>
|
||
[<span class="tok-w"> </span><span class="tok-k">on</span><span class="tok-w"> </span>target<span class="tok-w"> </span>rulename<span class="tok-w"> </span>field1<span class="tok-w"> </span>:<span class="tok-w"> </span>field2<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>fieldN<span class="tok-w"> </span>]<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A rule is invoked with values in <em>field1</em> through <em>fieldN</em>. They may be
|
||
referenced in the procedure’s statements as <code>$(1)</code> through <code>$(N)</code> (9
|
||
max), and the first two only may be referenced in the action’s
|
||
<em>commands</em> as <code>$(1)</code> and <code>$(2)</code>. <code>$(<)</code> and <code>$(>)</code> are synonymous with
|
||
<code>$(1)</code> and <code>$(2)</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Rules fall into two categories: updating rules (with actions), and pure
|
||
procedure rules (without actions). Updating rules treat arguments <code>$(1)</code>
|
||
and <code>$(2)</code> as built targets and sources, respectively, while pure
|
||
procedure rules can take arbitrary arguments.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When an updating rule is invoked, its updating actions are added to
|
||
those associated with its built targets (<code>$(1)</code>) before the rule’s
|
||
procedure is run. Later, to build the targets in the updating phase,
|
||
<em>commands</em> are passed to the OS command shell, with <code>$(1)</code> and <code>$(2)</code>
|
||
replaced by bound versions of the target names. See Binding above.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Rule invocation may be indirected through a variable:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-si">$(var)</span><span class="tok-w"> </span>field1<span class="tok-w"> </span>:<span class="tok-w"> </span>field2<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>fieldN<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
<span class="tok-k">on</span><span class="tok-w"> </span>target<span class="tok-w"> </span><span class="tok-si">$(var)</span><span class="tok-w"> </span>field1<span class="tok-w"> </span>:<span class="tok-w"> </span>field2<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>fieldN<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
|
||
[<span class="tok-w"> </span><span class="tok-si">$(var)</span><span class="tok-w"> </span>field1<span class="tok-w"> </span>:<span class="tok-w"> </span>field2<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>fieldN<span class="tok-w"> </span>]<span class="tok-w"></span>
|
||
[<span class="tok-w"> </span><span class="tok-k">on</span><span class="tok-w"> </span>target<span class="tok-w"> </span><span class="tok-si">$(var)</span><span class="tok-w"> </span>field1<span class="tok-w"> </span>:<span class="tok-w"> </span>field2<span class="tok-w"> </span>:<span class="tok-w"> </span>...<span class="tok-w"> </span>:<span class="tok-w"> </span>fieldN<span class="tok-w"> </span>]<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The variable’s value names the rule (or rules) to be invoked. A rule is
|
||
invoked for each element in the list of <code>$(var)`s values. The fields
|
||
`field1 : field2 : …​</code> are passed as arguments for each invocation For the [
|
||
…​ ] forms, the return value is the concatenation of the return values
|
||
for all of the invocations.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.rules.action_modifiers"><a class="anchor" href="#jam.language.rules.action_modifiers"></a>Action Modifiers</h5>
|
||
<div class="paragraph">
|
||
<p>The following action modifiers are understood:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>actions bind vars</code></dt>
|
||
<dd>
|
||
<p><code>$(vars)</code> will be replaced with bound values.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>actions existing</code></dt>
|
||
<dd>
|
||
<p><code>$(>)</code> includes only source targets currently existing.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>actions ignore</code></dt>
|
||
<dd>
|
||
<p>The return status of the commands is ignored.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>actions piecemeal</code></dt>
|
||
<dd>
|
||
<p>commands are repeatedly invoked with a subset of <code>$(>)</code> small enough
|
||
to fit in the command buffer on this OS.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>actions quietly</code></dt>
|
||
<dd>
|
||
<p>The action is not echoed to the standard output.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>actions together</code></dt>
|
||
<dd>
|
||
<p>The <code>$(>)</code> from multiple invocations of the same action on the same
|
||
built target are glommed together.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>actions updated</code></dt>
|
||
<dd>
|
||
<p><code>$(>)</code> includes only source targets themselves marked for updating.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.rules.argument_lists"><a class="anchor" href="#jam.language.rules.argument_lists"></a>Argument lists</h5>
|
||
<div class="paragraph">
|
||
<p>You can describe the arguments accepted by a rule, and refer to them by
|
||
name within the rule. For example, the following prints "I’m sorry,
|
||
Dave" to the console:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">report</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">pronoun</span><span class="tok-w"> </span><span class="tok-nv">index</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">state</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">names</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>he.suffix<span class="tok-w"> </span>she.suffix<span class="tok-w"> </span>it.suffix<span class="tok-w"> </span>=<span class="tok-w"> </span>s<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>I.suffix<span class="tok-w"> </span>=<span class="tok-w"> </span>m<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>they.suffix<span class="tok-w"> </span>you.suffix<span class="tok-w"> </span>=<span class="tok-w"> </span>re<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nb">ECHO</span><span class="tok-w"> </span><span class="tok-si">$(pronoun)</span>'<span class="tok-si">$($(pronoun).suffix)</span><span class="tok-w"> </span><span class="tok-si">$(state)</span>,<span class="tok-w"> </span><span class="tok-si">$(names[$(index)</span>])<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
}<span class="tok-w"></span>
|
||
report<span class="tok-w"> </span>I<span class="tok-w"> </span>2<span class="tok-w"> </span>:<span class="tok-w"> </span>sorry<span class="tok-w"> </span>:<span class="tok-w"> </span>Joe<span class="tok-w"> </span>Dave<span class="tok-w"> </span>Pete<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Each name in a list of formal arguments (separated by <code>:</code> in the rule
|
||
declaration) is bound to a single element of the corresponding actual
|
||
argument unless followed by one of these modifiers:</p>
|
||
</div>
|
||
<table class="tableblock frame-all grid-all fit-content">
|
||
<colgroup>
|
||
<col>
|
||
<col>
|
||
</colgroup>
|
||
<thead>
|
||
<tr>
|
||
<th class="tableblock halign-left valign-top">Symbol</th>
|
||
<th class="tableblock halign-left valign-top">Semantics of preceding symbol</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>?</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">optional</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>*</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Bind to zero or more unbound elements of the actual argument. When
|
||
<code>*</code> appears where an argument name is expected, any number of additional
|
||
arguments are accepted. This feature can be used to implement "varargs"
|
||
rules.</p></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>+</code></p></td>
|
||
<td class="tableblock halign-left valign-top"><p class="tableblock">Bind to one or more unbound elements of the actual argument.</p></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<div class="paragraph">
|
||
<p>The actual and formal arguments are checked for inconsistencies, which
|
||
cause <code>b2</code> to exit with an error code:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-c1">### argument error</span>
|
||
<span class="tok-c1"># rule report ( pronoun index ? : state : names + )</span>
|
||
<span class="tok-c1"># called with: ( I 2 foo : sorry : Joe Dave Pete )</span>
|
||
<span class="tok-c1"># extra argument foo</span>
|
||
<span class="tok-c1">### argument error</span>
|
||
<span class="tok-c1"># rule report ( pronoun index ? : state : names + )</span>
|
||
<span class="tok-c1"># called with: ( I 2 : sorry )</span>
|
||
<span class="tok-c1"># missing argument names</span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If you omit the list of formal arguments, all checking is bypassed as in
|
||
"classic" Jam. Argument lists drastically improve the reliability and
|
||
readability of your rules, however, and are <strong>strongly recommended</strong> for
|
||
any new Jam code you write.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.language.rules.builtins"><a class="anchor" href="#jam.language.rules.builtins"></a>12.2.4. Built-in Rules</h4>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> has a growing set of built-in rules, all of which are pure
|
||
procedure rules without updating actions. They are in three groups: the
|
||
first builds the dependency graph; the second modifies it; and the third
|
||
are just utility rules.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.rules.builtins.dependency_building"><a class="anchor" href="#jam.language.rules.builtins.dependency_building"></a>Dependency Building</h5>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.dependency_building._depends__"><a class="anchor" href="#jam.language.rules.builtins.dependency_building._depends__"></a><code>DEPENDS</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">DEPENDS</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets1</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">targets2</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Builds a direct dependency: makes each of <em>targets1</em> depend on each of
|
||
<em>targets2</em>. Generally, <em>targets1</em> will be rebuilt if <em>targets2</em> are
|
||
themselves rebuilt or are newer than <em>targets1</em>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.dependency_building._includes__"><a class="anchor" href="#jam.language.rules.builtins.dependency_building._includes__"></a><code>INCLUDES</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">INCLUDES</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets1</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">targets2</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Builds a sibling dependency: makes any target that depends on any of
|
||
<em>targets1</em> also depend on each of <em>targets2</em>. This reflects the
|
||
dependencies that arise when one source file includes another: the
|
||
object built from the source file depends both on the original and
|
||
included source file, but the two sources files don’t depend on each
|
||
other. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-nb">DEPENDS</span><span class="tok-w"> </span>foo.o<span class="tok-w"> </span>:<span class="tok-w"> </span>foo.c<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">INCLUDES</span><span class="tok-w"> </span>foo.c<span class="tok-w"> </span>:<span class="tok-w"> </span>foo.h<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>foo.o</code> depends on <code>foo.c</code> and <code>foo.h</code> in this example.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.rules.builtins.modifying_binding"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding"></a>Modifying Binding</h5>
|
||
<div class="paragraph">
|
||
<p>The six rules <code>ALWAYS</code>, <code>LEAVES</code>, <code>NOCARE</code>, <code>NOTFILE</code>, <code>NOUPDATE</code>, and
|
||
<code>TEMPORARY</code> modify the dependency graph so that <code>b2</code> treats the targets
|
||
differently during its target binding phase. See Binding above.
|
||
Normally, <code>b2</code> updates a target if it is missing, if its filesystem
|
||
modification time is older than any of its dependencies (recursively),
|
||
or if any of its dependencies are being updated. This basic behavior can
|
||
be changed by invoking the following rules:</p>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._always__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._always__"></a><code>ALWAYS</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">ALWAYS</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Causes <em>targets</em> to be rebuilt regardless of whether they are up-to-date
|
||
(they must still be in the dependency graph). This is used for the clean
|
||
and uninstall targets, as they have no dependencies and would otherwise
|
||
appear never to need building. It is best applied to targets that are
|
||
also <code>NOTFILE</code> targets, but it can also be used to force a real file to
|
||
be updated as well.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._leaves__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._leaves__"></a><code>LEAVES</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">LEAVES</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Makes each of <em>targets</em> depend only on its leaf sources, and not on any
|
||
intermediate targets. This makes it immune to its dependencies being
|
||
updated, as the "leaf" dependencies are those without their own
|
||
dependencies and without updating actions. This allows a target to be
|
||
updated only if original source files change.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._nocare__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._nocare__"></a><code>NOCARE</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">NOCARE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Causes <code>b2</code> to ignore <em>targets</em> that neither can be found nor have
|
||
updating actions to build them. Normally for such targets <code>b2</code> issues a
|
||
warning and then skips other targets that depend on these missing
|
||
targets. The <code>HdrRule</code> in <code>Jambase</code> uses <code>NOCARE</code> on the header file
|
||
names found during header file scanning, to let <code>b2</code> know that the
|
||
included files may not exist. For example, if an <code>#include</code> is within an
|
||
<code>#ifdef</code>, the included file may not actually be around.</p>
|
||
</div>
|
||
<div class="admonitionblock warning">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">⚠</div>
|
||
</td>
|
||
<td class="content">
|
||
For targets with build actions: if their build actions exit with a
|
||
nonzero return code, dependent targets will still be built.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._notfile__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._notfile__"></a><code>NOTFILE</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">NOTFILE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Marks <em>targets</em> as pseudo-targets and not real files. No timestamp is
|
||
checked, and so the actions on such a target are only executed if the
|
||
target’s dependencies are updated, or if the target is also marked with
|
||
<code>ALWAYS</code>. The default <code>b2</code> target <code>all</code> is a pseudo-target In
|
||
<code>Jambase</code>, <code>NOTFILE</code> is used to define several addition convenient
|
||
pseudo-targets</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._noupdate__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._noupdate__"></a><code>NOUPDATE</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">NOUPDATE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Causes the timestamps on <em>targets</em> to be ignored. This has two effects:
|
||
first, once the target has been created it will never be updated;
|
||
second, manually updating target will not cause other targets to be
|
||
updated. In <code>Jambase</code>, for example, this rule is applied to directories
|
||
by the <code>MkDir</code> rule, because <code>MkDir</code> only cares that the target
|
||
directory exists, not when it has last been updated.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._temporary__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._temporary__"></a><code>TEMPORARY</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">TEMPORARY</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Marks <em>targets</em> as temporary, allowing them to be removed after other
|
||
targets that depend upon them have been updated. If a <code>TEMPORARY</code> target
|
||
is missing, <code>b2</code> uses the timestamp of the target’s parent. <code>Jambase</code>
|
||
uses <code>TEMPORARY</code> to mark object files that are archived in a library
|
||
after they are built, so that they can be deleted after they are
|
||
archived.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._fail_expected__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._fail_expected__"></a><code>FAIL_EXPECTED</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">FAIL_EXPECTED</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>For handling targets whose build actions are expected to fail (e.g. when
|
||
testing that assertions or compile-time type checking work properly),
|
||
Boost Jam supplies the <code>FAIL_EXPECTED</code> rule in the same style as
|
||
<code>NOCARE</code>, et. al. During target updating, the return code of the build
|
||
actions for arguments to <code>FAIL_EXPECTED</code> is inverted: if it fails,
|
||
building of dependent targets continues as though it succeeded. If it
|
||
succeeds, dependent targets are skipped.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._rmold__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._rmold__"></a><code>RMOLD</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">RMOLD</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> removes any target files that may exist on disk when the rule used
|
||
to build those targets fails. However, targets whose dependencies fail
|
||
to build are not removed by default. The <code>RMOLD</code> rule causes its
|
||
arguments to be removed if any of their dependencies fail to build.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.modifying_binding._isfile__"><a class="anchor" href="#jam.language.rules.builtins.modifying_binding._isfile__"></a><code>ISFILE</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">ISFILE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>ISFILE</code> marks targets as required to be files. This changes the way
|
||
<code>b2</code> searches for the target such that it ignores matches for file
|
||
system items that are not files, like directories. This makes it
|
||
possible to avoid <code>#include "exception"</code> matching if one happens to have
|
||
a directory named exception in the header search path.</p>
|
||
</div>
|
||
<div class="admonitionblock warning">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">⚠</div>
|
||
</td>
|
||
<td class="content">
|
||
This is currently not fully implemented.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.rules.builtins.utility"><a class="anchor" href="#jam.language.rules.builtins.utility"></a>Utility</h5>
|
||
<div class="paragraph">
|
||
<p>The two rules <code>ECHO</code> and <code>EXIT</code> are utility rules, used only in `b2`s
|
||
parsing phase.</p>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._echo__"><a class="anchor" href="#jam.language.rules.builtins.utility._echo__"></a><code>ECHO</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">ECHO</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">args</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Blurts out the message <em>args</em> to stdout.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._exit__"><a class="anchor" href="#jam.language.rules.builtins.utility._exit__"></a><code>EXIT</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">EXIT</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">message</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">result-value</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Blurts out the <em>message</em> to stdout and then exits with a failure status
|
||
if no <em>result-value</em> is given, otherwise it exits with the given
|
||
<em>result-value</em>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>Echo</code>, <code>echo</code>, <code>Exit</code>, and <code>exit</code> are accepted as aliases for
|
||
<code>ECHO</code> and <code>EXIT</code>, since it is hard to tell that these are built-in
|
||
rules and not part of the language, like <code>include</code>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._glob__"><a class="anchor" href="#jam.language.rules.builtins.utility._glob__"></a><code>GLOB</code></h6>
|
||
<div class="paragraph">
|
||
<p>The <code>GLOB</code> rule does filename globing</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">GLOB</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">directories</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">patterns</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">downcase-opt</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Using the same wildcards as for the patterns in the switch statement. It
|
||
is invoked by being used as an argument to a rule invocation inside of
|
||
"[ ]". For example: <code>FILES = [ GLOB dir1 dir2 : *.c *.h ]</code> sets <code>FILES</code> to
|
||
the list of C source
|
||
and header files in <code>dir1</code> and <code>dir2</code>. The resulting filenames are the
|
||
full pathnames, including the directory, but the pattern is applied only
|
||
to the file name without the directory.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If <em>downcase-opt</em> is supplied, filenames are converted to all-lowercase
|
||
before matching against the pattern; you can use this to do
|
||
case-insensitive matching using lowercase patterns. The paths returned
|
||
will still have mixed case if the OS supplies them. On Windows NT and
|
||
Cygwin, and OpenVMS, filenames are always down-cased before matching.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._glob_archive__"><a class="anchor" href="#jam.language.rules.builtins.utility._glob_archive__"></a><code>GLOB_ARCHIVE</code></h6>
|
||
<div class="paragraph">
|
||
<p>The <code>GLOB_ARCHIVE</code> rule does name globing of object archive members.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">GLOB_ARCHIVE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">archives</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">member-patterns</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">downcase-opt</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">symbol-patterns</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Similarly to <code>GLOB</code>, this rule is used to match names of member files in
|
||
an archive (static object library). List of successfully matched members
|
||
is returned or null otherwise. The resulting member names are qualified
|
||
with pathname of the containing archive in the form
|
||
<code>archive-path(member-name)</code>. Member patterns are for matching member
|
||
name only; when no wildcards specified — an exact match is assumed.
|
||
Member names generally correspond to object file names and as such are
|
||
platform-specific — use of platform-defined object suffix in the
|
||
matching patterns can allow for portability.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If <em>downcase-opt</em> is supplied, the member names are converted to
|
||
all-lowercase before matching against the pattern; you can use this to
|
||
do case-insensitive matching using lowercase patterns. The paths
|
||
returned will still have mixed case if the OS supplies them. On Windows
|
||
NT, Cygwin, and OpenVMS, filenames are always down-cased before matching.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Additionally, members can be matched with symbol/function patterns on
|
||
supported platforms (currently, OpenVMS only). In this case, members
|
||
containing the matching symbols are returned. Member and symbol patterns
|
||
are applied as OR conditions, with member patterns taking precedence. On
|
||
unsupported platforms, null is returned when any symbol patterns are
|
||
specified.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._match__"><a class="anchor" href="#jam.language.rules.builtins.utility._match__"></a><code>MATCH</code></h6>
|
||
<div class="paragraph">
|
||
<p>The <code>MATCH</code> rule does pattern matching.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">MATCH</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">regexps</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">list</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Matches the <code>egrep</code>(1) style regular expressions <em>regexps</em> against the
|
||
strings in <em>list</em>. The result is a list of matching <code>()</code> subexpressions
|
||
for each string in <em>list</em>, and for each regular expression in <em>regexps</em>.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._backtrace__"><a class="anchor" href="#jam.language.rules.builtins.utility._backtrace__"></a><code>BACKTRACE</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">BACKTRACE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Returns a list of quadruples: <em>filename</em> <em>line</em> <em>module</em> <em>rulename</em>…​,
|
||
describing each shallower level of the call stack. This rule can be used
|
||
to generate useful diagnostic messages from Jam rules.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._update__"><a class="anchor" href="#jam.language.rules.builtins.utility._update__"></a><code>UPDATE</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">UPDATE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Classic jam treats any non-option element of command line as a name of
|
||
target to be updated. This prevented more sophisticated handling of
|
||
command line. This is now enabled again but with additional changes to
|
||
the <code>UPDATE</code> rule to allow for the flexibility of changing the list of
|
||
targets to update. The UPDATE rule has two effects:</p>
|
||
</div>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>It clears the list of targets to update, and</p>
|
||
</li>
|
||
<li>
|
||
<p>Causes the specified targets to be updated.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If no target was specified with the <code>UPDATE</code> rule, no targets will be
|
||
updated. To support changing of the update list in more useful ways, the
|
||
rule also returns the targets previously in the update list. This makes
|
||
it possible to add targets as such:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">local</span><span class="tok-w"> </span>previous-updates<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">UPDATE</span><span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-nb">UPDATE</span><span class="tok-w"> </span><span class="tok-si">$(previous-updates)</span><span class="tok-w"> </span>a-new-target<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._w32_getreg__"><a class="anchor" href="#jam.language.rules.builtins.utility._w32_getreg__"></a><code>W32_GETREG</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">W32_GETREG</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">path</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">data</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Defined only for win32 platform. It reads the registry of Windows.
|
||
'<em>path</em>' is the location of the information, and '<em>data</em>' is the name of
|
||
the value which we want to get. If '<em>data</em>' is omitted, the default
|
||
value of '<em>path</em>' will be returned. The '<em>path</em>' value must conform to
|
||
MS key path format and must be prefixed with one of the predefined root
|
||
keys. As usual,</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><code>HKLM</code> is equivalent to <code>HKEY_LOCAL_MACHINE</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>HKCU</code> is equivalent to <code>HKEY_CURRENT_USER</code>.</p>
|
||
</li>
|
||
<li>
|
||
<p><code>HKCR</code> is equivalent to <code>HKEY_CLASSES_ROOT</code>.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Other predefined root keys are not supported.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Currently supported data types : <code>REG_DWORD</code>, <code>REG_SZ</code>,
|
||
<code>REG_EXPAND_SZ</code>, <code>REG_MULTI_SZ</code>. The data with <code>REG_DWORD</code> type
|
||
will be turned into a string, <code>REG_MULTI_SZ</code> into a list of strings,
|
||
and for those with <code>REG_EXPAND_SZ</code> type environment variables in it
|
||
will be replaced with their defined values. The data with <code>REG_SZ</code>
|
||
type and other unsupported types will be put into a string without
|
||
modification. If it can’t receive the value of the data, it just return
|
||
an empty list. For example,</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">local</span><span class="tok-w"> </span>PSDK-location<span class="tok-w"> </span>=<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">W32_GETREG</span><span class="tok-w"> </span>HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MicrosoftSDK\\Directories<span class="tok-w"> </span>:<span class="tok-w"> </span>"Install<span class="tok-w"> </span>Dir"<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._w32_getregnames__"><a class="anchor" href="#jam.language.rules.builtins.utility._w32_getregnames__"></a><code>W32_GETREGNAMES</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">W32_GETREGNAMES</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">path</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">result-type</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Defined only for win32 platform. It reads the registry of Windows.
|
||
'<em>path</em>' is the location of the information, and '<em>result-type</em>' is
|
||
either <code>subkeys</code> or <code>values</code>. For more information on '<em>path</em>'
|
||
format and constraints, please see <code>W32_GETREG</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Depending on '<em>result-type</em>', the rule returns one of the following:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>subkeys</code></dt>
|
||
<dd>
|
||
<p>Names of all direct sub-keys of '<em>path</em>'.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>values</code></dt>
|
||
<dd>
|
||
<p>Names of values contained in registry key given by '<em>path</em>'. The
|
||
"default" value of the key appears in the returned list only if its
|
||
value has been set in the registry.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If '<em>result-type</em>' is not recognized, or requested data cannot be
|
||
retrieved, the rule returns an empty list. Example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">local</span><span class="tok-w"> </span>key<span class="tok-w"> </span>=<span class="tok-w"> </span>"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App<span class="tok-w"> </span>Paths"<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">local</span><span class="tok-w"> </span>subkeys<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">W32_GETREGNAMES</span><span class="tok-w"> </span>"<span class="tok-si">$(key)</span>"<span class="tok-w"> </span>:<span class="tok-w"> </span>subkeys<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>subkey<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(subkeys)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>values<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">W32_GETREGNAMES</span><span class="tok-w"> </span>"<span class="tok-si">$(key)</span>\\<span class="tok-si">$(subkey)</span>"<span class="tok-w"> </span>:<span class="tok-w"> </span>values<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>value<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(values)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>data<span class="tok-w"> </span>=<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">W32_GETREG</span><span class="tok-w"> </span>"<span class="tok-si">$(key)</span>\\<span class="tok-si">$(subkey)</span>"<span class="tok-w"> </span>:<span class="tok-w"> </span>"<span class="tok-si">$(value)</span>"<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nb">ECHO</span><span class="tok-w"> </span>"Registry<span class="tok-w"> </span>path:<span class="tok-w"> </span>"<span class="tok-w"> </span><span class="tok-si">$(key)</span>\\<span class="tok-si">$(subkey)</span><span class="tok-w"> </span>":"<span class="tok-w"> </span><span class="tok-si">$(value)</span><span class="tok-w"> </span>"="<span class="tok-w"> </span><span class="tok-si">$(data)</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._shell__"><a class="anchor" href="#jam.language.rules.builtins.utility._shell__"></a><code>SHELL</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">SHELL</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">command</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>SHELL</code> executes <em>command</em>, and then returns the standard output of
|
||
<em>command</em>. <code>SHELL</code> only works on platforms with a <code>popen()</code> function in
|
||
the C library. On platforms without a working <code>popen()</code> function,
|
||
<code>SHELL</code> is implemented as a no-op. <code>SHELL</code> works on Unix, MacOS X, and
|
||
most Windows compilers. <code>SHELL</code> is a no-op on Metrowerks compilers under
|
||
Windows. There is a variable set of allowed options as additional
|
||
arguments:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>exit-status</code></dt>
|
||
<dd>
|
||
<p>In addition to the output the result status of the executed command is
|
||
returned as a second element of the result.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>no-output</code></dt>
|
||
<dd>
|
||
<p>Don’t capture the output of the command. Instead an empty ("") string
|
||
value is returned in place of the output.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>strip-eol</code></dt>
|
||
<dd>
|
||
<p>Remove trailing end-of-line character from output, if any.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Because the Perforce/Jambase defines a <code>SHELL</code> rule which hides the
|
||
builtin rule, <code>COMMAND</code> can be used as an alias for <code>SHELL</code> in such a
|
||
case.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._md5__"><a class="anchor" href="#jam.language.rules.builtins.utility._md5__"></a><code>MD5</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">MD5</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">string</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>MD5</code> computes the MD5 hash of the string passed as parameter and
|
||
returns it.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._split_by_characters__"><a class="anchor" href="#jam.language.rules.builtins.utility._split_by_characters__"></a><code>SPLIT_BY_CHARACTERS</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">SPLIT_BY_CHARACTERS</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">string</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">delimiters</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>SPLIT_BY_CHARACTERS</code> splits the specified <em>string</em> on any delimiter
|
||
character present in <em>delimiters</em> and returns the resulting list.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._precious__"><a class="anchor" href="#jam.language.rules.builtins.utility._precious__"></a><code>PRECIOUS</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">PRECIOUS</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>PRECIOUS</code> rule specifies that each of the targets passed as the
|
||
arguments should not be removed even if the command updating that target
|
||
fails.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._pad__"><a class="anchor" href="#jam.language.rules.builtins.utility._pad__"></a><code>PAD</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">PAD</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">string</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">width</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If <em>string</em> is shorter than <em>width</em> characters, pads it with whitespace
|
||
characters on the right, and returns the result. Otherwise, returns
|
||
<em>string</em> unmodified.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._file_open__"><a class="anchor" href="#jam.language.rules.builtins.utility._file_open__"></a><code>FILE_OPEN</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">FILE_OPEN</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">filename</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">mode</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>FILE_OPEN</code> rule opens the specified file and returns a file
|
||
descriptor. The <em>mode</em> parameter can be either "w" or "r". Note that at
|
||
present, only the <code>UPDATE_NOW</code> rule can use the resulting file
|
||
descriptor number.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.rules.builtins.utility._update_now__"><a class="anchor" href="#jam.language.rules.builtins.utility._update_now__"></a><code>UPDATE_NOW</code></h6>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">UPDATE_NOW</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">targets</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">log</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">ignore-minus-n</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>UPDATE_NOW</code> caused the specified targets to be updated immediately.
|
||
If update was successful, non-empty string is returned. The <em>log</em>
|
||
parameter, if present, specifies a descriptor of a file where all output
|
||
from building is redirected. If the <em>ignore-minus-n</em> parameter is
|
||
specified, the targets are updated even if the <code>-n</code> parameter is
|
||
specified on the command line.</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.language.flow_of_control"><a class="anchor" href="#jam.language.flow_of_control"></a>12.2.5. Flow-of-Control</h4>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> has several simple flow-of-control statements:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">for</span><span class="tok-w"> </span>var<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span>list<span class="tok-w"> </span>{<span class="tok-w"> </span>statements<span class="tok-w"> </span>}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Executes <em>statements</em> for each element in <em>list</em>, setting the variable
|
||
<em>var</em> to the element value.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">if</span><span class="tok-w"> </span>cond<span class="tok-w"> </span>{<span class="tok-w"> </span>statements<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
[<span class="tok-w"> </span><span class="tok-k">else</span><span class="tok-w"> </span>{<span class="tok-w"> </span>statements<span class="tok-w"> </span>}<span class="tok-w"> </span>]<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Does the obvious; the <code>else</code> clause is optional. <em>cond</em> is built of:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>a</code></dt>
|
||
<dd>
|
||
<p>true if any <em>a</em> element is a non-zero-length string</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>a = b</code></dt>
|
||
<dd>
|
||
<p>list <em>a</em> matches list <em>b</em> string-for-string</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>a != b</code></dt>
|
||
<dd>
|
||
<p>list <em>a</em> does not match list <em>b</em></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>a < b</code></dt>
|
||
<dd>
|
||
<p><em>a[i]</em> string is less than <em>b[i]</em> string, where <em>i</em> is first
|
||
mismatched element in lists <em>a</em> and <em>b</em></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>a <= b</code></dt>
|
||
<dd>
|
||
<p>every <em>a</em> string is less than or equal to its <em>b</em> counterpart</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>a > b</code></dt>
|
||
<dd>
|
||
<p><em>a[i]</em> string is greater than <em>b[i]</em> string, where <em>i</em> is first
|
||
mismatched element</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>a >= b</code></dt>
|
||
<dd>
|
||
<p>every <em>a</em> string is greater than or equal to its <em>b</em> counterpart</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>a in b</code></dt>
|
||
<dd>
|
||
<p>true if all elements of <em>a</em> can be found in <em>b</em>, or if <em>a</em> has no
|
||
elements</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>! cond</code></dt>
|
||
<dd>
|
||
<p>condition not true</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cond && cond</code></dt>
|
||
<dd>
|
||
<p>conjunction</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>cond || cond</code></dt>
|
||
<dd>
|
||
<p>disjunction</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>( cond )</code></dt>
|
||
<dd>
|
||
<p>precedence grouping</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">include</span><span class="tok-w"> </span>file<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Causes <code>b2</code> to read the named <em>file</em>. The <em>file</em> is bound like a regular
|
||
target (see Binding above) but unlike a regular target the include
|
||
<em>file</em> cannot be built.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The include <em>file</em> is inserted into the input stream during the parsing
|
||
phase. The primary input file and all the included file(s) are treated
|
||
as a single file; that is, <code>b2</code> infers no scope boundaries from included
|
||
files.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">local</span><span class="tok-w"> </span>vars<span class="tok-w"> </span>[<span class="tok-w"> </span>=<span class="tok-w"> </span>values<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Creates new <em>vars</em> inside to the enclosing <code>{}</code> block, obscuring any
|
||
previous values they might have. The previous values for vars are
|
||
restored when the current block ends. Any rule called or file included
|
||
will see the local and not the previous value (this is sometimes called
|
||
Dynamic Scoping). The local statement may appear anywhere, even outside
|
||
of a block (in which case the previous value is restored when the input
|
||
ends). The <em>vars</em> are initialized to <em>values</em> if present, or left
|
||
uninitialized otherwise.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">return</span><span class="tok-w"> </span>values<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Within a rule body, the return statement sets the return value for an
|
||
invocation of the rule and returns to the caller.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">switch</span><span class="tok-w"> </span>value<span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">case</span><span class="tok-w"> </span>pattern1<span class="tok-w"> </span>:<span class="tok-w"> </span>statements<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">case</span><span class="tok-w"> </span>pattern2<span class="tok-w"> </span>:<span class="tok-w"> </span>statements<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>...<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The switch statement executes zero or one of the enclosed <em>statements</em>,
|
||
depending on which, if any, is the first case whose <em>pattern</em> matches
|
||
<em>value</em>. The <em>pattern</em> values are not variable-expanded. The pattern
|
||
values may include the following wildcards:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>?</code></dt>
|
||
<dd>
|
||
<p>match any single character</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>*</code></dt>
|
||
<dd>
|
||
<p>match zero or more characters</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>[chars]</code></dt>
|
||
<dd>
|
||
<p>match any single character in <em>chars</em></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>[^chars]</code></dt>
|
||
<dd>
|
||
<p>match any single character not in <em>chars</em></p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>\x</code></dt>
|
||
<dd>
|
||
<p>match <em>x</em> (escapes the other wildcards)</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">while</span><span class="tok-w"> </span>cond<span class="tok-w"> </span>{<span class="tok-w"> </span>statements<span class="tok-w"> </span>}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Repeatedly execute <em>statements</em> while <em>cond</em> remains true upon entry.
|
||
(See the description of <em>cond</em> expression syntax under if, above).</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">break</span><span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Immediately exits the nearest enclosing while or for loop.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">continue</span><span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Jumps to the top of the nearest enclosing while or for loop.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.language.variables"><a class="anchor" href="#jam.language.variables"></a>12.2.6. Variables</h4>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> variables are lists of zero or more elements, with each element
|
||
being a string value. An undefined variable is indistinguishable from a
|
||
variable with an empty list, however, a defined variable may have one
|
||
more elements which are null strings. All variables are referenced as
|
||
<code>$(variable)</code>.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Variables are either global or target-specific. In the latter case, the
|
||
variable takes on the given value only during the updating of the
|
||
specific target.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A variable is defined with:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>variable<span class="tok-w"> </span>=<span class="tok-w"> </span>elements<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
variable<span class="tok-w"> </span>+=<span class="tok-w"> </span>elements<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
variable<span class="tok-w"> </span><span class="tok-k">on</span><span class="tok-w"> </span>targets<span class="tok-w"> </span>=<span class="tok-w"> </span>elements<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
variable<span class="tok-w"> </span><span class="tok-k">on</span><span class="tok-w"> </span>targets<span class="tok-w"> </span>+=<span class="tok-w"> </span>elements<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
variable<span class="tok-w"> </span>default<span class="tok-w"> </span>=<span class="tok-w"> </span>elements<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
variable<span class="tok-w"> </span>?=<span class="tok-w"> </span>elements<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The first two forms set <em>variable</em> globally. The third and forth forms
|
||
set a target-specific variable. The <code>=</code> operator replaces any previous
|
||
elements of <em>variable</em> with <em>elements</em>; the <code>+=</code> operation adds
|
||
<em>elements</em> to <em>variable</em>'s list of elements. The final two forms are
|
||
synonymous: they set <em>variable</em> globally, but only if it was previously
|
||
unset.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Variables referenced in updating commands will be replaced with their
|
||
values; target-specific values take precedence over global values.
|
||
Variables passed as arguments (<code>$(1)</code> and <code>$(2)</code>) to actions are
|
||
replaced with their bound values; the <code>bind</code> modifier can be used on
|
||
actions to cause other variables to be replaced with bound values. See
|
||
Action Modifiers above.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> variables are not re-exported to the environment of the shell that
|
||
executes the updating actions, but the updating actions can reference
|
||
<code>b2</code> variables with <code>$(variable)</code>.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.variables.expansion"><a class="anchor" href="#jam.language.variables.expansion"></a>Variable Expansion</h5>
|
||
<div class="paragraph">
|
||
<p>During parsing, <code>b2</code> performs variable expansion on each token that is
|
||
not a keyword or rule name. Such tokens with embedded variable
|
||
references are replaced with zero or more tokens. Variable references
|
||
are of the form <code>$(v)</code> or <code>$(vm)</code>, where <em>v</em> is the variable name, and
|
||
<em>m</em> are optional modifiers.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Variable expansion in a rule’s actions is similar to variable expansion
|
||
in statements, except that the action string is tokenized at whitespace
|
||
regardless of quoting.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The result of a token after variable expansion is the <em>product</em> of the
|
||
components of the token, where each component is a literal substring or
|
||
a list substituting a variable reference. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>$(X) -> a b c
|
||
t$(X) -> ta tb tc
|
||
$(X)z -> az bz cz
|
||
$(X)-$(X) -> a-a a-b a-c b-a b-b b-c c-a c-b c-c</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The variable name and modifiers can themselves contain a variable
|
||
reference, and this partakes of the product as well:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>$(X) -> a b c
|
||
$(Y) -> 1 2
|
||
$(Z) -> X Y
|
||
$($(Z)) -> a b c 1 2</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Because of this product expansion, if any variable reference in a token
|
||
is undefined, the result of the expansion is an empty list. If any
|
||
variable element is a null string, the result propagates the non-null
|
||
elements:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>$(X) -> a ""
|
||
$(Y) -> "" 1
|
||
$(Z) ->
|
||
-$(X)$(Y)- -> -a- -a1- -- -1-
|
||
-$(X)$(Z)- -></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A variable element’s string value can be parsed into grist and
|
||
filename-related components. Modifiers to a variable are used to select
|
||
elements, select components, and replace components. The modifiers are:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>[n]</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select element number <em>n</em> (starting at 1). If the variable contains
|
||
fewer than <em>n</em> elements, the result is a zero-element list. <em>n</em> can be
|
||
negative in which case the element number <em>n</em> from the last leftward
|
||
is returned.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>[n-m]</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select elements number <em>n</em> through <em>m</em>. <em>n</em> and <em>m</em> can be negative in
|
||
which case they refer to elements counting from the last leftward.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>[n-]</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select elements number <em>n</em> through the last. <em>n</em> can be negative in
|
||
which case it refers to the element counting from the last leftward.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:B</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select filename base — a basename without extension.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:S</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select file extension — a (last) filename suffix.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:M</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select archive member name.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:D</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select directory path.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:P</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select parent directory.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:G</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Select grist.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:U</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Replace lowercase characters with uppercase.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:L</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Replace uppercase characters with lowercase.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:T</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>Converts all back-slashes ("\") to forward slashes ("/"). For example</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>x = "C:\\Program Files\\Borland" ; ECHO $(x:T) ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>prints <code>C:/Program Files/Borland</code></p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:W</code></dt>
|
||
<dd>
|
||
<div class="paragraph">
|
||
<p>When invoking Windows-based tools from <a href="http://www.cygwin.com/">Cygwin</a>
|
||
it can be important to pass them true windows-style paths. The <code>:W</code>
|
||
modifier, <strong>under Cygwin only</strong>, turns a cygwin path into a Win32 path
|
||
using the
|
||
<a href="http://www.cygwin.com/cygwin-api/func-cygwin-conv-to-win32-path.html"><code>cygwin_conv_to_win32_path</code></a>
|
||
function. For example</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>x = "/cygdrive/c/Program Files/Borland" ; ECHO $(x:W) ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>prints <code>C:\Program Files\Borland</code> on Cygwin</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Similarly, when used on OpenVMS, the <code>:W</code> modifier translates a
|
||
POSIX-style path into native VMS-style format using <code>decc$to_vms</code> CRTL
|
||
function. This modifier is generally used inside action blocks to
|
||
properly specify file paths in VMS-specific commands. For example</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>x = "subdir/filename.c" ; ECHO $(x:W) ;</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>prints <code>[.subdir]filename.c</code> on OpenVMS</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>On other platforms, the string is unchanged.</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:chars</code></dt>
|
||
<dd>
|
||
<p>Select the components listed in <em>chars</em>.</p>
|
||
<div class="paragraph">
|
||
<p>For example, <code>:BS</code> selects filename (basename and extension).</p>
|
||
</div>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:G=grist</code></dt>
|
||
<dd>
|
||
<p>Replace grist with <em>grist</em>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:D=path</code></dt>
|
||
<dd>
|
||
<p>Replace directory with <em>path</em>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:B=base</code></dt>
|
||
<dd>
|
||
<p>Replace the base part of file name with <em>base</em>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:S=suf</code></dt>
|
||
<dd>
|
||
<p>Replace the suffix of file name with <em>suf</em>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:M=mem</code></dt>
|
||
<dd>
|
||
<p>Replace the archive member name with <em>mem</em>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:R=root</code></dt>
|
||
<dd>
|
||
<p>Prepend <em>root</em> to the whole file name, if not already rooted.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:E=value</code></dt>
|
||
<dd>
|
||
<p>Assign <em>value</em> to the variable if it is unset.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:J=joinval</code></dt>
|
||
<dd>
|
||
<p>Concatenate list elements into single element, separated by
|
||
<em>joinval</em>.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:O=value</code></dt>
|
||
<dd>
|
||
<p>Sets semantic options for the evaluation of the variable. The format of the
|
||
<em>value</em> is specific to either variable or generated file expansion.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>On VMS, <code>$(var:P)</code> is the parent directory of <code>$(var:D)</code>.</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>:⇐value</code></dt>
|
||
<dd>
|
||
<p>After evaluating the expansion of the variable prefixes the given <em>value</em>
|
||
to the elements of the expanded expression values.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>:>=value</code></dt>
|
||
<dd>
|
||
<p>After evaluating the expansion of the variable postfixes the given <em>value</em>
|
||
to the elements of the expanded expression values.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.variables.local_for_loop_variables"><a class="anchor" href="#jam.language.variables.local_for_loop_variables"></a>Local For Loop Variables</h5>
|
||
<div class="paragraph">
|
||
<p>Boost Jam allows you to declare a local for loop control variable right
|
||
in the loop:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>x<span class="tok-w"> </span>=<span class="tok-w"> </span>1<span class="tok-w"> </span>2<span class="tok-w"> </span>3<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
y<span class="tok-w"> </span>=<span class="tok-w"> </span>4<span class="tok-w"> </span>5<span class="tok-w"> </span>6<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-k">for</span><span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>y<span class="tok-w"> </span><span class="tok-k">in</span><span class="tok-w"> </span><span class="tok-si">$(x)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nb">ECHO</span><span class="tok-w"> </span><span class="tok-si">$(y)</span><span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># prints "1", "2", or "3"</span>
|
||
}<span class="tok-w"></span>
|
||
<span class="tok-nb">ECHO</span><span class="tok-w"> </span><span class="tok-si">$(y)</span><span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># prints "4 5 6"</span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.variables.atfile"><a class="anchor" href="#jam.language.variables.atfile"></a>Generated File Expansion</h5>
|
||
<div class="paragraph">
|
||
<p>During expansion of expressions <code>b2</code> also looks for subexpressions of
|
||
the form <code>@(filename:E=filecontents)</code> and replaces the expression with
|
||
<code>filename</code> after creating the given file with the contents set to
|
||
<code>filecontents</code>. This is useful for creating compiler response files, and
|
||
other "internal" files. The expansion works both during parsing and
|
||
action execution. Hence it is possible to create files during any of the
|
||
three build phases. This expansion follows the same modifiers as variable
|
||
expansion. The generated file expansion accepts these (<code>:O=</code>) expansion
|
||
option values:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>F</code></dt>
|
||
<dd>
|
||
<p>Always replace the <code>@()</code> reference with the name of the file generated.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>C</code></dt>
|
||
<dd>
|
||
<p>Always replace the <code>@()</code> reference with the contents, i.e. the <em>value</em>
|
||
in the <code>:E=value</code> expression.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>FC</code> or <code>CF</code></dt>
|
||
<dd>
|
||
<p>Replace with either the file or contents depending on the length of the
|
||
contents (<code>:E=value</code>). It will replace with the contents in an action
|
||
if the length of the command is shorter than the allowed command length
|
||
limit. Otherwise the reference is replaced with the filename.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.variables.builtins"><a class="anchor" href="#jam.language.variables.builtins"></a>Built-in Variables</h5>
|
||
<div class="paragraph">
|
||
<p>This section discusses variables that have special meaning to <code>b2</code>. All
|
||
of these must be defined or used in the global module — using those
|
||
variables inside a named module will not have the desired effect. See
|
||
<a href="#jam.language.modules">Modules</a>.</p>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.variables.builtins.search"><a class="anchor" href="#jam.language.variables.builtins.search"></a>SEARCH and LOCATE</h6>
|
||
<div class="paragraph">
|
||
<p>These two variables control the binding of file target names to
|
||
locations in the file system. Generally, <code>$(SEARCH)</code> is used to find
|
||
existing sources while <code>$(LOCATE)</code> is used to fix the location for built
|
||
targets.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Rooted (absolute path) file targets are bound as is. Unrooted file
|
||
target names are also normally bound as is, and thus relative to the
|
||
current directory, but the settings of <code>$(LOCATE)</code> and <code>$(SEARCH)</code> alter
|
||
this:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>If <code>$(LOCATE)</code> is set then the target is bound relative to the first
|
||
directory in <code>$(LOCATE)</code>. Only the first element is used for binding.</p>
|
||
</li>
|
||
<li>
|
||
<p>If <code>$(SEARCH)</code> is set then the target is bound to the first directory
|
||
in <code>$(SEARCH)</code> where the target file already exists.</p>
|
||
</li>
|
||
<li>
|
||
<p>If the <code>$(SEARCH)</code> search fails, the target is bound relative to the
|
||
current directory anyhow.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Both <code>$(SEARCH)</code> and <code>$(LOCATE)</code> should be set target-specific and not
|
||
globally. If they were set globally, <code>b2</code> would use the same paths for
|
||
all file binding, which is not likely to produce sane results. When
|
||
writing your own rules, especially ones not built upon those in Jambase,
|
||
you may need to set <code>$(SEARCH)</code> or <code>$(LOCATE)</code> directly. Almost all of
|
||
the rules defined in Jambase set <code>$(SEARCH)</code> and <code>$(LOCATE)</code> to sensible
|
||
values for sources they are looking for and targets they create,
|
||
respectively.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.variables.builtins.hdrscan"><a class="anchor" href="#jam.language.variables.builtins.hdrscan"></a>HDRSCAN and HDRRULE</h6>
|
||
<div class="paragraph">
|
||
<p>These two variables control header file scanning. <code>$(HDRSCAN)</code> is an
|
||
<code>egrep(1)</code> pattern, with ()'s surrounding the file name, used to find
|
||
file inclusion statements in source files. <code>Jambase</code> uses
|
||
<code>$(HDRPATTERN)</code> as the pattern for <code>$(HDRSCAN)</code>. <code>$(HDRRULE)</code> is the
|
||
name of a rule to invoke with the results of the scan: the scanned file
|
||
is the target, the found files are the sources. This is the only place
|
||
where <code>b2</code> invokes a rule through a variable setting.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Both <code>$(HDRSCAN)</code> and <code>$(HDRRULE)</code> must be set for header file scanning
|
||
to take place, and they should be set target-specific and not globally.
|
||
If they were set globally, all files, including executables and
|
||
libraries, would be scanned for header file include statements.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The scanning for header file inclusions is not exact, but it is at least
|
||
dynamic, so there is no need to run something like <code>makedepend(GNU)</code> to
|
||
create a static dependency file. The scanning mechanism errs on the side
|
||
of inclusion (i.e., it is more likely to return filenames that are not
|
||
actually used by the compiler than to miss include files) because it
|
||
can’t tell if <code>#include</code> lines are inside <code>#ifdefs</code> or other conditional
|
||
logic. In <code>Jambase</code>, <code>HdrRule</code> applies the <code>NOCARE</code> rule to each header
|
||
file found during scanning so that if the file isn’t present yet doesn’t
|
||
cause the compilation to fail, <code>b2</code> won’t care.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Also, scanning for regular expressions only works where the included
|
||
file name is literally in the source file. It can’t handle languages
|
||
that allow including files using variable names (as the <code>Jam</code> language
|
||
itself does).</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.variables.builtins.semaphores"><a class="anchor" href="#jam.language.variables.builtins.semaphores"></a>Semaphores</h6>
|
||
<div class="paragraph">
|
||
<p>It is sometimes desirable to disallow parallel execution of some
|
||
actions. For example:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Old versions of yacc use files with fixed names. So, running two yacc
|
||
actions is dangerous.</p>
|
||
</li>
|
||
<li>
|
||
<p>One might want to perform parallel compiling, but not do parallel
|
||
linking, because linking is i/o bound and only gets slower.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Craig McPeeters has extended Perforce Jam to solve such problems, and
|
||
that extension was integrated in Boost.Jam.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Any target can be assigned a <em>semaphore</em>, by setting a variable called
|
||
<code>SEMAPHORE</code> on that target. The value of the variable is the semaphore
|
||
name. It must be different from names of any declared target, but is
|
||
arbitrary otherwise.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The semantic of semaphores is that in a group of targets which have the
|
||
same semaphore, only one can be updated at the moment, regardless of
|
||
<code>-j</code> option.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.variables.builtins.platform_identifier"><a class="anchor" href="#jam.language.variables.builtins.platform_identifier"></a>Platform Identifier</h6>
|
||
<div class="paragraph">
|
||
<p>A number of Jam built-in variables can be used to identify runtime
|
||
platform:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>OS</code></dt>
|
||
<dd>
|
||
<p>OS identifier string</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>OSPLAT</code></dt>
|
||
<dd>
|
||
<p>Underlying architecture, when applicable</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>MAC</code></dt>
|
||
<dd>
|
||
<p>true on MAC platform</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>NT</code></dt>
|
||
<dd>
|
||
<p>true on NT platform</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>OS2</code></dt>
|
||
<dd>
|
||
<p>true on OS2 platform</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>UNIX</code></dt>
|
||
<dd>
|
||
<p>true on Unix platforms</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>VMS</code></dt>
|
||
<dd>
|
||
<p>true on VMS platform</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.variables.builtins.jam_version"><a class="anchor" href="#jam.language.variables.builtins.jam_version"></a>Jam Version</h5>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>JAMDATE</code></dt>
|
||
<dd>
|
||
<p>Time and date at <code>b2</code> start-up as an ISO-8601 UTC value.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>JAMUNAME</code></dt>
|
||
<dd>
|
||
<p>Output of uname(1) command (Unix only)</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>JAMVERSION</code></dt>
|
||
<dd>
|
||
<p><code>b2</code> version, as a sematic triplet "X.Y.Z".</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>JAM_VERSION</code></dt>
|
||
<dd>
|
||
<p>A predefined global variable with two elements indicates the version
|
||
number of Boost Jam. Boost Jam versions start at <code>03</code> <code>00</code>.
|
||
Earlier versions of <code>Jam</code> do not automatically define <code>JAM_VERSION</code>.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.variables.builtins.jamshell"><a class="anchor" href="#jam.language.variables.builtins.jamshell"></a>JAMSHELL</h6>
|
||
<div class="paragraph">
|
||
<p>When <code>b2</code> executes a rule’s action block, it forks and execs a shell,
|
||
passing the action block as an argument to the shell. The invocation of
|
||
the shell can be controlled by <code>$(JAMSHELL)</code>. The default on Unix is,
|
||
for example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>JAMSHELL<span class="tok-w"> </span>=<span class="tok-w"> </span>/bin/sh<span class="tok-w"> </span>-c<span class="tok-w"> </span>%<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>%</code> is replaced with the text of the action block.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> does not directly support building in parallel across multiple
|
||
hosts, since that is heavily dependent on the local environment. To
|
||
build in parallel across multiple hosts, you need to write your own
|
||
shell that provides access to the multiple hosts. You then reset
|
||
<code>$(JAMSHELL)</code> to reference it.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Just as <code>b2</code> expands a <code>%</code> to be the text of the rule’s action block, it
|
||
expands a <code>!</code> to be the multi-process slot number. The slot number
|
||
varies between 1 and the number of concurrent jobs permitted by the <code>-j</code>
|
||
flag given on the command line. Armed with this, it is possible to write
|
||
a multiple host shell. For example:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="bash"><span></span><span class="tok-ch">#!/bin/sh</span>
|
||
|
||
<span class="tok-c1"># This sample JAMSHELL uses the SunOS on(1) command to execute a</span>
|
||
<span class="tok-c1"># command string with an identical environment on another host.</span>
|
||
|
||
<span class="tok-c1"># Set JAMSHELL = jamshell ! %</span>
|
||
<span class="tok-c1">#</span>
|
||
<span class="tok-c1"># where jamshell is the name of this shell file.</span>
|
||
<span class="tok-c1">#</span>
|
||
<span class="tok-c1"># This version handles up to -j6; after that they get executed</span>
|
||
<span class="tok-c1"># locally.</span>
|
||
|
||
<span class="tok-k">case</span> <span class="tok-nv">$1</span> in
|
||
<span class="tok-m">1</span><span class="tok-p">|</span><span class="tok-m">4</span><span class="tok-o">)</span> on winken sh -c <span class="tok-s2">"</span><span class="tok-nv">$2</span><span class="tok-s2">"</span><span class="tok-p">;;</span>
|
||
<span class="tok-m">2</span><span class="tok-p">|</span><span class="tok-m">5</span><span class="tok-o">)</span> on blinken sh -c <span class="tok-s2">"</span><span class="tok-nv">$2</span><span class="tok-s2">"</span><span class="tok-p">;;</span>
|
||
<span class="tok-m">3</span><span class="tok-p">|</span><span class="tok-m">6</span><span class="tok-o">)</span> on nod sh -c <span class="tok-s2">"</span><span class="tok-nv">$2</span><span class="tok-s2">"</span><span class="tok-p">;;</span>
|
||
*<span class="tok-o">)</span> <span class="tok-nb">eval</span> <span class="tok-s2">"</span><span class="tok-nv">$2</span><span class="tok-s2">"</span><span class="tok-p">;;</span>
|
||
<span class="tok-k">esac</span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect5">
|
||
<h6 id="jam.language.variables.builtins.actionrule"><a class="anchor" href="#jam.language.variables.builtins.actionrule"></a><code>__TIMING_RULE__</code> and <code>__ACTION_RULE__</code></h6>
|
||
<div class="paragraph">
|
||
<p>The <code>__TIMING_RULE__</code> and <code>__ACTION_RULE__</code> can be set to the name of a
|
||
rule for <code>b2</code> to call <strong>after</strong> an action completes for a target. They
|
||
both give diagnostic information about the action that completed. For
|
||
<code>__TIMING_RULE__</code> the rule is called as:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">timing-rule</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">args</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">start</span><span class="tok-w"> </span><span class="tok-nv">end</span><span class="tok-w"> </span><span class="tok-nv">user</span><span class="tok-w"> </span><span class="tok-nv">system</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>And <code>__ACTION_RULE__</code> is called as:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">action-rule</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">args</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">command</span><span class="tok-w"> </span><span class="tok-nv">status</span><span class="tok-w"> </span><span class="tok-nv">start</span><span class="tok-w"> </span><span class="tok-nv">end</span><span class="tok-w"> </span><span class="tok-nv">user</span><span class="tok-w"> </span><span class="tok-nv">system</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">output</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The arguments for both are:</p>
|
||
</div>
|
||
<div class="dlist">
|
||
<dl>
|
||
<dt class="hdlist1"><code>args</code></dt>
|
||
<dd>
|
||
<p>Any values following the rule name in the <code>__TIMING_RULE__</code> or
|
||
<code>__ACTION_RULE__</code> are passed along here.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>target</code></dt>
|
||
<dd>
|
||
<p>The <code>b2</code> target that was built.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>command</code></dt>
|
||
<dd>
|
||
<p>The text of the executed command in the action body.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>status</code></dt>
|
||
<dd>
|
||
<p>The integer result of the executed command.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>start</code></dt>
|
||
<dd>
|
||
<p>The starting timestamp of the executed command as a ISO-8601 UTC
|
||
value.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>end</code></dt>
|
||
<dd>
|
||
<p>The completion timestamp of the executed command as a ISO-8601 UTC
|
||
value.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>user</code></dt>
|
||
<dd>
|
||
<p>The number of user CPU seconds the executed command spent as a
|
||
floating point value.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>system</code></dt>
|
||
<dd>
|
||
<p>The number of system CPU seconds the executed command spent as a
|
||
floating point value.</p>
|
||
</dd>
|
||
<dt class="hdlist1"><code>output</code></dt>
|
||
<dd>
|
||
<p>The output of the command as a single string. The content of the
|
||
output reflects the use of the <code>-pX</code> option.</p>
|
||
</dd>
|
||
</dl>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
If both variables are set for a target both are called, first
|
||
<code>__TIMING_RULE__</code> then <code>__ACTION_RULE__</code>.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.language.modules"><a class="anchor" href="#jam.language.modules"></a>12.2.7. Modules</h4>
|
||
<div class="paragraph">
|
||
<p>Boost Jam introduces support for modules, which provide some rudimentary
|
||
namespace protection for rules and variables. A new keyword, <code>module</code>
|
||
was also introduced. The features described in this section are
|
||
primitives, meaning that they are meant to provide the operations needed
|
||
to write Jam rules which provide a more elegant module interface.</p>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.declaration"><a class="anchor" href="#jam.language.modules.declaration"></a>Declaration</h5>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">module</span><span class="tok-w"> </span><span class="tok-nn">expression</span><span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"> </span>...<span class="tok-w"> </span>}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Code within the <code>{ …​ }</code> executes within the module named by evaluating
|
||
expression. Rule definitions can be found in the module’s own namespace,
|
||
and in the namespace of the global module as <em>module-name</em>.<em>rule-name</em>,
|
||
so within a module, other rules in that module may always be invoked
|
||
without qualification:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">module</span><span class="tok-w"> </span><span class="tok-nn">my_module</span><span class="tok-w"></span>
|
||
<span class="tok-p">{</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">salute</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">x</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"> </span>{<span class="tok-w"> </span><span class="tok-nb">ECHO</span><span class="tok-w"> </span><span class="tok-si">$(x)</span>,<span class="tok-w"> </span>world<span class="tok-w"> </span>;<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">greet</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"> </span>{<span class="tok-w"> </span>salute<span class="tok-w"> </span>hello<span class="tok-w"> </span>;<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>greet<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
}<span class="tok-w"></span>
|
||
my_module.salute<span class="tok-w"> </span>goodbye<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>When an invoked rule is not found in the current module’s namespace, it
|
||
is looked up in the namespace of the global module, so qualified calls
|
||
work across modules:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">module</span><span class="tok-w"> </span><span class="tok-nn">your_module</span><span class="tok-w"></span>
|
||
<span class="tok-p">{</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">bedtime</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"> </span>{<span class="tok-w"> </span>my_module.salute<span class="tok-w"> </span>goodnight<span class="tok-w"> </span>;<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.variable_scope"><a class="anchor" href="#jam.language.modules.variable_scope"></a>Variable Scope</h5>
|
||
<div class="paragraph">
|
||
<p>Each module has its own set of dynamically nested variable scopes. When
|
||
execution passes from module A to module B, all the variable bindings
|
||
from A become unavailable, and are replaced by the bindings that belong
|
||
to B. This applies equally to local and global variables:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">module</span><span class="tok-w"> </span><span class="tok-nn">A</span><span class="tok-w"></span>
|
||
<span class="tok-p">{</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>x<span class="tok-w"> </span>=<span class="tok-w"> </span>1<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">f</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span>y<span class="tok-w"> </span>=<span class="tok-w"> </span>999<span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># becomes visible again when B.f calls A.g</span>
|
||
<span class="tok-w"> </span>B.f<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">g</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nb">ECHO</span><span class="tok-w"> </span><span class="tok-si">$(y)</span><span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># prints "999"</span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
}<span class="tok-w"></span>
|
||
<span class="tok-k">module</span><span class="tok-w"> </span><span class="tok-nn">B</span><span class="tok-w"></span>
|
||
<span class="tok-p">{</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>y<span class="tok-w"> </span>=<span class="tok-w"> </span>2<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">f</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span>{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nb">ECHO</span><span class="tok-w"> </span><span class="tok-si">$(y)</span><span class="tok-w"> </span>;<span class="tok-w"> </span><span class="tok-c1"># always prints "2"</span>
|
||
<span class="tok-w"> </span>A.g<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The only way to access another module’s variables is by entering that
|
||
module:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">peek</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">module-name</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">variables</span><span class="tok-w"> </span><span class="tok-p">+</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span>
|
||
{<span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">module</span><span class="tok-w"> </span><span class="tok-nn">$(module-name)</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">return</span><span class="tok-w"> </span><span class="tok-si">$($(>))</span><span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-w"> </span>}<span class="tok-w"></span>
|
||
}<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Note that because existing variable bindings change whenever a new
|
||
module scope is entered, argument bindings become unavailable. That
|
||
explains the use of <code>$(>)</code> in the peek rule above.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.local_rules"><a class="anchor" href="#jam.language.modules.local_rules"></a>Local Rules</h5>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">local</span><span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">rulename...</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The rule is declared locally to the current module. It is not entered in
|
||
the global module with qualification, and its name will not appear in
|
||
the result of:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span>[<span class="tok-w"> </span><span class="tok-nb">RULENAMES</span><span class="tok-w"> </span><span class="tok-k">module</span>-name<span class="tok-w"> </span>]<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.the__rulenames__rule"><a class="anchor" href="#jam.language.modules.the__rulenames__rule"></a>The <code>RULENAMES</code> Rule</h5>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">RULENAMES</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">module</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Returns a list of the names of all non-local rules in the given module.
|
||
If <em>module</em> is omitted, the names of all non-local rules in the global
|
||
module are returned.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.the__varnames__rule"><a class="anchor" href="#jam.language.modules.the__varnames__rule"></a>The <code>VARNAMES</code> Rule</h5>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">VARNAMES</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">module</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Returns a list of the names of all variable bindings in the given
|
||
module. If <em>module</em> is omitted, the names of all variable bindings in
|
||
the global module are returned.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
This includes any local variables in rules from the call stack which
|
||
have not returned at the time of the <code>VARNAMES</code> invocation.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.the__import__rule"><a class="anchor" href="#jam.language.modules.the__import__rule"></a>The <code>IMPORT</code> Rule</h5>
|
||
<div class="paragraph">
|
||
<p><code>IMPORT</code> allows rule name aliasing across modules:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">IMPORT</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">source_module</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">source_rules</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target_module</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">target_rules</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>IMPORT</code> rule copies rules from the <em>source_module</em> into the
|
||
<em>target_module</em> as local rules. If either <em>source_module</em> or
|
||
<em>target_module</em> is not supplied, it refers to the global module.
|
||
<em>source_rules</em> specifies which rules from the <em>source_module</em> to import;
|
||
<em>target_rules</em> specifies the names to give those rules in
|
||
<em>target_module</em>. If <em>source_rules</em> contains a name which doesn’t
|
||
correspond to a rule in <em>source_module</em>, or if it contains a different
|
||
number of items than <em>target_rules</em>, an error is issued. For example,</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-c1"># import m1.rule1 into m2 as local rule m1-rule1.</span>
|
||
<span class="tok-nb">IMPORT</span><span class="tok-w"> </span>m1<span class="tok-w"> </span>:<span class="tok-w"> </span>rule1<span class="tok-w"> </span>:<span class="tok-w"> </span>m2<span class="tok-w"> </span>:<span class="tok-w"> </span>m1-rule1<span class="tok-w"> </span>;<span class="tok-w"></span>
|
||
<span class="tok-c1"># import all non-local rules from m1 into m2</span>
|
||
<span class="tok-nb">IMPORT</span><span class="tok-w"> </span>m1<span class="tok-w"> </span>:<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">RULENAMES</span><span class="tok-w"> </span>m1<span class="tok-w"> </span>]<span class="tok-w"> </span>:<span class="tok-w"> </span>m2<span class="tok-w"> </span>:<span class="tok-w"> </span>[<span class="tok-w"> </span><span class="tok-nb">RULENAMES</span><span class="tok-w"> </span>m1<span class="tok-w"> </span>]<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.the__export__rule"><a class="anchor" href="#jam.language.modules.the__export__rule"></a>The <code>EXPORT</code> Rule</h5>
|
||
<div class="paragraph">
|
||
<p><code>EXPORT</code> allows rule name aliasing across modules:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">EXPORT</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">module</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">rules</span><span class="tok-w"> </span><span class="tok-p">*</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>The <code>EXPORT</code> rule marks <em>rules</em> from the <code>source_module</code> as non-local
|
||
(and thus exportable). If an element of <em>rules</em> does not name a rule in
|
||
<em>module</em>, an error is issued. For example,</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">module</span><span class="tok-w"> </span><span class="tok-nn">X</span><span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">local</span><span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">r</span><span class="tok-w"> </span><span class="tok-nv">{</span><span class="tok-w"> </span><span class="tok-nv">ECHO</span><span class="tok-w"> </span><span class="tok-nv">X.r</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"> </span><span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-nv">IMPORT</span><span class="tok-w"> </span><span class="tok-nv">X</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">r</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">r</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"> </span><span class="tok-c1"># error - r is local in X</span>
|
||
<span class="tok-nv">EXPORT</span><span class="tok-w"> </span><span class="tok-nv">X</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">r</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"></span>
|
||
<span class="tok-nv">IMPORT</span><span class="tok-w"> </span><span class="tok-nv">X</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">r</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-p">:</span><span class="tok-w"> </span><span class="tok-nv">r</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"> </span><span class="tok-c1"># OK.</span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.the__caller_module__rule"><a class="anchor" href="#jam.language.modules.the__caller_module__rule"></a>The <code>CALLER_MODULE</code> Rule</h5>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">CALLER_MODULE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">levels</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>CALLER_MODULE</code> returns the name of the module scope enclosing the call
|
||
to its caller (if levels is supplied, it is interpreted as an integer
|
||
number of additional levels of call stack to traverse to locate the
|
||
module). If the scope belongs to the global module, or if no such module
|
||
exists, returns the empty list. For example, the following prints "{Y}
|
||
{X}":</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">module</span><span class="tok-w"> </span><span class="tok-nn">X</span><span class="tok-w"> </span><span class="tok-p">{</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">get-caller</span><span class="tok-w"> </span><span class="tok-nv">{</span><span class="tok-w"> </span><span class="tok-nv">return</span><span class="tok-w"> </span><span class="tok-nv">[</span><span class="tok-w"> </span><span class="tok-nv">CALLER_MODULE</span><span class="tok-w"> </span><span class="tok-nv">]</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"> </span><span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">rule</span><span class="tok-w"> </span><span class="tok-nv">get-caller's-caller</span><span class="tok-w"> </span><span class="tok-nv">{</span><span class="tok-w"> </span><span class="tok-nv">return</span><span class="tok-w"> </span><span class="tok-nv">[</span><span class="tok-w"> </span><span class="tok-nv">CALLER_MODULE</span><span class="tok-w"> </span><span class="tok-nv">1</span><span class="tok-w"> </span><span class="tok-nv">]</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"> </span><span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">rule</span><span class="tok-w"> </span><span class="tok-nv">call-Y</span><span class="tok-w"> </span><span class="tok-nv">{</span><span class="tok-w"> </span><span class="tok-nv">return</span><span class="tok-w"> </span><span class="tok-nv">Y.call-X2</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"> </span><span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-nv">module</span><span class="tok-w"> </span><span class="tok-nv">Y</span><span class="tok-w"> </span><span class="tok-nv">{</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">rule</span><span class="tok-w"> </span><span class="tok-nv">call-X</span><span class="tok-w"> </span><span class="tok-nv">{</span><span class="tok-w"> </span><span class="tok-nv">return</span><span class="tok-w"> </span><span class="tok-nv">X.get-caller</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"> </span><span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-w"> </span><span class="tok-nv">rule</span><span class="tok-w"> </span><span class="tok-nv">call-X2</span><span class="tok-w"> </span><span class="tok-nv">{</span><span class="tok-w"> </span><span class="tok-nv">return</span><span class="tok-w"> </span><span class="tok-nv">X.get-caller's-caller</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"> </span><span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-nv">}</span><span class="tok-w"></span>
|
||
<span class="tok-nv">callers</span><span class="tok-w"> </span><span class="tok-nv">=</span><span class="tok-w"> </span><span class="tok-nv">[</span><span class="tok-w"> </span><span class="tok-nv">X.get-caller</span><span class="tok-w"> </span><span class="tok-nv">]</span><span class="tok-w"> </span><span class="tok-nv">[</span><span class="tok-w"> </span><span class="tok-nv">Y.call-X</span><span class="tok-w"> </span><span class="tok-nv">]</span><span class="tok-w"> </span><span class="tok-nv">[</span><span class="tok-w"> </span><span class="tok-nv">X.call-Y</span><span class="tok-w"> </span><span class="tok-nv">]</span><span class="tok-w"> </span><span class="tok-nv">;</span><span class="tok-w"></span>
|
||
<span class="tok-nv">ECHO</span><span class="tok-w"> </span><span class="tok-nv">{$(callers</span><span class="tok-p">)</span>}<span class="tok-w"> </span>;<span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect4">
|
||
<h5 id="jam.language.modules.the__delete_module__rule"><a class="anchor" href="#jam.language.modules.the__delete_module__rule"></a>The <code>DELETE_MODULE</code> Rule</h5>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre class="pygments highlight"><code data-lang="jam"><span></span><span class="tok-k">rule</span><span class="tok-w"> </span><span class="tok-nf">DELETE_MODULE</span><span class="tok-w"> </span><span class="tok-p">(</span><span class="tok-w"> </span><span class="tok-nv">module</span><span class="tok-w"> </span><span class="tok-p">?</span><span class="tok-w"> </span><span class="tok-p">)</span><span class="tok-w"></span></code></pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>DELETE_MODULE</code> removes all of the variable bindings and
|
||
otherwise-unreferenced rules from the given module (or the global
|
||
module, if no module is supplied), and returns their memory to the
|
||
system.</p>
|
||
</div>
|
||
<div class="admonitionblock note">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">ℹ</div>
|
||
</td>
|
||
<td class="content">
|
||
Though it won’t affect rules that are currently executing until they
|
||
complete, <code>DELETE_MODULE</code> should be used with extreme care because it
|
||
will wipe out any others and all variable (including locals in that
|
||
module) immediately. Because of the way dynamic binding works, variables
|
||
which are shadowed by locals will not be destroyed, so the results can
|
||
be really unpredictable.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="jam.miscellaneous"><a class="anchor" href="#jam.miscellaneous"></a>12.3. Miscellaneous</h3>
|
||
<div class="sect3">
|
||
<h4 id="jam.miscellaneous.diagnostics"><a class="anchor" href="#jam.miscellaneous.diagnostics"></a>12.3.1. Diagnostics</h4>
|
||
<div class="paragraph">
|
||
<p>In addition to generic error messages, <code>b2</code> may emit one of the
|
||
following:</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>warning: unknown rule X</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A rule was invoked that has not been defined with an <code>actions</code> or
|
||
<code>rule</code> statement.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>using N temp target(s)</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Targets marked as being temporary (but nonetheless present) have been
|
||
found.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>updating N target(s)</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Targets are out-of-date and will be updated.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>can't find N target(s)</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Source files can’t be found and there are no actions to create them.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>can't make N target(s)</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Due to sources not being found, other targets cannot be made.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>warning: X depends on itself</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A target depends on itself either directly or through its sources.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>don't know how to make X</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A target is not present and no actions have been defined to create it.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>X skipped for lack of Y</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A source failed to build, and thus a target cannot be built.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>warning: using independent target X</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A target that is not a dependency of any other target is being
|
||
referenced with <code>$(<)</code> or <code>$(>)</code>.</p>
|
||
</div>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>X removed</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p><code>B2</code> removed a partially built target after being interrupted.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.miscellaneous.bugs__limitations"><a class="anchor" href="#jam.miscellaneous.bugs__limitations"></a>12.3.2. Bugs, Limitations</h4>
|
||
<div class="paragraph">
|
||
<p>For parallel building to be successful, the dependencies among files
|
||
must be properly spelled out, as targets tend to get built in a
|
||
quickest-first ordering. Also, beware of un-parallelizable commands that
|
||
drop fixed-named files into the current directory, like <code>yacc(1)</code> does.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>A poorly set <code>$(JAMSHELL)</code> is likely to result in silent failure.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect3">
|
||
<h4 id="jam.miscellaneous.fundamentals"><a class="anchor" href="#jam.miscellaneous.fundamentals"></a>12.3.3. Fundamentals</h4>
|
||
<div class="paragraph">
|
||
<p>This section is derived from the official Jam documentation and from
|
||
experience using it and reading the Jambase rules. We repeat the
|
||
information here mostly because it is essential to understanding and
|
||
using Jam, but is not consolidated in a single place. Some of it is
|
||
missing from the official documentation altogether. We hope it will be
|
||
useful to anyone wishing to become familiar with Jam and the Boost build
|
||
system.</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Jam <code>rules</code> are actually simple procedural entities. Think of them
|
||
as functions. Arguments are separated by colons.</p>
|
||
</li>
|
||
<li>
|
||
<p>A Jam <strong>target</strong> is an abstract entity identified by an arbitrary
|
||
string. The built-in <code>DEPENDS</code> rule creates a link in the dependency
|
||
graph between the named targets.</p>
|
||
</li>
|
||
<li>
|
||
<p>Note that the original Jam documentation for the built-in <code>INCLUDES</code>
|
||
rule is incorrect: <code>INCLUDES targets1 : targets2</code> causes everything that
|
||
depends on a member of
|
||
<em>targets1</em> to depend on all members of <em>targets2</em>. It does this in an
|
||
odd way, by tacking <em>targets2</em> onto a special tail section in the
|
||
dependency list of everything in <em>targets1</em>. It seems to be OK to create
|
||
circular dependencies this way; in fact, it appears to be the "right
|
||
thing to do" when a single build action produces both <em>targets1</em> and
|
||
<em>targets2</em>.</p>
|
||
</li>
|
||
<li>
|
||
<p>When a rule is invoked, if there are <code>actions</code> declared with the same
|
||
name as the rule, the actions are added to the updating actions for the
|
||
target identified by the rule’s first argument. It is actually possible
|
||
to invoke an undeclared rule if corresponding actions are declared: the
|
||
rule is treated as empty.</p>
|
||
</li>
|
||
<li>
|
||
<p>Targets (other than <code>NOTFILE</code> targets) are associated with paths in
|
||
the file system through a process called binding. Binding is a process
|
||
of searching for a file with the same name as the target (sans grist),
|
||
based on the settings of the target-specific <code>SEARCH</code> and <code>LOCATE</code>
|
||
variables.</p>
|
||
</li>
|
||
<li>
|
||
<p>In addition to local and global variables, jam allows you to set a
|
||
variable <code>on</code> a target. Target-specific variable values can usually not
|
||
be read, and take effect only in the following contexts:</p>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>In updating actions, variable values are first looked up <code>on</code> the
|
||
target named by the first argument (the target being updated). Because
|
||
Jam builds its entire dependency tree before executing actions, Jam
|
||
rules make target-specific variable settings as a way of supplying
|
||
parameters to the corresponding actions.</p>
|
||
</li>
|
||
<li>
|
||
<p>Binding is controlled <em>entirely</em> by the target-specific setting of
|
||
the <code>SEARCH</code> and <code>LOCATE</code> variables, as described here.</p>
|
||
</li>
|
||
<li>
|
||
<p>In the special rule used for header file scanning, variable values
|
||
are first looked up <code>on</code> the target named by the rule’s first argument
|
||
(the source file being scanned).</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>The "bound value" of a variable is the path associated with the target
|
||
named by the variable. In build actions, the first two arguments are
|
||
automatically replaced with their bound values. Target-specific
|
||
variables can be selectively replaced by their bound values using the
|
||
<code>bind</code> action modifier.</p>
|
||
</li>
|
||
<li>
|
||
<p>Note that the term "binding" as used in the Jam documentation
|
||
indicates a phase of processing that includes three sub-phases:
|
||
<em>binding</em> (yes!), update determination, and header file scanning. The
|
||
repetition of the term "binding" can lead to some confusion. In
|
||
particular, the Modifying Binding section in the Jam documentation
|
||
should probably be titled "Modifying Update Determination".</p>
|
||
</li>
|
||
<li>
|
||
<p>"Grist" is just a string prefix of the form <<em>characters</em>>. It is
|
||
used in Jam to create unique target names based on simpler names. For
|
||
example, the file name <code>test.exe</code> may be used by targets in separate
|
||
sub-projects, or for the debug and release variants of the "same"
|
||
abstract target. Each distinct target bound to a file called "test.exe"
|
||
has its own unique grist prefix. The Boost build system also takes full
|
||
advantage of Jam’s ability to divide strings on grist boundaries,
|
||
sometimes concatenating multiple gristed elements at the beginning of a
|
||
string. Grist is used instead of identifying targets with absolute paths
|
||
for two reasons:</p>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p>The location of targets cannot always be derived solely from what
|
||
the user puts in a Jamfile, but sometimes depends also on the binding
|
||
process. Some mechanism to distinctly identify targets with the same
|
||
name is still needed.</p>
|
||
</li>
|
||
<li>
|
||
<p>Grist allows us to use a uniform abstract identifier for each built
|
||
target, regardless of target file location (as allowed by setting
|
||
ALL_LOCATE_TARGET).</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>When grist is extracted from a name with $(var:G), the result includes
|
||
the leading and trailing angle brackets. When grist is added to a name
|
||
with <code>$(var:G=expr)</code>, existing grist is first stripped. Then, if <code>expr</code> is
|
||
non-empty, leading <s and trailing >s are added if necessary to form an
|
||
expression of the form <expr2>; <expr2> is then prepended.</p>
|
||
</li>
|
||
<li>
|
||
<p>When Jam is invoked it imports all environment variable settings into
|
||
corresponding Jam variables, followed by all command-line (-s…​)
|
||
variable settings. Variables whose name ends in PATH, Path, or path are
|
||
split into string lists on OS-specific path-list separator boundaries
|
||
(e.g. ":" for UNIX and ";" for Windows). All other variables are split
|
||
on space (" ") boundaries. Boost Jam modifies that behavior by allowing
|
||
variables to be quoted.</p>
|
||
</li>
|
||
<li>
|
||
<p>A variable whose value is an empty list or which consists entirely of
|
||
empty strings has a negative logical value. Thus, for example, code like
|
||
the following allows a sensible non-empty default which can easily be
|
||
overridden by the user:</p>
|
||
<div class="listingblock">
|
||
<div class="content">
|
||
<pre>MESSAGE ?\= starting jam... ;
|
||
if $(MESSAGE) { ECHO The message is: $(MESSAGE) ; }</pre>
|
||
</div>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>If the user wants a specific message, he invokes jam with
|
||
<code>-sMESSAGE=message
|
||
text</code>. If he wants no message, he invokes jam with
|
||
<code>-sMESSAGE=</code> and nothing at all is printed.</p>
|
||
</div>
|
||
</li>
|
||
<li>
|
||
<p>The parsing of command line options in Jam can be rather unintuitive,
|
||
with regards to how other Unix programs accept options. There are two
|
||
variants accepted as valid for an option:</p>
|
||
<div class="olist arabic">
|
||
<ol class="arabic">
|
||
<li>
|
||
<p><code>-xvalue</code>, and</p>
|
||
</li>
|
||
<li>
|
||
<p><code>-x value</code>.</p>
|
||
</li>
|
||
</ol>
|
||
</div>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="sect1">
|
||
<h2 id="b2.history"><a class="anchor" href="#b2.history"></a>13. History</h2>
|
||
<div class="sectionbody">
|
||
<div class="sect2">
|
||
<h3 id="_version_4_4_1"><a class="anchor" href="#_version_4_4_1"></a>13.1. Version 4.4.1</h3>
|
||
<div class="paragraph">
|
||
<p>Minor patch to correct missing fix for macOS default engine compiler.</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Fix engine build defaulting to gcc instead of clang on macOX/Xcode. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_version_4_4_0"><a class="anchor" href="#_version_4_4_0"></a>13.2. Version 4.4.0</h3>
|
||
<div class="paragraph">
|
||
<p>Along with a variety of fixes this version introduces "dynamic" response file
|
||
support for some toolsets. This means that under most circumtances, if
|
||
supported by the toolset, response files are not generated. Instead the
|
||
command is expanded to include the options directly.</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><strong>New:</strong> Add <code>response-file</code> feature to control the kind of response file usage in
|
||
toolset action. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Add <code>:O=value</code> variable modifier for <code>@()</code> expansion. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Add <code>:⇐value</code> and <code>:>=value</code> variable modifiers for prefix and postfix
|
||
values <strong>after</strong> the complete expansion of variable references. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Implement PCH on clang-win and clang-darwin. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Add support for Intel oneAPI release to intel-linux toolset. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Add support for Intel oneAPI release to intel-windows toolset. — <em>Edward Diener</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Remove one at time linking limit. Once upon a time this was a performance
|
||
tweak as hardware and software was not up to doing multiple links at once.
|
||
Common setups are better equipped. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix building engine with GCC on AIX. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Support building engine as either 32 or 64 bit addressing model. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Basic support for building b2 engine on GNU/Hurd. — <em>Pino Toscano</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Update "borland" toolset to bcc32c for building B2. — <em>Tanzinul Islam</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Ensure Embarcadero toolset name is only "embtc". — <em>Tanzinul Islam</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Adapt for Emscripten 2.0 change of default behaviour for archives. — <em>Basil Fierz</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix path to bootstrap for back compat. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add missing BOOST_ROOT to boot strap search. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix for engine compile on FreeBSD. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Default MSVC to a native platform, and remove ambiguous implicit
|
||
address-model ARM/ARM64 values. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix detection of MIPS32 for b2 engine build. — <em>Ivan Melnikov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Enable building b2 engine with clang on Windows. — <em>Gei0r</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix building b2 engine with Intel Linux icpc. — <em>Alain Miniussi</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Rework <code>build.sh</code> to fix many bugs and to avoid use of common env vars. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Remove limitation of relevant features for configure checks. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Reformat configure check output to inform the variants of the checks in a
|
||
reasonably brief form. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Support building engine on Windows Bash with Mingw. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_version_4_3_0"><a class="anchor" href="#_version_4_3_0"></a>13.3. Version 4.3.0</h3>
|
||
<div class="paragraph">
|
||
<p>There are many invidual fixes in this release. Many thanks for the
|
||
contributions. Special thanks to Nikita for the many improvements to msvc
|
||
and general plugging of support holes in all the compilers.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>There are some notable new features from Dmitry, Edward, and Nkita:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p><strong>New:</strong> Add <code>force-include</code> feature to include headers before all sources. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Partial support for Embarcadero C++ compilers based on clang-5. — <em>Edward Diener</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Implement configurable installation prefixes that use features. — <em>Dmitry Arkhipov</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Add <code>translate-path</code> feature. The translate-path feature allows for
|
||
custom path handling, with a provided rule, on a per target basis. This can
|
||
be used to support custom path syntax. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p><strong>New:</strong> Add portable B2 system install option. This allows the b2 executable
|
||
and the build system files to live side by side. And hence to be (re)located
|
||
anywhere on disk. Soon to be used to supports Windows and other installers.
|
||
This removes the need for the <code>boost-build.jam</code> file for bootstrap. Making
|
||
it easier for users to get started. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Unbreak building from VS Preview command prompt. — <em>Marcel Raad</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix compiler version check on macOS darwin toolset. — <em>Bo Anderson</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Remove pch target naming restriction on GCC. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Select appropriate QNX target platform. — <em>Alexander Karzhenkov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Various space & performance improvements to the b2 engine build on Windows. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fill extra and pedantic warning options for every compiler. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Include OS error reason for engine IO failures. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Use /Zc:inline and /Zc:throwingNew flags for better language conformance. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add cxxstd value 20 for C++20. — <em>Andrey Semashev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Parallel B2 engine compilation on MSVC. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Updated instruction-set feature with new x86 targets. — <em>Andrey Semashev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Pass /nologo to rc on Windows compilers. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fixed negation in conditional properties. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Remove leftover manifest generation early exiting. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix timestamp delta calculation. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add missing assembler options to clang-win.jam, to enable Context to build. — <em>Peter Dimov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Updated scarce <code>:chars</code> documentation with <code>:BS</code> example. — <em>Nikita Kniazev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix link statically against boost-python on linux. — <em>Joris Carrier</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Ongoing cleanup of engine build warnings. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Allow self-testing of toolsets that use response files. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Port <code>Jambase</code> to native C++. Hence removing one of the oldest parts of the
|
||
original Jam bootstrap process. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_version_4_2_0"><a class="anchor" href="#_version_4_2_0"></a>13.4. Version 4.2.0</h3>
|
||
<div class="paragraph">
|
||
<p>This release is predominantly minor fixes and cleanup of the engine. In
|
||
particular the bootstrap/build process now clearly communicates C++11
|
||
requirement.</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Add <code>saxonhe_dir</code> action. — <em>Richard Hodges</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add CI testing for historical Boost versions on Windows MSVC. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Check for C++11 support when building engine. Including an informative
|
||
error message as to that fact. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Update Jam grammar parser with latest <code>bison</code> version. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Allow root <code>b2 b2</code> engine build to work even if <code>bison</code> grammar generator
|
||
is not available. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Warning free engine build on at least Windows, macOS, and Linux. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Sanitize Windows engine build to consistently use ANSI Win32 API. — <em>Mateusz Loskot</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix b2 engine not exiting, with error, early when it detects a Jam language
|
||
error. — <em>Mateusz Loskot</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Print help for local modules, i.e. current dir. — <em>Thomas Brown</em></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_version_4_1_0"><a class="anchor" href="#_version_4_1_0"></a>13.5. Version 4.1.0</h3>
|
||
<div class="paragraph">
|
||
<p>Many small bug fixes in this release. But there are some new features also.
|
||
There’s now an <code>lto</code> feature to specify the use of LTO, and what kind. The
|
||
existing <code>stdlib</code> feature now has real values and corresponding options
|
||
for some toolsets. But most importantly there’s new documentation for all
|
||
the features.</p>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Thank to all the users that contributed to this release with these changes:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Support for VS2019 for intel-vin 19.0. — <em>Edward Diener</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix compiler warnings about <code>-std=gnu11</code> when building <code>b2</code> on Cygwin. — <em>Andrey Semashev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add example of creating multiple PCHs for individual headers. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add QNX threading flags for GCC toolset. — <em>Aurelien Chartier</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix version option for IBM and Sun compilers when building b2 engine — <em>Juan Alday</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Rename <code>strings.h</code> to <code>jam_strings.h</code> in <code>b2</code> engine to avoid clash with
|
||
POSIX <code>strings.h</code> header. — <em>Andrey Semashev</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add options for <code>cxxstd</code> feature for IBM compiler. — <em>Edward Diener</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Many fixes to intel-win toolset. — <em>Edwad Diener</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add z15 instruction set for gcc based toolsets. — <em>Neale Ferguson</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Improve using MSVC from a Cygwin shell. — <em>Michael Haubenwallner</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add LTO feature and corresponding support for gcc and clang toolsets. — <em>Dmitry Arkhipov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix errors when a source doesn’t have a type. — <em>Peter Dimov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add documentation for features. — <em>Dmitry Arkhipov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Enhance <code>stdlib</code> feature, and corresponding documentation, for clang, gcc,
|
||
and sun toolsets. — <em>Dmitry Arkhipov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Install rule now makes explicit only the immediate targets it creates. —  <em>Dmitry Arkhipov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add armasm (32 and 64) support for msvc toolset. — <em>Michał Janiszewski</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix errors with custom un-versioned gcc toolset specifications. — <em>Peter Dimov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Allow arflags override in gcc toolset specifications. — <em>hyc</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix founds libs not making it to the clang-win link command line. — <em>Peter Dimov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Updated intel-win toolset to support for Intel C++ 19.1. — <em>Edward Diener</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Detect difference between MIPS32 and MIPS64 for OS in b2 engine. — <em>YunQiang Su</em></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_version_4_0_1"><a class="anchor" href="#_version_4_0_1"></a>13.6. Version 4.0.1</h3>
|
||
<div class="paragraph">
|
||
<p>This patch release fixes a minor issue when trying to configure toolsets that
|
||
override the toolset version with a non-version tag. Currently this is only
|
||
known to be a problem if you: (a) configure a toolset version to something
|
||
like “tot” (b) in Boost 1.72.0 when it creates cmake install artifacts.
|
||
Fix for this was provided Peter Dimov.</p>
|
||
</div>
|
||
</div>
|
||
<div class="sect2">
|
||
<h3 id="_version_4_0_0"><a class="anchor" href="#_version_4_0_0"></a>13.7. Version 4.0.0</h3>
|
||
<div class="paragraph">
|
||
<p>After even more years of development the landscape of build systems has changed
|
||
considerably, and so has the landscape of compilers. This version marks the
|
||
start of B2 transitioning to a C++ implementation. Initially this means that
|
||
the engine will be compiled as C++ source but that source is still the base
|
||
C implementation. Over time it will transform to a C++ code base in both the
|
||
engine and build system. Some changes in this start:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Requires C++ 11 to build engine.</p>
|
||
</li>
|
||
<li>
|
||
<p>Simplified build scripts to make it easier to maintain.</p>
|
||
</li>
|
||
<li>
|
||
<p>Building with C++ optimizations gives an immediate performance improvement.</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="paragraph">
|
||
<p>Other changes in this release:</p>
|
||
</div>
|
||
<div class="ulist">
|
||
<ul>
|
||
<li>
|
||
<p>Add support for using prebuilt OpenSSL. — <em>Damian Jarek</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Define the riscv architecture feature. — <em>Andreas Schwab</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add ARM64 as a valid architecture for MSVC. — <em>Marc Sweetgall</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Set coverage flags, from coverage feature, for gcc and clang. — <em>Damian Jarek</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add s390x CPU and support in gcc/clang. — <em>Neale Ferguson</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Support importing pkg-config packages. — <em>Dmitry Arkhipov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Support for leak sanitizer. — <em>Damian Jarek</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Fix missing <code>/manifest</code> option in clang-win to fix admin elevation for exes
|
||
with "update" in the name. — <em>Peter Dimov</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Add <code>freertos</code> to <code>os</code> feature. — <em>Thomas Brown</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Default parallel jobs (<code>-jX</code>) to the available CPU threads. — <em>René Ferdinand Rivera Morell</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Simpler coverage feature. — <em>Hans Dembinski</em></p>
|
||
</li>
|
||
<li>
|
||
<p>Better stacks for sanitizers. — <em>James E. King III</em></p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div class="admonitionblock warning">
|
||
<table>
|
||
<tr>
|
||
<td class="icon">
|
||
<div class="title">⚠</div>
|
||
</td>
|
||
<td class="content">
|
||
The default number of parallel jobs has changed in this release from
|
||
"1" to the number of cores. There are circumstances when that default can be
|
||
larger than the allocated cpu resources, for instance in some virtualized
|
||
container installs.
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div id="footnotes">
|
||
<hr>
|
||
<div class="footnote" id="_footnotedef_1">
|
||
<a href="#_footnoteref_1">1</a>. See <a href="#bbv2.reference.features.attributes">the section called “Feature Attributes”</a>
|
||
</div>
|
||
<div class="footnote" id="_footnotedef_2">
|
||
<a href="#_footnoteref_2">2</a>. Many features will be overridden, rather than added-to, in sub-projects See <a href="#bbv2.reference.features.attributes">the section called “Feature Attributes”</a> for more information
|
||
</div>
|
||
<div class="footnote" id="_footnotedef_3">
|
||
<a href="#_footnoteref_3">3</a>. see the definition of "free" in <a href="#bbv2.reference.features.attributes">the section called “Feature Attributes”</a>.
|
||
</div>
|
||
<div class="footnote" id="_footnotedef_4">
|
||
<a href="#_footnoteref_4">4</a>. This name is historic, and will be eventually changed to <code>metatarget</code>
|
||
</div>
|
||
<div class="footnote" id="_footnotedef_5">
|
||
<a href="#_footnoteref_5">5</a>. This create-then-register pattern is caused by limitations of the Boost.Jam language. Python port is likely to never create duplicate targets.
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html> |