mirror of
https://github.com/boostorg/build.git
synced 2026-02-16 01:12:13 +00:00
Work on BB43 (hang on loop in main target references).
* new/targets.jam (start-building, end-building): New rules. (main-target.generate): Call the above rules. * test/loop.py: New test. [SVN r19241]
This commit is contained in:
@@ -298,6 +298,32 @@ rule project-target ( name : project : requirements * : default-build * )
|
||||
}
|
||||
class project-target : abstract-target ;
|
||||
|
||||
|
||||
|
||||
# Helper rules to detect cycles in main target references
|
||||
local rule start-building ( main-target-instance )
|
||||
{
|
||||
if $(main-target-instance) in $(.targets-being-built)
|
||||
{
|
||||
local names ;
|
||||
for local t in $(.targets-being-built) $(main-target-instance)
|
||||
{
|
||||
names += [ $(t).full-name ] ;
|
||||
}
|
||||
|
||||
errors.error "Recursion in main target references"
|
||||
: "the following target are being built currently:"
|
||||
: $(names) ;
|
||||
}
|
||||
.targets-being-built += $(main-target-instance) ;
|
||||
}
|
||||
|
||||
local rule end-building ( main-target-instance )
|
||||
{
|
||||
.targets-being-built = $(.targets-being-built[1--2]) ;
|
||||
}
|
||||
|
||||
|
||||
# A named top-level target in Jamfile
|
||||
rule main-target ( name : project )
|
||||
{
|
||||
@@ -309,6 +335,7 @@ rule main-target ( name : project )
|
||||
import sequence ;
|
||||
import print ;
|
||||
import build-request feature property-set ;
|
||||
import targets : start-building end-building ;
|
||||
|
||||
# Add a new alternative for this target
|
||||
rule add-alternative ( target )
|
||||
@@ -407,6 +434,7 @@ rule main-target ( name : project )
|
||||
# Returns the result of calling 'generate' on that alternative.
|
||||
rule generate ( property-set )
|
||||
{
|
||||
start-building $(__name__) ;
|
||||
local all-property-sets = [ apply-default-build $(property-set) ] ;
|
||||
local usage-requirements = [ property-set.empty ] ;
|
||||
local result ;
|
||||
@@ -418,6 +446,7 @@ rule main-target ( name : project )
|
||||
usage-requirements = [ $(usage-requirements).add $(r[1]) ] ;
|
||||
result += $(r[2-]) ;
|
||||
}
|
||||
end-building $(__name__) ;
|
||||
return $(usage-requirements) $(result) ;
|
||||
}
|
||||
|
||||
|
||||
28
test/loop.py
Normal file
28
test/loop.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
from BoostBuild import Tester, List
|
||||
from string import find
|
||||
|
||||
t = Tester()
|
||||
|
||||
|
||||
t.write("project-root.jam", "")
|
||||
t.write("Jamfile", """
|
||||
|
||||
lib main : main.cpp l ;
|
||||
lib l : l.cpp main ;
|
||||
""")
|
||||
|
||||
t.write("main.cpp", "")
|
||||
t.write("l.cpp", "")
|
||||
|
||||
t.run_build_system("--no-error-backtrace", status=1)
|
||||
t.fail_test(find(t.stdout(), "error: Recursion in main target references") == -1)
|
||||
t.fail_test(find(t.stdout(), "./main ./l ./main") == -1)
|
||||
|
||||
t.cleanup()
|
||||
@@ -100,6 +100,7 @@ tests = [ "project_test1",
|
||||
"inline",
|
||||
"conditionals2",
|
||||
"property_expansion",
|
||||
"loop",
|
||||
]
|
||||
|
||||
if os.name == 'posix':
|
||||
|
||||
@@ -298,6 +298,32 @@ rule project-target ( name : project : requirements * : default-build * )
|
||||
}
|
||||
class project-target : abstract-target ;
|
||||
|
||||
|
||||
|
||||
# Helper rules to detect cycles in main target references
|
||||
local rule start-building ( main-target-instance )
|
||||
{
|
||||
if $(main-target-instance) in $(.targets-being-built)
|
||||
{
|
||||
local names ;
|
||||
for local t in $(.targets-being-built) $(main-target-instance)
|
||||
{
|
||||
names += [ $(t).full-name ] ;
|
||||
}
|
||||
|
||||
errors.error "Recursion in main target references"
|
||||
: "the following target are being built currently:"
|
||||
: $(names) ;
|
||||
}
|
||||
.targets-being-built += $(main-target-instance) ;
|
||||
}
|
||||
|
||||
local rule end-building ( main-target-instance )
|
||||
{
|
||||
.targets-being-built = $(.targets-being-built[1--2]) ;
|
||||
}
|
||||
|
||||
|
||||
# A named top-level target in Jamfile
|
||||
rule main-target ( name : project )
|
||||
{
|
||||
@@ -309,6 +335,7 @@ rule main-target ( name : project )
|
||||
import sequence ;
|
||||
import print ;
|
||||
import build-request feature property-set ;
|
||||
import targets : start-building end-building ;
|
||||
|
||||
# Add a new alternative for this target
|
||||
rule add-alternative ( target )
|
||||
@@ -407,6 +434,7 @@ rule main-target ( name : project )
|
||||
# Returns the result of calling 'generate' on that alternative.
|
||||
rule generate ( property-set )
|
||||
{
|
||||
start-building $(__name__) ;
|
||||
local all-property-sets = [ apply-default-build $(property-set) ] ;
|
||||
local usage-requirements = [ property-set.empty ] ;
|
||||
local result ;
|
||||
@@ -418,6 +446,7 @@ rule main-target ( name : project )
|
||||
usage-requirements = [ $(usage-requirements).add $(r[1]) ] ;
|
||||
result += $(r[2-]) ;
|
||||
}
|
||||
end-building $(__name__) ;
|
||||
return $(usage-requirements) $(result) ;
|
||||
}
|
||||
|
||||
|
||||
28
v2/test/loop.py
Normal file
28
v2/test/loop.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and
|
||||
# distribute this software is granted provided this copyright notice appears in
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
from BoostBuild import Tester, List
|
||||
from string import find
|
||||
|
||||
t = Tester()
|
||||
|
||||
|
||||
t.write("project-root.jam", "")
|
||||
t.write("Jamfile", """
|
||||
|
||||
lib main : main.cpp l ;
|
||||
lib l : l.cpp main ;
|
||||
""")
|
||||
|
||||
t.write("main.cpp", "")
|
||||
t.write("l.cpp", "")
|
||||
|
||||
t.run_build_system("--no-error-backtrace", status=1)
|
||||
t.fail_test(find(t.stdout(), "error: Recursion in main target references") == -1)
|
||||
t.fail_test(find(t.stdout(), "./main ./l ./main") == -1)
|
||||
|
||||
t.cleanup()
|
||||
@@ -100,6 +100,7 @@ tests = [ "project_test1",
|
||||
"inline",
|
||||
"conditionals2",
|
||||
"property_expansion",
|
||||
"loop",
|
||||
]
|
||||
|
||||
if os.name == 'posix':
|
||||
|
||||
Reference in New Issue
Block a user