From 79cd3623f4e529a4ce2e6084c7078f3166569403 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 26 May 2004 09:57:03 +0000 Subject: [PATCH] Remove check for 'unused sources'. The check causes bogus warnings in at least a couple of cases. 1. On Windows, DLLs are never directly linked to, so they are considered unused and cause a warning. There used to be special code in exe-target-class and lib-target-class to supress that warning, but this failed for unit-test, for example, since main target class for unit test is not related with exe-target-class. And making yet another main target class looks ugly. 2. A target specified via project-wide or property is added to sources for all targets, and cause a warning when it's not used. However, there are valid cases to ignore such sources. For example obj a : a.cpp : off ; need to comsume any libraries. It was not clear how to fix both problems. Further, the only case when I found the warning to be usefull is when declaring new toolsets, and it that case it does not add much information compared to --debug-generators output. So, let's just kill the feature for now. [SVN r22927] --- src/build/alias.jam | 7 +------ src/build/targets.jam | 46 +------------------------------------------ src/tools/builtin.jam | 20 +------------------ src/tools/gettext.jam | 6 +----- src/tools/stage.jam | 5 ----- test/test_all.py | 1 - 6 files changed, 4 insertions(+), 81 deletions(-) diff --git a/src/build/alias.jam b/src/build/alias.jam index eaecf069e..e85d415ef 100644 --- a/src/build/alias.jam +++ b/src/build/alias.jam @@ -50,12 +50,7 @@ class alias-target-class : basic-target rule check-for-link-compatibility ( * : * ) { } - - rule check-for-unused-sources ( * : * ) - { - } - - + rule compute-usage-requirements ( subvariant ) { local base = [ basic-target.compute-usage-requirements $(subvariant) ] ; diff --git a/src/build/targets.jam b/src/build/targets.jam index b9c7a01ea..68e87876b 100644 --- a/src/build/targets.jam +++ b/src/build/targets.jam @@ -972,8 +972,6 @@ class basic-target : abstract-target local result = [ construct $(source-targets) : $(rproperties) ] ; - check-for-unused-sources - $(result) : $(source-targets) ; local s = [ create-subvariant $(result) : $(property-set) : $(source-targets) : $(rproperties) : $(usage-requirements) ] ; @@ -1038,49 +1036,7 @@ class basic-target : abstract-target } return $(s) ; } - - - # Check that each source virtual target which is not marked as intermediate - # is present dependency graph of 'result'. - # If this is not the case, issues a warning. - # Sources which are directly presentin result are not considered used, and - # a warning will be issued for them as well. - # - # Note that 'result' *can* be empty. For - # example, in this use case: - # alias platform-sources ; - # alias platform-sources : a.cpp : NT ; - # result will be empty in the first case. - local rule check-for-unused-sources ( result * : sources * ) - { - local isources ; - for local i in $(sources) - { - if ! [ $(i).intermediate ] - { - isources += $(i) ; - } - } - sources = $(isources) ; - - local used-sources ; - for local r in $(result) - { - used-sources += [ virtual-target.traverse $(r) : include-roots : 1 ] ; - } - # Consider sources which are bypassed as unused - used-sources = [ set.difference $(used-sources) : $(result) ] ; - - local unused = [ set.difference $(sources) : $(used-sources) ] ; - if $(unused) - { - for local u in $(unused) - { - errors.warning "Unused source" [ $(u).str ] "in main target" [ full-name ] ; - } - } - } - + # 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 ) diff --git a/src/tools/builtin.jam b/src/tools/builtin.jam index ca566b8cb..46df7f90b 100644 --- a/src/tools/builtin.jam +++ b/src/tools/builtin.jam @@ -428,25 +428,7 @@ class lib-target-class : basic-target } return $(result) ; - } - - rule check-for-unused-sources ( result * : sources * ) - { - # For library targets, it's okay to bypass input sources of - # type LIB: with static we can't consume library. - - local sources-to-check ; - for local s in $(sources) - { - if ! [ type.is-derived [ $(s).type ] LIB ] - { - sources-to-check += $(s) ; - } - } - basic-target.check-for-unused-sources $(result) : $(sources-to-check) ; - } - - + } } rule lib ( name : sources * : requirements * : default-build * diff --git a/src/tools/gettext.jam b/src/tools/gettext.jam index bb0de1c6c..f749a2a8e 100644 --- a/src/tools/gettext.jam +++ b/src/tools/gettext.jam @@ -169,11 +169,7 @@ class update-translations-class : basic-target } } return $(.constructed) ; - } - - rule check-for-unused-sources ( result * : sources * ) - { - } + } } flags gettext.extract KEYWORD ; diff --git a/src/tools/stage.jam b/src/tools/stage.jam index c7d7602c9..470a62f62 100644 --- a/src/tools/stage.jam +++ b/src/tools/stage.jam @@ -224,11 +224,6 @@ class stage-target-class : basic-target result = [ sequence.unique $(result) ] ; } - # Don't do nothing. - rule check-for-unused-sources ( result * : sources * ) - { - } - rule check-for-link-compatibility ( * : * ) { } diff --git a/test/test_all.py b/test/test_all.py index d82e74ce7..8f9f9b0de 100644 --- a/test/test_all.py +++ b/test/test_all.py @@ -92,7 +92,6 @@ tests = [ "project_test1", "make_rule", "alias", "alternatives", - "unused", "default_features", "print", "ndebug",