Subversion Repositories DevTools

Rev

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

Rev 237 Rev 241
Line 527... Line 527...
527
    'File' => { 'PBase' => '$(PKGDIR)'       ,'IBase' => '$(LOCALDIR)'       , 'Dir' => '' },
527
    'File' => { 'PBase' => '$(PKGDIR)'       ,'IBase' => '$(LOCALDIR)'       , 'Dir' => '' },
528
    'Hdr'  => { 'PBase' => '$(INCDIR_PKG)'   ,'IBase' => '$(INCDIR_LOCAL)'   , 'Dir' => ''},
528
    'Hdr'  => { 'PBase' => '$(INCDIR_PKG)'   ,'IBase' => '$(INCDIR_LOCAL)'   , 'Dir' => ''},
529
    'Lib'  => { 'PBase' => '$(LIBDIR_PKG)'   ,'IBase' => '$(LIBDIR_LOCAL)'   , 'Dir' => '/$(GBE_PLATFORM)'},
529
    'Lib'  => { 'PBase' => '$(LIBDIR_PKG)'   ,'IBase' => '$(LIBDIR_LOCAL)'   , 'Dir' => '/$(GBE_PLATFORM)'},
530
    'Prog' => { 'PBase' => '$(BINDIR_PKG)'   ,'IBase' => '$(BINDIR_LOCAL)'   , 'Dir' => '/$(GBE_PLATFORM)$(GBE_TYPE)'},
530
    'Prog' => { 'PBase' => '$(BINDIR_PKG)'   ,'IBase' => '$(BINDIR_LOCAL)'   , 'Dir' => '/$(GBE_PLATFORM)$(GBE_TYPE)'},
531
    'Jar'  => { 'PBase' => '$(CLSDIR_PKG)'   ,'IBase' => '$(CLSDIR_LOCAL)'   , 'Dir' => ''},
531
    'Jar'  => { 'PBase' => '$(CLSDIR_PKG)'   ,'IBase' => '$(CLSDIR_LOCAL)'   , 'Dir' => ''},
-
 
532
    'Tool' => { 'PBase' => '$(PKGDIR)'       ,'IBase' => '$(LOCALDIR)'       , 'Dir' => '/tools/bin/$(GBE_HOSTMACH)'},
532
    );
533
    );
533
 
534
 
534
MakeLib2Init();                                 # Runtime initialisation
535
MakeLib2Init();                                 # Runtime initialisation
535
 
536
 
536
sub MakeLib2Init
537
sub MakeLib2Init
Line 5067... Line 5068...
5067
            _PackageFromProject( $proj, $basedir, 'Hdr', undef, $1 );
5068
            _PackageFromProject( $proj, $basedir, 'Hdr', undef, $1 );
5068
 
5069
 
5069
        } elsif ( m/^--PackageFile=(.*)/ ) {
5070
        } elsif ( m/^--PackageFile=(.*)/ ) {
5070
            _PackageFromProject( $proj, $basedir, 'File', undef, $1 );
5071
            _PackageFromProject( $proj, $basedir, 'File', undef, $1 );
5071
 
5072
 
-
 
5073
        } elsif ( m/^--PackageTool(Prod)*=(.*)/ ) {
-
 
5074
            _PackageFromProject( $proj, $basedir, 'Tool', 'P', $2 );
-
 
5075
 
-
 
5076
        } elsif ( m/^--PackageToolDebug=(.*)/ ) {
-
 
5077
            _PackageFromProject( $proj, $basedir, 'Tool', 'D', $1 );
-
 
5078
 
5072
        } elsif ( m/^--Package/ ) {
5079
        } elsif ( m/^--Package/ ) {
5073
            Error("MakeProject. Unknown Package option: $_");
5080
            Error("MakeProject. Unknown Package option: $_");
5074
 
5081
 
5075
        } else {
5082
        } else {
5076
            push @tool_options, $_;
5083
            push @tool_options, $_;
Line 5102... Line 5109...
5102
#                   $base       - Base directory of files
5109
#                   $base       - Base directory of files
5103
#                   $etype      - Type of Package (Progs, Libs, ... )
5110
#                   $etype      - Type of Package (Progs, Libs, ... )
5104
#                   $type       - Debug or Production or both
5111
#                   $type       - Debug or Production or both
5105
#                   $items      - Item to add. It may be comma seperated
5112
#                   $items      - Item to add. It may be comma seperated
5106
#
5113
#
5107
my %PackageToData = ( 'Hdr'  => \%PACKAGE_HDRS,
5114
my %PackageToData = ( 'Hdr'   => \%PACKAGE_HDRS,
5108
                      'Lib'  => \%PACKAGE_LIBS,
5115
                      'Lib'   => \%PACKAGE_LIBS,
5109
                      'Prog'  => \%PACKAGE_PROGS,
5116
                      'Prog'  => \%PACKAGE_PROGS,
5110
                      'File'  => \%PACKAGE_FILES,
5117
                      'File'  => \%PACKAGE_FILES,
-
 
5118
                      'Tool'  => \%PACKAGE_FILES,
5111
                    );
5119
                    );
5112
 
5120
 
5113
sub _PackageFromProject
5121
sub _PackageFromProject
5114
{
5122
{
5115
    my( $proj, $base, $etype, $type, $items ) = @_;
5123
    my( $proj, $base, $etype, $type, $items ) = @_;
Line 5477... Line 5485...
5477
 
5485
 
5478
    } elsif (/^--Dir=(.*)/) {                   # prefix with target specific subdir
5486
    } elsif (/^--Dir=(.*)/) {                   # prefix with target specific subdir
5479
        Error ('Packaging directive with --Dir option does not specify a directory.',
5487
        Error ('Packaging directive with --Dir option does not specify a directory.',
5480
               'Possible bad use of option of the form:--Dir=$xxx',
5488
               'Possible bad use of option of the form:--Dir=$xxx',
5481
               'Note: Use of package.pl and this construct is deprecated') unless ( $1 );
5489
               'Note: Use of package.pl and this construct is deprecated') unless ( $1 );
-
 
5490
        my $udir = $1;
-
 
5491
 
-
 
5492
        #
-
 
5493
        #   Remove leading ./
-
 
5494
        #   Check for leading ../
-
 
5495
        while ( $udir =~ s{^\./}{} ){};
-
 
5496
 
-
 
5497
        if ( $udir =~ m~^\.\./~ )
-
 
5498
        {
-
 
5499
            Warning("Packaging directive with --Dir option contains relative path (removed)", "Option: $_");
-
 
5500
            while ( $udir =~ s{^\.\./}{} ){};
-
 
5501
        }
5482
        if ($flags & $T_PKG) {
5502
        if ($flags & $T_PKG) {
5483
            $dir = __PkgDir( $1 );
5503
            $dir = __PkgDir( $udir );
5484
        } else {
5504
        } else {
5485
            $dir = "\$(LOCALDIR)/$1";
5505
            $dir = "\$(LOCALDIR)/$udir";
5486
        }
5506
        }
5487
    }
5507
    }
5488
 
5508
 
5489
    return ($consumed) if ($dir eq "");
5509
    return ($consumed) if ($dir eq "");
5490
    $dir =~ s~//~/~g;
5510
    $dir =~ s~//~/~g;
Line 5509... Line 5529...
5509
 
5529
 
5510
    $dir =~ s~^$::Pbase[/]?~~;
5530
    $dir =~ s~^$::Pbase[/]?~~;
5511
    Debug2( "  PkgDir: converted \"$org\" to \"$dir\"" );
5531
    Debug2( "  PkgDir: converted \"$org\" to \"$dir\"" );
5512
 
5532
 
5513
    $dir = "\$(PKGDIR)/$dir";
5533
    $dir = "\$(PKGDIR)/$dir";
5514
    $dir =~ s~\./~/~g;
-
 
5515
 
-
 
5516
    return $dir;
5534
    return $dir;
5517
}
5535
}
5518
 
5536
 
5519
 
5537
 
5520
#   getMajorMinor ---
5538
#   getMajorMinor ---
Line 7605... Line 7623...
7605
#                   if the directive should be ignored for the current platform
7623
#                   if the directive should be ignored for the current platform
7606
#
7624
#
7607
# Inputs          : $platform_spec      - A platform specifier
7625
# Inputs          : $platform_spec      - A platform specifier
7608
#                                         This is a bit complex.
7626
#                                         This is a bit complex.
7609
#
7627
#
-
 
7628
#                   Format of platform_spec. One or more of
-
 
7629
#                       PlatformName
-
 
7630
#                       AliasName
-
 
7631
#                       TargetName,--Target
-
 
7632
#                       --Project=ProjectName
-
 
7633
#                       --Defined=SomeValue
-
 
7634
#
-
 
7635
#                   Each can be prefxied with a '!' to negate the test
-
 
7636
#
-
 
7637
#                   Valid options are:
-
 
7638
#                       --Target        - indicates that the plaform is a 'target'
-
 
7639
#
7610
# Returns         : TRUE if the platform spec contains the current platform
7640
# Returns         : TRUE if the platform spec is satisfied
7611
#
7641
#
7612
sub ActivePlatform
7642
sub ActivePlatform
7613
{
7643
{
7614
    my( $platform_spec ) = @_;
7644
    my( $platform_spec ) = @_;
7615
    my( @platforms, $scmplatform, $platform );
7645
    my( @platforms, $scmplatform, $platform );
7616
    my( %arguments, @args, $filter );
7646
    my( %arguments, @args, $filter );
-
 
7647
    my @plist;
-
 
7648
    my ($match_count, $count_invert, $count_vert) = (0,0,0);
-
 
7649
 
-
 
7650
    #
-
 
7651
    #   Short circuit check
-
 
7652
    #   '*' is used so often that it pays to check it first
-
 
7653
    #
-
 
7654
    if ( $platform_spec eq '*' )
-
 
7655
    {
-
 
7656
        Debug3( " ActivePlatform(@_) = TRUE" );
-
 
7657
        return 1;
-
 
7658
    }
-
 
7659
 
-
 
7660
 
-
 
7661
    #
7617
    my( $and, $warning ) = 0;                   # AND result
7662
    #   Platform specifier may be a comma seperated list
-
 
7663
    #   ie:  WIN32,MOS,XXX
-
 
7664
    #   Extract non-platform arguments
-
 
7665
    #   Process to yeild a dummy platform of '0' or '1' - these will be seen later
-
 
7666
    #
-
 
7667
    foreach ( split( '\s*,\s*', $platform_spec ) )
-
 
7668
    {
-
 
7669
        if ( m~^(!?)--Project=(.+)~ ) {
-
 
7670
            my $result = ActiveProject( $2);
-
 
7671
            $result = $result ? 1 : 0;
-
 
7672
            push @plist, "$1$result";
-
 
7673
            next;
-
 
7674
        }
-
 
7675
        elsif ( m~^(!?)--Defined=(.+)~ ) {
-
 
7676
            my $result = 0;
-
 
7677
            no strict 'refs';
-
 
7678
            $result = 1 if ( defined( $$2 ) || defined( @$2 ) );
-
 
7679
            use strict 'refs';
7618
 
7680
 
7619
    @platforms = split( '\s*,\s*', $platform_spec );  # split list
7681
            $result = $result ? 1 : 0;
-
 
7682
            push @plist, "$1$result";
-
 
7683
            next;
-
 
7684
        }
-
 
7685
 
-
 
7686
        #
7620
    @platforms = ExpandPlatforms( @platforms ); # aliasing
7687
        #   Must be a platform argument
-
 
7688
        #   Add to a list
-
 
7689
        #
-
 
7690
        push @platforms, $_;
-
 
7691
    }
7621
 
7692
 
-
 
7693
    #   Platform specified may be an Alias
-
 
7694
    #   Perform alias expansion
-
 
7695
    #
-
 
7696
    @platforms = ExpandPlatforms( @platforms );         # aliasing
7622
    Debug3( " ActivePlatform(@_)" );
7697
    Debug3( " ActivePlatform(@_)" );
7623
 
7698
 
7624
#.. Arguments
7699
#.. Arguments
7625
#   At this point we have a space-separated list if platforms and arguments
7700
#   At this point we have a list of platforms and arguments
7626
#   Build up a hash of --Arguments for each platform being parsed
7701
#   Build up a hash of arguments for each platform being parsed
7627
#   Multiple arguments can follow a platform name
7702
#   Multiple arguments can follow a platform name
-
 
7703
#   Arguments apply to the preceeding platform name
7628
#
7704
#
7629
    $platform = "";
7705
    $platform = undef;
7630
    foreach ( @platforms )
7706
    foreach ( @platforms )
7631
    {
7707
    {
7632
        if (/^--(.*)/) {                        # Arguments
7708
        if ( /^--Target/ ) {                     # Arguments
-
 
7709
            if ( $platform ) {
7633
            HashJoin( \%arguments, $;, $platform, "$1" )
7710
                $arguments{$platform}{'Target'} = 1;
-
 
7711
            } else {
-
 
7712
                Warning ("No Platform preceedig platform option: $_");
-
 
7713
            }
-
 
7714
 
-
 
7715
        } elsif ( /^--/ ) {
7634
                if ( $platform ne "" );
7716
            Warning ("Unknown platform option: $_");
-
 
7717
 
7635
        } else {                                # Target
7718
        } else {                                # Target
7636
            $platform = $_;
7719
            $platform = $_;
-
 
7720
            push @plist, $platform;
7637
        }
7721
        }
7638
    }
7722
    }
7639
 
7723
 
7640
#.. Specification
7724
#.. Scan the expression
7641
#
7725
#
7642
    $scmplatform = uc( $ScmPlatform );          # current platform
7726
    $scmplatform = uc( $ScmPlatform );          # current platform
7643
 
-
 
7644
LOOP:
-
 
7645
    foreach ( @platforms )
7727
    foreach ( @plist )
7646
    {
7728
    {
7647
        next if ( /^--(.*)/ );                  # ignore arguments
-
 
7648
 
-
 
7649
        $platform = uc( Trim( $_ ) );           # trim white and convert case
7729
        $platform = uc( Trim( $_ ) );           # trim white and convert case
7650
        $filter = $scmplatform;                 # filter specification
-
 
7651
 
7730
 
7652
        #   Process arguments first
-
 
7653
        #
7731
        #
-
 
7732
        #   Determine filter comparison
-
 
7733
        #   Either a Platform or a Target
-
 
7734
        #
7654
        if ( $arguments{ $_ } )
7735
        if ( $arguments{$platform}{'Target'} )
7655
        {
7736
        {
7656
            @args = split( /$;/, $arguments{ $_ } );
7737
            $filter = uc( $ScmTarget );
7657
            foreach (@args) {
7738
        }
7658
                $filter = uc( $ScmTarget ) if (/^Target$/);
7739
        else
7659
            }
7740
        {
-
 
7741
            $filter = $scmplatform;             # filter specification
7660
        }
7742
        }
-
 
7743
 
7661
        Debug3( "   Platform=$platform, Filter=$filter" );
7744
        Debug3( "   Platform=$platform, Filter=$filter" );
7662
 
7745
 
7663
        #
7746
        #
7664
        #   Examine platform names
7747
        #   Examine platform names
7665
        #   Allow negation of name (!), but all the names must be negated
7748
        #   Allow negation of name (!), but all the names must be negated
7666
        #   as a mix does not make sense.
7749
        #   as a mix does not make sense.
7667
        #   ie:     !P1,!P2,!P3     - All except P1,P2 or P3
7750
        #   ie:     !P1,!P2,!P3     - All except P1,P2 or P3
7668
        #            P1,P2,P2       - Only P1,P2,P3
7751
        #            P1,P2,P2       - Only P1,P2,P3
7669
        #
7752
        #
7670
        if ( substr($platform, 0, 1) eq "!" )
7753
        my $invert = 0;
7671
        {                                       # NOT
-
 
7672
            if (substr($platform, 1) ne $filter) {
7754
        if ( substr($platform, 0, 1) eq '!' )
7673
                $and += 1 if ($and >= 0);       # .. true, accumulate
-
 
7674
            } else {
7755
        {
7675
                $and = -1;                      # .. false, invalidate
7756
            $count_invert++;
7676
            }
7757
            $platform = substr($platform, 1);
7677
        }
7758
        }
7678
        else
7759
        else
7679
        {                                       # OR
-
 
7680
            Warning( "Platform expression '@_' makes no sense" )
-
 
7681
                if ( $and != 0 && $warning++ == 0 );
-
 
7682
 
-
 
7683
            if ( $platform eq "" || $platform eq "*" ||
-
 
7684
                    $platform eq $filter )
-
 
7685
            {                                   # .. true, short ciruit
-
 
7686
                Debug3( "   (@_ == $ScmPlatform) = TRUE" );
-
 
7687
                return 1;
7760
        {
7688
            }
7761
            $count_vert++;
7689
        }
7762
        }
-
 
7763
 
-
 
7764
        $match_count++ if ( $platform eq ''  ||
-
 
7765
                            $platform eq '*' ||
-
 
7766
                            $platform eq '1' ||
-
 
7767
                            $platform eq $filter );
-
 
7768
    }
-
 
7769
 
-
 
7770
    #
-
 
7771
    #   Sanity test
-
 
7772
    #   Force failure on bad sanity
-
 
7773
    #
-
 
7774
    if ( $count_vert && $count_invert )
-
 
7775
    {
-
 
7776
        Warning( "Platform expression makes no sense. Mixed use of '!' operator",
-
 
7777
                 "Expression: @_" );
-
 
7778
        return 0;
7690
    }
7779
    }
7691
 
7780
 
-
 
7781
    #
7692
    if ( $and > 0 ) {
7782
    #   Test for pass
-
 
7783
    #   If not using '!', then any match passes : P1 or P2 or P3
-
 
7784
    #   If are using '!', then any match is bad : !P1 and !P2 and !P3 == !(P1 or P2 or P3)
-
 
7785
    #
-
 
7786
    if ( ( $count_vert && $match_count ) || ( $count_invert && ( not $match_count) )   )
-
 
7787
    {
7693
        Debug3( " ActivePlatform(@_ == $ScmPlatform) = TRUE" );
7788
        Debug3( " ActivePlatform(@_ == $ScmPlatform) = TRUE" );
7694
        return 1;
7789
        return 1;
7695
    }
7790
    }
-
 
7791
 
7696
    Debug3( " ActivePlatform(@_ == $ScmPlatform) = FALSE" );
7792
    Debug3( " ActivePlatform(@_ == $ScmPlatform) = FALSE" );
7697
    return 0;
7793
    return 0;
7698
}
7794
}
7699
 
7795
 
7700
#-------------------------------------------------------------------------------
7796
#-------------------------------------------------------------------------------
Line 8017... Line 8113...
8017
#-------------------------------------------------------------------------------
8113
#-------------------------------------------------------------------------------
8018
#   
8114
#   
8019
#
8115
#
8020
MakeHeader ("Tool Search Path",
8116
MakeHeader ("Tool Search Path",
8021
            "Extend the PATH seen by all the tools to include",
8117
            "Extend the PATH seen by all the tools to include",
8022
            "The tool/bin directories discovered in Packages" );
8118
            "The tools/bin directories discovered in Packages" );
8023
my $put_PATH;
8119
my $put_PATH;
8024
my $put_LD_LIBRARY_PATH;
8120
my $put_LD_LIBRARY_PATH;
8025
for my $path ( ToolExtensionPaths() )
8121
for my $path ( ToolExtensionPaths() )
8026
{
8122
{
8027
    MakePrint( "PATH := $path$::ScmPathSep\$(PATH)\n" );
8123
    MakePrint( "PATH := $path$::ScmPathSep\$(PATH)\n" );
Line 8886... Line 8982...
8886
}
8982
}
8887
 
8983
 
8888
    print MAKEFILE <<EOF;
8984
    print MAKEFILE <<EOF;
8889
	"\\n"
8985
	"\\n"
8890
 
8986
 
-
 
8987
#   make_init - Test toolset presence and sanity
-
 
8988
#   Will only be called ONCE for each platform in a recursive build
-
 
8989
#   Should be used to ensure that the required toolset is present
-
 
8990
#
8891
.PHONY:		make_init
8991
.PHONY:		make_init
8892
make_init:	make_dir $initdep
8992
make_init:	$initdep
8893
 
8993
 
-
 
8994
#   make_dir    - Create required subdirectories
-
 
8995
#   Will be invoked as a part of most targets that create files
-
 
8996
#   Will not be invoked when cleaning
-
 
8997
#
8894
.PHONY:		make_dir
8998
.PHONY:		make_dir
8895
make_dir:	$mkdirdep
8999
make_dir:	$mkdirdep
8896
 
9000
 
8897
make_clean:
9001
make_clean:
8898
	-\@echo "Removing generated files (objects, libraries, binaries etc)";
9002
	-\@echo "Removing generated files (objects, libraries, binaries etc)";