Subversion Repositories DevTools

Rev

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

Rev 4344 Rev 4778
Line 27... Line 27...
27
#                 endef
27
#                 endef
28
#
28
#
29
#                The --Raw option creates
29
#                The --Raw option creates
30
#                   Recipe
30
#                   Recipe
31
#
31
#
-
 
32
#                The --Raw with --Phony option creates
-
 
33
#                   .PHONY <targets>
-
 
34
#                   <targets>:
-
 
35
#                       Recipe
-
 
36
#
-
 
37
#
32
#
38
#
33
#......................................................................#
39
#......................................................................#
34
 
40
 
35
use 5.006_001;
41
use 5.006_001;
36
use strict;
42
use strict;
Line 84... Line 90...
84
    $self->{RAW}            = 0;
90
    $self->{RAW}            = 0;
85
    $self->{FH}             = $handle;
91
    $self->{FH}             = $handle;
86
    $self->{FH_inmemory}    = 0;
92
    $self->{FH_inmemory}    = 0;
87
    $self->{RECIPE_PREFIX}  = '';
93
    $self->{RECIPE_PREFIX}  = '';
88
    $self->{RECIPE_COMMENT} = '';
94
    $self->{RECIPE_COMMENT} = '';
-
 
95
    $self->{STACK}          = [];
89
 
96
 
90
    push @{$self->{NAME}}, split(/,/,$name) if ( $name );
97
    push @{$self->{NAME}}, split(/,/,$name) if ( $name );
91
 
98
 
92
    bless ($self, __PACKAGE__);
99
    bless ($self, __PACKAGE__);
93
 
100
 
Line 156... Line 163...
156
}
163
}
157
 
164
 
158
#-------------------------------------------------------------------------------
165
#-------------------------------------------------------------------------------
159
# Function        : AddName
166
# Function        : AddName
160
#
167
#
161
# Description     : Add a name to the entry
168
# Description     : Add a target name to the entry
162
#
169
#
163
# Inputs          : An array of names to add
170
# Inputs          : An array of names to add
164
#
171
#
165
# Returns         :
172
# Returns         :
166
#
173
#
Line 343... Line 350...
343
# Description     : Add recipe lines that will be processed within a 'shell'
350
# Description     : Add recipe lines that will be processed within a 'shell'
344
#
351
#
345
# Inputs          : One or more recipe lines
352
# Inputs          : One or more recipe lines
346
#
353
#
347
#                   An array will be treated as a recipe with implicit line
354
#                   An array will be treated as a recipe with implicit line
348
#                   breakes for formatting purposes.
355
#                   breaks for formatting purposes.
349
#
356
#
350
# Returns         :
357
# Returns         :
351
#
358
#
352
sub AddShellRecipe
359
sub AddShellRecipe
353
{
360
{
354
    my $self = shift;
361
    my $self = shift;
355
    push @{$self->{SHELL}}, @_
362
    push @{$self->{SHELL}}, @_
356
}
363
}
357
 
364
 
-
 
365
#-------------------------------------------------------------------------------
-
 
366
# Function        : NewSection 
-
 
367
#
-
 
368
# Description     : Create a new section within the current recipe
-
 
369
#                   Only used within a standard recipe (not raw or defined)
-
 
370
#                   Used to create multiple sections in cases with multiple shell
-
 
371
#                   and recipe sections.
-
 
372
#
-
 
373
#                   Save existing entries and start again
-
 
374
#
-
 
375
# Inputs          : None 
-
 
376
#
-
 
377
# Returns         : 
-
 
378
#
-
 
379
sub NewSection
-
 
380
{
-
 
381
    my $self = shift;
-
 
382
    my %data;
-
 
383
 
-
 
384
    $data{RECIPE}           = $self->{RECIPE};
-
 
385
    $data{SHELL}            = $self->{SHELL};
-
 
386
    $data{RECIPE_PREFIX}    = $self->{RECIPE_PREFIX};
-
 
387
    $data{RECIPE_COMMENT}   = $self->{RECIPE_COMMENT};
-
 
388
 
-
 
389
    push @{$self->{STACK}}, \%data;
-
 
390
 
-
 
391
    $self->{RECIPE}         = []; 
-
 
392
    $self->{SHELL}          = [];
-
 
393
    $self->{RECIPE_PREFIX}  = '';
-
 
394
    $self->{RECIPE_COMMENT} = '';
-
 
395
}
358
 
396
 
359
#-------------------------------------------------------------------------------
397
#-------------------------------------------------------------------------------
360
# Function        : Print
398
# Function        : Print
361
#
399
#
362
# Description     : Print the entry
400
# Description     : Print the entry
Line 417... Line 455...
417
        }
455
        }
418
    }
456
    }
419
 
457
 
420
    if ( $self->{RAW}  )
458
    if ( $self->{RAW}  )
421
    {
459
    {
-
 
460
        if ( $self->{PHONY} )
-
 
461
        {
-
 
462
            my $tstring = $self->{NAME}[0];
-
 
463
            print($tstring . ":\n");
-
 
464
        }
422
        my $tstring = join ("\n", @{$self->{RECIPE}});
465
        my $tstring = join ("\n", @{$self->{RECIPE}});
423
        print $tstring;
466
        print $tstring;
424
    }
467
    }
425
    elsif ( $self->{DEFINE}  )
468
    elsif ( $self->{DEFINE}  )
426
    {
469
    {
Line 450... Line 493...
450
        $join = $nlength + length ($tstring) < $llength ? ' ' : " \\\n\t";
493
        $join = $nlength + length ($tstring) < $llength ? ' ' : " \\\n\t";
451
        $tstring =~ s~$;~$join~g;
494
        $tstring =~ s~$;~$join~g;
452
        print $join . $tstring;
495
        print $join . $tstring;
453
 
496
 
454
        #
497
        #
455
        #   Print the Recipe runtime comment
498
        #   Push the current section onto the stack
-
 
499
        #   This will simplify processing of all sections
456
        #
500
        #
457
        if ( $self->{RECIPE_COMMENT} )
501
        $self->NewSection();
-
 
502
        
-
 
503
        foreach my $recipeEntry (@{$self->{STACK}})
458
        {
504
        {
459
            print "\n\t\@echo \"$self->{RECIPE_COMMENT}\"";
505
            my $comment = $recipeEntry->{RECIPE_COMMENT};
-
 
506
            my $prefix =  $recipeEntry->{RECIPE_PREFIX};
-
 
507
            my $recipe =  $recipeEntry->{RECIPE};
-
 
508
            my $shell =   $recipeEntry->{SHELL};
-
 
509
            #
-
 
510
            #   Print the Recipe runtime comment
-
 
511
            #
-
 
512
            if ( $comment )
-
 
513
            {
-
 
514
                print "\n\t\@echo \"$comment\"";
460
        }
515
            }
461
 
516
 
462
        #
517
            #
463
        #   Print the recipe
518
            #   Print the recipe
464
        #
519
            #
465
        print_list ( '', '', $self->{RECIPE}, '');
520
            print_list ( '', '', $recipe, '');
-
 
521
 
-
 
522
            #
-
 
523
            #   Print the recipe as a shell command
-
 
524
            #   Bracket the recipes with ( .. ) and place semi colons between lines
-
 
525
            #   Use the current recipe prefix
-
 
526
            #
-
 
527
            print_list ( $prefix . '(', ';\\', $shell, ')');
-
 
528
        }
466
 
529
 
467
        #
-
 
468
        #   Print the recipe as a shell command
-
 
469
        #   Bracket the recipes with ( .. ) and place semi colons between lines
-
 
470
        #   Use the current recipe prefix
-
 
471
        #
-
 
472
        print_list ( $self->{RECIPE_PREFIX} . '(', ';\\', $self->{SHELL}, ')');
-
 
473
    }
530
    }
474
 
531
 
475
    print "\n\n";
532
    print "\n\n";
476
 
533
 
477
    #
534
    #
Line 537... Line 594...
537
            }
594
            }
538
        }
595
        }
539
 
596
 
540
        if ( $suffix )
597
        if ( $suffix )
541
        {
598
        {
-
 
599
            $leadin = chop($leadin) if ($prefix);
542
            print( "\n" . $leadin . $suffix );
600
            print( "\n" . $leadin . $suffix );
543
        }
601
        }
544
    }
602
    }
545
}
603
}
546
 
604