diff --git a/new/targets.jam b/new/targets.jam index ed4a50d39..dc58b6a8f 100644 --- a/new/targets.jam +++ b/new/targets.jam @@ -876,6 +876,8 @@ class basic-target : abstract-target local more-targets = [ targets.generate-from-reference $(s) : $(self.project) : $(property-set) ] ; + check-for-link-compatibility $(more-targets[2-]) : $(property-set) ; + usage-requirements = [ $(usage-requirements).add $(more-targets[1]) ] ; source-targets += $(more-targets[2-]) ; @@ -919,9 +921,11 @@ class basic-target : abstract-target rproperties = [ targets.generate-dependencies $(rproperties) : $(self.project) - : $(rproperties) ] ; + : $(rproperties) ] ; usage-requirements = [ $(usage-requirements).add $(rproperties[1]) ] ; rproperties = $(rproperties[2-]) ; + local deps = [ $(rproperties).dependency ] ; + check-for-link-compatibility $(deps:G=) : $(property-set) ; local source-target-groups = [ generate-sources $(rproperties) ] ; @@ -1044,6 +1048,35 @@ class basic-target : abstract-target } } + # Checks if 'targets' are link-compatible with 'build-request' and + # issues a warning if that's not the case. + local rule check-for-link-compatibility ( targets * : build-request ) + { + local checked ; + for local t in $(targets) + { + local a = [ $(t).action ] ; + if $(a) + { + local p = [ $(a).properties-ps ] ; + if ! $(p) in $(cheched) + { + if [ $(p).link-incompatible-with $(build-request) ] + { + local dg = [ $(t).dg ] ; + local other-mt = [ $(dg).main-target ] ; + ECHO "warning: targets produced from" [ $(other-mt).name ] + "are link incompatible" ; + ECHO "warning: with main target" [ name ] ; + } + } + checked += $(p) ; + } + } + + } + + # Constructs the virtual targets for this abstract targets and # the dependecy graph. Returns the list of virtual targets. diff --git a/test/project_test4.py b/test/project_test4.py index 968cd5d5f..080dd995d 100644 --- a/test/project_test4.py +++ b/test/project_test4.py @@ -35,25 +35,13 @@ t.expect_content("bin/$toolset/debug/main-target-b.exe/b.exe", "bin/$toolset/debug/a.obj\n" ) -# TODO: restore this test when we have new notion of link-compatibility -#t.copy("lib/Jamfile3", "lib/Jamfile") -#t.run_build_system(status=None) -#t.fail_test(find(t.stdout(), "warning: skipped build of lib/b.obj with properties") \ -# != 0) +t.copy("lib/Jamfile3", "lib/Jamfile") -# Check that project can be skipped as well -#t.copy("Jamfile4", "Jamfile") - -#expected="warning: skipping build of project at lib2 due to unsatisfied requirements." -#t.run_build_system("rtti=on") -#t.fail_test(find(t.stdout(), expected) != 0) - -#t.copy("lib2/Jamfile2", "lib2/Jamfile") - -#expected="warning: skipping build of project /mylib at lib2 due to unsatisfied\nrequirements." -#t.run_build_system("rtti=on") -#t.fail_test(find(t.stdout(), expected) != 0) +t.run_build_system(status=None) +t.fail_test(find(t.stdout(), +"""warning: targets produced from b.obj are link incompatible +warning: with main target a.exe""") !=-0) # We don't yet make targets depend on Jamfile, so need to start from scratch # The following test is disabled, because of problems related to diff --git a/v2/build/targets.jam b/v2/build/targets.jam index ed4a50d39..dc58b6a8f 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -876,6 +876,8 @@ class basic-target : abstract-target local more-targets = [ targets.generate-from-reference $(s) : $(self.project) : $(property-set) ] ; + check-for-link-compatibility $(more-targets[2-]) : $(property-set) ; + usage-requirements = [ $(usage-requirements).add $(more-targets[1]) ] ; source-targets += $(more-targets[2-]) ; @@ -919,9 +921,11 @@ class basic-target : abstract-target rproperties = [ targets.generate-dependencies $(rproperties) : $(self.project) - : $(rproperties) ] ; + : $(rproperties) ] ; usage-requirements = [ $(usage-requirements).add $(rproperties[1]) ] ; rproperties = $(rproperties[2-]) ; + local deps = [ $(rproperties).dependency ] ; + check-for-link-compatibility $(deps:G=) : $(property-set) ; local source-target-groups = [ generate-sources $(rproperties) ] ; @@ -1044,6 +1048,35 @@ class basic-target : abstract-target } } + # Checks if 'targets' are link-compatible with 'build-request' and + # issues a warning if that's not the case. + local rule check-for-link-compatibility ( targets * : build-request ) + { + local checked ; + for local t in $(targets) + { + local a = [ $(t).action ] ; + if $(a) + { + local p = [ $(a).properties-ps ] ; + if ! $(p) in $(cheched) + { + if [ $(p).link-incompatible-with $(build-request) ] + { + local dg = [ $(t).dg ] ; + local other-mt = [ $(dg).main-target ] ; + ECHO "warning: targets produced from" [ $(other-mt).name ] + "are link incompatible" ; + ECHO "warning: with main target" [ name ] ; + } + } + checked += $(p) ; + } + } + + } + + # Constructs the virtual targets for this abstract targets and # the dependecy graph. Returns the list of virtual targets. diff --git a/v2/test/project_test4.py b/v2/test/project_test4.py index 968cd5d5f..080dd995d 100644 --- a/v2/test/project_test4.py +++ b/v2/test/project_test4.py @@ -35,25 +35,13 @@ t.expect_content("bin/$toolset/debug/main-target-b.exe/b.exe", "bin/$toolset/debug/a.obj\n" ) -# TODO: restore this test when we have new notion of link-compatibility -#t.copy("lib/Jamfile3", "lib/Jamfile") -#t.run_build_system(status=None) -#t.fail_test(find(t.stdout(), "warning: skipped build of lib/b.obj with properties") \ -# != 0) +t.copy("lib/Jamfile3", "lib/Jamfile") -# Check that project can be skipped as well -#t.copy("Jamfile4", "Jamfile") - -#expected="warning: skipping build of project at lib2 due to unsatisfied requirements." -#t.run_build_system("rtti=on") -#t.fail_test(find(t.stdout(), expected) != 0) - -#t.copy("lib2/Jamfile2", "lib2/Jamfile") - -#expected="warning: skipping build of project /mylib at lib2 due to unsatisfied\nrequirements." -#t.run_build_system("rtti=on") -#t.fail_test(find(t.stdout(), expected) != 0) +t.run_build_system(status=None) +t.fail_test(find(t.stdout(), +"""warning: targets produced from b.obj are link incompatible +warning: with main target a.exe""") !=-0) # We don't yet make targets depend on Jamfile, so need to start from scratch # The following test is disabled, because of problems related to