File: recursive.jam

package info (click to toggle)
boost-build 2.0-m11-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,624 kB
  • ctags: 2,387
  • sloc: ansic: 12,978; python: 5,209; xml: 4,782; cpp: 555; yacc: 456; sh: 237; makefile: 71
file content (118 lines) | stat: -rw-r--r-- 3,792 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# (C) Copyright David Abrahams 2001. 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.

##############################################################
# Rules and actions that test Jam by invoking it recursively #
#                                                            #
# This is necessary for testing anything that requires Jam   #
# to execute build actions whose results must be checked,    #
# and anything which exits Jam with a failure code (e.g. a   #
# failed assertion).                                         #
##############################################################

# Creates a fake target, always built, which succeeds in building if Invoking a
# Jamfile containing the given string succeeds. If optional-expected-output is
# supplied, creates another fake target which succeeds in building if
# optional-expected-output is in the Jam output.
#
# RETURNS: the target name of the Jam command.
rule Jam ( command : expected-output ? )
{
    local jam-cmd = "$(command:G=jam_command)" ;
    
    NOTFILE "$(jam-cmd)" ;
    ALWAYS "$(jam-cmd)" ;
    DEPENDS all : "$(jam-cmd)" ;

    if ($NT)
    {
        redirect on $(jam-cmd) = "nul" ;
    }
    else if $(UNIX)
    {
        redirect on $(jam-cmd) = "/dev/null" ;
    }

    if $(VERBOSE)
    {
        redirect on $(jam-cmd) = ;
    }

    invoke-Jam "$(jam-cmd)" ;
    
    if $(expected-output)
    {
        redirect on $(jam-cmd) = "scratch-output.txt" ;
        local output-target = "$(expected-output:G=$(command))" ;
        NOTFILE "$(output-target)" ;
        ALWAYS "$(output-target)" ;
        DEPENDS all : "$(output-target)" ;
        Expect-in-output "$(output-target)" ;
        
        if $(VERBOSE)
        {
            if $(NT) { VERBOSE on $(output-target) = "type " ; }
            else { VERBOSE on $(output-target) = "cat " ; }
        }
    }
    return $(jam-cmd) ;
}

# Just like the "Jam" rule, above, but only succeeds if the Jam command /fails/.
rule Jam-fail ( command : expected-output ? )
{
    local target = [ Jam $(command) : $(expected-output) ] ;
    FAIL_EXPECTED $(target) ;
    return $(target) ;
}

# The temporary jamfile we write is called "temp.jam". If the user has set
# BOOST_BUILD_ROOT, it will be built there.
gBOOST_TEST_JAMFILE = temp.jam ;
LOCATE on gBOOST_TEST_JAMFILE ?= $(BOOST_BUILD_ROOT) ;

# Runs Jam on a temporary Jamfile which contains the string in $(command:G=)
# and redirects the results into a file whose name is given by $(redirect) on
# command
rule invoke-Jam ( command )
{
    PREFIX on $(command) = "actions unbuilt { } unbuilt all ;" ;
    if $(NT)
    {
        REMOVE on $(command) = $(SystemRoot)\System32\find ;
    }
    REMOVE on $(command) ?= rm ;
}
actions invoke-Jam
{
    echo $(PREFIX) $(<:G=) > $(gBOOST_TEST_JAMFILE)
    jam -sBOOST_ROOT=../../.. -sJAMFILE=$(gBOOST_TEST_JAMFILE)  $(JAMARGS) >$(redirect)
}
#     $(REMOVE) $(gBOOST_TEST_JAMFILE)


# These actions expect to find the ungristed part of $(<) in scratch-output.txt
# and return a nonzero exit code otherwise
if $(NT)
{
    # Explicitly get the NT find command in case someone has another find in their path.
    actions quietly Expect-in-output
    {
        $(VERBOSE)scratch-output.txt ;
        $(SystemRoot)\System32\find /C "$(<:G=)" scratch-output.txt >nul
    }
}
else
{
    # Not really the right actions for Unix; the argument will be interpreted as
    # a regular expression. Is there a simpler find?
    actions quietly Expect-in-output
    {
        $(VERBOSE)scratch-output.txt;
        grep "$(<:G=)" scratch-output.txt
    }
}