Subversion Repositories DevTools

Rev

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

Rev 4109 Rev 4728
Line 11... Line 11...
11
#............................................................................#
11
#............................................................................#
12
 
12
 
13
use strict;
13
use strict;
14
use warnings;
14
use warnings;
15
 
15
 
-
 
16
# Global variables
16
our $ScmPlatform;
17
our $ScmPlatform;
17
our $ScmNoToolsTest;
18
our $ScmNoToolsTest;
-
 
19
our $ScmToolsetProcessTests;
-
 
20
 
-
 
21
#   Misc variables
-
 
22
my $UseGcov = 0;
-
 
23
my $UseCppcheck = 0;
18
 
24
 
19
##############################################################################
25
##############################################################################
20
#   Configuration information
26
#   Configuration information
21
#   Cross reference from CrossCompiler Alias to actual paths
27
#   Cross reference from CrossCompiler Alias to actual paths
22
#   Structure:
28
#   Structure:
Line 135... Line 141...
135
ToolsetInit();
141
ToolsetInit();
136
 
142
 
137
sub ToolsetInit
143
sub ToolsetInit
138
{
144
{
139
    my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCObjCopy );
145
    my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCObjCopy );
140
    my( $GCCFlags,  $GCCFlagsP, $GCCFlagsD );
146
    my( $GCCFlags,  $GCCFlagsP, $GCCFlagsD, $LDFlags );
141
    my( $PkgArch);
147
    my( $PkgArch);
142
    my( $arg_alias, $tools_found, $compiler_tool );
148
    my( $arg_alias, $tools_found, $compiler_tool );
143
 
149
 
144
#.. Toolset configuration
150
#.. Toolset configuration
145
#
151
#
146
    $::ScmToolsetVersion = "1.0.0";             # our version
152
    $::ScmToolsetVersion = "1.0.0";             # our version
147
    $::ScmToolsetGenerate = 0;                  # GEN generate optional
153
    $::ScmToolsetGenerate = 0;                  # GEN generate optional
148
    $::ScmToolsetCompilerPath = 1;              # Exports Compiler path to makefile via SCM_COMPILERPATH
154
    $::ScmToolsetCompilerPath = 1;              # Exports Compiler path to makefile via SCM_COMPILERPATH
149
    $::ScmToolsetProgDependancies = 0;          # handle Prog dependancies myself
155
    $::ScmToolsetProgDependancies = 0;          # handle Prog dependancies myself
150
    $::ScmToolsetSoName = 1;                    # Shared library supports SoName
156
    $::ScmToolsetSoName = 1;                    # Shared library supports SoName
-
 
157
    $ScmToolsetProcessTests = 0;                # Unit Tests require Pre/Post processing - set later
151
 
158
 
152
#.. Standard.rul requirements
159
#.. Standard.rul requirements
153
#
160
#
154
    $::s = "asm";
161
    $::s = "asm";
155
    $::o = "o";
162
    $::o = "o";
Line 164... Line 171...
164
            $GCCTarget = "$1";
171
            $GCCTarget = "$1";
165
 
172
 
166
        } elsif (/^--CrossAlias=(.*)/) {        # CrossCompiler target-alias
173
        } elsif (/^--CrossAlias=(.*)/) {        # CrossCompiler target-alias
167
            $arg_alias = $1;
174
            $arg_alias = $1;
168
 
175
 
-
 
176
        } elsif (/^--UseGcov/) {                # Compile for code coverage
-
 
177
            $UseGcov = 1;
-
 
178
 
-
 
179
        } elsif (/^--UseCppcheck/) {            # Use cppcheck as the lint tool
-
 
180
            $UseCppcheck = 1;
-
 
181
 
169
        } elsif (/^--CompilerTool=(.*)/) {      # CrossCompiler located in package
182
        } elsif (/^--CompilerTool=(.*)/) {      # CrossCompiler located in package
170
            $compiler_tool = $1;
183
            $compiler_tool = $1;
171
 
184
 
172
        } else {
185
        } else {
173
            Message( "gcc toolset: unknown option $_ -- ignored\n" );
186
            Message( "gcc toolset: unknown option $_ -- ignored\n" );
Line 326... Line 339...
326
        $GCCRoot = '/usr';
339
        $GCCRoot = '/usr';
327
        $GCCBin = 'gcc';
340
        $GCCBin = 'gcc';
328
        $GCCAr = 'ar';
341
        $GCCAr = 'ar';
329
        $GCCObjCopy =  'objcopy';
342
        $GCCObjCopy =  'objcopy';
330
    }
343
    }
-
 
344
    
-
 
345
    #
-
 
346
    #   When running under gcov we need to instruct GCC to perform code coverage
-
 
347
    #   generation in both C flags and LD flags
-
 
348
    #
-
 
349
    if ( $UseGcov )
-
 
350
    {
-
 
351
        $GCCFlags .= ' -coverage';
-
 
352
        $LDFlags  .= ' -coverage';
-
 
353
    }
-
 
354
    
-
 
355
    #
-
 
356
    #   When running with cppcheck we need to include it in our environment
-
 
357
    #
-
 
358
    if ( $UseCppcheck )
-
 
359
    {
-
 
360
        ToolsetRequire( "cppcheck" );
-
 
361
        PlatformDefine( "CPPCHECK_PLATFORM := unix32" );
-
 
362
    }
-
 
363
        
331
 
364
 
332
#.. Define GCC environment
365
#.. Define GCC environment
333
#
366
#
334
    PlatformDefine( "
367
    PlatformDefine( "
335
#################################################
368
#################################################
Line 342... Line 375...
342
    PlatformDefine( "GCC_AR             := $GCCAr" );
375
    PlatformDefine( "GCC_AR             := $GCCAr" );
343
    PlatformDefine( "GCC_OBJCOPY        := $GCCObjCopy" );
376
    PlatformDefine( "GCC_OBJCOPY        := $GCCObjCopy" );
344
    PlatformDefine( "GCC_CFLAGS         := $GCCFlags" ) if defined $GCCFlags;
377
    PlatformDefine( "GCC_CFLAGS         := $GCCFlags" ) if defined $GCCFlags;
345
    PlatformDefine( "GCC_CFLAGSP        := $GCCFlagsP" ) if defined $GCCFlagsP;
378
    PlatformDefine( "GCC_CFLAGSP        := $GCCFlagsP" ) if defined $GCCFlagsP;
346
    PlatformDefine( "GCC_CFLAGSD        := $GCCFlagsD" ) if defined $GCCFlagsD;
379
    PlatformDefine( "GCC_CFLAGSD        := $GCCFlagsD" ) if defined $GCCFlagsD;
-
 
380
    PlatformDefine( "GCC_LDFLAGS        := $LDFlags" ) if defined $LDFlags;
347
 
381
 
348
    #
382
    #
349
    #   Required since this toolset advertises: ScmToolsetCompilerPath
383
    #   Required since this toolset advertises: ScmToolsetCompilerPath
350
    #
384
    #
351
    PlatformDefine( "SCM_COMPILERPATH   := \$\{GCC_CC\}" );
385
    PlatformDefine( "SCM_COMPILERPATH   := \$\{GCC_CC\}" );
Line 452... Line 486...
452
        MakePrint( "\tCFLAGS +=$cflags\n" );
486
        MakePrint( "\tCFLAGS +=$cflags\n" );
453
    }
487
    }
454
 
488
 
455
    $file = StripExt( $obj );                   # Metric working file
489
    $file = StripExt( $obj );                   # Metric working file
456
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
490
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
-
 
491
 
-
 
492
    if ( $UseGcov )
-
 
493
    {
-
 
494
        $ScmToolsetProcessTests = 1;
-
 
495
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcno' );
-
 
496
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcda' );
-
 
497
    }
457
}
498
}
458
 
499
 
459
 
500
 
460
###############################################################################
501
###############################################################################
461
#   ToolsetCCDepend( $depend, \@sources )
502
#   ToolsetCCDepend( $depend, \@sources )
Line 498... Line 539...
498
        MakePrint( "\tCXXFLAGS +=$cflags\n" );
539
        MakePrint( "\tCXXFLAGS +=$cflags\n" );
499
    }
540
    }
500
 
541
 
501
    $file = StripExt( $obj );                   # Metric working file
542
    $file = StripExt( $obj );                   # Metric working file
502
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
543
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
-
 
544
 
-
 
545
    if ( $UseGcov )
-
 
546
    {
-
 
547
        $ScmToolsetProcessTests = 1;
-
 
548
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcno' );
-
 
549
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcda' );
-
 
550
    }
503
}
551
}
504
 
552
 
505
 
553
 
506
###############################################################################
554
###############################################################################
507
#   ToolsetCXXDepend( $depend, \@sources )
555
#   ToolsetCXXDepend( $depend, \@sources )
Line 899... Line 947...
899
    PackageProgAddFiles ( $name, $dbg );
947
    PackageProgAddFiles ( $name, $dbg );
900
 
948
 
901
}
949
}
902
 
950
 
903
 
951
 
-
 
952
###############################################################################
-
 
953
# Function        : ToolsetPreprocessTests
-
 
954
#
-
 
955
# Description     : 
-
 
956
#
-
 
957
# Inputs          : None
-
 
958
#
-
 
959
# Returns         : Nothing
-
 
960
#
-
 
961
# Output:         : Rules and recipes to run before unit tests
-
 
962
#
-
 
963
sub ToolsetPreprocessTests
-
 
964
{
-
 
965
    my ($io) = ToolsetPrinter::New();
-
 
966
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
-
 
967
    {
-
 
968
        #   Force The Pre/Post/Collate rules to be processed
-
 
969
        $ScmToolsetProcessTests = 1;
-
 
970
 
-
 
971
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
-
 
972
        my $final=$finaldir . '/lcov-final.info';
-
 
973
        
-
 
974
        ToolsetGenerate( '$(OBJDIR)/lcov-baseline.info' );
-
 
975
        $io->PrtLn('.PHONY: preprocess_tests' );
-
 
976
        $io->PrtLn('preprocess_tests:' );
-
 
977
 
-
 
978
        my $key;
-
 
979
        my $value;
-
 
980
        while(($key, $value) = each(%::OBJSOURCE))
-
 
981
        {
-
 
982
            $io->PrtLn("\t" . '$(XX_PRE)rm -f $(OBJDIR)/' . $key . ".gcda");
-
 
983
        }
-
 
984
        $io->PrtLn("\t" . '${XX_PRE}$(rm) -f ' . $final);
-
 
985
        $io->PrtLn("\t" . '${XX_PRE}lcov'
-
 
986
                      . ' --rc lcov_branch_coverage=1'
-
 
987
                      . ' --capture'
-
 
988
                      . ' --initial'
-
 
989
                      . ' --base-directory ' . $::Cwd
-
 
990
                      . ' --directory $(OBJDIR)'
-
 
991
                      . ' --output-file $(OBJDIR)/lcov-baseline.info' ); 
-
 
992
    }
-
 
993
}
-
 
994
 
-
 
995
 
-
 
996
###############################################################################
-
 
997
# Function        : ToolsetPostprocessTests
-
 
998
#
-
 
999
# Description     : 
-
 
1000
#
-
 
1001
# Inputs          : None
-
 
1002
#
-
 
1003
# Returns         : Nothing
-
 
1004
#
-
 
1005
# Output:         : Rules and recipes to run after the unit tests
-
 
1006
#
-
 
1007
sub ToolsetPostprocessTests
-
 
1008
{
-
 
1009
    my ($io) = ToolsetPrinter::New();
-
 
1010
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
-
 
1011
    {
-
 
1012
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
-
 
1013
        my $final=$finaldir . '/lcov-final.info';
-
 
1014
        
-
 
1015
        ToolsetGenerate( '$(OBJDIR)/lcov-capture.info' );
-
 
1016
        ToolsetGenerate( $final );
-
 
1017
        
-
 
1018
        $io->PrtLn('.PHONY: postprocess_tests' );
-
 
1019
        $io->PrtLn('postprocess_tests:' );
-
 
1020
        $io->PrtLn("\t" . '$(eval GCDA_COUNT := $(shell find $(OBJDIR) -name "*.gcda"))');
-
 
1021
        
-
 
1022
        $io->PrtLn  ("\t" . '$(XX_PRE)$(mkdir) -p ' . $finaldir);
-
 
1023
        $io->PrtPart("\t" . '$(XX_PRE)if [ "$(GCDA_COUNT)" = "" ]; then');
-
 
1024
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
-
 
1025
        $io->PrtPart("\t\t\t" . '$(cp) $(OBJDIR)/lcov-baseline.info ' . $final . ';');
-
 
1026
        $io->PrtPart("\t\t" . 'else');
-
 
1027
        $io->PrtPart("\t\t\t" . 'lcov'
-
 
1028
                          . ' --rc lcov_branch_coverage=1'
-
 
1029
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
-
 
1030
                          . ' --add-tracefile ' . $final
-
 
1031
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
-
 
1032
                          . ';'); 
-
 
1033
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
-
 
1034
        $io->PrtPart("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . ';');
-
 
1035
        $io->PrtPart("\t\t" . 'fi' . ';');
-
 
1036
        $io->PrtPart("\t" . 'else');
-
 
1037
        $io->PrtPart("\t\t" . 'lcov'
-
 
1038
                        . ' --rc lcov_branch_coverage=1'
-
 
1039
                        . ' --capture'
-
 
1040
                        . ' --base-directory ' . $::Cwd
-
 
1041
                        . ' --directory $(OBJDIR)'
-
 
1042
                        . ' --output-file $(OBJDIR)/lcov-capture.info' 
-
 
1043
                        . ';'); 
-
 
1044
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
-
 
1045
        $io->PrtPart("\t\t\t" . 'lcov'
-
 
1046
                          . ' --rc lcov_branch_coverage=1'
-
 
1047
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
-
 
1048
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
-
 
1049
                          . ' --output-file ' .  $final
-
 
1050
                          . ';'); 
-
 
1051
        $io->PrtPart("\t\t" . 'else');
-
 
1052
        $io->PrtPart("\t\t\t" . 'lcov'
-
 
1053
                          . ' --rc lcov_branch_coverage=1'
-
 
1054
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
-
 
1055
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
-
 
1056
                          . ' --add-tracefile ' . $final
-
 
1057
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
-
 
1058
                          . ';'); 
-
 
1059
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
-
 
1060
        $io->PrtPart("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . ';');
-
 
1061
        $io->PrtPart("\t\t" . 'fi' . ';');
-
 
1062
        $io->PrtLn  ("\t" . 'fi');
-
 
1063
    }
-
 
1064
}
-
 
1065
 
-
 
1066
 
-
 
1067
###############################################################################
-
 
1068
# Function        : ToolsetCollateTestResults
-
 
1069
#
-
 
1070
# Description     : 
-
 
1071
#
-
 
1072
# Inputs          : None
-
 
1073
#
-
 
1074
# Returns         : Nothing
-
 
1075
#
-
 
1076
# Output:         : Rules and recipes to run after unit test result 
-
 
1077
#                   postprocessing.
-
 
1078
#
-
 
1079
sub ToolsetCollateTestResults
-
 
1080
{
-
 
1081
    my ($io) = ToolsetPrinter::New();
-
 
1082
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
-
 
1083
    {
-
 
1084
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
-
 
1085
        my $final=$finaldir . '/lcov-final.info';
-
 
1086
        
-
 
1087
        my $reportdir='$(PKGDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
-
 
1088
        my $reportindex=$reportdir . '/index.html';
-
 
1089
        
-
 
1090
        $io->PrtLn('.PHONY: collate_test_results' );
-
 
1091
        $io->PrtLn('collate_test_results: ' . $reportindex);
-
 
1092
        $io->Newline();
-
 
1093
        $io->PrtLn($reportindex . ': ' . $final);
-
 
1094
        $io->PrtLn("\t" . 'genhtml'
-
 
1095
                      . ' --frames'
-
 
1096
                      . ' --show-details'
-
 
1097
                      . ' --function-coverage'
-
 
1098
                      . ' --branch-coverage'
-
 
1099
                      . ' --output-directory ' . $reportdir
-
 
1100
                      . ' --legend'
-
 
1101
                      . ' --demangle-cpp'
-
 
1102
                      . ' ' . $final);
-
 
1103
    }
-
 
1104
}
-
 
1105
 
-
 
1106
 
-
 
1107
###############################################################################
-
 
1108
#   ToolsetARLINT( $name, \@args, \@objs )
-
 
1109
#       This subroutine takes the user options and builds the rules
-
 
1110
#       required to lint the static library 'name'.
-
 
1111
#
-
 
1112
#   Arguments:
-
 
1113
#       --xxx                   No arguments currently defined
-
 
1114
#
-
 
1115
#   Output:
-
 
1116
#       [ $(LIBDIR)/name$_lint:   .... ]
-
 
1117
#           $(ARLINT)
-
 
1118
#
-
 
1119
###############################################################################
-
 
1120
 
-
 
1121
sub ToolsetARLINT
-
 
1122
{
-
 
1123
    if ( $UseCppcheck )
-
 
1124
    {
-
 
1125
        CppcheckAR( @_ );
-
 
1126
    }
-
 
1127
}
-
 
1128
 
-
 
1129
 
-
 
1130
###############################################################################
-
 
1131
#   ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
-
 
1132
#       This subroutine takes the user options and builds the rules
-
 
1133
#       required to lint the shared library 'name'.
-
 
1134
#
-
 
1135
#   Arguments:
-
 
1136
#       (none)
-
 
1137
#
-
 
1138
#   Output:
-
 
1139
#       [ $(LIBDIR)/$name_lint:   .... ]
-
 
1140
#           $(SHLIBLINT)
-
 
1141
#
-
 
1142
###############################################################################
-
 
1143
 
-
 
1144
sub ToolsetSHLDLINT
-
 
1145
{
-
 
1146
    if ( $UseCppcheck )
-
 
1147
    {
-
 
1148
        CppcheckSHLD( @_ );
-
 
1149
    }
-
 
1150
}
-
 
1151
 
-
 
1152
 
-
 
1153
###############################################################################
-
 
1154
#   ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
-
 
1155
#       This subroutine takes the user options and builds the rules
-
 
1156
#       required to lint the program 'name'.
-
 
1157
#
-
 
1158
#   Arguments:
-
 
1159
#       (none)
-
 
1160
#
-
 
1161
#   Output:
-
 
1162
#       [ $(BINDIR)/$name_lint:   .... ]
-
 
1163
#           $(LDLINT)
-
 
1164
#
-
 
1165
###############################################################################
-
 
1166
 
-
 
1167
sub ToolsetLDLINT
-
 
1168
{
-
 
1169
    if ( $UseCppcheck )
-
 
1170
    {
-
 
1171
        CppcheckLD( @_ );
-
 
1172
    }
-
 
1173
}
-
 
1174
 
904
########################################################################
1175
########################################################################
905
#
1176
#
906
#   Push standard "system" libraries. This is a helper function
1177
#   Push standard "system" libraries. This is a helper function
907
#   used within this toolset.
1178
#   used within this toolset.
908
#
1179
#