Subversion Repositories DevTools

Rev

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

Rev 267 Rev 271
Line 125... Line 125...
125
require 5.006_001;
125
require 5.006_001;
126
use strict;
126
use strict;
127
use warnings;
127
use warnings;
128
use Getopt::Long;
128
use Getopt::Long;
129
use Data::Dumper;
129
use Data::Dumper;
-
 
130
use JatsError;
130
use JatsEnv;
131
use JatsEnv;
131
use MakeEntry;
132
use MakeEntry;
132
use JatsLocateFiles;
133
use JatsLocateFiles;
133
use JatsDPackage;
134
use JatsDPackage;
-
 
135
use MakeIf;
-
 
136
 
134
 
137
 
135
 
138
 
136
our $ScmVersion             = "2.34";
139
our $ScmVersion             = "2.34";
137
our $ScmGlobal              = 0;
140
our $ScmGlobal              = 0;
138
our $ScmExpert              = 0;
141
our $ScmExpert              = 0;
Line 301... Line 304...
301
#   Some toolset options that affect the generation of the makefile
304
#   Some toolset options that affect the generation of the makefile
302
#
305
#
303
our $UseAbsObjects          = 0;                # Default is relative paths to objects
306
our $UseAbsObjects          = 0;                # Default is relative paths to objects
304
our $UseRelativeRoot        = 0;                # Default is absolute paths to build root
307
our $UseRelativeRoot        = 0;                # Default is absolute paths to build root
305
 
308
 
-
 
309
#
-
 
310
#   Arrays of hook functions
-
 
311
#
-
 
312
our %MF_RegisterSrcHooks;                       # Hook source file discovery
-
 
313
 
-
 
314
 
306
###############################################################################
315
###############################################################################
307
#
316
#
308
#   Packaging and Installation Information
317
#   Packaging and Installation Information
309
#   Held in a structure as its used in a few places
318
#   Held in a structure as its used in a few places
310
#   Items
319
#   Items
Line 570... Line 579...
570
    push( @ScmDepends, "$ScmMakelib" );         # parent
579
    push( @ScmDepends, "$ScmMakelib" );         # parent
571
 
580
 
572
    $file = Require( "$::GBE_CONFIG", "Rules", "Common rules " );
581
    $file = Require( "$::GBE_CONFIG", "Rules", "Common rules " );
573
    push( @ScmDepends, "$file" );
582
    push( @ScmDepends, "$file" );
574
 
583
 
575
    require "$::GBE_TOOLS/makeif.pl";           # plug-in interface
-
 
576
    push( @ScmDepends, "$::GBE_TOOLS/makeif.pl" );
-
 
577
 
-
 
578
#.. Platform (defines ScmToolset)
584
#.. Platform (defines ScmToolset)
579
#
585
#
580
    if ( defined( %::ScmBuildProducts ) &&      # interface/build.cfg
586
    if ( defined( %::ScmBuildProducts ) &&      # interface/build.cfg
581
            $::ScmBuildProducts{ $ScmPlatform } )
587
            $::ScmBuildProducts{ $ScmPlatform } )
582
    {
588
    {
Line 666... Line 672...
666
            require $file;
672
            require $file;
667
        }
673
        }
668
    }
674
    }
669
 
675
 
670
    #
676
    #
-
 
677
    #   Include local toolset extensions
-
 
678
    #   These are rooted in the build directory and are not to be confused with
-
 
679
    #   extensions that may be packaged
-
 
680
    #
-
 
681
    my $local_base_dir = "$ScmRoot/gbe/DIRECTIVES";
-
 
682
    if ( -d $local_base_dir )
-
 
683
    {
-
 
684
        foreach my $file  ( glob ("$local_base_dir/*.pm") )
-
 
685
        {
-
 
686
            push( @ScmDepends, "$file" );
-
 
687
            require $file;
-
 
688
        }
-
 
689
    }
-
 
690
 
-
 
691
    #
671
    #   All makefile.pl's will include a makefile.pl found in the build
692
    #   All makefile.pl's will include a makefile.pl found in the build
672
    #   root directory ( The same directory as build.pl ). This makefile.pl
693
    #   root directory ( The same directory as build.pl ). This makefile.pl
673
    #   is a little bit different - It should not "require "$ARGV[1]", nor
694
    #   is a little bit different - It should not "require "$ARGV[1]", nor
674
    #   should it use a Platform directive.
695
    #   should it use a Platform directive.
675
    #
696
    #
Line 737... Line 758...
737
    Debug2( "PlatformDefine(@_)" );
758
    Debug2( "PlatformDefine(@_)" );
738
 
759
 
739
    $script = Exists( "PLATFORM", $script,      # locate image
760
    $script = Exists( "PLATFORM", $script,      # locate image
740
                "PlatformDefines", @ScmPlatformDirs );
761
                "PlatformDefines", @ScmPlatformDirs );
741
 
762
 
-
 
763
    push( @DEFINES, "# PlatformDefines from: $script" );
742
    open( SCRIPT, $script ) || Error( "Opening $script" );
764
    open( SCRIPT, $script ) || Error( "Opening $script" );
743
    while (<SCRIPT>) {
765
    while (<SCRIPT>) {
744
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & nl
766
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & nl
745
        push( @DEFINES, $_ );
767
        push( @DEFINES, $_ );
746
    }
768
    }
Line 932... Line 954...
932
    my( $line );
954
    my( $line );
933
 
955
 
934
    Debug2( "ToolsetRules(@_)" );
956
    Debug2( "ToolsetRules(@_)" );
935
 
957
 
936
    $script = Exists( "$::GBE_CONFIG/TOOLSET", $script, "ToolsetRules" );
958
    $script = Exists( "$::GBE_CONFIG/TOOLSET", $script, "ToolsetRules" );
-
 
959
    push( @TOOLSETRULES, "# ToolsetRules from: $script" );
937
    open( SCRIPT, $script ) || Error( "Opening $script" );
960
    open( SCRIPT, $script ) || Error( "Opening $script" );
938
    while (<SCRIPT>) {
961
    while (<SCRIPT>) {
939
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & newline
962
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & newline
940
        push( @TOOLSETRULES, $_ );
963
        push( @TOOLSETRULES, $_ );
941
    }
964
    }
Line 1674... Line 1697...
1674
#                   False       - File is not a 'known' source file
1697
#                   False       - File is not a 'known' source file
1675
#
1698
#
1676
sub __AddSourceFile
1699
sub __AddSourceFile
1677
{
1700
{
1678
    my( $push, $path, $obj, $type ) = @_;
1701
    my( $push, $path, $obj, $type ) = @_;
1679
    my( $file, $ext, $srcfile, $is_obj, $ext_type, $result );
1702
    my( $filename, $ext, $srcfile, $is_obj, $ext_type, $result );
1680
 
1703
 
1681
    $file = StripExt($path);                    # file name
1704
    $filename = StripDir($path);                # file name
1682
 
1705
 
1683
    $ext  = StripFile($path);                   # extension
1706
    $ext  = StripFile($path);                   # extension
1684
    $ext = lc($ext)
1707
    $ext = lc($ext)
1685
        if ( $::ScmHost ne "Unix" );
1708
        if ( $::ScmHost ne "Unix" );
1686
 
1709
 
1687
    if (! ($srcfile = $SRCS{ $path })) {
1710
    if (! ($srcfile = $SRCS{$filename})) {
1688
        $srcfile = $path;                       # generated
1711
        $srcfile = $path;                       # generated
1689
    }
1712
    }
1690
 
1713
 
1691
    $obj  = StripDir( $file )                   # Base name of object file
1714
    $obj  = StripExt( $filename )               # Base name of object file
1692
        if ( ! defined($obj) || $obj eq "" );
1715
        if ( ! defined($obj) || $obj eq "" );
1693
 
1716
 
1694
    $type = ""                                  # optional type
1717
    $type = ""                                  # optional type
1695
        if ( ! defined( $type ) );
1718
        if ( ! defined( $type ) );
1696
 
1719
 
Line 1759... Line 1782...
1759
            use strict 'refs';
1782
            use strict 'refs';
1760
        }
1783
        }
1761
    }
1784
    }
1762
 
1785
 
1763
    #
1786
    #
-
 
1787
    #   See if there is a hook function for this type of source file
-
 
1788
    #   Invoke user function to perform additional processing on the file
-
 
1789
    #
-
 
1790
    if ( %MF_RegisterSrcHooks )
-
 
1791
    {
-
 
1792
        my @listeners;
-
 
1793
        push @listeners, @{$MF_RegisterSrcHooks{$ext}} if ( exists $MF_RegisterSrcHooks{$ext} );
-
 
1794
        push @listeners, @{$MF_RegisterSrcHooks{'*'}}  if ( exists $MF_RegisterSrcHooks{'*'} );
-
 
1795
        while ( @listeners )
-
 
1796
        {
-
 
1797
            Debug( "RegisterSrcHook: Invoke SrcHook function" );
-
 
1798
            my ($fname, @args) = @{shift @listeners};
-
 
1799
            &$fname ( $srcfile ,$filename, $obj, $ext ,@args );
-
 
1800
        }
-
 
1801
    }
-
 
1802
 
-
 
1803
    #
1764
    #   Object files are saved in
1804
    #   Object files are saved in
1765
    #       OBJSOURCE   - Generate a recipe to create the object
1805
    #       OBJSOURCE   - Generate a recipe to create the object
1766
    #       OBJS        - A list of ALL non-shared object files
1806
    #       OBJS        - A list of ALL non-shared object files
1767
    #
1807
    #
1768
    if ( $is_obj && $::o )
1808
    if ( $is_obj && $::o )
Line 3566... Line 3606...
3566
    my( $line );
3606
    my( $line );
3567
 
3607
 
3568
    Debug2( "Defines($path, $script)" );
3608
    Debug2( "Defines($path, $script)" );
3569
 
3609
 
3570
    $script = Exists( $path, $script, "Defines" );
3610
    $script = Exists( $path, $script, "Defines" );
-
 
3611
    push( @DEFINES, "# Defines from: $script" );
3571
    open( SCRIPT, $script ) || Error( "Opening $script" );
3612
    open( SCRIPT, $script ) || Error( "Opening $script" );
3572
    while (<SCRIPT>) {
3613
    while (<SCRIPT>) {
3573
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & nl
3614
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & nl
3574
        push( @DEFINES, $_ );
3615
        push( @DEFINES, $_ );
3575
    }
3616
    }
3576
    push( @ScmDepends, "$script" );             # makefile dependencies
3617
    push( @ScmDepends, "$script" );             # makefile dependencies
3577
    close( SCRIPT );
3618
    close( SCRIPT );
3578
}
3619
}
-
 
3620
#-------------------------------------------------------------------------------
-
 
3621
# Function        : Rule
3579
 
3622
#
-
 
3623
# Description     : Add a Rule and Recipe to the generated makefile
-
 
3624
#                   This is not encouraged as it has been misused to create
-
 
3625
#                   unreadable and unmaintainable makefiles.
-
 
3626
#
-
 
3627
#                   Rules will be added to the makefile after the rules and
-
 
3628
#                   recipes created by JATS directives
-
 
3629
#
-
 
3630
# Inputs          : $platform               - Platform predicate
-
 
3631
#                   @rule                   - Array of rules to add
-
 
3632
#
-
 
3633
# Returns         : 
3580
 
3634
#
3581
sub Rule
3635
sub Rule
3582
{
3636
{
3583
    my( $platforms, @rule ) = @_;
3637
    my( $platforms, @rule ) = @_;
3584
 
3638
 
3585
    return if ( ! ActivePlatform($platforms) );
3639
    return if ( ! ActivePlatform($platforms) );
3586
 
3640
 
3587
    push( @RULES, @rule );
3641
    push( @RULES, @rule );
3588
    Message("Rule directive used. Consider replacing with GenerateFiles");
3642
    Message("Rule directive used. Consider replacing with GenerateFiles");
3589
}
3643
}
3590
 
3644
 
-
 
3645
#-------------------------------------------------------------------------------
-
 
3646
# Function        : Rules
3591
 
3647
#
-
 
3648
# Description     : Add a file of Rules and Recipes to the generated makefile
-
 
3649
#                   Used internally ONLY as there is no platform predicate
-
 
3650
#                   Similar to 'Rule()'
-
 
3651
#
-
 
3652
# Inputs          : $path                   - path to script
-
 
3653
#                   $script                 - File fo Rules
-
 
3654
#
-
 
3655
# Returns         : 
-
 
3656
#
3592
sub Rules
3657
sub Rules
3593
{
3658
{
3594
    my( $path, $script ) = @_;
3659
    my( $path, $script ) = @_;
3595
    my( $line );
3660
    my( $line );
3596
 
3661
 
3597
    $script = Exists( $path, $script, "Rules" );
3662
    $script = Exists( $path, $script, "Rules" );
-
 
3663
    push( @RULES, "# Rules from: $script" );
3598
    open( SCRIPT, $script ) || Error( "Opening $script" );
3664
    open( SCRIPT, $script ) || Error( "Opening $script" );
3599
    while (<SCRIPT>) {
3665
    while (<SCRIPT>) {
3600
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & nl
3666
        $_ =~ s/\s*(\n|$)//;                    # kill trailing whitespace & nl
3601
        push( @RULES, $_ );
3667
        push( @RULES, $_ );
3602
    }
3668
    }
3603
    push( @ScmDepends, "$script" );             # makefile dependencies
3669
    push( @ScmDepends, "$script" );             # makefile dependencies
3604
    close( SCRIPT );
3670
    close( SCRIPT );
3605
}
3671
}
3606
 
3672
 
-
 
3673
#-------------------------------------------------------------------------------
-
 
3674
# Function        : AddRule
-
 
3675
#
-
 
3676
# Description     : Inernal function
-
 
3677
#                   Add a line to the Rules area
-
 
3678
#
-
 
3679
# Inputs          : @elements                   - Array of lines to add
-
 
3680
#
-
 
3681
# Returns         : Nothing
-
 
3682
#
-
 
3683
sub AddRule
-
 
3684
{
-
 
3685
    push( @RULES, @_ );
-
 
3686
}
3607
 
3687
 
-
 
3688
#-------------------------------------------------------------------------------
-
 
3689
# Function        : Src
-
 
3690
#
-
 
3691
# Description     : This directive is used to identify files to JATS
-
 
3692
#                   Once a file has been identified as a 'Source' file, then it
-
 
3693
#                   can be used by name, without the need to locate the file again.
-
 
3694
#                   This implies that filenames must be unique.
-
 
3695
#                   The directories cannot be used to make files of the same name
-
 
3696
#                   unqiue - this is not the JATS way
-
 
3697
#
-
 
3698
#                   Source files will be classified as one of:
-
 
3699
#                       c, c++, header, assembler or other
-
 
3700
#
-
 
3701
#
-
 
3702
# Inputs          : $platform               - Active Platform Predicate
-
 
3703
#                   @elements               - A list of files and options
-
 
3704
#
-
 
3705
#                   Valid options are:
-
 
3706
#                       --c                 - Specifies the type of file
-
 
3707
#                       --cpp
-
 
3708
#                       --h, --headers
-
 
3709
#                       --asm
-
 
3710
#                       --FromPackage       - Search packages for the file
-
 
3711
#                       --List=xxx          - Append file to a named list
-
 
3712
#                       --Depends=xxx       - Manually name a dependency
-
 
3713
#
-
 
3714
#                   Options are processed before file elements
-
 
3715
#                   Thus options apply to all files in the list
-
 
3716
#
-
 
3717
# Returns         : Nothing
-
 
3718
#
3608
sub Src
3719
sub Src
3609
{
3720
{
3610
    my( $platforms, @elements ) = @_;
3721
    my( $platforms, @elements ) = @_;
3611
    my( $type, @args, $source, $basename, $from_package, @lists );
3722
    my( $type, @args, $source, $basename, $from_package, @lists );
3612
    my( @depends, @srcs );
3723
    my( @depends, @srcs );
Line 7495... Line 7606...
7495
#                       --Defined=SomeValue
7606
#                       --Defined=SomeValue
7496
#
7607
#
7497
#                   Each can be prefxied with a '!' to negate the test
7608
#                   Each can be prefxied with a '!' to negate the test
7498
#
7609
#
7499
#                   Valid options are:
7610
#                   Valid options are:
7500
#                       --Target        - indicates that the plaform is a 'target'
7611
#                       --Target        - indicates that the platform is a 'target'
7501
#
7612
#
7502
# Returns         : TRUE if the platform spec is satisfied
7613
# Returns         : TRUE if the platform spec is satisfied
7503
#
7614
#
7504
sub ActivePlatform
7615
sub ActivePlatform
7505
{
7616
{
Line 7683... Line 7794...
7683
   #
7794
   #
7684
   push @MF_Generators, \@_;
7795
   push @MF_Generators, \@_;
7685
}
7796
}
7686
 
7797
 
7687
#-------------------------------------------------------------------------------
7798
#-------------------------------------------------------------------------------
-
 
7799
# Function        : RegisterSrcHook
-
 
7800
#
-
 
7801
# Description     : Register a function to be called when a source file is
-
 
7802
#                   declared
-
 
7803
#
-
 
7804
# Inputs          : $ext        - Extension of interest
-
 
7805
#                                 '*' will be used by all
-
 
7806
#                   $fname      - Name of the function
-
 
7807
#                   $args       - Function Arguments
-
 
7808
#
-
 
7809
# Returns         : Nothing
-
 
7810
#
-
 
7811
sub RegisterSrcHook
-
 
7812
{
-
 
7813
    my $ext = shift;
-
 
7814
    my ($fref) = @_;
-
 
7815
    my $rtype = ref($fref) || 'not a reference';
-
 
7816
 
-
 
7817
    Error ("RegisterSrcHook called incorrectly",
-
 
7818
           "Second argument MUST be a code reference",
-
 
7819
           "It is a $rtype"
-
 
7820
           ) unless ( $rtype eq 'CODE' );
-
 
7821
 
-
 
7822
    #
-
 
7823
    #    Save the arguments by reference in an array
-
 
7824
    #    The array will be processed later
-
 
7825
    #
-
 
7826
    push @{$MF_RegisterSrcHooks{$ext}}, \@_;
-
 
7827
}
-
 
7828
 
-
 
7829
 
-
 
7830
#-------------------------------------------------------------------------------
7688
# Function        : MakefileHeader
7831
# Function        : MakefileHeader
7689
#
7832
#
7690
# Description:    : Generate a "standard" makefile header.
7833
# Description:    : Generate a "standard" makefile header.
7691
#
7834
#
7692
#..
7835
#..
Line 7753... Line 7896...
7753
                 "Dir: $::Cwd");
7896
                 "Dir: $::Cwd");
7754
        return;
7897
        return;
7755
    }
7898
    }
7756
    $MakefileGenerate_once = 1;
7899
    $MakefileGenerate_once = 1;
7757
 
7900
 
7758
 
-
 
7759
    #
7901
    #
7760
    #   Invoke all registered Makefile Generator functions
7902
    #   Invoke all registered Makefile Generator functions
7761
    #   These allow clever directives to collect information to be
7903
    #   These allow clever directives to collect information to be
7762
    #   processed before the makefiles are created
7904
    #   processed before the makefiles are created
7763
    #
7905
    #
Line 8217... Line 8359...
8217
        MakePrint( "#---- (${i})\n\n" );
8359
        MakePrint( "#---- (${i})\n\n" );
8218
        if ( $ScmToolsetProgDependancies )
8360
        if ( $ScmToolsetProgDependancies )
8219
        {
8361
        {
8220
            #
8362
            #
8221
            #   Original style Prog Interface
8363
            #   Original style Prog Interface
8222
            #   Write some depnedency information here and some in the toolset
8364
            #   Write some dependency information here and some in the toolset
-
 
8365
            #   Problems:
-
 
8366
            #       1) Errors in library dependency generation will be
-
 
8367
            #          reported after all the object files have been created
-
 
8368
            #          Thus the error message and the make-stop are seperated
-
 
8369
            #          by many,many lines of output. This makes it difficult
-
 
8370
            #          to see the error.
-
 
8371
            #
-
 
8372
            #       2) Lack of Flexability
8223
            #
8373
            #
8224
            MakeEntry( "\$(BINDIR)/$i$::exe: ", "", "\\\n\t\t", ".$::o ", @objects );
8374
            MakeEntry( "\$(BINDIR)/$i$::exe: ", "", "\\\n\t\t", ".$::o ", @objects );
8225
        }
8375
        }
8226
        else
8376
        else
8227
        {
8377
        {