|
Boost-Commit : |
From: jurko.gospodnetic_at_[hidden]
Date: 2008-05-03 12:05:18
Author: jurko
Date: 2008-05-03 12:05:17 EDT (Sat, 03 May 2008)
New Revision: 45070
URL: http://svn.boost.org/trac/boost/changeset/45070
Log:
Cleaned up the main Boost Build module a bit related to how it processes explicit file (not target) references specified on the command line. Improved the related unit test. Minor stylistic changes.
Text files modified:
trunk/tools/build/v2/build-system.jam | 44 +++++----
trunk/tools/build/v2/test/build_file.py | 178 +++++++++++++++++++++++++++++++++------
2 files changed, 175 insertions(+), 47 deletions(-)
Modified: trunk/tools/build/v2/build-system.jam
==============================================================================
--- trunk/tools/build/v2/build-system.jam (original)
+++ trunk/tools/build/v2/build-system.jam 2008-05-03 12:05:17 EDT (Sat, 03 May 2008)
@@ -599,12 +599,21 @@
local cleanall ; if "--clean-all" in $(.argv) { cleanall = true ; }
- # List of Boost Build meta-targets and actual raw Jam targets directly
- # requested by the user. Raw Jam targets are used when user's request
- # contains a reference to a specific file not modeled using a main Boost
- # Build target.
+ # List of explicitly requested files to build. Any target references read
+ # from the command line parameter not recognized as one of the targets
+ # defined in the loaded Jamfiles will be interpreted as an explicitly
+ # requested file to build. If any such files are explicitly requested then
+ # only those files and the targets they depend on will be built and they
+ # will be searched for among targets that would have been built had there
+ # been no explicitly requested files.
+ local explicitly-requested-files
+
+
+ # List of Boost Build meta-targets, virtual-targets and actual Jam targets
+ # constructed in this build system run.
local targets ;
- local bjam-targets ;
+ local virtual-targets ;
+ local actual-targets ;
# Process each target specified on the command-line and convert it into
@@ -633,7 +642,7 @@
{
ECHO "notice: could not find main target" $(id) ;
ECHO "notice: assuming it's a name of file to create." ;
- bjam-targets += $(id) ;
+ explicitly-requested-files += $(id) ;
}
else
{
@@ -647,10 +656,6 @@
}
- # List of all virtual-targets created in this build system run.
- local virtual-targets ;
-
-
# Now that we have a set of targets to build and a set of property sets to
# build the targets with, we can start the main build process by using each
# property set to generate virtual targets from all of our listed targets
@@ -670,11 +675,7 @@
}
- # List of all Jam targets constructed in this build system run.
- local actual-targets ;
-
-
- # Convert all collected virtual targets into actual raw Jam targets.
+ # Convert collected virtual targets into actual raw Jam targets.
for t in $(virtual-targets)
{
actual-targets += [ $(t).actualize ] ;
@@ -863,12 +864,15 @@
# And now that all the actual raw Jam targets and all the dependencies
- # between them have been prepared (or we have everything set so we can
- # easily prepare them) all that is left is to tell Jam to update those
- # targets.
- if $(bjam-targets)
+ # between them have been prepared all that is left is to tell Jam to update
+ # those targets.
+ if $(explicitly-requested-files)
{
- UPDATE $(bjam-targets:G=e) $(.out-xml) ;
+ # Note that this case can not be joined with the regular one when only
+ # exact Boost Build targets are requested as here we do not build those
+ # requested targets but only use them to construct the dependency tree
+ # needed to build the explicitly requested files.
+ UPDATE $(explicitly-requested-files:G=e) $(.out-xml) ;
}
else if $(cleanall)
{
Modified: trunk/tools/build/v2/test/build_file.py
==============================================================================
--- trunk/tools/build/v2/test/build_file.py (original)
+++ trunk/tools/build/v2/test/build_file.py 2008-05-03 12:05:17 EDT (Sat, 03 May 2008)
@@ -1,46 +1,170 @@
#!/usr/bin/python
# Copyright (C) Vladimir Prus 2006.
+# Copyright (C) Jurko Gospodnetic 2008.
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-# Tests that we can build a file (not target), by it's name
-from BoostBuild import Tester, List
-from string import find
+# Tests that we explicitly request a file (not target) to be built by
+# specifying its name on the command line.
-# Create a temporary working directory
-t = Tester()
+import BoostBuild
-# Create the needed files
-t.write("Jamroot", """
+
+################################################################################
+#
+# test_building_file_from_specific_project()
+# ------------------------------------------
+#
+################################################################################
+
+def test_building_file_from_specific_project():
+ t = BoostBuild.Tester()
+
+ t.write("Jamroot.jam", """
exe hello : hello.cpp ;
+exe hello2 : hello.cpp ;
build-project sub ;
""")
-t.write("hello.cpp", """
-int main()
-{
- return 0;
-}
-""")
-t.write("sub/Jamfile", """
+ t.write("hello.cpp", "int main() { return 0; }")
+ t.write("sub/Jamfile.jam", """
exe hello : hello.cpp ;
+exe hello2 : hello.cpp ;
exe sub : hello.cpp ;
""")
-t.write("sub/hello.cpp", """
-int main()
-{
- return 0;
-}
-""")
+ t.write("sub/hello.cpp", "int main() { return 0; }")
+ t.run_build_system("sub " + t.adjust_suffix("hello.obj"))
+ t.expect_output_line("*depends on itself*", False)
+ t.expect_addition("sub/bin/$toolset/debug/hello.obj")
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+
+################################################################################
+#
+# test_building_file_from_specific_target()
+# -----------------------------------------
+#
+################################################################################
+
+def test_building_file_from_specific_target():
+ t = BoostBuild.Tester()
+
+ t.write("Jamroot.jam", """
+exe hello1 : hello1.cpp ;
+exe hello2 : hello2.cpp ;
+exe hello3 : hello3.cpp ;
+""")
+ t.write("hello1.cpp", "int main() { return 0; }")
+ t.write("hello2.cpp", "int main() { return 0; }")
+ t.write("hello3.cpp", "int main() { return 0; }")
+
+ t.run_build_system("hello1 " + t.adjust_suffix("hello1.obj"))
+ t.expect_addition("bin/$toolset/debug/hello1.obj")
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+
+################################################################################
+#
+# test_building_missing_file_from_specific_target()
+# -------------------------------------------------
+#
+################################################################################
+
+def test_building_missing_file_from_specific_target():
+ t = BoostBuild.Tester()
+
+ t.write("Jamroot.jam", """
+exe hello1 : hello1.cpp ;
+exe hello2 : hello2.cpp ;
+exe hello3 : hello3.cpp ;
+""")
+ t.write("hello1.cpp", "int main() { return 0; }")
+ t.write("hello2.cpp", "int main() { return 0; }")
+ t.write("hello3.cpp", "int main() { return 0; }")
+
+ t.run_build_system("hello1 " + t.adjust_suffix("hello2.obj"), status=1)
+ t.expect_output_line("don't know how to make*hello2.obj")
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+
+################################################################################
+#
+# test_building_multiple_files_with_different_names()
+# ---------------------------------------------------
+#
+################################################################################
+
+def test_building_multiple_files_with_different_names():
+ t = BoostBuild.Tester()
+
+ t.write("Jamroot.jam", """
+exe hello1 : hello1.cpp ;
+exe hello2 : hello2.cpp ;
+exe hello3 : hello3.cpp ;
+""")
+ t.write("hello1.cpp", "int main() { return 0; }")
+ t.write("hello2.cpp", "int main() { return 0; }")
+ t.write("hello3.cpp", "int main() { return 0; }")
+
+ t.run_build_system(
+ t.adjust_suffix("hello1.obj") + " " +
+ t.adjust_suffix("hello2.obj"))
+ t.expect_addition("bin/$toolset/debug/hello1.obj")
+ t.expect_addition("bin/$toolset/debug/hello2.obj")
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+
+################################################################################
+#
+# test_building_multiple_files_with_the_same_name()
+# -------------------------------------------------
+#
+################################################################################
-t.run_build_system(t.adjust_suffix("hello.obj"))
+def test_building_multiple_files_with_the_same_name():
+ t = BoostBuild.Tester()
-t.fail_test(find(t.stdout(), "depends on itself") != -1)
-t.expect_addition("bin/$toolset/debug/hello.obj")
-t.expect_addition("sub/bin/$toolset/debug/hello.obj")
-t.expect_nothing_more()
+ t.write("Jamroot.jam", """
+exe hello : hello.cpp ;
+exe hello2 : hello.cpp ;
+build-project sub ;
+""")
+ t.write("hello.cpp", "int main() { return 0; }")
+ t.write("sub/Jamfile.jam", """
+exe hello : hello.cpp ;
+exe hello2 : hello.cpp ;
+exe sub : hello.cpp ;
+""")
+ t.write("sub/hello.cpp", "int main() { return 0; }")
-# Remove temporary directories
-t.cleanup()
+ t.run_build_system(t.adjust_suffix("hello.obj"))
+ t.expect_output_line("*depends on itself*", False)
+ t.expect_addition("bin/$toolset/debug/hello.obj")
+ t.expect_addition("sub/bin/$toolset/debug/hello.obj")
+ t.expect_nothing_more()
+
+ t.cleanup()
+
+
+################################################################################
+#
+# main()
+# ------
+#
+################################################################################
+
+test_building_file_from_specific_project()
+test_building_file_from_specific_target()
+test_building_missing_file_from_specific_target()
+test_building_multiple_files_with_different_names()
+test_building_multiple_files_with_the_same_name()
Boost-Commit 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