2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-16 01:12:13 +00:00

Added future generators test -- not automated now.

[SVN r14926]
This commit is contained in:
Vladimir Prus
2002-08-16 14:25:22 +00:00
parent 835b82eeae
commit 00be3e6cc4
32 changed files with 606 additions and 0 deletions

View File

@@ -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 ;

View File

@@ -0,0 +1,10 @@
int foo();
int bar();
int main()
{
foo();
bar();
return 0;
}

View File

@@ -0,0 +1,2 @@
int foo() { return 0; }

View File

View File

View File

View File

@@ -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 $(<)
}

View File

@@ -0,0 +1,52 @@
import property ;
rule compile ( target : sources * : property-set * )
{
local options ;
for local p in $(property-set)
{
if $(p) = <optimization>on
{
options += -O2 ;
}
else if $(p) = <debug-symbols>on
{
options += -g ;
}
else if $(p:G) = <define>
{
options += -D$(p:G=) ;
}
}
OPTIONS on $(target) = $(options) ;
}
actions compile
{
g++ $(OPTIONS) -c -o $(<) $(>)
}
rule link ( target : sources * : property-set * )
{
local options ;
if <debug-symbols>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 $(<) $(>)
}

View File

@@ -0,0 +1,9 @@
rule lex ( target : source : properties * )
{
}
actions lex
{
flex -o$(<) $(>)
}

View File

@@ -0,0 +1,2 @@
lib aux : c.cpp ;

View File

@@ -0,0 +1,2 @@
int bar() { return 0; }

View File

@@ -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 $(<)
}

View File

@@ -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 : <toolset>gcc ;
generators.register-composing gcc.archive : OBJ : LIB : <toolset>gcc ;
generators.register-standard gcc.compile : CPP : OBJ : <toolset>gcc ;
generators.register-standard gcc.compile : C : OBJ : <toolset>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 : <toolset>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 <main-target-type>NM_EXE ;
}
rule optional-properties ( )
{
return <main-target-type>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 ] ;
#}

View File

@@ -0,0 +1,19 @@
rule uic ( target : sources * : properties * )
{
}
actions uic
{
echo "//" $(>) > $(<)
}
rule uic-h ( target : sources * : properties * )
{
}
actions uic-h
{
echo "//" $(>) > $(<)
}

5
test/generators-test/x.l Normal file
View File

@@ -0,0 +1,5 @@
%option noyywrap
%%
%%

View File

View File

@@ -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 ;

View File

@@ -0,0 +1,10 @@
int foo();
int bar();
int main()
{
foo();
bar();
return 0;
}

View File

@@ -0,0 +1,2 @@
int foo() { return 0; }

View File

View File

View File

View File

@@ -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 $(<)
}

View File

@@ -0,0 +1,52 @@
import property ;
rule compile ( target : sources * : property-set * )
{
local options ;
for local p in $(property-set)
{
if $(p) = <optimization>on
{
options += -O2 ;
}
else if $(p) = <debug-symbols>on
{
options += -g ;
}
else if $(p:G) = <define>
{
options += -D$(p:G=) ;
}
}
OPTIONS on $(target) = $(options) ;
}
actions compile
{
g++ $(OPTIONS) -c -o $(<) $(>)
}
rule link ( target : sources * : property-set * )
{
local options ;
if <debug-symbols>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 $(<) $(>)
}

View File

@@ -0,0 +1,9 @@
rule lex ( target : source : properties * )
{
}
actions lex
{
flex -o$(<) $(>)
}

View File

@@ -0,0 +1,2 @@
lib aux : c.cpp ;

View File

@@ -0,0 +1,2 @@
int bar() { return 0; }

View File

@@ -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 $(<)
}

View File

@@ -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 : <toolset>gcc ;
generators.register-composing gcc.archive : OBJ : LIB : <toolset>gcc ;
generators.register-standard gcc.compile : CPP : OBJ : <toolset>gcc ;
generators.register-standard gcc.compile : C : OBJ : <toolset>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 : <toolset>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 <main-target-type>NM_EXE ;
}
rule optional-properties ( )
{
return <main-target-type>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 ] ;
#}

View File

@@ -0,0 +1,19 @@
rule uic ( target : sources * : properties * )
{
}
actions uic
{
echo "//" $(>) > $(<)
}
rule uic-h ( target : sources * : properties * )
{
}
actions uic-h
{
echo "//" $(>) > $(<)
}

View File

@@ -0,0 +1,5 @@
%option noyywrap
%%
%%

View File