Subversion Repositories DevTools

Rev

Rev 5731 | Rev 5744 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
# -*- mode: perl; tabs: 8; indent-width: 4; show-tabs: yes; -*-
2
#
3
# Module name   : GCC
4
# Module type   : Makefile system
5
# Compiler(s)   : ANSI C
6
# Environment(s): GCC
7
#
8
# Description:
9
#       GCC C/C++ toolset
10
#
11
#............................................................................#
12
 
13
use strict;
14
use warnings;
15
 
4728 dpurdie 16
# Global variables
4034 dpurdie 17
our $ScmPlatform;
18
our $ScmNoToolsTest;
19
 
4728 dpurdie 20
#   Misc variables
21
my $UseGcov = 0;
4835 dpurdie 22
my $LcovExplicitBranch = '';
4728 dpurdie 23
my $UseCppcheck = 0;
24
 
227 dpurdie 25
##############################################################################
26
#   Configuration information
27
#   Cross reference from CrossCompiler Alias to actual paths
28
#   Structure:
29
#   Hash reference: Array of toolchain information
369 dpurdie 30
#       Mandatory
31
#          ROOT             => Root of compiler
32
#          BASE             => Base for binaries
33
#       Optional
34
#          CC_OPTS          => Additonal Compiler options
4034 dpurdie 35
#          CC_OPTSP         => Production Compiler options
36
#          CC_OPTSD         => Debug Compiler options
369 dpurdie 37
#          UNCONTROLLED     => Boolean to create warning
3967 dpurdie 38
#          PACKAGE_ARCH     => Packageing architecture
39
#          VERSION          => Version reported by GCC
40
#          MACHINE          => Machine reported by GCC
4034 dpurdie 41
#          COMPILER_OPTIONS => Toolset specific compiler initial options
42
#                              This is a comma seperated list
227 dpurdie 43
my %ToolsetConfig = (
44
 
369 dpurdie 45
    'i386-unknown-linux-gnu'    => {
5708 dpurdie 46
        ROOT        => '/opt/crosstool/gcc-4.1.1-glibc-2.5/i586-unknown-linux-gnu',
47
        BASE        => 'bin/i586-unknown-linux-gnu-',
3967 dpurdie 48
       VERSION      => '4.1.1',
49
       MACHINE      => 'i586-unknown-linux-gnu'
369 dpurdie 50
    },
227 dpurdie 51
 
369 dpurdie 52
    'arm-9tdmi-linux-gnu'       => {
5708 dpurdie 53
        ROOT        => '/opt/crosstool/gcc-4.1.1-glibc-2.5/arm-9tdmi-linux-gnu',
54
        BASE        => 'bin/arm-9tdmi-linux-gnu-',
55
        VERSION     => '4.1.1',
56
        MACHINE     => 'arm-9tdmi-linux-gnu'
369 dpurdie 57
        },
247 dpurdie 58
 
369 dpurdie 59
    'powerpc-603e-linux-gnu'    => {
5708 dpurdie 60
       ROOT         => '/opt/crosstool/gcc-4.1.1-glibc-2.5/powerpc-603e-linux-gnu',
61
       BASE         => 'bin/powerpc-603e-linux-gnu-',
3967 dpurdie 62
       VERSION      => '4.1.1',
63
       MACHINE      => 'powerpc-603e-linux-gnu'
369 dpurdie 64
    },
337 dpurdie 65
 
369 dpurdie 66
    'arm-926ejs-linux-gnueabi'  => {
5708 dpurdie 67
       ROOT         => '/opt/crosstool/gcc-4.4.3-glibc-2.9/arm-926ejs-linux-gnueabi',
68
       BASE         => 'bin/arm-926ejs-linux-gnueabi-',
69
       CC_OPTS      => '-Wno-psabi',
3967 dpurdie 70
       VERSION      => '4.4.3',
71
       MACHINE      => 'arm-926ejs-linux-gnueabi'
369 dpurdie 72
    },
73
 
5708 dpurdie 74
    'arm-926ejs-linux-gnueabi-v2'  => {
75
       ROOT         => '/opt/crosstool/gcc-5.2.0-glibc-2.17/arm-926ejs-linux-gnueabi',
76
       BASE         => 'bin/arm-926ejs-linux-gnueabi-',
77
       CC_OPTS      => '-Wno-psabi',
5736 dpurdie 78
       CXX_OPTS     => '-std=gnu++11',
5708 dpurdie 79
       VERSION      => '5.2.0',
80
       MACHINE      => 'arm-926ejs-linux-gnueabi'
81
    },
82
 
83
    'powerpc-603e-linux-gnu-v2'  => {
84
       ROOT         => '/opt/crosstool/gcc-5.2.0-glibc-2.17/powerpc-603e-linux-gnu',
85
       BASE         => 'bin/powerpc-603e-linux-gnu-',
5736 dpurdie 86
       CXX_OPTS     => '-std=gnu++11',
5708 dpurdie 87
       VERSION      => '5.2.0',
88
       MACHINE      => 'powerpc-603e-linux-gnu'
89
    },
90
 
3967 dpurdie 91
    'i686-linux-gnu'    => {
92
       ROOT         => '/usr',
93
       BASE         => 'bin/',
94
       PACKAGE_ARCH => 'i386',
95
       VERSION      => '4.6',
96
       MACHINE      => 'i686-linux-gnu'
97
    },
98
 
5716 dpurdie 99
    'i686-vix_ubuntu12_c11-linux-gnu'    => {
100
       ROOT         => '/opt/crosstool/gcc-5.2.0-glibc-2.17/i686-vix_ubuntu12_c11-linux-gnu',
101
       BASE         => 'bin/i686-vix_ubuntu12_c11-linux-gnu-',
102
       PACKAGE_ARCH => 'i386',
5736 dpurdie 103
       CXX_OPTS     => '-std=gnu++11',
5716 dpurdie 104
       VERSION      => '5.2.0',
105
       MACHINE      => 'i686-vix_ubuntu12_c11-linux-gnu'
106
    },
107
 
4109 dpurdie 108
    'arm-iwmmxt-linux-gnueabi'  => {
5708 dpurdie 109
       ROOT         => '/opt/marvel',
110
       BASE         => 'bin/arm-iwmmxt-linux-gnueabi-',
4109 dpurdie 111
       VERSION      => '4.2.4',
112
       MACHINE      => 'arm-iwmmxt-linux-gnueabi'
113
    },
114
 
5619 dpurdie 115
    'arm-unknown-linux-gnueabi-sk20-4.1.1.0'  => {
5708 dpurdie 116
       ROOT         => '/opt/arm-unknown-linux-gnueabi-sk20-4.1.1.0',
117
       BASE         => 'bin/arm-unknown-linux-gnueabi-',
5330 dpurdie 118
       VERSION      => '4.8.2',
119
       MACHINE      => 'arm-unknown-linux-gnueabi'
120
    },
121
 
4814 dpurdie 122
    'x86_64-linux-gnu'    => {
123
       ROOT         => '/usr',
124
       BASE         => 'bin/',
125
       PACKAGE_ARCH => 'amd64',
126
       VERSION      => '4.8',
4928 dpurdie 127
       MACHINE      => 'x86_64-linux-gnu',
5115 dpurdie 128
       COMPILER_OPTIONS =>  'pic'               # Always create PIC
4814 dpurdie 129
    },
4109 dpurdie 130
 
227 dpurdie 131
    #
132
    #   Old (not to be used) version of the embedded toolchain
4003 dpurdie 133
    #   This was deprecated in favor of gcc-4.1.1-glibc-2.5
227 dpurdie 134
    #   It is not possible to reproduce old packages using the old compiler
135
    #   This is a known issue
136
    #
369 dpurdie 137
    'i386-unknown-linux-gnu.glibc-2.3.2' => {
5708 dpurdie 138
       ROOT         => '/opt/crosstool/gcc-4.1.0-glibc-2.3.2/i386-unknown-linux-gnu',
139
       BASE         => 'bin/i386-unknown-linux-gnu-'
369 dpurdie 140
    },
227 dpurdie 141
 
369 dpurdie 142
    'arm-9tdmi-linux-gnu.glibc-2.3.2' => {
5708 dpurdie 143
       ROOT         => '/opt/crosstool/gcc-4.1.0-glibc-2.3.2/arm-9tdmi-linux-gnu',
144
       BASE         => 'bin/arm-9tdmi-linux-gnu-'
369 dpurdie 145
    },
227 dpurdie 146
 
147
    #
148
    #   Not too sure where this is used
149
    #
369 dpurdie 150
    'armv4l-unknown-linux-gcc' => {
5708 dpurdie 151
       ROOT         => '/opt/host/armv4l',
152
       BASE         => 'bin/armv4l-unknown-linux-'
369 dpurdie 153
    },
227 dpurdie 154
 
155
    #
156
    #   The compiler for the current local machine
157
    #
369 dpurdie 158
    'i386-unknown-linux-gcc' => {
5708 dpurdie 159
       ROOT         => '/usr',
160
       BASE         => 'bin/',
369 dpurdie 161
       UNCONTROLLED => 1,
3967 dpurdie 162
       PACKAGE_ARCH => 'i386',
369 dpurdie 163
    },
164
);
227 dpurdie 165
 
166
#
167
#   Cross reference from GCCTarget to GBE_MACHTYPE for which it can
168
#   build using the 'native gcc'. This is NOT the preferred mode of operation
169
#   as the compiler is not as controlled as the cross compilers.
170
#
171
my %NativeCompilers = (
172
    'Linux i386'       => 'linux_i386',
173
    );
174
 
175
##############################################################################
176
#   ToolsetInit()
177
#       Runtime initialisation
178
#
179
##############################################################################
180
 
181
ToolsetInit();
182
 
183
sub ToolsetInit
184
{
5731 dpurdie 185
    my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCObjCopy, $GCCGcovTool );
4728 dpurdie 186
    my( $GCCFlags,  $GCCFlagsP, $GCCFlagsD, $LDFlags );
5726 dpurdie 187
    my( $GCCXXFlags );
3967 dpurdie 188
    my( $PkgArch);
4034 dpurdie 189
    my( $arg_alias, $tools_found, $compiler_tool );
227 dpurdie 190
 
191
#.. Toolset configuration
192
#
193
    $::ScmToolsetVersion = "1.0.0";             # our version
194
    $::ScmToolsetGenerate = 0;                  # GEN generate optional
195
    $::ScmToolsetCompilerPath = 1;              # Exports Compiler path to makefile via SCM_COMPILERPATH
271 dpurdie 196
    $::ScmToolsetProgDependancies = 0;          # handle Prog dependancies myself
339 dpurdie 197
    $::ScmToolsetSoName = 1;                    # Shared library supports SoName
227 dpurdie 198
 
199
#.. Standard.rul requirements
200
#
201
    $::s = "asm";
202
    $::o = "o";
203
    $::so = "so";
204
    $::a = "a";
205
    $::exe = "";
206
 
207
#.. Parse arguments
208
#
209
    foreach $_ ( @::ScmToolsetArgs ) {
210
        if (/^--Target=(.*)/) {                 # OS Version
211
            $GCCTarget = "$1";
212
 
213
        } elsif (/^--CrossAlias=(.*)/) {        # CrossCompiler target-alias
214
            $arg_alias = $1;
215
 
4728 dpurdie 216
        } elsif (/^--UseGcov/) {                # Compile for code coverage
217
            $UseGcov = 1;
218
 
4835 dpurdie 219
        } elsif (/^--LcovExplicitBranch/) {     # Version of lcov requires explicit branch coverage
220
            $LcovExplicitBranch = ' --rc lcov_branch_coverage=1';
221
 
4728 dpurdie 222
        } elsif (/^--UseCppcheck/) {            # Use cppcheck as the lint tool
223
            $UseCppcheck = 1;
224
 
4034 dpurdie 225
        } elsif (/^--CompilerTool=(.*)/) {      # CrossCompiler located in package
226
            $compiler_tool = $1;
227
 
227 dpurdie 228
        } else {
229
            Message( "gcc toolset: unknown option $_ -- ignored\n" );
230
        }
231
    }
232
 
233
    foreach $_ ( @::ScmPlatformArgs ) {
234
        if (/^--product=(.*)/) {                # GBE product
235
 
236
        } else {
237
            Message( "gcc toolset: unknown platform argument $_ -- ignored\n" );
238
        }
239
    }
240
 
241
    Error ("TOOLSET/gcc - Target undefined" )
242
        unless ($GCCTarget);
243
 
4034 dpurdie 244
    #
245
    #   If the toolset is not required, then do not process any futher
246
    #   We may not find the compiler
247
    #
248
    return
249
        if ($ScmNoToolsTest);
250
 
227 dpurdie 251
#.. Cross compile support
4034 dpurdie 252
#   Compiler provided in package, rather than install on machine
227 dpurdie 253
#
4034 dpurdie 254
if ( $compiler_tool  )
255
{
256
    #
257
    #   The GCC toolset will handle a compiler provided within a package
258
    #   Initial requirement was for ANDROID NDKs where the compiler is
259
    #   a part of the NDK and will change.
260
    #
261
    #   Compilers in packages will have a file in gbe/COMPILERS/<compiler_tool>
262
    #   that contains data specifically designed for this toolset
263
    #
264
    Verbose("Locate compiler in package: $compiler_tool");
265
    my @toolList;
266
    my $toolPath;
267
    my $toolPkg;
268
    for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} })
269
    {
270
        my $tpath = join('/', $entry->{ROOT}, 'gbe', 'COMPILERS' , $compiler_tool);
271
        if ( -f $tpath  )
272
        {
273
            push @toolList, $entry->{NAME};
274
            $toolPath = $tpath;
275
            $toolPkg = $entry;
276
        }
277
    }
278
    Error ("Multiple packages provide required compiler:", @toolList)
279
        if ( scalar(@toolList) > 1 );
280
    Error ("Required compiler not found in any package", "Compiler: $compiler_tool")
281
        unless ( scalar(@toolList) == 1 );
282
 
283
    #
284
    #   Process the compiler info file
285
    #   Rip out the data and create a hash of item/values
286
    #   File format:
287
    #       '#' is a line comment
288
    #       item=value
289
    #
290
    my %data;
291
    open (my $DATA, '<', $toolPath ) || Error("Cannot open compiler datafile. $!", "File: $toolPath");
292
    while ( <$DATA> )
293
    {
294
        $_ =~ s~\s+$~~;
295
        next if ( m~^#~ );
296
        m~(.*?)\s*=\s*(.*)~;
297
        $data{$1} = $2;
298
    }
299
    close $DATA;
300
 
301
    #
302
    #   Force this compilers data into the ToolsetConfig hash
303
    #
304
    $arg_alias = $compiler_tool;
305
    %ToolsetConfig = ();
306
 
307
    $ToolsetConfig{$arg_alias}{ROOT} = join('/', $toolPkg->{ROOT}, $data{ROOT} );
308
    $ToolsetConfig{$arg_alias}{BASE} = $data{BASE} . '-';
309
    $ToolsetConfig{$arg_alias}{CC_OPTS} = $data{CFLAGS};
310
    $ToolsetConfig{$arg_alias}{CC_OPTSP} = $data{CFLAGSP};
311
    $ToolsetConfig{$arg_alias}{CC_OPTSD} = $data{CFLAGSD};
5726 dpurdie 312
    $ToolsetConfig{$arg_alias}{CXX_OPTS} = $data{CXXFLAGS};
4034 dpurdie 313
    $ToolsetConfig{$arg_alias}{VERSION} = $data{VERSION};
314
    $ToolsetConfig{$arg_alias}{MACHINE} = $data{MACHINE};
315
    $ToolsetConfig{$arg_alias}{COMPILER_OPTIONS} = $data{COMPILER_OPTIONS};
316
}
317
 
318
#.. Cross compile support
319
#
227 dpurdie 320
#   Toolchain=root,[bin]
321
#
322
    if ( $arg_alias )
323
    {
324
        if ( exists $ToolsetConfig{ $arg_alias } )
325
        {
369 dpurdie 326
            $GCCToolchain = $ToolsetConfig{ $arg_alias };
5330 dpurdie 327
            my $testCompilerPath = $GCCToolchain->{ROOT} . '/' . $GCCToolchain->{BASE} . 'gcc';
328
            $tools_found = (-d $GCCToolchain->{ROOT}) && ( -f $testCompilerPath);
227 dpurdie 329
            Warning ("gcc toolset: CrossPlatform toolchain not found for: $arg_alias",
5708 dpurdie 330
                     "Path    : $GCCToolchain->{ROOT}" ,
331
                     "Compiler: $testCompilerPath " 
5330 dpurdie 332
                      ) unless $tools_found;
227 dpurdie 333
        }
334
        else
335
        {
336
            Error("gcc toolset: CrossPlatform Alias not configured: $arg_alias");
337
        }
369 dpurdie 338
 
339
        Warning ("Uncontrolled toolchain used: $arg_alias")
340
            if ( exists($GCCToolchain->{UNCONTROLLED}) && $GCCToolchain->{UNCONTROLLED} );
227 dpurdie 341
    }
342
 
343
    #
344
    #   If no Cross compiler toolchain is found (preferred method), then attempt
345
    #   to match a native compiler. Only known targets allow a native build
346
    #
347
    unless ( $tools_found )
348
    {
349
        if ( exists ( $NativeCompilers{$GCCTarget} ))
350
        {
351
            if ( $NativeCompilers{$GCCTarget} eq $::GBE_MACHTYPE )
352
            {
353
                $tools_found = 1;
369 dpurdie 354
                $GCCToolchain = undef;
227 dpurdie 355
            }
356
        }
357
    }
358
 
359
    #
360
    #   Must have a toolset by now, either a cross compiler or Native
361
    #
362
    Error ("gcc toolset: Toolchain not found for: $GCCTarget" )
363
        unless ( $tools_found );
364
 
365
 
369 dpurdie 366
    if ( defined $GCCToolchain )
227 dpurdie 367
    {
368
        #
369 dpurdie 369
        #   Parse GCCToolchain. Potential parts to create
370
        #       GCCRoot     - Location to find the effective /usr/include directory
371
        #       GCCBin      - Path to the gcc executable
372
        #       GCCAr       - Path to the ar executable
4034 dpurdie 373
        #       GCCFlags    - Additional compiler flags. Also Production and Debug
227 dpurdie 374
        #
369 dpurdie 375
        $GCCRoot = $GCCToolchain->{ROOT};
376
        $GCCBin = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'gcc';
377
        $GCCAr =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'ar';
5731 dpurdie 378
        $GCCGcovTool = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'gcov';
373 dpurdie 379
        $GCCObjCopy =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'objcopy';
369 dpurdie 380
        $GCCFlags = $GCCToolchain->{CC_OPTS};
4034 dpurdie 381
        $GCCFlagsP = $GCCToolchain->{CC_OPTSP};
382
        $GCCFlagsD = $GCCToolchain->{CC_OPTSD};
5726 dpurdie 383
        $GCCXXFlags = $GCCToolchain->{CXX_OPTS};
3967 dpurdie 384
        $PkgArch = $GCCToolchain->{PACKAGE_ARCH};
227 dpurdie 385
    }
386
    else
387
    {
373 dpurdie 388
        $GCCRoot = '/usr';
389
        $GCCBin = 'gcc';
390
        $GCCAr = 'ar';
391
        $GCCObjCopy =  'objcopy';
227 dpurdie 392
    }
4728 dpurdie 393
 
394
    #
395
    #   When running under gcov we need to instruct GCC to perform code coverage
396
    #   generation in both C flags and LD flags
397
    #
398
    if ( $UseGcov )
399
    {
400
        $GCCFlags .= ' -coverage';
401
        $LDFlags  .= ' -coverage';
402
    }
403
 
404
    #
405
    #   When running with cppcheck we need to include it in our environment
406
    #
407
    if ( $UseCppcheck )
408
    {
409
        ToolsetRequire( "cppcheck" );
410
        PlatformDefine( "CPPCHECK_PLATFORM := unix32" );
411
    }
412
 
227 dpurdie 413
 
414
#.. Define GCC environment
415
#
416
    PlatformDefine( "
417
#################################################
418
# GCC toolchain definitions 
419
#
420
#..");
369 dpurdie 421
    PlatformDefine( "GCC_TARGET         := $GCCTarget" );
422
    PlatformDefine( "GCC_ROOT           := $GCCRoot" );
423
    PlatformDefine( "GCC_CC             := $GCCBin" );
424
    PlatformDefine( "GCC_AR             := $GCCAr" );
373 dpurdie 425
    PlatformDefine( "GCC_OBJCOPY        := $GCCObjCopy" );
5731 dpurdie 426
    PlatformDefine( "GCC_GCOVTOOL       := $GCCGcovTool" );
369 dpurdie 427
    PlatformDefine( "GCC_CFLAGS         := $GCCFlags" ) if defined $GCCFlags;
4034 dpurdie 428
    PlatformDefine( "GCC_CFLAGSP        := $GCCFlagsP" ) if defined $GCCFlagsP;
429
    PlatformDefine( "GCC_CFLAGSD        := $GCCFlagsD" ) if defined $GCCFlagsD;
4728 dpurdie 430
    PlatformDefine( "GCC_LDFLAGS        := $LDFlags" ) if defined $LDFlags;
5726 dpurdie 431
    PlatformDefine( "GCC_CXXFLAGS       := $GCCXXFlags" ) if defined $GCCXXFlags;
369 dpurdie 432
 
5726 dpurdie 433
 
227 dpurdie 434
    #
435
    #   Required since this toolset advertises: ScmToolsetCompilerPath
436
    #
369 dpurdie 437
    PlatformDefine( "SCM_COMPILERPATH   := \$\{GCC_CC\}" );
3967 dpurdie 438
 
439
    #
440
    #   Sanity checking
441
    #
442
    PlatformDefine( "GCC_EVERSION       := " . $GCCToolchain->{VERSION} ) if defined $GCCToolchain->{VERSION};
443
    PlatformDefine( "GCC_EMACHINE       := " . $GCCToolchain->{MACHINE} ) if defined $GCCToolchain->{MACHINE};
444
 
445
    #
446
    #   Option indication of packaging architecture
447
    #   Used by non-embedded systems for packaging. See debian_packager
448
    #
449
    PlatformDefine( "PACKAGE_ARCH       := $PkgArch" ) if (defined $PkgArch);
369 dpurdie 450
    PlatformDefine( "" );
227 dpurdie 451
 
452
#.. Piece the world together
453
#
3967 dpurdie 454
    Init( 'gcc' );
227 dpurdie 455
    ToolsetDefines( "gcc.def" );
456
    ToolsetRules( "gcc.rul" );
457
    ToolsetRules( "standard.rul" );
458
 
4094 dpurdie 459
 
460
    PlatformDefine( "CTAGS_EXE:= ctags" );
461
    ToolsetRequire( "exctags" );                # and Exuberant Ctags
462
 
227 dpurdie 463
#   Create a standard data structure
464
#   This is a hash of hashes
465
#       The first hash is keyed by CompileOption keyword
466
#       The second hash contains pairs of values to set or remove
467
#
468
    %::ScmToolsetCompilerOptions =
469
    (
470
        #
471
        #   Control the thread model to use
472
        #   This will affect the compiler options and the linker options
473
        #
474
        'staticprogs'        => { 'STATIC_PROGS' , '1' },      # Progams link staticlly
475
        'no_staticprogs'     => { 'STATIC_PROGS' , undef },    # Default
4034 dpurdie 476
        'noversiondll'       => { 'NO_VERSIONED_DLLS', 1 },    # Matches usage elsewhere
5115 dpurdie 477
        'pic'                => { 'GEN_PIC' , '1' },           # Force PIC for static libs
478
        'nopic'              => { 'GEN_PIC' , undef },         # No Pic on Static libs
227 dpurdie 479
    );
480
 
481
    #
482
    #   Set default options
483
    #
484
    $::ScmCompilerOpts{'STATIC_PROGS'} = undef;
4034 dpurdie 485
    $::ScmCompilerOpts{'NO_VERSIONED_DLLS'} = undef;
486
 
487
    #
488
    #   Process toolset-specfic compiler options
489
    #
490
    if ( exists $GCCToolchain->{COMPILER_OPTIONS} )
491
    {
492
        CompileOptions('*', split(',',$GCCToolchain->{COMPILER_OPTIONS}) );
493
    }
227 dpurdie 494
}
495
 
4094 dpurdie 496
###############################################################################
497
#   ToolsetCTAGS()
498
#       This subroutine takes the user options and builds the rules
499
#       required to build the CTAGS database.
500
#
501
#   Arguments:
502
#       --xxx                   No arguments currently defined
503
#
504
#   Output:
505
#       [ctags:]
506
#           $(EXCTAGS)
507
#
508
###############################################################################
227 dpurdie 509
 
4094 dpurdie 510
sub ToolsetCTAGS
511
{
512
    EXCTAGS( @_ );
513
}
514
 
515
 
227 dpurdie 516
###############################################################################
517
#   ToolsetCC( $source, $obj, \@args )
518
#       This subroutine takes the user options and builds the rule(s)
519
#       required to compile the source file 'source' to 'obj'
520
#
521
###############################################################################
522
 
523
sub ToolsetCC
524
{
525
    my( $source, $obj, $pArgs ) = @_;
526
    my( $cflags, $file ) = "";
527
 
528
    foreach $_ ( @$pArgs ) {
529
        if (/--Shared$/) {                      # Building a 'shared' object
530
            $cflags  = "$cflags \$(SHCFLAGS)";
531
        } else {
532
            Message( "CC: unknown option $_ -- ignored\n" );
533
        }
534
    }
535
 
536
    MakePrint( "\n\t\$(CC)\n" );
537
    if ( $cflags )
538
    {                                           # object specific CFLAGS
539
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
540
        MakePrint( "\tCFLAGS +=$cflags\n" );
541
    }
542
 
543
    $file = StripExt( $obj );                   # Metric working file
544
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
4728 dpurdie 545
 
546
    if ( $UseGcov )
547
    {
548
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcno' );
549
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcda' );
550
    }
227 dpurdie 551
}
552
 
553
 
554
###############################################################################
555
#   ToolsetCCDepend( $depend, \@sources )
556
#       This subroutine takes the user options and builds the
557
#       rule(s) required to build the dependencies for the source
558
#       files 'sources' to 'depend'.
559
#
560
###############################################################################
561
 
562
sub ToolsetCCDepend
563
{
564
    MakePrint( "\t\$(CCDEPEND)\n" );
565
}
566
 
567
 
568
###############################################################################
569
#   ToolsetCXX( $source, $obj, \@args )
570
#       This subroutine takes the user options and builds the rule(s)
571
#       required to compile the source file 'source' to 'obj'
572
#
573
###############################################################################
574
 
575
sub ToolsetCXX
576
{
577
    my( $source, $obj, $pArgs ) = @_;
578
    my( $cflags, $file ) = "";
579
 
580
    foreach $_ ( @$pArgs ) {
581
        if (/--Shared$/) {                      # Building a 'shared' object
582
            $cflags  = "$cflags \$(SHCXXFLAGS)";
583
        } else {
584
            Message( "CXX: unknown option $_ -- ignored\n" );
585
        }
586
    }
587
 
588
    MakePrint( "\n\t\$(CXX)\n" );
589
    if ( $cflags )
590
    {                                           # object specific CFLAGS
591
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
592
        MakePrint( "\tCXXFLAGS +=$cflags\n" );
593
    }
594
 
595
    $file = StripExt( $obj );                   # Metric working file
596
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
4728 dpurdie 597
 
598
    if ( $UseGcov )
599
    {
600
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcno' );
601
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcda' );
602
    }
227 dpurdie 603
}
604
 
605
 
606
###############################################################################
607
#   ToolsetCXXDepend( $depend, \@sources )
608
#       This subroutine takes the user options and builds the
609
#       rule(s) required to build the dependencies for the source
610
#       files 'sources' to 'depend'.
611
#
612
###############################################################################
613
 
614
sub ToolsetCXXDepend
615
{
287 dpurdie 616
    ToolsetCCDepend();
227 dpurdie 617
}
618
 
619
 
620
###############################################################################
621
#   ToolsetAS( $source, $obj, \@args )
622
#       This subroutine takes the user options and builds the rule(s)
623
#       required to compile the source file 'source' to 'obj'
624
#
625
###############################################################################
626
 
627
sub ToolsetAS
628
{
629
    MakePrint( "\n\t\$(AS)\n" );
630
}
631
 
632
sub ToolsetASDepend
633
{
634
}
635
 
636
 
637
###############################################################################
638
#   ToolsetAR( $name, \@args, \@objs )
639
#       This subroutine takes the user options and builds the rules
640
#       required to build the library 'name'.
641
#
642
#   Arguments:
643
#       n/a
644
#
645
#   Output:
646
#       $(BINDIR)/name$.${a}:   .... ]
647
#           $(AR)
648
#
649
#       name_ld += ...  Linker command file
650
#           :
651
#
652
#       name_dp += ...  Dependency list
653
#           :
654
#
655
###############################################################################
656
 
657
sub ToolsetAR
658
{
659
    my( $name, $pArgs, $pObjs ) = @_;
660
 
661
#.. Parse arguments
662
#
663
    foreach $_ ( @$pArgs )
664
    {
665
        Message( "AR: unknown option $_ -- ignored\n" );
666
    }
667
 
668
#.. Target
669
#
670
    MakePrint( "#.. Library ($name)\n\n" );     # label
671
 
672
    MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).$::a:\t",
673
        "", "\\\n\t\t", ".$::o", @$pObjs );
674
 
675
#.. Build library rule (just append to standard rule)
676
#
677
    MakePrint( "\n\t\$(AR)\n\n" );
678
}
679
 
680
 
681
###############################################################################
682
#   ToolsetARMerge( $name, \@args, \@libs )
683
#       This subroutine takes the user options and builds the rules
684
#       required to build the library 'name' by merging the specified
685
#       libaries
686
#
687
#   Arguments:
688
#       --xxx                   No arguments currently defined
689
#
690
#   Output:
691
#       [ $(LIBDIR)/name$.${a}:   .... ]
692
#           ...
693
#
694
###############################################################################
695
 
696
sub ToolsetARMerge
697
{
698
    MakePrint( "\n\t\$(ARMERGE)\n\n" );
699
}
700
 
701
 
702
###############################################################################
289 dpurdie 703
#   ToolsetSHLD( $name, \@args, \@objs, \@libraries, $ver )
227 dpurdie 704
#       This subroutine takes the user options and builds the rules
339 dpurdie 705
#       required to link the Shared Library 'name'.
227 dpurdie 706
#
707
#   Arguments:
708
#   n/a
709
#
710
#   Output:
711
#       $(LIBDIR)/name:     $(LIBDIR)/shared
712
#           ln -s $shared $name
713
#
714
#       $(LIBDIR)/name.dep: $(GBE_OBJDIR)
715
#       $(LIBDIR)/name.dep: $(GBE_LIBDIR)
716
#       $(LIBDIR)/name.dep: $(GBE_PLATFORM).mk
717
#           $(SHLDDEPEND)
718
#
719
#       $(LIBDIR)/shared:   SHNAME=name
720
#       $(LIBDIR)/shared:   SHBASE=base
721
#       $(LIBDIR)/shared:   $(LIBDIR)/name.dep  \
722
#           $(OBJECTS)
723
#                           
724
#       ifneq "$(findstring $(IFLAG),23)" ""
725
#       -include            "$(LIBDIR)/name.dep"
726
#       endif
727
#
728
#       name_ld += ...
729
#           :
730
#
731
###############################################################################
732
 
733
sub ToolsetSHLD
734
{
289 dpurdie 735
    my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
373 dpurdie 736
    my( $linkname, $soname, $shared, $dbgname, $def, $def_pref, $multi_scan );
4034 dpurdie 737
    my $sosuffix;
738
    my $noVersionedLib = $::ScmCompilerOpts{'NO_VERSIONED_DLLS'};
227 dpurdie 739
 
4034 dpurdie 740
 
227 dpurdie 741
#.. Parse arguments
742
#
743
    foreach $_ ( @$pArgs )
744
    {
745
        if (/^--Def=(.*?)(\,(.*))?$/) {         # Library definition
746
            #
747
            #   Locate the Def file.
748
            #   If it is a generate file so it will be in the SRCS hash
749
            #   Otherwise the user will have to use Src to locate the file
750
            #
751
            $def = MakeSrcResolve($1);
752
            $def_pref = '';
753
            if ( $1 =~ m~\.def$~ ) {
754
                $def_pref = '--version-script='; # Old def file
755
            }
756
        } elsif ( /^--MultiScan/i ) {
757
            $multi_scan = 1;
758
 
759
        } elsif ( /^--NoMultiScan/i ) {
760
            $multi_scan = 0;
761
 
339 dpurdie 762
        } elsif ( /^--SoNameSuffix=(.*)/i ) {
763
            $sosuffix = $1;
764
 
4034 dpurdie 765
        } elsif (/^--NoVersionDll/i) {
766
            $noVersionedLib = 1;
767
 
227 dpurdie 768
        } else {
769
            Message( "SHLD: unknown option $_ -- ignored\n" );
770
        }
771
    }
772
 
4034 dpurdie 773
    #
774
    # Determine the 'soname' in none has been provided
775
    #
776
    $sosuffix = '.' . $ver
777
        unless ( defined $sosuffix );
778
    $sosuffix = ''
779
        if ( $noVersionedLib );
780
 
339 dpurdie 781
#.. Various library names
227 dpurdie 782
#
339 dpurdie 783
    $linkname = "$name\$(GBE_TYPE).$::so";
4034 dpurdie 784
    $shared = $noVersionedLib ? $linkname : "$linkname.$ver";
339 dpurdie 785
    $soname = "$linkname$sosuffix";
4034 dpurdie 786
 
373 dpurdie 787
    my $shared_path = "\$(LIBDIR)/${shared}";
788
    my $dbg_path =  $shared_path . '.dbg';
227 dpurdie 789
 
790
#.. Cleanup rules
791
#
792
#   map     Map file
793
#   ln      Link from LIBDIR to BINDIR
794
#
261 dpurdie 795
    ToolsetGenerate( "\$(LIBDIR)/${name}.map" );
796
    ToolsetGenerate( "\$(LIBDIR)/${shared}" );
339 dpurdie 797
    ToolsetGenerate( "\$(BINDIR)/${soname}" );
373 dpurdie 798
    ToolsetGenerate( $dbg_path );
227 dpurdie 799
 
800
#.. Build rules
801
#
802
#   name        Base name
803
#   shared      Library name, includes GBE_TYPE specification
804
#
805
    my ($io) = ToolsetPrinter::New();
335 dpurdie 806
    my $dep = $io->SetShldTarget($shared);
227 dpurdie 807
 
808
    $io->Label( "Shared library", $name );
339 dpurdie 809
    PackageShlibAddFiles( $name, "\$(LIBDIR)/$shared" );
373 dpurdie 810
    PackageShlibAddFiles( $name, $dbg_path );
4034 dpurdie 811
 
227 dpurdie 812
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
339 dpurdie 813
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
814
    $io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
321 dpurdie 815
    $io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
227 dpurdie 816
    $io->Prt( "\\\n\t\t$def" ) if($def);
373 dpurdie 817
    $io->Prt( "\n\t\$(SHLD)" );
818
    $io->Prt( "\n\t\$(call LDSTRIP,$shared_path,$dbg_path)\n\n" );
321 dpurdie 819
 
339 dpurdie 820
#
821
#   Create soft links
822
#       'Real Name' to its 'Link Name'
823
#       'Real Name' to 'SoName' in the BINDIR (for testing I think)
824
#       'Real Name' to 'SoName' in the LIBDIR (if different)
825
#
4034 dpurdie 826
    if ( $shared ne $linkname)
827
    {
828
        $io->Label( "Shared library Symbolic Links", $name );
829
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$linkname" );
830
        $io->Prt( "\$(LIBDIR)/$linkname:\t\\\n" .
831
                  "\t\t\$(GBE_BINDIR)\\\n" .
832
                  "\t\t\$(LIBDIR)/${shared}\n" .
833
                  "\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n\n" );
834
    }
835
 
836
    $io->Label( "Shared library BINDIR Symbolic Links", $name );
837
    PackageShlibAddFiles( $name, "\$(BINDIR)/$soname" );
838
    $io->Prt( "\$(BINDIR)/$soname:\t\\\n" .
339 dpurdie 839
              "\t\t\$(GBE_BINDIR)\\\n" .
840
              "\t\t\$(LIBDIR)/${shared}\n" .
4034 dpurdie 841
              "\t\$(AA_PRE)(rm -f \$@; ln -s ../\$(LIBDIR)/$shared \$@)\n\n" );
339 dpurdie 842
 
4034 dpurdie 843
    if ( $soname ne $shared )
339 dpurdie 844
    {
845
        $io->Label( "Shared library SoName Symbolic Links", $name );
846
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$soname" );
847
        $io->Prt( "\$(LIBDIR)/$soname:\t\\\n" .
848
                  "\t\t\$(GBE_LIBDIR)\\\n" .
849
                  "\t\t\$(LIBDIR)/${shared}\n" .
850
                  "\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n" );
851
    }
852
 
227 dpurdie 853
#.. Linker command file
854
#
855
#       Now the fun part... piecing together a variable $(name_shld)
856
#       which ends up in the command file.
857
#
339 dpurdie 858
    $io->Newline();
227 dpurdie 859
    $io->SetTag( "${name}_shld" );              # command tag
860
    $io->SetTerm( "\n" );
861
 
862
    $io->Label( "Linker commands", $name );     # label
863
 
864
                                                # object list
865
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
866
 
867
    ToolsetLibStd( $pLibs );                    # push standard libraries
868
 
869
    $io->Cmd( "-Wl,$def_pref$def" ) if ($def);
870
 
871
    $io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
872
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
873
    $io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
874
 
875
    $io->Newline();
876
 
335 dpurdie 877
    #.. Dependency link,
878
    #   Create a library dependency file
879
    #       Create command file to build applicaton dependency list
880
    #       from the list of dependent libraries
881
    #
882
    #       Create makefile directives to include the dependency
883
    #       list into the makefile.
884
    #
885
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, "\$(LIBDIR)/${shared}" );
339 dpurdie 886
    $io->SHLDDEPEND($name, $soname);
227 dpurdie 887
}
888
 
889
 
890
###############################################################################
271 dpurdie 891
# Function        : ToolsetLD
227 dpurdie 892
#
271 dpurdie 893
# Description     : Takes the user options and builds the rules required to
894
#                   link the program 'name'.
227 dpurdie 895
#
271 dpurdie 896
# Inputs          : $name           - base name of the program
897
#                   $pArgs          - Ref to program arguments
898
#                   $pObjs          - Ref to program objects
899
#                   $pLibs          - Ref to program library list
227 dpurdie 900
#
271 dpurdie 901
# Returns         : Nothing
227 dpurdie 902
#
271 dpurdie 903
# Output:         : Rules and recipes to create a program
904
#                       Create program rules and recipes
905
#                       Create linker input script
906
#                       Create library dependency list
907
#                       Include library dependency information
227 dpurdie 908
#
909
sub ToolsetLD
910
{
911
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
912
    my $static = $::ScmCompilerOpts{'STATIC_PROGS'};
913
    my $multi_scan;
914
 
915
#.. Parse arguments
916
#
917
    foreach $_ ( @$pArgs )
918
    {
919
        if ( m/^--Static$/ ) {
920
            $static = 1;
921
 
922
        } elsif ( m/^--Shared/ ) {
923
            $static = 0;
924
 
925
        } elsif ( /^--MultiScan/i ) {
926
            $multi_scan = 1;
927
 
928
        } elsif ( /^--NoMultiScan/i ) {
929
            $multi_scan = 0;
930
 
931
        } else {
932
            Message( "LD: unknown option $_ -- ignored\n" );
933
        }
934
    }
935
 
271 dpurdie 936
#.. Names of programs and components
937
#
938
    my $base = "\$(BINDIR)/${name}";
939
    my $full = $base . $::exe;
940
    my $map  = $base . '.map';
941
    my $ld  =  $base . '.ld';
373 dpurdie 942
    my $dbg =  $base . '.dbg';
271 dpurdie 943
 
227 dpurdie 944
#.. Cleanup rules
945
#
271 dpurdie 946
    ToolsetGenerate( $ld );
947
    ToolsetGenerate( $map );
373 dpurdie 948
    ToolsetGenerate( $dbg );
227 dpurdie 949
 
950
#.. Build rules
951
#
952
    my ($io) = ToolsetPrinter::New();
335 dpurdie 953
    my $dep = $io->SetLdTarget( $name );
227 dpurdie 954
 
271 dpurdie 955
    $io->Prt( "$full : $dep " );
956
    $io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
373 dpurdie 957
    $io->Prt( "\n\t\$(LD)" );
958
    $io->Prt( "\n\t\$(call LDSTRIP,$full,$dbg)\n\n" );
227 dpurdie 959
 
271 dpurdie 960
 
227 dpurdie 961
#.. Linker command file
962
#
963
#       Now the fun part... piecing together a variable $(name_ld)
964
#       which ends up in the command file.
965
#
966
    $io->SetTag( "${name}_ld" );                # macro tag
967
    $io->SetTerm( "\n" );
968
 
969
    $io->Label( "Linker commands", $name );     # label
970
 
971
    $io->Cmd( "-static" ) if ($static);         # Link as a static program
972
 
973
                                                # object list
974
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
975
 
976
    ToolsetLibStd( $pLibs );                    # push standard libraries
977
 
978
                                                # library list
979
    $io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
980
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
981
    $io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
982
 
983
    $io->Newline();
984
 
335 dpurdie 985
    #.. Dependency link,
986
    #   Create a library dependency file
987
    #       Create command file to build applicaton dependency list
988
    #       from the list of dependent libraries
989
    #
990
    #       Create makefile directives to include the dependency
991
    #       list into the makefile.
992
    #
993
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, $base );
994
    $io->LDDEPEND();
271 dpurdie 995
 
996
#.. Package up the program and other artifacts
997
#
998
    PackageProgAddFiles ( $name, $full );
373 dpurdie 999
    PackageProgAddFiles ( $name, $dbg );
271 dpurdie 1000
 
227 dpurdie 1001
}
1002
 
4778 dpurdie 1003
  #-------------------------------------------------------------------------------
1004
# Function        : ToolsetPostprocess 
1005
#
1006
# Description     : Last chance by the toolset to perform processing
1007
#                   All Directives have been processed
1008
#
1009
#                   If automated unit test are being used,
1010
#                   then we need to post process the results
1011
#
1012
# Inputs          : None
1013
#
1014
# Returns         : 
1015
#
1016
sub ToolsetPostprocess
1017
{
1018
    ToolsetPreprocessTests();
1019
    ToolsetPostprocessTests();
1020
    ToolsetCollateTestResults();
1021
}
227 dpurdie 1022
 
4728 dpurdie 1023
###############################################################################
1024
# Function        : ToolsetPreprocessTests
1025
#
1026
# Description     : 
1027
#
1028
# Inputs          : None
1029
#
1030
# Returns         : Nothing
1031
#
1032
# Output:         : Rules and recipes to run before unit tests
1033
#
1034
sub ToolsetPreprocessTests
1035
{
1036
    my ($io) = ToolsetPrinter::New();
1037
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1038
    {
4778 dpurdie 1039
        my $ruleName = 'preprocess_gcov_data';
4728 dpurdie 1040
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1041
        my $final=$finaldir . '/lcov-final.info';
1042
 
1043
        ToolsetGenerate( '$(OBJDIR)/lcov-baseline.info' );
4778 dpurdie 1044
        ToolsetAddUnitTestPreProcess($ruleName);
1045
        $io->PrtLn('.PHONY: ' . $ruleName );
1046
        $io->PrtLn($ruleName . ':' );
4728 dpurdie 1047
 
1048
        my $key;
1049
        my $value;
1050
        while(($key, $value) = each(%::OBJSOURCE))
1051
        {
1052
            $io->PrtLn("\t" . '$(XX_PRE)rm -f $(OBJDIR)/' . $key . ".gcda");
1053
        }
1054
        $io->PrtLn("\t" . '${XX_PRE}$(rm) -f ' . $final);
5731 dpurdie 1055
        $io->PrtLn("\t" . 'echo PREPROCESSING: $$PWD');
4728 dpurdie 1056
        $io->PrtLn("\t" . '${XX_PRE}lcov'
4835 dpurdie 1057
                        . $LcovExplicitBranch
1058
                        . ' --capture'
1059
                        . ' --initial'
1060
                        . ' --base-directory ' . $::Cwd
1061
                        . ' --directory $(OBJDIR)'
5731 dpurdie 1062
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
4835 dpurdie 1063
                        . ' --output-file $(OBJDIR)/lcov-baseline.info' );
5731 dpurdie 1064
        $io->PrtLn("\t" . 'echo PREPROCESSING DONE');
4778 dpurdie 1065
        $io->Newline();
4728 dpurdie 1066
    }
1067
}
1068
 
1069
 
1070
###############################################################################
1071
# Function        : ToolsetPostprocessTests
1072
#
1073
# Description     : 
1074
#
1075
# Inputs          : None
1076
#
1077
# Returns         : Nothing
1078
#
1079
# Output:         : Rules and recipes to run after the unit tests
1080
#
1081
sub ToolsetPostprocessTests
1082
{
1083
    my ($io) = ToolsetPrinter::New();
1084
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1085
    {
4778 dpurdie 1086
        my $ruleName = 'postprocess_gcov_data';
4728 dpurdie 1087
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1088
        my $final=$finaldir . '/lcov-final.info';
1089
 
1090
        ToolsetGenerate( '$(OBJDIR)/lcov-capture.info' );
1091
        ToolsetGenerate( $final );
4778 dpurdie 1092
        ToolsetAddUnitTestPostProcess($ruleName);
1093
 
1094
        $io->PrtLn('.PHONY: ' . $ruleName );
1095
        $io->PrtLn($ruleName . ':' );
4728 dpurdie 1096
        $io->PrtLn("\t" . '$(eval GCDA_COUNT := $(shell find $(OBJDIR) -name "*.gcda"))');
1097
 
1098
        $io->PrtLn  ("\t" . '$(XX_PRE)$(mkdir) -p ' . $finaldir);
1099
        $io->PrtPart("\t" . '$(XX_PRE)if [ "$(GCDA_COUNT)" = "" ]; then');
1100
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
1101
        $io->PrtPart("\t\t\t" . '$(cp) $(OBJDIR)/lcov-baseline.info ' . $final . ';');
1102
        $io->PrtPart("\t\t" . 'else');
1103
        $io->PrtPart("\t\t\t" . 'lcov'
4835 dpurdie 1104
                          . $LcovExplicitBranch
4728 dpurdie 1105
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1106
                          . ' --add-tracefile ' . $final
5731 dpurdie 1107
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
4728 dpurdie 1108
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1109
                          . ';'); 
1110
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
1111
        $io->PrtPart("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . ';');
1112
        $io->PrtPart("\t\t" . 'fi' . ';');
1113
        $io->PrtPart("\t" . 'else');
1114
        $io->PrtPart("\t\t" . 'lcov'
4835 dpurdie 1115
                          . $LcovExplicitBranch
4728 dpurdie 1116
                        . ' --capture'
1117
                        . ' --base-directory ' . $::Cwd
1118
                        . ' --directory $(OBJDIR)'
5731 dpurdie 1119
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
4728 dpurdie 1120
                        . ' --output-file $(OBJDIR)/lcov-capture.info' 
1121
                        . ';'); 
1122
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
1123
        $io->PrtPart("\t\t\t" . 'lcov'
4835 dpurdie 1124
                          . $LcovExplicitBranch
4728 dpurdie 1125
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1126
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
5731 dpurdie 1127
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
4728 dpurdie 1128
                          . ' --output-file ' .  $final
1129
                          . ';'); 
1130
        $io->PrtPart("\t\t" . 'else');
1131
        $io->PrtPart("\t\t\t" . 'lcov'
4835 dpurdie 1132
                          . $LcovExplicitBranch
4728 dpurdie 1133
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1134
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
1135
                          . ' --add-tracefile ' . $final
5731 dpurdie 1136
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
4728 dpurdie 1137
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1138
                          . ';'); 
1139
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
1140
        $io->PrtPart("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . ';');
1141
        $io->PrtPart("\t\t" . 'fi' . ';');
1142
        $io->PrtLn  ("\t" . 'fi');
4778 dpurdie 1143
        $io->Newline();
4728 dpurdie 1144
    }
1145
}
1146
 
1147
 
1148
###############################################################################
1149
# Function        : ToolsetCollateTestResults
1150
#
1151
# Description     : 
1152
#
1153
# Inputs          : None
1154
#
1155
# Returns         : Nothing
1156
#
1157
# Output:         : Rules and recipes to run after unit test result 
1158
#                   postprocessing.
1159
#
1160
sub ToolsetCollateTestResults
1161
{
1162
    my ($io) = ToolsetPrinter::New();
1163
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1164
    {
4778 dpurdie 1165
        my $ruleName = 'collate_gcov_results';
4728 dpurdie 1166
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1167
        my $final=$finaldir . '/lcov-final.info';
4778 dpurdie 1168
 
1169
        ToolsetAddUnitTestCollateProcess($ruleName);
4728 dpurdie 1170
 
1171
        my $reportdir='$(PKGDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1172
        my $reportindex=$reportdir . '/index.html';
1173
 
4778 dpurdie 1174
        $io->PrtLn('.PHONY: ' . $ruleName );
1175
        $io->PrtLn($ruleName . ': ' . $reportindex);
4728 dpurdie 1176
        $io->Newline();
1177
        $io->PrtLn($reportindex . ': ' . $final);
1178
        $io->PrtLn("\t" . 'genhtml'
1179
                      . ' --frames'
1180
                      . ' --show-details'
1181
                      . ' --function-coverage'
1182
                      . ' --branch-coverage'
1183
                      . ' --output-directory ' . $reportdir
1184
                      . ' --legend'
1185
                      . ' --demangle-cpp'
1186
                      . ' ' . $final);
4778 dpurdie 1187
        $io->Newline();
4728 dpurdie 1188
    }
1189
}
1190
 
1191
 
1192
###############################################################################
1193
#   ToolsetARLINT( $name, \@args, \@objs )
1194
#       This subroutine takes the user options and builds the rules
1195
#       required to lint the static library 'name'.
1196
#
1197
#   Arguments:
1198
#       --xxx                   No arguments currently defined
1199
#
1200
#   Output:
1201
#       [ $(LIBDIR)/name$_lint:   .... ]
1202
#           $(ARLINT)
1203
#
1204
###############################################################################
1205
 
1206
sub ToolsetARLINT
1207
{
1208
    if ( $UseCppcheck )
1209
    {
1210
        CppcheckAR( @_ );
1211
    }
1212
}
1213
 
1214
 
1215
###############################################################################
1216
#   ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
1217
#       This subroutine takes the user options and builds the rules
1218
#       required to lint the shared library 'name'.
1219
#
1220
#   Arguments:
1221
#       (none)
1222
#
1223
#   Output:
1224
#       [ $(LIBDIR)/$name_lint:   .... ]
1225
#           $(SHLIBLINT)
1226
#
1227
###############################################################################
1228
 
1229
sub ToolsetSHLDLINT
1230
{
1231
    if ( $UseCppcheck )
1232
    {
1233
        CppcheckSHLD( @_ );
1234
    }
1235
}
1236
 
1237
 
1238
###############################################################################
1239
#   ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
1240
#       This subroutine takes the user options and builds the rules
1241
#       required to lint the program 'name'.
1242
#
1243
#   Arguments:
1244
#       (none)
1245
#
1246
#   Output:
1247
#       [ $(BINDIR)/$name_lint:   .... ]
1248
#           $(LDLINT)
1249
#
1250
###############################################################################
1251
 
1252
sub ToolsetLDLINT
1253
{
1254
    if ( $UseCppcheck )
1255
    {
1256
        CppcheckLD( @_ );
1257
    }
1258
}
1259
 
227 dpurdie 1260
########################################################################
1261
#
1262
#   Push standard "system" libraries. This is a helper function
1263
#   used within this toolset.
1264
#
1265
#   Arguments:
1266
#       $plib       Reference to library array.
1267
#
1268
########################################################################
1269
 
1270
sub ToolsetLibStd
1271
{
1272
}
1273
 
1274
 
1275
########################################################################
1276
#
1277
#   Generate a linker object recipe.  This is a helper function used 
1278
#   within this toolset.
1279
#
1280
#   Arguments:
1281
#       $io         I/O stream
1282
#
1283
#       $target     Name of the target
1284
#
1285
#       $obj        Library specification
1286
#
1287
########################################################################
1288
 
1289
sub ToolsetObjRecipe
1290
{
1291
    my ($io, $target, $obj) = @_;
1292
 
1293
    $io->Cmd( "\$(strip $obj).$::o" );
1294
}
1295
 
1296
 
1297
###############################################################################
1298
#
1299
#   Parse a linker lib list
1300
#   This is a helper function used within this toolset
1301
#
1302
#   Arguments:
1303
#       $target     Name of the target
1304
#
1305
#       $lib        Library specification
1306
#
1307
#       $tag        Tag (user specified)
1308
#
1309
#       $dp         If building a depend list, the full target name.
1310
#
1311
###############################################################################
1312
 
1313
sub ToolsetLibRecipe
1314
{
1315
    my ($io, $target, $lib, $dp) = @_;
1316
 
1317
    if ( ! defined($dp) ) {                     # linker
1318
        $lib =~ s/^lib//;                       # .. remove leading 'lib'
1319
        $io->Cmd( "-l$lib" );
1320
 
1321
    } else {                                    # depend
1322
        $io->Cmd( "$dp:\t@(vlib2,$lib,GCC_LIB)" );
1323
 
1324
    }
1325
}
1326
 
1327
#.. Successful termination
1328
1;
1329