diff --git a/new/builtin.jam b/new/builtin.jam index 60464826c..7f0d2a424 100644 --- a/new/builtin.jam +++ b/new/builtin.jam @@ -405,61 +405,84 @@ rule link-action ( targets + : sources * : action-name : properties * ) { action.__init__ $(targets) : $(sources) : $(action-name) : $(properties) ; - # For all sources which are instances searched-lib-targets, add - # appropriate or propertry - # For all library sources, add property with that source. + # Find all libraries in sources, and properties + # For each source/property-value, which is instance of searched-lib-target, + # add appropriate or property. + # (replacing the origianal is needed) + # Convert library sources into properties. # If true is in properties, for each library source # add property with the absolute path to that library. rule adjust-properties ( properties * ) { + # Identify all library sources and all properties + # Remove that latter from 'properties' + + local libraries ; + for local s in $(self.sources) + { + if [ type.is-derived [ $(s).type ] LIB ] + { + libraries += $(s) ; + } + } + local properties2 ; + for local p in $(properties) + { + if $(p:G) = + { + libraries += $(p:G=) ; + } + else + { + properties2 += $(p) ; + } + } + local hardcore-rpath ; - local rpaths ; if true in $(properties) { hardcore-rpath = true ; } + + # Add needed properties local pwd = [ path.pwd ] ; - local extra ; - for local s in $(self.sources) + local rpaths ; + for local s in $(libraries) { if [ class.is-a $(s) : searched-lib-target ] { local name = [ $(s).real-name ] ; if [ $(s).shared ] { - extra += $(name) ; + properties2 += $(name) ; } else { - extra += $(name) ; + properties2 += $(name) ; } local search = [ $(s).search ] ; - extra += $(search) ; + if $(hardcore-rpath) + { + rpaths += $(search) ; + } + properties2 += $(search) ; } - # We also move orginary libs form sources to - # "library" property. This allows us to - # easily repeat all the list of libs on - # command line, when it's needed. - else if [ type.is-derived [ $(s).type ] LIB ] + else { - extra += $(s) ; + if $(hardcore-rpath) + { + rpaths += [ path.root [ $(s).path ] $(pwd) ] ; + } + properties2 += $(s) ; } } - properties += $(extra) ; if $(hardcore-rpath) { - for local p in $(properties) - { - if $(p:G) = - { - rpaths += [ path.root [ $(p:G=).path ] $(pwd) ] ; - } - } rpaths = [ sequence.unique $(rpaths) ] ; - properties += $(rpaths) ; + properties2 += $(rpaths) ; } - return $(properties) ; + return $(properties2) ; } # Filters out all sources which are of LIB type and actualizes the remaining diff --git a/test/searched_lib.py b/test/searched_lib.py new file mode 100644 index 000000000..7cb3007df --- /dev/null +++ b/test/searched_lib.py @@ -0,0 +1,35 @@ +#!/usr/bin/python + +# Test usage of searched-libs: one which are found via -l +# switch to the linker/compiler + +from BoostBuild import Tester, exe_suffix +t = Tester() + +# A regression test: property referring to +# searched-lib was mishandled. As the result, we were +# putting target name to the command line! +# Note that +# g++ ...... <.>z +# works nicely in some cases, sending output from compiler +# to file 'z'. +# This problem shows up when searched libs are in usage +# requirements. + +t.write('project-root.jam', 'import gcc ;') +t.write('Jamfile', 'exe main : main.cpp d/d2/a ;') +t.write("main.cpp", """ +int main() {} +""") + +t.write('d/d2/Jamfile', """ +lib z : : z ; +lib a : a.cpp : : : z ; +""") +t.write('d/d2/a.cpp', """ +""") + +t.run_build_system() + + +t.cleanup() diff --git a/test/test_all.py b/test/test_all.py index f3c9f37ee..ffb3d6f30 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -37,4 +37,5 @@ import project_dependencies import build_dir if os.name == 'posix': import symlink +import searched_lib diff --git a/v2/test/searched_lib.py b/v2/test/searched_lib.py new file mode 100644 index 000000000..7cb3007df --- /dev/null +++ b/v2/test/searched_lib.py @@ -0,0 +1,35 @@ +#!/usr/bin/python + +# Test usage of searched-libs: one which are found via -l +# switch to the linker/compiler + +from BoostBuild import Tester, exe_suffix +t = Tester() + +# A regression test: property referring to +# searched-lib was mishandled. As the result, we were +# putting target name to the command line! +# Note that +# g++ ...... <.>z +# works nicely in some cases, sending output from compiler +# to file 'z'. +# This problem shows up when searched libs are in usage +# requirements. + +t.write('project-root.jam', 'import gcc ;') +t.write('Jamfile', 'exe main : main.cpp d/d2/a ;') +t.write("main.cpp", """ +int main() {} +""") + +t.write('d/d2/Jamfile', """ +lib z : : z ; +lib a : a.cpp : : : z ; +""") +t.write('d/d2/a.cpp', """ +""") + +t.run_build_system() + + +t.cleanup() diff --git a/v2/test/test_all.py b/v2/test/test_all.py index f3c9f37ee..ffb3d6f30 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -37,4 +37,5 @@ import project_dependencies import build_dir if os.name == 'posix': import symlink +import searched_lib diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 60464826c..7f0d2a424 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -405,61 +405,84 @@ rule link-action ( targets + : sources * : action-name : properties * ) { action.__init__ $(targets) : $(sources) : $(action-name) : $(properties) ; - # For all sources which are instances searched-lib-targets, add - # appropriate or propertry - # For all library sources, add property with that source. + # Find all libraries in sources, and properties + # For each source/property-value, which is instance of searched-lib-target, + # add appropriate or property. + # (replacing the origianal is needed) + # Convert library sources into properties. # If true is in properties, for each library source # add property with the absolute path to that library. rule adjust-properties ( properties * ) { + # Identify all library sources and all properties + # Remove that latter from 'properties' + + local libraries ; + for local s in $(self.sources) + { + if [ type.is-derived [ $(s).type ] LIB ] + { + libraries += $(s) ; + } + } + local properties2 ; + for local p in $(properties) + { + if $(p:G) = + { + libraries += $(p:G=) ; + } + else + { + properties2 += $(p) ; + } + } + local hardcore-rpath ; - local rpaths ; if true in $(properties) { hardcore-rpath = true ; } + + # Add needed properties local pwd = [ path.pwd ] ; - local extra ; - for local s in $(self.sources) + local rpaths ; + for local s in $(libraries) { if [ class.is-a $(s) : searched-lib-target ] { local name = [ $(s).real-name ] ; if [ $(s).shared ] { - extra += $(name) ; + properties2 += $(name) ; } else { - extra += $(name) ; + properties2 += $(name) ; } local search = [ $(s).search ] ; - extra += $(search) ; + if $(hardcore-rpath) + { + rpaths += $(search) ; + } + properties2 += $(search) ; } - # We also move orginary libs form sources to - # "library" property. This allows us to - # easily repeat all the list of libs on - # command line, when it's needed. - else if [ type.is-derived [ $(s).type ] LIB ] + else { - extra += $(s) ; + if $(hardcore-rpath) + { + rpaths += [ path.root [ $(s).path ] $(pwd) ] ; + } + properties2 += $(s) ; } } - properties += $(extra) ; if $(hardcore-rpath) { - for local p in $(properties) - { - if $(p:G) = - { - rpaths += [ path.root [ $(p:G=).path ] $(pwd) ] ; - } - } rpaths = [ sequence.unique $(rpaths) ] ; - properties += $(rpaths) ; + properties2 += $(rpaths) ; } - return $(properties) ; + return $(properties2) ; } # Filters out all sources which are of LIB type and actualizes the remaining