2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 13:22:11 +00:00

Prevent the 'make' rule perform reduntant builds. Thanks to Kirill Lapshin

for the bug report.

* new/make.jam
    (make-target-class.construct): Pass the result through
    'virtual-target.register'.

* new/virtual-target.jam
    (register): Ignore incidental properties when deciding if targets are
    equivivalent.

* test/make_rule.py: Add new test.


[SVN r17701]
This commit is contained in:
Vladimir Prus
2003-03-03 07:47:14 +00:00
parent 006bae5309
commit caa491f503
6 changed files with 112 additions and 12 deletions

View File

@@ -30,7 +30,7 @@ rule make-target-class ( name : project : sources * : requirements *
local a = [ new action $(t) : $(source-targets) : $(self.make-rule)
: $(property-set) ] ;
$(t).action $(a) ;
return $(t) ;
return [ virtual-target.register $(t) ] ;
}
}

View File

@@ -705,18 +705,28 @@ rule register ( target )
{
local a1 = [ $(t).action ] ;
local a2 = [ $(target).action ] ;
if ! $(result)
{
if ! $(a1) && ! $(a2)
{
result = $(t) ;
}
else if $(a1) && $(a2) && [ $(a1).action-name ] = [ $(a2).action-name ]
&& [ $(a1).properties-ps ] = [ $(a2).properties-ps ] && [ $(a1).sources ] = [ $(a2).sources ]
else
{
result = $(t) ;
}
if $(a1) && $(a2) && [ $(a1).action-name ] = [ $(a2).action-name ] &&
[ $(a1).sources ] = [ $(a2).sources ]
{
local ps1 = [ $(a1).properties-ps ] ;
local ps2 = [ $(a2).properties-ps ] ;
local p1 = [ $(ps1).base ] [ $(ps1).free ] [ $(ps1).dependency ] ;
local p2 = [ $(ps2).base ] [ $(ps2).free ] [ $(ps2).dependency ] ;
if $(p1) = $(p2)
{
result = $(t) ;
}
}
}
}
}
if ! $(result)

View File

@@ -28,5 +28,45 @@ t.run_build_system()
t.expect_addition("bin/$toolset/debug/foo.bar")
t.fail_test(find(t.read("bin/$toolset/debug/foo.bar"), "foobar") == -1)
# Regression test. Make sure that if main target requested two times,
# and build request differ only in incidental properties, the main target
# if created only once. The bug was discovered by Kirill Lapshin.
t.write("Jamfile", """
# Make sure that incidental property does not
# cause second creation of 'hello1.cpp'.
exe a : dir/hello1.cpp ;
exe b : dir/hello1.cpp/<hardcode-dll-paths>true ;
""")
t.write("project-root.jam", """
import gcc ;
rule copy-file ( targets * : sources * : * )
{
copy-file-action $(targets) : $(sources) ;
}
actions copy-file-action
{
cp $(>) $(<)
}
IMPORT $(__name__) : copy-file : : copy-file ;
""")
t.write("dir/Jamfile", """
make hello1.cpp : hello.cpp : copy-file ;
""")
t.write("dir/hello.cpp", """
int main()
{
return 1;
}
""")
t.run_build_system("-d2")
t.fail_test(t.stdout().count("copy-file") != 1)
t.cleanup()

View File

@@ -705,18 +705,28 @@ rule register ( target )
{
local a1 = [ $(t).action ] ;
local a2 = [ $(target).action ] ;
if ! $(result)
{
if ! $(a1) && ! $(a2)
{
result = $(t) ;
}
else if $(a1) && $(a2) && [ $(a1).action-name ] = [ $(a2).action-name ]
&& [ $(a1).properties-ps ] = [ $(a2).properties-ps ] && [ $(a1).sources ] = [ $(a2).sources ]
else
{
result = $(t) ;
}
if $(a1) && $(a2) && [ $(a1).action-name ] = [ $(a2).action-name ] &&
[ $(a1).sources ] = [ $(a2).sources ]
{
local ps1 = [ $(a1).properties-ps ] ;
local ps2 = [ $(a2).properties-ps ] ;
local p1 = [ $(ps1).base ] [ $(ps1).free ] [ $(ps1).dependency ] ;
local p2 = [ $(ps2).base ] [ $(ps2).free ] [ $(ps2).dependency ] ;
if $(p1) = $(p2)
{
result = $(t) ;
}
}
}
}
}
if ! $(result)

View File

@@ -28,5 +28,45 @@ t.run_build_system()
t.expect_addition("bin/$toolset/debug/foo.bar")
t.fail_test(find(t.read("bin/$toolset/debug/foo.bar"), "foobar") == -1)
# Regression test. Make sure that if main target requested two times,
# and build request differ only in incidental properties, the main target
# if created only once. The bug was discovered by Kirill Lapshin.
t.write("Jamfile", """
# Make sure that incidental property does not
# cause second creation of 'hello1.cpp'.
exe a : dir/hello1.cpp ;
exe b : dir/hello1.cpp/<hardcode-dll-paths>true ;
""")
t.write("project-root.jam", """
import gcc ;
rule copy-file ( targets * : sources * : * )
{
copy-file-action $(targets) : $(sources) ;
}
actions copy-file-action
{
cp $(>) $(<)
}
IMPORT $(__name__) : copy-file : : copy-file ;
""")
t.write("dir/Jamfile", """
make hello1.cpp : hello.cpp : copy-file ;
""")
t.write("dir/hello.cpp", """
int main()
{
return 1;
}
""")
t.run_build_system("-d2")
t.fail_test(t.stdout().count("copy-file") != 1)
t.cleanup()

View File

@@ -30,7 +30,7 @@ rule make-target-class ( name : project : sources * : requirements *
local a = [ new action $(t) : $(source-targets) : $(self.make-rule)
: $(property-set) ] ;
$(t).action $(a) ;
return $(t) ;
return [ virtual-target.register $(t) ] ;
}
}