diff --git a/test/generators-test/Jamfile b/test/generators-test/Jamfile new file mode 100644 index 000000000..f6aff8a7e --- /dev/null +++ b/test/generators-test/Jamfile @@ -0,0 +1,5 @@ + +exe a : a.cpp b.cpp c.ui d.wd x.l y.x_pro lib/aux ; +#exe a : a.cpp b.cpp c.ui d.wd x.l y.x_pro ; + +nm_exe e : e.cpp ; diff --git a/test/generators-test/a.cpp b/test/generators-test/a.cpp new file mode 100644 index 000000000..90793520e --- /dev/null +++ b/test/generators-test/a.cpp @@ -0,0 +1,10 @@ + +int foo(); +int bar(); + +int main() +{ + foo(); + bar(); + return 0; +} \ No newline at end of file diff --git a/test/generators-test/b.cpp b/test/generators-test/b.cpp new file mode 100644 index 000000000..2b906fb47 --- /dev/null +++ b/test/generators-test/b.cpp @@ -0,0 +1,2 @@ + +int foo() { return 0; } \ No newline at end of file diff --git a/test/generators-test/c.ui b/test/generators-test/c.ui new file mode 100644 index 000000000..e69de29bb diff --git a/test/generators-test/d.wd b/test/generators-test/d.wd new file mode 100644 index 000000000..e69de29bb diff --git a/test/generators-test/e.cpp b/test/generators-test/e.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/test/generators-test/extra.jam b/test/generators-test/extra.jam new file mode 100644 index 000000000..ea7b39f6c --- /dev/null +++ b/test/generators-test/extra.jam @@ -0,0 +1,56 @@ + +rule whale ( targets * : sources * : properties * ) +{ +} + +actions whale +{ + echo "Whale consuming " $(>) + touch $(<) +} + +rule dolphin ( targets * : source * : properties * ) +{ +} + +actions dolphin +{ + echo "Dolphin consuming" $(>) + touch $(<) +} + +rule wd ( targets * : source * : properties * ) +{ +} + +actions wd +{ + echo "WD consuming" $(>) + touch $(<) +} + +rule x ( target * : source * : properties * ) +{ +} + + +actions x +{ + echo "X: source is " $(>) + touch $(<) +} + +rule x_pro ( target * : source * : properties * ) +{ +} + + +actions x_pro +{ + echo "X_PRO: source is " $(>) + touch $(<) +} + + + + diff --git a/test/generators-test/gcc.jam b/test/generators-test/gcc.jam new file mode 100644 index 000000000..66d07382a --- /dev/null +++ b/test/generators-test/gcc.jam @@ -0,0 +1,52 @@ + +import property ; + +rule compile ( target : sources * : property-set * ) +{ + local options ; + for local p in $(property-set) + { + if $(p) = on + { + options += -O2 ; + } + else if $(p) = on + { + options += -g ; + } + else if $(p:G) = + { + options += -D$(p:G=) ; + } + } + OPTIONS on $(target) = $(options) ; +} + +actions compile +{ + g++ $(OPTIONS) -c -o $(<) $(>) +} + +rule link ( target : sources * : property-set * ) +{ + local options ; + if on in $(property-set) + { + options += -g ; + } + OPTIONS on $(target) = $(options) ; +} + +actions link +{ + g++ $(OPTIONS) -o $(<) $(>) +} + +rule archive ( target : sources * : property-set * ) +{ +} + +actions archive +{ + ar ur $(<) $(>) +} diff --git a/test/generators-test/lex.jam b/test/generators-test/lex.jam new file mode 100644 index 000000000..8721f0581 --- /dev/null +++ b/test/generators-test/lex.jam @@ -0,0 +1,9 @@ + +rule lex ( target : source : properties * ) +{ +} + +actions lex +{ + flex -o$(<) $(>) +} \ No newline at end of file diff --git a/test/generators-test/lib/Jamfile b/test/generators-test/lib/Jamfile new file mode 100644 index 000000000..78fe21756 --- /dev/null +++ b/test/generators-test/lib/Jamfile @@ -0,0 +1,2 @@ + +lib aux : c.cpp ; \ No newline at end of file diff --git a/test/generators-test/lib/c.cpp b/test/generators-test/lib/c.cpp new file mode 100644 index 000000000..2235513ec --- /dev/null +++ b/test/generators-test/lib/c.cpp @@ -0,0 +1,2 @@ + +int bar() { return 0; } \ No newline at end of file diff --git a/test/generators-test/nm.jam b/test/generators-test/nm.jam new file mode 100644 index 000000000..a952ce5da --- /dev/null +++ b/test/generators-test/nm.jam @@ -0,0 +1,25 @@ + +rule target-source ( targets * : sources * : properties * ) +{ +} + +actions target-source +{ + echo "NM target source consuming " $(>) + echo "int main() {}" > $(<) +} + +rule cpp-mark ( targets * : sources * : properties * ) +{ +} + +actions cpp-mark +{ + echo "CPP-MARK consuming " $(>) + touch $(<) +} + + + + + diff --git a/test/generators-test/project-root.jam b/test/generators-test/project-root.jam new file mode 100644 index 000000000..2a9196a69 --- /dev/null +++ b/test/generators-test/project-root.jam @@ -0,0 +1,116 @@ + +import class : class new ; + +import gcc ; +import lex ; +import qt ; +import extra ; + +import type ; + +type.register EXE : : : main ; +type.register LIB : : : main ; +type.register CPP : cpp ; +type.register C : c ; +type.register OBJ : o ; +type.register LEX : l ; +type.register WHL : whl ; +type.register DLP : dlp ; +type.register WHL-LR0 : lr0 ; +type.register WD : wd ; +type.register H : h ; +type.register UI : ui ; +type.register UIC-H : h ; + +type.register X1 : x1 ; +type.register X2 : x2 ; +type.register X_PRO : x_pro ; + +import generators ; + +generators.register-composing gcc.link : LIB OBJ : EXE : gcc ; +generators.register-composing gcc.archive : OBJ : LIB : gcc ; +generators.register-standard gcc.compile : CPP : OBJ : gcc ; +generators.register-standard gcc.compile : C : OBJ : gcc ; +generators.register-standard lex.lex : LEX : C ; + +generators.register-standard extra.whale : WHL : CPP WHL-LR0 ; +generators.register-standard extra.dolphin : DLP : CPP ; +generators.register-standard extra.wd : WD : WHL DLP ; +generators.register-standard qt.uic : UI UIC-H : CPP ; +generators.register-standard qt.uic-h : UI : UIC-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 ; + +type.register CPP-MARKED : marked.cpp : CPP ; +type.register POSITIONS : positions ; +type.register NM.TARGET.CPP : target.cpp : CPP ; +type.register NM_EXE : : EXE : main ; + +# Should inherit generators from base class? +generators.register-composing gcc.link : OBJ : NM_EXE : gcc ; +generators.register-standard nm.target-source : CPP-MARKED : NM.TARGET.CPP ; +generators.register-standard nm.cpp-mark : CPP : CPP-MARKED POSITIONS ; + + +rule nm.target.cpp-obj-generator +{ + generator.__init__ nm.target-obj : NM.TARGET.CPP : OBJ ; + + rule requirements ( ) + { + return NM_EXE ; + } + + rule optional-properties ( ) + { + return NM_EXE ; + } + + # Consider: it it OK to ignore all other generated targets except for the first? + rule run ( project name ? : properties * : source : multiple ? ) + { + if [ $(source).type ] = CPP { + local converted = [ generators.construct-dbg $(project) : NM.TARGET.CPP : $(properties) : $(source) ] ; + local first = [ $(converted).at 1 ] ; + if ! [ $(first).empty ] + { + converted = [ $(first).get ] ; + local result = [ generators.construct-dbg $(project) : OBJ : $(properties) : $(converted) ] ; + return [ $(result).get-at 1 ] ; + } + else + { + return ; + } + } + else + { + return ; + } + } +} +class nm.target.cpp-obj-generator : generator ; + +generators.register [ new nm.target.cpp-obj-generator ] ; +#} + + + + + + + + + diff --git a/test/generators-test/qt.jam b/test/generators-test/qt.jam new file mode 100644 index 000000000..315c9bc94 --- /dev/null +++ b/test/generators-test/qt.jam @@ -0,0 +1,19 @@ + +rule uic ( target : sources * : properties * ) +{ +} + +actions uic +{ + echo "//" $(>) > $(<) +} + +rule uic-h ( target : sources * : properties * ) +{ +} + +actions uic-h +{ + echo "//" $(>) > $(<) +} + diff --git a/test/generators-test/x.l b/test/generators-test/x.l new file mode 100644 index 000000000..16beb4d9b --- /dev/null +++ b/test/generators-test/x.l @@ -0,0 +1,5 @@ +%option noyywrap + +%% + +%% \ No newline at end of file diff --git a/test/generators-test/y.x_pro b/test/generators-test/y.x_pro new file mode 100644 index 000000000..e69de29bb diff --git a/v2/test/generators-test/Jamfile b/v2/test/generators-test/Jamfile new file mode 100644 index 000000000..f6aff8a7e --- /dev/null +++ b/v2/test/generators-test/Jamfile @@ -0,0 +1,5 @@ + +exe a : a.cpp b.cpp c.ui d.wd x.l y.x_pro lib/aux ; +#exe a : a.cpp b.cpp c.ui d.wd x.l y.x_pro ; + +nm_exe e : e.cpp ; diff --git a/v2/test/generators-test/a.cpp b/v2/test/generators-test/a.cpp new file mode 100644 index 000000000..90793520e --- /dev/null +++ b/v2/test/generators-test/a.cpp @@ -0,0 +1,10 @@ + +int foo(); +int bar(); + +int main() +{ + foo(); + bar(); + return 0; +} \ No newline at end of file diff --git a/v2/test/generators-test/b.cpp b/v2/test/generators-test/b.cpp new file mode 100644 index 000000000..2b906fb47 --- /dev/null +++ b/v2/test/generators-test/b.cpp @@ -0,0 +1,2 @@ + +int foo() { return 0; } \ No newline at end of file diff --git a/v2/test/generators-test/c.ui b/v2/test/generators-test/c.ui new file mode 100644 index 000000000..e69de29bb diff --git a/v2/test/generators-test/d.wd b/v2/test/generators-test/d.wd new file mode 100644 index 000000000..e69de29bb diff --git a/v2/test/generators-test/e.cpp b/v2/test/generators-test/e.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/v2/test/generators-test/extra.jam b/v2/test/generators-test/extra.jam new file mode 100644 index 000000000..ea7b39f6c --- /dev/null +++ b/v2/test/generators-test/extra.jam @@ -0,0 +1,56 @@ + +rule whale ( targets * : sources * : properties * ) +{ +} + +actions whale +{ + echo "Whale consuming " $(>) + touch $(<) +} + +rule dolphin ( targets * : source * : properties * ) +{ +} + +actions dolphin +{ + echo "Dolphin consuming" $(>) + touch $(<) +} + +rule wd ( targets * : source * : properties * ) +{ +} + +actions wd +{ + echo "WD consuming" $(>) + touch $(<) +} + +rule x ( target * : source * : properties * ) +{ +} + + +actions x +{ + echo "X: source is " $(>) + touch $(<) +} + +rule x_pro ( target * : source * : properties * ) +{ +} + + +actions x_pro +{ + echo "X_PRO: source is " $(>) + touch $(<) +} + + + + diff --git a/v2/test/generators-test/gcc.jam b/v2/test/generators-test/gcc.jam new file mode 100644 index 000000000..66d07382a --- /dev/null +++ b/v2/test/generators-test/gcc.jam @@ -0,0 +1,52 @@ + +import property ; + +rule compile ( target : sources * : property-set * ) +{ + local options ; + for local p in $(property-set) + { + if $(p) = on + { + options += -O2 ; + } + else if $(p) = on + { + options += -g ; + } + else if $(p:G) = + { + options += -D$(p:G=) ; + } + } + OPTIONS on $(target) = $(options) ; +} + +actions compile +{ + g++ $(OPTIONS) -c -o $(<) $(>) +} + +rule link ( target : sources * : property-set * ) +{ + local options ; + if on in $(property-set) + { + options += -g ; + } + OPTIONS on $(target) = $(options) ; +} + +actions link +{ + g++ $(OPTIONS) -o $(<) $(>) +} + +rule archive ( target : sources * : property-set * ) +{ +} + +actions archive +{ + ar ur $(<) $(>) +} diff --git a/v2/test/generators-test/lex.jam b/v2/test/generators-test/lex.jam new file mode 100644 index 000000000..8721f0581 --- /dev/null +++ b/v2/test/generators-test/lex.jam @@ -0,0 +1,9 @@ + +rule lex ( target : source : properties * ) +{ +} + +actions lex +{ + flex -o$(<) $(>) +} \ No newline at end of file diff --git a/v2/test/generators-test/lib/Jamfile b/v2/test/generators-test/lib/Jamfile new file mode 100644 index 000000000..78fe21756 --- /dev/null +++ b/v2/test/generators-test/lib/Jamfile @@ -0,0 +1,2 @@ + +lib aux : c.cpp ; \ No newline at end of file diff --git a/v2/test/generators-test/lib/c.cpp b/v2/test/generators-test/lib/c.cpp new file mode 100644 index 000000000..2235513ec --- /dev/null +++ b/v2/test/generators-test/lib/c.cpp @@ -0,0 +1,2 @@ + +int bar() { return 0; } \ No newline at end of file diff --git a/v2/test/generators-test/nm.jam b/v2/test/generators-test/nm.jam new file mode 100644 index 000000000..a952ce5da --- /dev/null +++ b/v2/test/generators-test/nm.jam @@ -0,0 +1,25 @@ + +rule target-source ( targets * : sources * : properties * ) +{ +} + +actions target-source +{ + echo "NM target source consuming " $(>) + echo "int main() {}" > $(<) +} + +rule cpp-mark ( targets * : sources * : properties * ) +{ +} + +actions cpp-mark +{ + echo "CPP-MARK consuming " $(>) + touch $(<) +} + + + + + diff --git a/v2/test/generators-test/project-root.jam b/v2/test/generators-test/project-root.jam new file mode 100644 index 000000000..2a9196a69 --- /dev/null +++ b/v2/test/generators-test/project-root.jam @@ -0,0 +1,116 @@ + +import class : class new ; + +import gcc ; +import lex ; +import qt ; +import extra ; + +import type ; + +type.register EXE : : : main ; +type.register LIB : : : main ; +type.register CPP : cpp ; +type.register C : c ; +type.register OBJ : o ; +type.register LEX : l ; +type.register WHL : whl ; +type.register DLP : dlp ; +type.register WHL-LR0 : lr0 ; +type.register WD : wd ; +type.register H : h ; +type.register UI : ui ; +type.register UIC-H : h ; + +type.register X1 : x1 ; +type.register X2 : x2 ; +type.register X_PRO : x_pro ; + +import generators ; + +generators.register-composing gcc.link : LIB OBJ : EXE : gcc ; +generators.register-composing gcc.archive : OBJ : LIB : gcc ; +generators.register-standard gcc.compile : CPP : OBJ : gcc ; +generators.register-standard gcc.compile : C : OBJ : gcc ; +generators.register-standard lex.lex : LEX : C ; + +generators.register-standard extra.whale : WHL : CPP WHL-LR0 ; +generators.register-standard extra.dolphin : DLP : CPP ; +generators.register-standard extra.wd : WD : WHL DLP ; +generators.register-standard qt.uic : UI UIC-H : CPP ; +generators.register-standard qt.uic-h : UI : UIC-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 ; + +type.register CPP-MARKED : marked.cpp : CPP ; +type.register POSITIONS : positions ; +type.register NM.TARGET.CPP : target.cpp : CPP ; +type.register NM_EXE : : EXE : main ; + +# Should inherit generators from base class? +generators.register-composing gcc.link : OBJ : NM_EXE : gcc ; +generators.register-standard nm.target-source : CPP-MARKED : NM.TARGET.CPP ; +generators.register-standard nm.cpp-mark : CPP : CPP-MARKED POSITIONS ; + + +rule nm.target.cpp-obj-generator +{ + generator.__init__ nm.target-obj : NM.TARGET.CPP : OBJ ; + + rule requirements ( ) + { + return NM_EXE ; + } + + rule optional-properties ( ) + { + return NM_EXE ; + } + + # Consider: it it OK to ignore all other generated targets except for the first? + rule run ( project name ? : properties * : source : multiple ? ) + { + if [ $(source).type ] = CPP { + local converted = [ generators.construct-dbg $(project) : NM.TARGET.CPP : $(properties) : $(source) ] ; + local first = [ $(converted).at 1 ] ; + if ! [ $(first).empty ] + { + converted = [ $(first).get ] ; + local result = [ generators.construct-dbg $(project) : OBJ : $(properties) : $(converted) ] ; + return [ $(result).get-at 1 ] ; + } + else + { + return ; + } + } + else + { + return ; + } + } +} +class nm.target.cpp-obj-generator : generator ; + +generators.register [ new nm.target.cpp-obj-generator ] ; +#} + + + + + + + + + diff --git a/v2/test/generators-test/qt.jam b/v2/test/generators-test/qt.jam new file mode 100644 index 000000000..315c9bc94 --- /dev/null +++ b/v2/test/generators-test/qt.jam @@ -0,0 +1,19 @@ + +rule uic ( target : sources * : properties * ) +{ +} + +actions uic +{ + echo "//" $(>) > $(<) +} + +rule uic-h ( target : sources * : properties * ) +{ +} + +actions uic-h +{ + echo "//" $(>) > $(<) +} + diff --git a/v2/test/generators-test/x.l b/v2/test/generators-test/x.l new file mode 100644 index 000000000..16beb4d9b --- /dev/null +++ b/v2/test/generators-test/x.l @@ -0,0 +1,5 @@ +%option noyywrap + +%% + +%% \ No newline at end of file diff --git a/v2/test/generators-test/y.x_pro b/v2/test/generators-test/y.x_pro new file mode 100644 index 000000000..e69de29bb