Boost logo

Boost-Build :

From: Jurko Gospodnetiæ (jurko.gospodnetic_at_[hidden])
Date: 2007-12-22 22:48:51


   Hi.

   I believe that when an alias alternative matching the current
feature-set can not be found that Boost Build should not display a
warning to that affect unless someone actually wants to use (build/use
as source/whatever...) that alias with that feature set.

   We encountered a problem with this warning in the following scenario:

     1. Master project A declared with a <link>static requirement
(propagated feature).

     2. Sub-project B declares two alias alternatives conditioned on the
<toolset> feature.

   Now when we try to build project B Boost Build complains that it can
not find the 'best alternative' for the alias. This does not prevent
targets depending on the alias to be build successfully since when they
are built both <link> and <toolset> features have well defined values.

   When you trim this down to the simplest possible use case you get a
Jamfile with:

alias a : : <link>static <toolset>gcc ;
alias a : : <link>static <toolset>msvc ;

   Now just running bjam on it causes that same warning even though
there are no alias targets actually getting built.

   I'm attaching a bit refactored alias rule tests (split into two
files) and an added alias_no_warning.py test for this catching this warning.

   Hope this helps.

   Best regards,
     Jurko Gospodnetiæ

Left base folder: X:\Boost_Build\20071222_nightly_build\Original\boost-build
Right base folder: X:\Boost_Build\20071222_nightly_build\Modified\boost-build
--- test\alias.py 2007-12-21 15:33:44.000000000 +-0100
+++ test\alias.py 2007-12-23 04:23:24.000000000 +-0100
@@ -1,17 +1,16 @@
 #!/usr/bin/python
 
-# Copyright 2003 Dave Abrahams
-# Copyright 2003 Vladimir Prus
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+# Copyright 2003 Dave Abrahams
+# Copyright 2003 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 
 from BoostBuild import Tester, List
 t = Tester()
 
-# Test that top-level project can affect build dir
 t.write("project-root.jam", "")
 t.write("Jamfile", """
 
 exe a : a.cpp ;
 exe b : b.cpp ;
 exe c : c.cpp ;
@@ -26,55 +25,24 @@
 t.write("a.cpp", "int main() { return 0; }\n")
 t.copy("a.cpp", "b.cpp")
 t.copy("a.cpp", "c.cpp")
 t.copy("a.cpp", "hello.cpp")
 t.write("s.cpp", "")
 
-# Check that targets to which "bin1" refers are updated,
-# and only those.
+# Check that targets to which "bin1" refers are updated, and only those.
 t.run_build_system("bin1")
-t.ignore("*.tds")
 t.expect_addition(List("bin/$toolset/debug/") * "a.exe a.obj")
 t.expect_nothing_more()
 
 # Try again with "bin2"
 t.run_build_system("bin2")
-t.ignore("*.tds")
 t.expect_addition(List("bin/$toolset/debug/") * "b.exe b.obj")
 t.expect_nothing_more()
 
-# Try building everything, making sure 'hello' target is
-# created
+# Try building everything, making sure 'hello' target is created.
 t.run_build_system()
-t.ignore("*.tds")
-t.expect_addition("bin/$toolset/debug/hello.exe")
-
-# Regression test.
-# Check if usage requirements are propagated via "alias"
-
-t.write("l.cpp", """
-void
-#if defined(_WIN32)
-__declspec(dllexport)
-#endif
-foo() {}
+t.expect_addition(List("bin/$toolset/debug/") * "hello.exe hello.obj")
+t.expect_addition("bin/$toolset/debug/s.obj")
+t.expect_addition(List("bin/$toolset/debug/") * "c.exe c.obj")
+t.expect_nothing_more()
 
-""")
-
-t.write("Jamfile", """
-lib l : l.cpp : : : <define>WANT_MAIN ;
-alias la : l ;
-exe main : main.cpp la ;
-""")
-
-t.write("main.cpp", """
-#ifdef WANT_MAIN
-int main() { return 0; }
-#endif
-
-""")
-
-t.write("project-root.jam", "")
-
-t.run_build_system()
-
 t.cleanup()
---
+++ test\alias_requirement_warning.py 2007-12-23 04:23:18.000000000 +-0100
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+# Copyright 2007 Jurko Gospodnetic.
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+# Make sure Boost Build does not issue a warning if no alias alternative can
+# be found for the given feature set in case noone actually uses the alias with
+# that feature set. In a simple one level project it would be easy to get rid of
+# such warnings by specifying an alias alternative with no requirements.
+# However, this solution does not work in case of a sub-project inheriting a
+# propagated feature from its master project as then even that 'simple alias
+# alternative' is affected by the propagated property.
+from BoostBuild import Tester, List
+t = Tester()
+
+t.write("project-root.jam", "")
+
+t.write("Jamfile", """
+alias a : : <link>static <toolset>gcc ;
+alias a : : <link>static <toolset>msvc ;
+""")
+
+t.run_build_system(stdout="")
+t.cleanup()
---
+++ test\alias_source_usage_req.py 2007-12-23 04:23:21.000000000 +-0100
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+# Copyright 2003 Dave Abrahams
+# Copyright 2003 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+
+# Check whether usage requirements are propagated via "alias". In case they
+# are not link will fail as there will be no main() function defined anywhere in
+# the source.
+from BoostBuild import Tester, List
+t = Tester()
+
+t.write("project-root.jam", "")
+
+t.write("l.cpp", """
+void
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+foo() {}
+""")
+
+t.write("Jamfile", """
+lib l : l.cpp : : : <define>WANT_MAIN ;
+alias la : l ;
+exe main : main.cpp la ;
+""")
+
+t.write("main.cpp", """
+#ifdef WANT_MAIN
+int main() { return 0; }
+#endif
+""")
+
+t.run_build_system()
+t.cleanup()


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk