Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/cxx
Browse files Browse the repository at this point in the history
  • Loading branch information
grafikrobot committed Apr 2, 2019
2 parents fde8e3c + 1c50088 commit a3b3054
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 52 deletions.
7 changes: 3 additions & 4 deletions doc/src/reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ implicitly when their containing project is built.

[[bbv2.reference.rules.always]]`always`::
The `always` function takes a single parameter—a list of metatarget
names. The top-level targets produced by the named metatargets will be
names. The targets produced by the named metatargets will be
always considered out of date. Consider this example:
+
----
Expand All @@ -161,10 +161,9 @@ exe bye : bye.cpp ;
always hello ;
----
+
If a build of `hello` is requested, then the binary will always be
relinked. The object files will not be recompiled, though. Note that
If a build of `hello` is requested, then it will always be recompiled. Note that
if a build of `hello` is not requested, for example you specify just
`bye` on the command line, `hello` will not be relinked.
`bye` on the command line, `hello` will not be recompiled.

[[bbv2.reference.rules.constant]]`constant`::
Sets project-wide constant. Takes two parameters: variable name and a
Expand Down
36 changes: 32 additions & 4 deletions src/build/configure.jam
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

import "class" : new ;
import common ;
import indirect ;
import path ;
import project ;
import property ;
import property-set ;
import targets ;
Expand Down Expand Up @@ -477,14 +479,18 @@ class check-target-builds-worker
import configure ;
import property-set ;
import targets ;
import project ;
import property ;

rule __init__ ( target message ? : true-properties * : false-properties * )
{
local project = [ project.current ] ;
self.target = $(target) ;
self.message = $(message) ;
self.true-properties = $(true-properties) ;
self.false-properties = $(false-properties) ;
self.true-properties =
[ configure.translate-properties $(true-properties) : $(project) ] ;
self.false-properties =
[ configure.translate-properties $(false-properties) : $(project) ] ;
}

rule check ( properties * )
Expand All @@ -507,8 +513,10 @@ class configure-choose-worker
{
import configure ;
import property ;
import project ;
rule __init__ ( message : * )
{
local project = [ project.current ] ;
self.message = $(message) ;
for i in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
{
Expand All @@ -523,6 +531,8 @@ class configure-choose-worker
{
self.props.$(name) = $($(i)[2-]) ;
}
self.props.$(name) = [ configure.translate-properties
$(self.props.$(name)) : $(project) ] ;
}
}
rule all-properties ( )
Expand Down Expand Up @@ -559,13 +569,30 @@ class configure-choose-worker
}
}

rule translate-properties ( properties * : project ? )
{
if $(project) && [ $(project).location ]
{
local location = [ $(project).location ] ;
local m = [ $(project).project-module ] ;
local project-id = [ project.attribute $(m) id ] ;
project-id ?= [ path.root $(location) [ path.pwd ] ] ;
return [ property.translate $(properties)
: $(project-id) : $(location) : $(m) ] ;
}
else
{
return $(properties) ;
}
}

rule check-target-builds ( target message ? : true-properties * :
false-properties * )
{
local instance = [ new check-target-builds-worker $(target) $(message) :
$(true-properties) : $(false-properties) ] ;
return <conditional>@$(instance).check
local rulename = [ indirect.make check : $(instance) ] ;
return <conditional>@$(rulename)
[ property.evaluate-conditional-relevance
$(true-properties) $(false-properties)
: [ configure.get-relevant-features ] ] ;
Expand All @@ -582,7 +609,8 @@ rule choose ( message : * )
: $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9)
: $(10) : $(11) : $(12) : $(13) : $(14) : $(15) : $(16)
: $(17) : $(18) : $(19) ] ;
return <conditional>@$(instance).check
local rulename = [ indirect.make check : $(instance) ] ;
return <conditional>@$(rulename)
[ property.evaluate-conditional-relevance
[ $(instance).all-properties ]
: [ configure.get-relevant-features ] ] ;
Expand Down
6 changes: 5 additions & 1 deletion src/build/property.jam
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ rule evaluate-conditionals-in-context ( properties * : context * )
local new = [ indirect.call $(i) $(context) ] ;
if $(p) && [ $(p).location ]
{
result += [ translate-paths $(new) : [ $(p).location ] ] ;
local location = [ $(p).location ] ;
local project-id = [ project.attribute $(m) id ] ;
project-id ?= [ path.root $(location) [ path.pwd ] ] ;
result +=
[ translate $(new) : $(project-id) : $(location) : $(m) ] ;
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions src/build/targets.jam
Original file line number Diff line number Diff line change
Expand Up @@ -1376,20 +1376,20 @@ class basic-target : abstract-target
[ property.change [ $(gur).raw ] : <relevant> ]
<relevant>$(relevant) ] ;

local s = [ create-subvariant $(result)
: [ virtual-target.recent-targets ]
: $(property-set) : $(source-targets)
: $(rproperties) : $(usage-requirements) ] ;
virtual-target.clear-recent-targets ;

if $(self.always)
{
for local t in $(result)
for local t in [ $(s).created-targets ]
{
$(t).always ;
}
}

local s = [ create-subvariant $(result)
: [ virtual-target.recent-targets ]
: $(property-set) : $(source-targets)
: $(rproperties) : $(usage-requirements) ] ;
virtual-target.clear-recent-targets ;

local ur = [ compute-usage-requirements $(s) ] ;
ur = [ $(ur).add $(gur) ] ;
$(s).set-usage-requirements $(ur) ;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/common.jam
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ local rule toolset-tag ( name : type ? : property-set )
case tru64cxx* : tag += tru ;
case vacpp* : tag += xlc ;
}
local version = [ MATCH "<toolset.*version>([0123456789]+)[.]([0123456789]*)"
local version = [ MATCH "<toolset.*version>([0123456789]+)[.]?([0123456789]*)"
: $(properties) ] ;
# For historical reasons, vc6.0 and vc7.0 use different naming.
if $(tag) = vc
Expand Down
59 changes: 32 additions & 27 deletions src/tools/gcc.jam
Original file line number Diff line number Diff line change
Expand Up @@ -181,31 +181,27 @@ rule init ( version ? : command * : options * : requirement * )
tool-command-string = $(tool-command-string:J=" ") ;
local tool-version = [ dump-full-version
$(tool-command-string) ] ;
if $(tool-version) != $(version)
# Permit a match between a two-digit version specified by the
# user (e.g. 4.4) and a 3-digit version reported by gcc.
# Since only two digits are present in the binary name
# anyway, insisting that user specify the 3-digit version
# when configuring Boost.Build, while it is not required on
# the command line, would be strange.
local versionl = [ regex.split $(version) "[.]" ] ;
local tool-versionl = [ regex.split $(tool-version) "[.]" ] ;
if ! ( $(versionl[1]) = $(tool-versionl[1]) &&
$(versionl[2]:E=$(tool-versionl[2])) = $(tool-versionl[2]) &&
$(versionl[3]:E=$(tool-versionl[3])) = $(tool-versionl[3]) )
{
# Permit a match between a two-digit version specified by the
# user (e.g. 4.4) and a 3-digit version reported by gcc.
# Since only two digits are present in the binary name
# anyway, insisting that user specify the 3-digit version
# when configuring Boost.Build, while it is not required on
# the command line, would be strange.
local stripped = [ MATCH "^([0-9]+\.[0-9]+).*" :
$(tool-version) ] ;
if $(stripped) != $(version)
{
import errors ;
errors.error toolset gcc "initialization:"
: version '$(version)' requested but
'g++-$(version)' not found and version
'$(tool-version)' of default '$(tool-command)'
does not match
: initialized from [ errors.nearest-user-location ]
;
tool-command = ;
}
# Use full 3-digit version to be compatible with the
# 'using gcc ;' case
version = $(tool-version) ;
import errors ;
errors.error toolset gcc "initialization:"
: version '$(version)' requested but
'g++-$(version)' not found and version
'$(tool-version)' of default '$(tool-command)'
does not match
: initialized from [ errors.nearest-user-location ]
;
tool-command = ;
}
}
else
Expand Down Expand Up @@ -263,7 +259,7 @@ rule init ( version ? : command * : options * : requirement * )
{
local machine = [ MATCH "^([^ ]+)" :
[ SHELL "$(command-string) -dumpmachine" ] ] ;
version ?= [ dump-full-version $(command-string) ] ;
version ?= [ dump-version $(command-string) ] ;
switch $(machine:L)
{
case *mingw* : flavor ?= mingw ;
Expand Down Expand Up @@ -376,6 +372,15 @@ local rule dump-full-version ( command-string )
[ SHELL "$(command-string) -dumpfullversion -dumpversion" ] ] ;
}

local rule dump-version ( command-string )
{
# -dumpfullversion is only supported for gcc 7+.
# Passing both options works, as the first one that's
# recognized will be used.
return [ MATCH "^([0-9.]+)" :
[ SHELL "$(command-string) -dumpversion" ] ] ;
}

# Uses -print-prog-name to get the name of the tool.
# Converts the path to native form if using cygwin.
rule .get-prog-name ( command-string : tool : flavor ? )
Expand Down Expand Up @@ -494,8 +499,8 @@ local rule compile-link-flags ( * )
local rule init-cxxstd-flags ( condition * : version )
{
local std ;
if [ version-ge $(version) : 8.0 ] { std = 2a ; }
else if [ version-ge $(version) : 5.1 ] { std = 1z ; }
if [ version-ge $(version) : 8 ] { std = 2a ; }
else if [ version-ge $(version) : 5 ] { std = 1z ; }
else if [ version-ge $(version) : 4.8 ] { std = 1y ; }
else if [ version-ge $(version) : 4.7 ] { std = 11 ; }
else if [ version-ge $(version) : 3.3 ] { std = 98 ; }
Expand Down
2 changes: 1 addition & 1 deletion test/TestToolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_toolset(toolset, version, property_sets):
def path(t):
return toolset.split("-")[0] + "-*" + version + compute_path(properties, t)
os.environ["B2_PROPERTIES"] = " ".join(expand_properties(properties))
t.run_build_system(["--user-config="] + properties)
t.run_build_system(["--user-config=", "-sPYTHON_CMD=%s" % sys.executable] + properties)
t.expect_addition("bin/%s/lib.obj" % (path("obj")))
if "link=static" not in properties:
t.expect_addition("bin/%s/l1.dll" % (path("dll")))
Expand Down
30 changes: 30 additions & 0 deletions test/always.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/python

# Copyright 2016 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)

import BoostBuild

t = BoostBuild.Tester(use_test_config=False)

t.write("main.cpp", """\
int main() {}
""")

t.write("Jamroot", """\
exe test : main.cpp ;
always test ;
""")

t.run_build_system()
t.expect_addition("bin/$toolset/debug*/main.obj")
t.expect_addition("bin/$toolset/debug*/test.exe")
t.expect_nothing_more()

t.run_build_system()
t.expect_touch("bin/$toolset/debug*/main.obj")
t.expect_touch("bin/$toolset/debug*/test.exe")
t.expect_nothing_more()

t.cleanup()
48 changes: 48 additions & 0 deletions test/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,53 @@ def test_choose():

t.cleanup()

def test_translation():
"""Tests scoping for targets, paths, and rules within check-target-builds"""
t = BoostBuild.Tester(use_test_config=0)
t.write("Jamroot", "")
t.write("subdir/Jamfile", """
import configure ;
obj pass : pass.cpp ;
obj fail : fail.cpp ;
explicit pass fail ;
obj foo : :
[ configure.check-target-builds pass
: [ configure.check-target-builds fail : <define>FAIL
: <define>PASS <include>include1 <conditional>@c1 ]
: <define>FAIL ] ;
obj bar : :
[ configure.choose "which one?" : pass
[ configure.choose "Try again?" : pass
<define>PASS <include>include1 <conditional>@c1 ] ] ;
rule c1 ( properties * )
{
return <include>include2 <source>foo.cpp ;
}
""")
t.write("subdir/include1/a.h", "")
t.write("subdir/include2/b.h", "")
t.write("subdir/pass.cpp", "void f() {}\n")
t.write("subdir/fail.cpp", "#error fail.cpp\n")
t.write("subdir/foo.cpp", """
#include <a.h>
#include <b.h>
#ifndef PASS
#error PASS not defined
#endif
#ifdef FAIL
#error FAIL is defined
#endif
""")
t.run_build_system(["subdir"])
t.expect_output_lines([
" - pass builds : yes",
" - fail builds : no"])
t.expect_addition("subdir/bin/$toolset/debug*/pass.obj")
t.expect_addition("subdir/bin/$toolset/debug*/foo.obj")
t.expect_addition("subdir/bin/$toolset/debug*/bar.obj")
t.expect_nothing_more()
t.cleanup()

def test_choose_none():
"""Tests choose when none of the alternatives match."""
t = BoostBuild.Tester(use_test_config=0)
Expand Down Expand Up @@ -216,4 +263,5 @@ def test_choose_none():

test_check_target_builds()
test_choose()
test_translation()
test_choose_none()
Loading

0 comments on commit a3b3054

Please sign in to comment.