2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-14 12:42:11 +00:00

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 <source> or <library> 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 : <optimization>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]
This commit is contained in:
Vladimir Prus
2004-05-26 09:57:03 +00:00
parent bc84dc2847
commit 79cd3623f4
6 changed files with 4 additions and 81 deletions

View File

@@ -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) ] ;

View File

@@ -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 : <os>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 )

View File

@@ -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 <link>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 *

View File

@@ -169,11 +169,7 @@ class update-translations-class : basic-target
}
}
return $(.constructed) ;
}
rule check-for-unused-sources ( result * : sources * )
{
}
}
}
flags gettext.extract KEYWORD <gettext.keyword> ;

View File

@@ -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 ( * : * )
{
}

View File

@@ -92,7 +92,6 @@ tests = [ "project_test1",
"make_rule",
"alias",
"alternatives",
"unused",
"default_features",
"print",
"ndebug",