From 593ceeef79d3eac8cfcc9b98c48fd5f42818a981 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 13 Oct 2004 08:02:23 +0000 Subject: [PATCH] Restore the gcc specific link generators. * build/toolset.jam (inherit-generator): New parameter 'generators-to-ignore'. * tools/gcc.jam: Ignore *link* generators when inheriting. Declare the gcc specific generator. * test/gcc_runtime.py: Test that static is correctly handled. The gcc specific generator is necessary exactly for that reason. [SVN r25700] --- v2/build/toolset.jam | 37 ++++++++++++++++++++----------------- v2/test/gcc_runtime.py | 31 +++++++++++++++++++++++++++++++ v2/test/test_all.py | 4 ++++ v2/tools/gcc.jam | 17 +++++++++++++++-- 4 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 v2/test/gcc_runtime.py diff --git a/v2/build/toolset.jam b/v2/build/toolset.jam index 7b1196291..d847156b1 100644 --- a/v2/build/toolset.jam +++ b/v2/build/toolset.jam @@ -285,30 +285,33 @@ rule inherit ( toolset : base ) inherit-rules $(toolset) : $(base) ; } -rule inherit-generators ( toolset properties * : base ) +rule inherit-generators ( toolset properties * : base : generators-to-ignore * ) { properties ?= $(toolset) ; local base-generators = [ generators.generators-for-toolset $(base) ] ; for local g in $(base-generators) { local id = [ $(g).id ] ; + + if ! $(id) in $(generators-to-ignore) + { + # Some generator names have multiple periods in their name, so + # $(id:B=$(toolset)) doesn't generate the right new-id name. + # e.g. if id = gcc.compile.c++, $(id:B=darwin) = darwin.c++, + # which is not what we want. Manually parse the base and suffix + # (if there's a better way to do this, I'd love to see it.) + # See also register in module generators. + local base = $(id) ; + local suffix = "" ; + while $(base:S) + { + suffix = $(base:S)$(suffix) ; + base = $(base:B) ; + } + local new-id = $(toolset)$(suffix) ; - # Some generator names have multiple periods in their name, so - # $(id:B=$(toolset)) doesn't generate the right new-id name. - # e.g. if id = gcc.compile.c++, $(id:B=darwin) = darwin.c++, - # which is not what we want. Manually parse the base and suffix - # (if there's a better way to do this, I'd love to see it.) - # See also register in module generators. - local base = $(id) ; - local suffix = "" ; - while $(base:S) - { - suffix = $(base:S)$(suffix) ; - base = $(base:B) ; - } - local new-id = $(toolset)$(suffix) ; - - generators.register [ $(g).clone $(new-id) : $(properties) ] ; + generators.register [ $(g).clone $(new-id) : $(properties) ] ; + } } } diff --git a/v2/test/gcc_runtime.py b/v2/test/gcc_runtime.py new file mode 100644 index 000000000..114b1c1a3 --- /dev/null +++ b/v2/test/gcc_runtime.py @@ -0,0 +1,31 @@ +#!/usr/bin/python + +# Copyright (C) Vladimir Prus 2004. Permission to copy, use, modify, sell and +# distribute this software is granted provided this copyright notice appears in +# all copies. This software is provided "as is" without express or implied +# warranty, and with no claim as to its suitability for any purpose. + +# Tests that on gcc, we correctly report problem when static runtime +# is requested when building DLL. +from BoostBuild import Tester, List +import string + +t = Tester() + +# Create the needed files +t.write("project-root.jam", "") +t.write("Jamfile", """ +lib hello : hello.cpp ; +""") +t.write("hello.cpp", """ +int main() +{ + return 0; +} +""") + +t.run_build_system("link-runtime=static", status=1) +t.fail_test(string.find(t.stdout(), + "on gcc, DLL can't be build with static") == -1) + +t.cleanup() diff --git a/v2/test/test_all.py b/v2/test/test_all.py index 5b33e56f8..36a923b78 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -1,5 +1,6 @@ #!/usr/bin/python import os, sys, string +from BoostBuild import get_toolset # clear environment for testing # @@ -133,6 +134,9 @@ if os.name == 'posix': # Besides, it fails ;-) tests.append("library_order") +if string.find(get_toolset(), 'gcc') == 0: + tests.append("gcc_runtime") + if os.environ.has_key('QTDIR'): tests.append("railsys") else: diff --git a/v2/tools/gcc.jam b/v2/tools/gcc.jam index 3d67ec39c..706e3199e 100644 --- a/v2/tools/gcc.jam +++ b/v2/tools/gcc.jam @@ -17,7 +17,13 @@ import set ; import common ; feature.extend toolset : gcc ; -toolset.inherit gcc : unix ; + +import unix ; +toolset.inherit-generators gcc : unix : unix.link unix.link.dll ; +toolset.inherit-flags gcc : unix ; +toolset.inherit-rules gcc : unix ; + + # Make the "o" suffix used for gcc toolset on all # platforms @@ -151,10 +157,17 @@ class gcc-linking-generator : unix-linking-generator } return [ unix-linking-generator.generated-targets - $(sources) : $(property-set) : $(property-set) $(name) ] ; + $(sources) : $(property-set) : $(project) $(name) ] ; } } +generators.register [ new gcc-linking-generator gcc.link : LIB OBJ : EXE + : gcc ] ; + +generators.register [ new gcc-linking-generator gcc.link.dll : LIB OBJ : SHARED_LIB + : gcc ] ; + + # Declare flags and action for linking flags gcc.link OPTIONS on : -g ;