Subversion Repositories DevTools

Rev

Rev 255 | Rev 4344 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 255 Rev 271
Line 40... Line 40...
40
#-------------------------------------------------------------------------------
40
#-------------------------------------------------------------------------------
41
# Function        : New
41
# Function        : New
42
#
42
#
43
# Description     : Create a new empty entry
43
# Description     : Create a new empty entry
44
#
44
#
45
# Inputs          : FILEHANDLE          - eg: *MAKEFILE
45
# Inputs          : handle              - FILEHANDLE or variable ref
-
 
46
#                                         eg: *MAKEFILE     - print to handle
-
 
47
#                                              \$var        - print to variable
-
 
48
#
46
#                   Name                - Primary target name
49
#                   name                - Primary target name
47
#                   Options             - Preload the fields
50
#                   options             - Preload the fields
48
#                           --Target=name,name,name
51
#                           --Target=name,name,name
49
#                           --Comment=text
52
#                           --Comment=text
50
#                           --Prereq=name,name,name
53
#                           --Prereq=name,name,name
51
#                           --Recipe=text
54
#                           --Recipe=text
52
#                           --Phony
55
#                           --Phony
Line 65... Line 68...
65
    $self->{PRINTED}        = 0;
68
    $self->{PRINTED}        = 0;
66
    $self->{COMMENT}        = [];
69
    $self->{COMMENT}        = [];
67
    $self->{DEFN}           = {};
70
    $self->{DEFN}           = {};
68
    $self->{PHONY}          = 0;
71
    $self->{PHONY}          = 0;
69
    $self->{FH}             = $handle;
72
    $self->{FH}             = $handle;
-
 
73
    $self->{FH_inmemory}    = 0;
70
    $self->{RECIPE_PREFIX}  = '';
74
    $self->{RECIPE_PREFIX}  = '';
71
    $self->{RECIPE_COMMENT} = '';
75
    $self->{RECIPE_COMMENT} = '';
72
 
76
 
73
    push @{$self->{NAME}}, split(/,/,$name) if ( $name );
77
    push @{$self->{NAME}}, split(/,/,$name) if ( $name );
74
 
78
 
Line 105... Line 109...
105
            $self->AddDependancy( $_ );
109
            $self->AddDependancy( $_ );
106
 
110
 
107
        }
111
        }
108
    }
112
    }
109
 
113
 
-
 
114
    #
-
 
115
    #   Set up the printer handle
-
 
116
    #   May be
-
 
117
    #       Empty           - use stderr
-
 
118
    #       ref to a scalar - use in memory file
-
 
119
    #       typeglob        - normal handle
-
 
120
    #
-
 
121
    if ( ref $handle eq 'SCALAR' )
-
 
122
    {
-
 
123
        $$handle = '' if ( ! defined $$handle );
-
 
124
        open(MEMORY,'>>', $handle) || Error ("Cannot open in-memory file");
110
    $self->Print() if ( $print );
125
        $self->{FH_inmemory} = $handle;
-
 
126
        $self->{FH} = \*MEMORY;
-
 
127
 
-
 
128
    } elsif ( ! $handle ) {
-
 
129
       $self->{FH} = \*STDERR;
-
 
130
    }
111
 
131
 
-
 
132
    #
-
 
133
    #   Print simple entry if required
-
 
134
    #
-
 
135
    $self->Print() if ( $print );
112
    return $self;
136
    return $self;
113
}
137
}
114
 
138
 
115
#-------------------------------------------------------------------------------
139
#-------------------------------------------------------------------------------
116
# Function        : AddName
140
# Function        : AddName
Line 296... Line 320...
296
    #
320
    #
297
    #   Set the default print stream to the desired stream
321
    #   Set the default print stream to the desired stream
298
    #   This greatly simplifies the use of print
322
    #   This greatly simplifies the use of print
299
    #
323
    #
300
    my $fh = $self->{FH};
324
    my $fh = $self->{FH};
301
        $fh = \*STDERR unless $fh;
-
 
302
    my $old_fh = select($fh);
325
    my $old_fh = select($fh);
303
#    my $old_fh = $fh;
-
 
-
 
326
 
304
 
327
 
305
    #
328
    #
306
    #   A nice comment header
329
    #   A nice comment header
307
    #
330
    #
308
    if ( @{$self->{COMMENT}} )
331
    if ( @{$self->{COMMENT}} )
Line 470... Line 493...
470
    {
493
    {
471
        $self->{PRINT} = 1;
494
        $self->{PRINT} = 1;
472
        Error ("Destroying MakeEntry before printing.",
495
        Error ("Destroying MakeEntry before printing.",
473
               "Name: @{$self->{NAME}}");
496
               "Name: @{$self->{NAME}}");
474
    }
497
    }
-
 
498
 
-
 
499
    #
-
 
500
    #   If using an in-memory file close the handle
-
 
501
    #
-
 
502
    close $self->{FH} if ( $self->{FH_inmemory} );
475
}
503
}
476
 
504
 
477
1;
505
1;
478
 
506
 
479
 
507