diff --git a/v2/test/generators-test/a.cpp b/v2/test/generators-test/a.cpp index 7ef7f6872..e69de29bb 100644 --- a/v2/test/generators-test/a.cpp +++ b/v2/test/generators-test/a.cpp @@ -1,22 +0,0 @@ -// Copyright (c) 2003 Vladimir Prus -// -// 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) -// -// http://www.boost.org -// - -int foo(); -int bar(); - -void z1(), z2(); - -int main() -{ - foo(); - bar(); - z1(); - z2(); - return 0; -} diff --git a/v2/test/generators-test/b.cxx b/v2/test/generators-test/b.cxx index 85b41d3f9..e69de29bb 100644 --- a/v2/test/generators-test/b.cxx +++ b/v2/test/generators-test/b.cxx @@ -1,10 +0,0 @@ -// Copyright (c) 2003 Vladimir Prus -// -// 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) -// -// http://www.boost.org -// - -int foo() { return 0; } diff --git a/v2/test/generators-test/e.cpp b/v2/test/generators-test/e.cpp index ccecbb414..e69de29bb 100644 --- a/v2/test/generators-test/e.cpp +++ b/v2/test/generators-test/e.cpp @@ -1,8 +0,0 @@ -// Copyright (c) 2003 Vladimir Prus -// -// 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) -// -// http://www.boost.org -// diff --git a/v2/test/generators-test/extra.jam b/v2/test/generators-test/extra.jam deleted file mode 100644 index d3500c73c..000000000 --- a/v2/test/generators-test/extra.jam +++ /dev/null @@ -1,120 +0,0 @@ -# Copyright 2002, 2003, 2005 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) - - -import type ; -import generators ; -import "class" : new ; -import common ; - -type.register WHL : whl ; -type.register DLP : dlp ; -type.register WHL_LR0 : lr0 ; -type.register WD : wd ; - -generators.register-standard extra.whale : WHL : CPP WHL_LR0 H H(%_symbols) ; -generators.register-standard extra.dolphin : DLP : CPP ; -generators.register-standard extra.wd : WD : WHL(%_parser) DLP(%_lexer) ; - -class wd-to-cpp : generator -{ - rule __init__ ( * : * : * ) - { - generator.__init__ $(1) : $(2) : $(3) ; - } - - rule run ( project name ? : property-set : source ) - { - local new-sources ; - if ! [ $(source).type ] in WHL DLP - { - local r1 = [ generators.construct $(project) $(name) - : WHL : $(property-set) : $(source) ] ; - local r2 = [ generators.construct $(project) $(name) - : DLP : $(property-set) : $(source) ] ; - - new-sources = [ sequence.unique $(r1[2-]) $(r2[2-]) ] ; - } - else - { - new-sources = $(source) ; - } - - local result ; - for local i in $(new-sources) - { - local t = [ generators.construct $(project) $(name) : CPP - : $(property-set) : $(i) ] ; - result += $(t[2-]) ; - } - return $(result) ; - } -} -generators.override extra.wd-to-cpp : extra.whale ; -generators.override extra.wd-to-cpp : extra.dolphin ; - -generators.register [ new wd-to-cpp extra.wd-to-cpp : : CPP ] ; - -rule whale ( targets * : sources * : properties * ) -{ -} - -TOUCH = [ common.file-touch-command ] ; - -actions whale -{ - echo "Whale consuming " $(>) - $(TOUCH) $(<[1]) - $(TOUCH) $(<[2]) - $(TOUCH) $(<[3]) - $(TOUCH) $(<[4]) -} - -rule dolphin ( targets * : source * : properties * ) -{ -} - -actions dolphin -{ - echo "Dolphin consuming" $(>) - $(TOUCH) $(<) -} - -rule wd ( targets * : source * : properties * ) -{ -} - -actions wd -{ - echo "WD consuming" $(>) - $(TOUCH) $(<[1]) - $(TOUCH) $(<[2]) -} - -rule x ( target * : source * : properties * ) -{ -} - - -actions x -{ - echo "X: source is " $(>) - $(TOUCH) $(<[1]) -} - -rule x_pro ( target * : source * : properties * ) -{ -} - - -actions x_pro -{ - echo "X_PRO: source is " $(>) - $(TOUCH) $(<[1]) - $(TOUCH) $(<[2]) -} - - - - diff --git a/v2/test/generators-test/jamfile.jam b/v2/test/generators-test/jamfile.jam deleted file mode 100644 index e5d9242d3..000000000 --- a/v2/test/generators-test/jamfile.jam +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2002, 2003, 2005 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) - - -project - # This is needed to supress gcc warning on flex output, which otherwise - # results in test failure - : requirements YY_NO_UNPUT - ; - -exe a : a.cpp b.cxx obj_1 obj_2 c.tui d.wd x.l y.x_pro lib//auxilliary ; -# This should not cause second compilation of a.cpp -exe f : a.cpp b.cxx obj_1 obj_2 lib//auxilliary ; - -obj obj_1 : z.cpp : SELECT=1 ; -obj obj_2 : z.cpp : SELECT=2 ; - -nm-exe e : e.cpp ; diff --git a/v2/test/generators-test/jamroot.jam b/v2/test/generators-test/jamroot.jam index abe08bc43..95eeffd4f 100644 --- a/v2/test/generators-test/jamroot.jam +++ b/v2/test/generators-test/jamroot.jam @@ -1,95 +1,192 @@ -# Copyright 2002, 2003, 2004, 2005 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 2002, 2003, 2004, 2005 Vladimir Prus +# Copyright 2012 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) +import appender ; import "class" : new ; - -import lex ; -import qt ; -import extra ; - +import generators ; import type ; + +################################################################################ +# +# We use our own custom EXE, LIB & OBJ target generators as using the regular +# ones would force us to have to deal with different compiler/linker specific +# 'features' that really have nothing to do with this test. For example, IBM XL +# C/C++ for AIX, V12.1 (Version: 12.01.0000.0000) compiler exits with a non-zero +# exit code and thus fails our build when run with a source file using an +# unknown suffix like '.marked_cpp'. +# +################################################################################ + +type.register MY_EXE : my_exe ; +type.register MY_LIB : my_lib ; +type.register MY_OBJ : my_obj ; + +appender.register compile-c : C : MY_OBJ ; +appender.register compile-cpp : CPP : MY_OBJ ; +appender.register link-lib true : MY_OBJ : MY_LIB ; +appender.register link-exe true : MY_OBJ MY_LIB : MY_EXE ; + + +################################################################################ +# +# LEX --> C +# +################################################################################ + +type.register LEX : l ; + +appender.register lex-to-c : LEX : C ; + + +################################################################################ +# +# /--> tUI_H --\ +# tUI --< >--> CPP +# \------------/ +# +################################################################################ + type.register tUI : tui ; -type.register tUIC_H ; -type.set-generated-target-suffix tUIC_H : : h ; +type.register tUI_H : tui_h ; + +appender.register ui-to-cpp : tUI tUI_H : CPP ; +appender.register ui-to-h : tUI : tUI_H ; + + +################################################################################ +# +# /--> X1 --\ +# X_PRO --< >--> CPP +# \--> X2 --/ +# +################################################################################ type.register X1 : x1 ; type.register X2 : x2 ; type.register X_PRO : x_pro ; -import generators ; +appender.register x1-x2-to-cpp : X1 X2 : CPP ; +appender.register x-pro-to-x1-x2 : X_PRO : X1 X2 ; -generators.register-standard qt.uic : tUI tUIC_H : CPP ; -generators.register-standard qt.uic-h : tUI : tUIC_H ; -# That's an interesting example. Currently, X_PRO will be processed -# twice. -generators.register-standard extra.x : X1 X2 : CPP ; -generators.register-standard extra.x_pro : X_PRO : X1 X2 ; - -# The point of this setup of to implement this functionality -# "When main target type is EST_EXE, build OBJ from CPP-MARKED, not -# for anything else (like CPP) -# Unfortunately, this does not really works. - -#if $(no-var) { -import nm ; +################################################################################ +# +# When the main target type is NM_EXE, build OBJ from CPP-MARKED and not from +# anything else, e.g. directly from CPP. +# +################################################################################ type.register CPP_MARKED : marked_cpp : CPP ; type.register POSITIONS : positions ; type.register NM.TARGET.CPP : target_cpp : CPP ; -type.register NM_EXE : : EXE ; +type.register NM_EXE : : MY_EXE ; + +appender.register marked-to-target-cpp : CPP_MARKED : NM.TARGET.CPP ; +appender.register cpp-to-marked-positions : CPP : CPP_MARKED POSITIONS ; -generators.register-standard nm.target-source : CPP_MARKED : NM.TARGET.CPP ; -generators.register-standard nm.cpp-mark : CPP : CPP_MARKED POSITIONS ; - class nm::target::cpp-obj-generator : generator { - rule __init__ ( ) - { - generator.__init__ nm.target-obj : NM.TARGET.CPP : OBJ ; + rule __init__ ( id ) + { + generator.__init__ $(id) : NM.TARGET.CPP : MY_OBJ ; + generator.set-rule-name appender.appender ; } - + rule requirements ( ) { return NM_EXE ; } - - # Consider: it it OK to ignore all other generated targets except for the first? - rule run ( project name ? : properties * : source : multiple ? ) + + rule run ( project name ? : properties * : source : multiple ? ) { - if [ $(source).type ] = CPP { - local converted = [ generators.construct $(project) : NM.TARGET.CPP : $(properties) : $(source) ] ; - if $(converted[1]) - { - local result = [ generators.construct $(project) : OBJ : $(properties) : $(converted[2]) ] ; - return $(result) ; - } - else - { - return ; - } - } - else + if [ $(source).type ] = CPP { - return ; - } - } + local converted = [ generators.construct $(project) : NM.TARGET.CPP + : $(properties) : $(source) ] ; + if $(converted) + { + return [ generators.construct $(project) : MY_OBJ : + $(properties) : $(converted[2]) ] ; + } + } + } } - -generators.register [ new nm::target::cpp-obj-generator ] ; - -generators.override nm.target-obj : all ; - -#} - - +generators.register [ new nm::target::cpp-obj-generator target-obj ] ; +generators.override target-obj : all ; +################################################################################ +# +# A more complex test case scenario with the following generators: +# 1. WHL --> CPP, WHL_LR0, H, H(%_symbols) +# 2. DLP --> CPP +# 3. WD --> WHL(%_parser) DLP(%_lexer) +# 4. A custom generator of higher priority than generators 1. & 2. that helps +# disambiguate between them when generating CPP files from WHL and DLP +# sources. +# +################################################################################ + +type.register WHL : whl ; +type.register DLP : dlp ; +type.register WHL_LR0 : lr0 ; +type.register WD : wd ; + +local whale-generator-id = [ appender.register whale : WHL : CPP WHL_LR0 H + H(%_symbols) ] ; +local dolphin-generator-id = [ appender.register dolphin : DLP : CPP ] ; +appender.register wd : WD : WHL(%_parser) DLP(%_lexer) ; + +class wd-to-cpp : generator +{ + rule __init__ ( id : sources * : targets * ) + { + generator.__init__ $(id) : $(sources) : $(targets) ; + } + + rule run ( project name ? : property-set : source ) + { + local new-sources = $(source) ; + if ! [ $(source).type ] in WHL DLP + { + local r1 = [ generators.construct $(project) $(name) : WHL : + $(property-set) : $(source) ] ; + local r2 = [ generators.construct $(project) $(name) : DLP : + $(property-set) : $(source) ] ; + new-sources = [ sequence.unique $(r1[2-]) $(r2[2-]) ] ; + } + + local result ; + for local i in $(new-sources) + { + local t = [ generators.construct $(project) $(name) : CPP : + $(property-set) : $(i) ] ; + result += $(t[2-]) ; + } + return $(result) ; + } +} +generators.override $(__name__).wd-to-cpp : $(whale-generator-id) ; +generators.override $(__name__).wd-to-cpp : $(dolphin-generator-id) ; +generators.register [ new wd-to-cpp $(__name__).wd-to-cpp : : CPP ] ; +################################################################################ +# +# Declare build targets. +# +################################################################################ +# This should not cause two CPP --> MY_OBJ constructions for a.cpp or b.cpp. +my-exe a : a.cpp b.cxx obj_1 obj_2 c.tui d.wd x.l y.x_pro lib//auxilliary ; +my-exe f : a.cpp b.cxx obj_1 obj_2 lib//auxilliary ; +# This should cause two CPP --> MY_OBJ constructions for z.cpp. +my-obj obj_1 : z.cpp ; +my-obj obj_2 : z.cpp ; +nm-exe e : e.cpp ; diff --git a/v2/test/generators-test/lex.jam b/v2/test/generators-test/lex.jam deleted file mode 100644 index 4ae5422e9..000000000 --- a/v2/test/generators-test/lex.jam +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2002, 2003, 2004, 2005 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) - -import type ; -import generators ; -import feature ; -import property ; -import print ; - -type.register LEX : l ; - -generators.register-standard lex.lex : LEX : C ; - -rule lex ( targets * : sources * : properties * ) -{ - print.output $(<) ; - # Need to supress SunCC's warning about empty source - # file. - print.text "void foo() {} -" ; -} - -actions lex -{ -} diff --git a/v2/test/generators-test/lib/jamfile.jam b/v2/test/generators-test/lib/jamfile.jam index cf3b31417..9287f7e88 100644 --- a/v2/test/generators-test/lib/jamfile.jam +++ b/v2/test/generators-test/lib/jamfile.jam @@ -3,4 +3,4 @@ # 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) -static-lib auxilliary : c.cpp ; +my-lib auxilliary : c.cpp ; diff --git a/v2/test/generators-test/nm.jam b/v2/test/generators-test/nm.jam deleted file mode 100644 index 0b1ad984a..000000000 --- a/v2/test/generators-test/nm.jam +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2002, 2003 Dave Abrahams -# Copyright 2002 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) - -import modules ; -import common ; - -TOUCH = [ common.file-touch-command ] ; - -rule target-source ( targets * : sources * : properties * ) -{ - if [ modules.peek : NT ] - { - main on $(<) = "int main() { return 0; }" ; - } - else - { - main on $(<) = "\"int main() { return 0; }\"" ; - } -} - -actions target-source -{ - echo "NM target source consuming " $(>) - echo $(main) > $(<) -} - -rule cpp-mark ( targets * : sources * : properties * ) -{ -} - -actions cpp-mark -{ - echo "CPP-MARK consuming " $(>) - $(TOUCH) $(<[1]) - $(TOUCH) $(<[2]) -} - - - - - diff --git a/v2/test/generators-test/qt.jam b/v2/test/generators-test/qt.jam deleted file mode 100644 index ec0ee3374..000000000 --- a/v2/test/generators-test/qt.jam +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2002 Dave Abrahams -# Copyright 2002 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) - -import modules ; - -if [ modules.peek : NT ] -{ - comment = // ; -} -else -{ - comment = \"//\" ; -} - -rule uic ( target : sources * : properties * ) -{ - comment on $(<) = $(comment) ; -} -rule uic-h ( target : sources * : properties * ) -{ - comment on $(<) = $(comment) ; -} - -actions uic -{ - echo $(comment) $(>) > $(<) -} - -actions uic-h -{ - echo $(comment) $(>) > $(<) -} diff --git a/v2/test/generators-test/x.l b/v2/test/generators-test/x.l index 16beb4d9b..e69de29bb 100644 --- a/v2/test/generators-test/x.l +++ b/v2/test/generators-test/x.l @@ -1,5 +0,0 @@ -%option noyywrap - -%% - -%% \ No newline at end of file diff --git a/v2/test/generators-test/z.cpp b/v2/test/generators-test/z.cpp index 7826c1ca7..e69de29bb 100644 --- a/v2/test/generators-test/z.cpp +++ b/v2/test/generators-test/z.cpp @@ -1,16 +0,0 @@ -// Copyright (c) 2003 Vladimir Prus -// -// 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) -// -// http://www.boost.org -// - -#if SELECT == 1 -void z1() {} -#elif SELECT == 2 -void z2() {} -#else -#error Invlid value of SELECT -#endif diff --git a/v2/test/generators_test.py b/v2/test/generators_test.py index 2fea62e60..ce734da84 100644 --- a/v2/test/generators_test.py +++ b/v2/test/generators_test.py @@ -10,14 +10,15 @@ import BoostBuild t = BoostBuild.Tester() t.set_tree("generators-test") -t.run_build_system() -t.expect_addition("bin/$toolset/debug/" * BoostBuild.List("a.exe a.obj " - "b.obj c.h c.cpp c.obj d_parser.whl d_lexer.dlp d_parser.cpp d_lexer.cpp " - "d_lexer.obj d_parser.lr0 d_parser.h d_parser.obj d_parser_symbols.h x.c " - "x.obj y.x1 y.x2 y.cpp y.obj e.marked_cpp e.positions e.target_cpp e.obj " - "e.exe f.exe obj_1.obj obj_2.obj")) -t.expect_addition("lib/bin/$toolset/debug/" * BoostBuild.List("c.obj " - "auxilliary.lib")) +t.run_build_system("-d1") +t.expect_addition("bin/$toolset/debug/" * BoostBuild.List("a.my_exe a.my_obj " + "b.my_obj c.tui_h c.cpp c.my_obj d_parser.whl d_lexer.dlp d_parser.cpp " + " d_lexer.cpp d_lexer.my_obj d_parser.lr0 d_parser.h d_parser.my_obj " + "d_parser_symbols.h x.c x.my_obj y.x1 y.x2 y.cpp y.my_obj e.marked_cpp " + "e.positions e.target_cpp e.my_obj e.my_exe f.my_exe obj_1.my_obj " + "obj_2.my_obj")) +t.expect_addition("lib/bin/$toolset/debug/" * BoostBuild.List("c.my_obj " + "auxilliary.my_lib")) t.expect_nothing_more() t.cleanup()