Subversion Repositories DevTools

Rev

Rev 5716 | Rev 5731 | 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',
5726 dpurdie 78
       CXX_OPTS     => '-std=c++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-',
5726 dpurdie 86
       CXX_OPTS     => '-std=c++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',
5726 dpurdie 103
       CXX_OPTS     => '-std=c++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
{
4034 dpurdie 185
    my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCObjCopy );
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';
373 dpurdie 378
        $GCCObjCopy =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'objcopy';
369 dpurdie 379
        $GCCFlags = $GCCToolchain->{CC_OPTS};
4034 dpurdie 380
        $GCCFlagsP = $GCCToolchain->{CC_OPTSP};
381
        $GCCFlagsD = $GCCToolchain->{CC_OPTSD};
5726 dpurdie 382
        $GCCXXFlags = $GCCToolchain->{CXX_OPTS};
3967 dpurdie 383
        $PkgArch = $GCCToolchain->{PACKAGE_ARCH};
227 dpurdie 384
    }
385
    else
386
    {
373 dpurdie 387
        $GCCRoot = '/usr';
388
        $GCCBin = 'gcc';
389
        $GCCAr = 'ar';
390
        $GCCObjCopy =  'objcopy';
227 dpurdie 391
    }
4728 dpurdie 392
 
393
    #
394
    #   When running under gcov we need to instruct GCC to perform code coverage
395
    #   generation in both C flags and LD flags
396
    #
397
    if ( $UseGcov )
398
    {
399
        $GCCFlags .= ' -coverage';
400
        $LDFlags  .= ' -coverage';
401
    }
402
 
403
    #
404
    #   When running with cppcheck we need to include it in our environment
405
    #
406
    if ( $UseCppcheck )
407
    {
408
        ToolsetRequire( "cppcheck" );
409
        PlatformDefine( "CPPCHECK_PLATFORM := unix32" );
410
    }
411
 
227 dpurdie 412
 
413
#.. Define GCC environment
414
#
415
    PlatformDefine( "
416
#################################################
417
# GCC toolchain definitions 
418
#
419
#..");
369 dpurdie 420
    PlatformDefine( "GCC_TARGET         := $GCCTarget" );
421
    PlatformDefine( "GCC_ROOT           := $GCCRoot" );
422
    PlatformDefine( "GCC_CC             := $GCCBin" );
423
    PlatformDefine( "GCC_AR             := $GCCAr" );
373 dpurdie 424
    PlatformDefine( "GCC_OBJCOPY        := $GCCObjCopy" );
369 dpurdie 425
    PlatformDefine( "GCC_CFLAGS         := $GCCFlags" ) if defined $GCCFlags;
4034 dpurdie 426
    PlatformDefine( "GCC_CFLAGSP        := $GCCFlagsP" ) if defined $GCCFlagsP;
427
    PlatformDefine( "GCC_CFLAGSD        := $GCCFlagsD" ) if defined $GCCFlagsD;
4728 dpurdie 428
    PlatformDefine( "GCC_LDFLAGS        := $LDFlags" ) if defined $LDFlags;
5726 dpurdie 429
    PlatformDefine( "GCC_CXXFLAGS       := $GCCXXFlags" ) if defined $GCCXXFlags;
369 dpurdie 430
 
5726 dpurdie 431
 
227 dpurdie 432
    #
433
    #   Required since this toolset advertises: ScmToolsetCompilerPath
434
    #
369 dpurdie 435
    PlatformDefine( "SCM_COMPILERPATH   := \$\{GCC_CC\}" );
3967 dpurdie 436
 
437
    #
438
    #   Sanity checking
439
    #
440
    PlatformDefine( "GCC_EVERSION       := " . $GCCToolchain->{VERSION} ) if defined $GCCToolchain->{VERSION};
441
    PlatformDefine( "GCC_EMACHINE       := " . $GCCToolchain->{MACHINE} ) if defined $GCCToolchain->{MACHINE};
442
 
443
    #
444
    #   Option indication of packaging architecture
445
    #   Used by non-embedded systems for packaging. See debian_packager
446
    #
447
    PlatformDefine( "PACKAGE_ARCH       := $PkgArch" ) if (defined $PkgArch);
369 dpurdie 448
    PlatformDefine( "" );
227 dpurdie 449
 
450
#.. Piece the world together
451
#
3967 dpurdie 452
    Init( 'gcc' );
227 dpurdie 453
    ToolsetDefines( "gcc.def" );
454
    ToolsetRules( "gcc.rul" );
455
    ToolsetRules( "standard.rul" );
456
 
4094 dpurdie 457
 
458
    PlatformDefine( "CTAGS_EXE:= ctags" );
459
    ToolsetRequire( "exctags" );                # and Exuberant Ctags
460
 
227 dpurdie 461
#   Create a standard data structure
462
#   This is a hash of hashes
463
#       The first hash is keyed by CompileOption keyword
464
#       The second hash contains pairs of values to set or remove
465
#
466
    %::ScmToolsetCompilerOptions =
467
    (
468
        #
469
        #   Control the thread model to use
470
        #   This will affect the compiler options and the linker options
471
        #
472
        'staticprogs'        => { 'STATIC_PROGS' , '1' },      # Progams link staticlly
473
        'no_staticprogs'     => { 'STATIC_PROGS' , undef },    # Default
4034 dpurdie 474
        'noversiondll'       => { 'NO_VERSIONED_DLLS', 1 },    # Matches usage elsewhere
5115 dpurdie 475
        'pic'                => { 'GEN_PIC' , '1' },           # Force PIC for static libs
476
        'nopic'              => { 'GEN_PIC' , undef },         # No Pic on Static libs
227 dpurdie 477
    );
478
 
479
    #
480
    #   Set default options
481
    #
482
    $::ScmCompilerOpts{'STATIC_PROGS'} = undef;
4034 dpurdie 483
    $::ScmCompilerOpts{'NO_VERSIONED_DLLS'} = undef;
484
 
485
    #
486
    #   Process toolset-specfic compiler options
487
    #
488
    if ( exists $GCCToolchain->{COMPILER_OPTIONS} )
489
    {
490
        CompileOptions('*', split(',',$GCCToolchain->{COMPILER_OPTIONS}) );
491
    }
227 dpurdie 492
}
493
 
4094 dpurdie 494
###############################################################################
495
#   ToolsetCTAGS()
496
#       This subroutine takes the user options and builds the rules
497
#       required to build the CTAGS database.
498
#
499
#   Arguments:
500
#       --xxx                   No arguments currently defined
501
#
502
#   Output:
503
#       [ctags:]
504
#           $(EXCTAGS)
505
#
506
###############################################################################
227 dpurdie 507
 
4094 dpurdie 508
sub ToolsetCTAGS
509
{
510
    EXCTAGS( @_ );
511
}
512
 
513
 
227 dpurdie 514
###############################################################################
515
#   ToolsetCC( $source, $obj, \@args )
516
#       This subroutine takes the user options and builds the rule(s)
517
#       required to compile the source file 'source' to 'obj'
518
#
519
###############################################################################
520
 
521
sub ToolsetCC
522
{
523
    my( $source, $obj, $pArgs ) = @_;
524
    my( $cflags, $file ) = "";
525
 
526
    foreach $_ ( @$pArgs ) {
527
        if (/--Shared$/) {                      # Building a 'shared' object
528
            $cflags  = "$cflags \$(SHCFLAGS)";
529
        } else {
530
            Message( "CC: unknown option $_ -- ignored\n" );
531
        }
532
    }
533
 
534
    MakePrint( "\n\t\$(CC)\n" );
535
    if ( $cflags )
536
    {                                           # object specific CFLAGS
537
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
538
        MakePrint( "\tCFLAGS +=$cflags\n" );
539
    }
540
 
541
    $file = StripExt( $obj );                   # Metric working file
542
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
4728 dpurdie 543
 
544
    if ( $UseGcov )
545
    {
546
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcno' );
547
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcda' );
548
    }
227 dpurdie 549
}
550
 
551
 
552
###############################################################################
553
#   ToolsetCCDepend( $depend, \@sources )
554
#       This subroutine takes the user options and builds the
555
#       rule(s) required to build the dependencies for the source
556
#       files 'sources' to 'depend'.
557
#
558
###############################################################################
559
 
560
sub ToolsetCCDepend
561
{
562
    MakePrint( "\t\$(CCDEPEND)\n" );
563
}
564
 
565
 
566
###############################################################################
567
#   ToolsetCXX( $source, $obj, \@args )
568
#       This subroutine takes the user options and builds the rule(s)
569
#       required to compile the source file 'source' to 'obj'
570
#
571
###############################################################################
572
 
573
sub ToolsetCXX
574
{
575
    my( $source, $obj, $pArgs ) = @_;
576
    my( $cflags, $file ) = "";
577
 
578
    foreach $_ ( @$pArgs ) {
579
        if (/--Shared$/) {                      # Building a 'shared' object
580
            $cflags  = "$cflags \$(SHCXXFLAGS)";
581
        } else {
582
            Message( "CXX: unknown option $_ -- ignored\n" );
583
        }
584
    }
585
 
586
    MakePrint( "\n\t\$(CXX)\n" );
587
    if ( $cflags )
588
    {                                           # object specific CFLAGS
589
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:" );
590
        MakePrint( "\tCXXFLAGS +=$cflags\n" );
591
    }
592
 
593
    $file = StripExt( $obj );                   # Metric working file
594
    ToolsetGenerate( "\$(OBJDIR)/$file.met" );
4728 dpurdie 595
 
596
    if ( $UseGcov )
597
    {
598
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcno' );
599
        ToolsetGenerate( '$(OBJDIR)/' . $file . '.gcda' );
600
    }
227 dpurdie 601
}
602
 
603
 
604
###############################################################################
605
#   ToolsetCXXDepend( $depend, \@sources )
606
#       This subroutine takes the user options and builds the
607
#       rule(s) required to build the dependencies for the source
608
#       files 'sources' to 'depend'.
609
#
610
###############################################################################
611
 
612
sub ToolsetCXXDepend
613
{
287 dpurdie 614
    ToolsetCCDepend();
227 dpurdie 615
}
616
 
617
 
618
###############################################################################
619
#   ToolsetAS( $source, $obj, \@args )
620
#       This subroutine takes the user options and builds the rule(s)
621
#       required to compile the source file 'source' to 'obj'
622
#
623
###############################################################################
624
 
625
sub ToolsetAS
626
{
627
    MakePrint( "\n\t\$(AS)\n" );
628
}
629
 
630
sub ToolsetASDepend
631
{
632
}
633
 
634
 
635
###############################################################################
636
#   ToolsetAR( $name, \@args, \@objs )
637
#       This subroutine takes the user options and builds the rules
638
#       required to build the library 'name'.
639
#
640
#   Arguments:
641
#       n/a
642
#
643
#   Output:
644
#       $(BINDIR)/name$.${a}:   .... ]
645
#           $(AR)
646
#
647
#       name_ld += ...  Linker command file
648
#           :
649
#
650
#       name_dp += ...  Dependency list
651
#           :
652
#
653
###############################################################################
654
 
655
sub ToolsetAR
656
{
657
    my( $name, $pArgs, $pObjs ) = @_;
658
 
659
#.. Parse arguments
660
#
661
    foreach $_ ( @$pArgs )
662
    {
663
        Message( "AR: unknown option $_ -- ignored\n" );
664
    }
665
 
666
#.. Target
667
#
668
    MakePrint( "#.. Library ($name)\n\n" );     # label
669
 
670
    MakeEntry( "\$(LIBDIR)/$name\$(GBE_TYPE).$::a:\t",
671
        "", "\\\n\t\t", ".$::o", @$pObjs );
672
 
673
#.. Build library rule (just append to standard rule)
674
#
675
    MakePrint( "\n\t\$(AR)\n\n" );
676
}
677
 
678
 
679
###############################################################################
680
#   ToolsetARMerge( $name, \@args, \@libs )
681
#       This subroutine takes the user options and builds the rules
682
#       required to build the library 'name' by merging the specified
683
#       libaries
684
#
685
#   Arguments:
686
#       --xxx                   No arguments currently defined
687
#
688
#   Output:
689
#       [ $(LIBDIR)/name$.${a}:   .... ]
690
#           ...
691
#
692
###############################################################################
693
 
694
sub ToolsetARMerge
695
{
696
    MakePrint( "\n\t\$(ARMERGE)\n\n" );
697
}
698
 
699
 
700
###############################################################################
289 dpurdie 701
#   ToolsetSHLD( $name, \@args, \@objs, \@libraries, $ver )
227 dpurdie 702
#       This subroutine takes the user options and builds the rules
339 dpurdie 703
#       required to link the Shared Library 'name'.
227 dpurdie 704
#
705
#   Arguments:
706
#   n/a
707
#
708
#   Output:
709
#       $(LIBDIR)/name:     $(LIBDIR)/shared
710
#           ln -s $shared $name
711
#
712
#       $(LIBDIR)/name.dep: $(GBE_OBJDIR)
713
#       $(LIBDIR)/name.dep: $(GBE_LIBDIR)
714
#       $(LIBDIR)/name.dep: $(GBE_PLATFORM).mk
715
#           $(SHLDDEPEND)
716
#
717
#       $(LIBDIR)/shared:   SHNAME=name
718
#       $(LIBDIR)/shared:   SHBASE=base
719
#       $(LIBDIR)/shared:   $(LIBDIR)/name.dep  \
720
#           $(OBJECTS)
721
#                           
722
#       ifneq "$(findstring $(IFLAG),23)" ""
723
#       -include            "$(LIBDIR)/name.dep"
724
#       endif
725
#
726
#       name_ld += ...
727
#           :
728
#
729
###############################################################################
730
 
731
sub ToolsetSHLD
732
{
289 dpurdie 733
    my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
373 dpurdie 734
    my( $linkname, $soname, $shared, $dbgname, $def, $def_pref, $multi_scan );
4034 dpurdie 735
    my $sosuffix;
736
    my $noVersionedLib = $::ScmCompilerOpts{'NO_VERSIONED_DLLS'};
227 dpurdie 737
 
4034 dpurdie 738
 
227 dpurdie 739
#.. Parse arguments
740
#
741
    foreach $_ ( @$pArgs )
742
    {
743
        if (/^--Def=(.*?)(\,(.*))?$/) {         # Library definition
744
            #
745
            #   Locate the Def file.
746
            #   If it is a generate file so it will be in the SRCS hash
747
            #   Otherwise the user will have to use Src to locate the file
748
            #
749
            $def = MakeSrcResolve($1);
750
            $def_pref = '';
751
            if ( $1 =~ m~\.def$~ ) {
752
                $def_pref = '--version-script='; # Old def file
753
            }
754
        } elsif ( /^--MultiScan/i ) {
755
            $multi_scan = 1;
756
 
757
        } elsif ( /^--NoMultiScan/i ) {
758
            $multi_scan = 0;
759
 
339 dpurdie 760
        } elsif ( /^--SoNameSuffix=(.*)/i ) {
761
            $sosuffix = $1;
762
 
4034 dpurdie 763
        } elsif (/^--NoVersionDll/i) {
764
            $noVersionedLib = 1;
765
 
227 dpurdie 766
        } else {
767
            Message( "SHLD: unknown option $_ -- ignored\n" );
768
        }
769
    }
770
 
4034 dpurdie 771
    #
772
    # Determine the 'soname' in none has been provided
773
    #
774
    $sosuffix = '.' . $ver
775
        unless ( defined $sosuffix );
776
    $sosuffix = ''
777
        if ( $noVersionedLib );
778
 
339 dpurdie 779
#.. Various library names
227 dpurdie 780
#
339 dpurdie 781
    $linkname = "$name\$(GBE_TYPE).$::so";
4034 dpurdie 782
    $shared = $noVersionedLib ? $linkname : "$linkname.$ver";
339 dpurdie 783
    $soname = "$linkname$sosuffix";
4034 dpurdie 784
 
373 dpurdie 785
    my $shared_path = "\$(LIBDIR)/${shared}";
786
    my $dbg_path =  $shared_path . '.dbg';
227 dpurdie 787
 
788
#.. Cleanup rules
789
#
790
#   map     Map file
791
#   ln      Link from LIBDIR to BINDIR
792
#
261 dpurdie 793
    ToolsetGenerate( "\$(LIBDIR)/${name}.map" );
794
    ToolsetGenerate( "\$(LIBDIR)/${shared}" );
339 dpurdie 795
    ToolsetGenerate( "\$(BINDIR)/${soname}" );
373 dpurdie 796
    ToolsetGenerate( $dbg_path );
227 dpurdie 797
 
798
#.. Build rules
799
#
800
#   name        Base name
801
#   shared      Library name, includes GBE_TYPE specification
802
#
803
    my ($io) = ToolsetPrinter::New();
335 dpurdie 804
    my $dep = $io->SetShldTarget($shared);
227 dpurdie 805
 
806
    $io->Label( "Shared library", $name );
339 dpurdie 807
    PackageShlibAddFiles( $name, "\$(LIBDIR)/$shared" );
373 dpurdie 808
    PackageShlibAddFiles( $name, $dbg_path );
4034 dpurdie 809
 
227 dpurdie 810
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
339 dpurdie 811
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
812
    $io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
321 dpurdie 813
    $io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
227 dpurdie 814
    $io->Prt( "\\\n\t\t$def" ) if($def);
373 dpurdie 815
    $io->Prt( "\n\t\$(SHLD)" );
816
    $io->Prt( "\n\t\$(call LDSTRIP,$shared_path,$dbg_path)\n\n" );
321 dpurdie 817
 
339 dpurdie 818
#
819
#   Create soft links
820
#       'Real Name' to its 'Link Name'
821
#       'Real Name' to 'SoName' in the BINDIR (for testing I think)
822
#       'Real Name' to 'SoName' in the LIBDIR (if different)
823
#
4034 dpurdie 824
    if ( $shared ne $linkname)
825
    {
826
        $io->Label( "Shared library Symbolic Links", $name );
827
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$linkname" );
828
        $io->Prt( "\$(LIBDIR)/$linkname:\t\\\n" .
829
                  "\t\t\$(GBE_BINDIR)\\\n" .
830
                  "\t\t\$(LIBDIR)/${shared}\n" .
831
                  "\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n\n" );
832
    }
833
 
834
    $io->Label( "Shared library BINDIR Symbolic Links", $name );
835
    PackageShlibAddFiles( $name, "\$(BINDIR)/$soname" );
836
    $io->Prt( "\$(BINDIR)/$soname:\t\\\n" .
339 dpurdie 837
              "\t\t\$(GBE_BINDIR)\\\n" .
838
              "\t\t\$(LIBDIR)/${shared}\n" .
4034 dpurdie 839
              "\t\$(AA_PRE)(rm -f \$@; ln -s ../\$(LIBDIR)/$shared \$@)\n\n" );
339 dpurdie 840
 
4034 dpurdie 841
    if ( $soname ne $shared )
339 dpurdie 842
    {
843
        $io->Label( "Shared library SoName Symbolic Links", $name );
844
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$soname" );
845
        $io->Prt( "\$(LIBDIR)/$soname:\t\\\n" .
846
                  "\t\t\$(GBE_LIBDIR)\\\n" .
847
                  "\t\t\$(LIBDIR)/${shared}\n" .
848
                  "\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n" );
849
    }
850
 
227 dpurdie 851
#.. Linker command file
852
#
853
#       Now the fun part... piecing together a variable $(name_shld)
854
#       which ends up in the command file.
855
#
339 dpurdie 856
    $io->Newline();
227 dpurdie 857
    $io->SetTag( "${name}_shld" );              # command tag
858
    $io->SetTerm( "\n" );
859
 
860
    $io->Label( "Linker commands", $name );     # label
861
 
862
                                                # object list
863
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
864
 
865
    ToolsetLibStd( $pLibs );                    # push standard libraries
866
 
867
    $io->Cmd( "-Wl,$def_pref$def" ) if ($def);
868
 
869
    $io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
870
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
871
    $io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
872
 
873
    $io->Newline();
874
 
335 dpurdie 875
    #.. Dependency link,
876
    #   Create a library dependency file
877
    #       Create command file to build applicaton dependency list
878
    #       from the list of dependent libraries
879
    #
880
    #       Create makefile directives to include the dependency
881
    #       list into the makefile.
882
    #
883
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, "\$(LIBDIR)/${shared}" );
339 dpurdie 884
    $io->SHLDDEPEND($name, $soname);
227 dpurdie 885
}
886
 
887
 
888
###############################################################################
271 dpurdie 889
# Function        : ToolsetLD
227 dpurdie 890
#
271 dpurdie 891
# Description     : Takes the user options and builds the rules required to
892
#                   link the program 'name'.
227 dpurdie 893
#
271 dpurdie 894
# Inputs          : $name           - base name of the program
895
#                   $pArgs          - Ref to program arguments
896
#                   $pObjs          - Ref to program objects
897
#                   $pLibs          - Ref to program library list
227 dpurdie 898
#
271 dpurdie 899
# Returns         : Nothing
227 dpurdie 900
#
271 dpurdie 901
# Output:         : Rules and recipes to create a program
902
#                       Create program rules and recipes
903
#                       Create linker input script
904
#                       Create library dependency list
905
#                       Include library dependency information
227 dpurdie 906
#
907
sub ToolsetLD
908
{
909
    my( $name, $pArgs, $pObjs, $pLibs ) = @_;
910
    my $static = $::ScmCompilerOpts{'STATIC_PROGS'};
911
    my $multi_scan;
912
 
913
#.. Parse arguments
914
#
915
    foreach $_ ( @$pArgs )
916
    {
917
        if ( m/^--Static$/ ) {
918
            $static = 1;
919
 
920
        } elsif ( m/^--Shared/ ) {
921
            $static = 0;
922
 
923
        } elsif ( /^--MultiScan/i ) {
924
            $multi_scan = 1;
925
 
926
        } elsif ( /^--NoMultiScan/i ) {
927
            $multi_scan = 0;
928
 
929
        } else {
930
            Message( "LD: unknown option $_ -- ignored\n" );
931
        }
932
    }
933
 
271 dpurdie 934
#.. Names of programs and components
935
#
936
    my $base = "\$(BINDIR)/${name}";
937
    my $full = $base . $::exe;
938
    my $map  = $base . '.map';
939
    my $ld  =  $base . '.ld';
373 dpurdie 940
    my $dbg =  $base . '.dbg';
271 dpurdie 941
 
227 dpurdie 942
#.. Cleanup rules
943
#
271 dpurdie 944
    ToolsetGenerate( $ld );
945
    ToolsetGenerate( $map );
373 dpurdie 946
    ToolsetGenerate( $dbg );
227 dpurdie 947
 
948
#.. Build rules
949
#
950
    my ($io) = ToolsetPrinter::New();
335 dpurdie 951
    my $dep = $io->SetLdTarget( $name );
227 dpurdie 952
 
271 dpurdie 953
    $io->Prt( "$full : $dep " );
954
    $io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
373 dpurdie 955
    $io->Prt( "\n\t\$(LD)" );
956
    $io->Prt( "\n\t\$(call LDSTRIP,$full,$dbg)\n\n" );
227 dpurdie 957
 
271 dpurdie 958
 
227 dpurdie 959
#.. Linker command file
960
#
961
#       Now the fun part... piecing together a variable $(name_ld)
962
#       which ends up in the command file.
963
#
964
    $io->SetTag( "${name}_ld" );                # macro tag
965
    $io->SetTerm( "\n" );
966
 
967
    $io->Label( "Linker commands", $name );     # label
968
 
969
    $io->Cmd( "-static" ) if ($static);         # Link as a static program
970
 
971
                                                # object list
972
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
973
 
974
    ToolsetLibStd( $pLibs );                    # push standard libraries
975
 
976
                                                # library list
977
    $io->Cmd( "-Wl,--start-group" ) if ($multi_scan);
978
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
979
    $io->Cmd( "-Wl,--end-group" ) if ($multi_scan);
980
 
981
    $io->Newline();
982
 
335 dpurdie 983
    #.. Dependency link,
984
    #   Create a library dependency file
985
    #       Create command file to build applicaton dependency list
986
    #       from the list of dependent libraries
987
    #
988
    #       Create makefile directives to include the dependency
989
    #       list into the makefile.
990
    #
991
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, $base );
992
    $io->LDDEPEND();
271 dpurdie 993
 
994
#.. Package up the program and other artifacts
995
#
996
    PackageProgAddFiles ( $name, $full );
373 dpurdie 997
    PackageProgAddFiles ( $name, $dbg );
271 dpurdie 998
 
227 dpurdie 999
}
1000
 
4778 dpurdie 1001
  #-------------------------------------------------------------------------------
1002
# Function        : ToolsetPostprocess 
1003
#
1004
# Description     : Last chance by the toolset to perform processing
1005
#                   All Directives have been processed
1006
#
1007
#                   If automated unit test are being used,
1008
#                   then we need to post process the results
1009
#
1010
# Inputs          : None
1011
#
1012
# Returns         : 
1013
#
1014
sub ToolsetPostprocess
1015
{
1016
    ToolsetPreprocessTests();
1017
    ToolsetPostprocessTests();
1018
    ToolsetCollateTestResults();
1019
}
227 dpurdie 1020
 
4728 dpurdie 1021
###############################################################################
1022
# Function        : ToolsetPreprocessTests
1023
#
1024
# Description     : 
1025
#
1026
# Inputs          : None
1027
#
1028
# Returns         : Nothing
1029
#
1030
# Output:         : Rules and recipes to run before unit tests
1031
#
1032
sub ToolsetPreprocessTests
1033
{
1034
    my ($io) = ToolsetPrinter::New();
1035
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1036
    {
4778 dpurdie 1037
        my $ruleName = 'preprocess_gcov_data';
4728 dpurdie 1038
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1039
        my $final=$finaldir . '/lcov-final.info';
1040
 
1041
        ToolsetGenerate( '$(OBJDIR)/lcov-baseline.info' );
4778 dpurdie 1042
        ToolsetAddUnitTestPreProcess($ruleName);
1043
        $io->PrtLn('.PHONY: ' . $ruleName );
1044
        $io->PrtLn($ruleName . ':' );
4728 dpurdie 1045
 
1046
        my $key;
1047
        my $value;
1048
        while(($key, $value) = each(%::OBJSOURCE))
1049
        {
1050
            $io->PrtLn("\t" . '$(XX_PRE)rm -f $(OBJDIR)/' . $key . ".gcda");
1051
        }
1052
        $io->PrtLn("\t" . '${XX_PRE}$(rm) -f ' . $final);
1053
        $io->PrtLn("\t" . '${XX_PRE}lcov'
4835 dpurdie 1054
                        . $LcovExplicitBranch
1055
                        . ' --capture'
1056
                        . ' --initial'
1057
                        . ' --base-directory ' . $::Cwd
1058
                        . ' --directory $(OBJDIR)'
1059
                        . ' --output-file $(OBJDIR)/lcov-baseline.info' );
4778 dpurdie 1060
        $io->Newline();
4728 dpurdie 1061
    }
1062
}
1063
 
1064
 
1065
###############################################################################
1066
# Function        : ToolsetPostprocessTests
1067
#
1068
# Description     : 
1069
#
1070
# Inputs          : None
1071
#
1072
# Returns         : Nothing
1073
#
1074
# Output:         : Rules and recipes to run after the unit tests
1075
#
1076
sub ToolsetPostprocessTests
1077
{
1078
    my ($io) = ToolsetPrinter::New();
1079
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1080
    {
4778 dpurdie 1081
        my $ruleName = 'postprocess_gcov_data';
4728 dpurdie 1082
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1083
        my $final=$finaldir . '/lcov-final.info';
1084
 
1085
        ToolsetGenerate( '$(OBJDIR)/lcov-capture.info' );
1086
        ToolsetGenerate( $final );
4778 dpurdie 1087
        ToolsetAddUnitTestPostProcess($ruleName);
1088
 
1089
        $io->PrtLn('.PHONY: ' . $ruleName );
1090
        $io->PrtLn($ruleName . ':' );
4728 dpurdie 1091
        $io->PrtLn("\t" . '$(eval GCDA_COUNT := $(shell find $(OBJDIR) -name "*.gcda"))');
1092
 
1093
        $io->PrtLn  ("\t" . '$(XX_PRE)$(mkdir) -p ' . $finaldir);
1094
        $io->PrtPart("\t" . '$(XX_PRE)if [ "$(GCDA_COUNT)" = "" ]; then');
1095
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
1096
        $io->PrtPart("\t\t\t" . '$(cp) $(OBJDIR)/lcov-baseline.info ' . $final . ';');
1097
        $io->PrtPart("\t\t" . 'else');
1098
        $io->PrtPart("\t\t\t" . 'lcov'
4835 dpurdie 1099
                          . $LcovExplicitBranch
4728 dpurdie 1100
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1101
                          . ' --add-tracefile ' . $final
1102
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1103
                          . ';'); 
1104
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
1105
        $io->PrtPart("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . ';');
1106
        $io->PrtPart("\t\t" . 'fi' . ';');
1107
        $io->PrtPart("\t" . 'else');
1108
        $io->PrtPart("\t\t" . 'lcov'
4835 dpurdie 1109
                          . $LcovExplicitBranch
4728 dpurdie 1110
                        . ' --capture'
1111
                        . ' --base-directory ' . $::Cwd
1112
                        . ' --directory $(OBJDIR)'
1113
                        . ' --output-file $(OBJDIR)/lcov-capture.info' 
1114
                        . ';'); 
1115
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
1116
        $io->PrtPart("\t\t\t" . 'lcov'
4835 dpurdie 1117
                          . $LcovExplicitBranch
4728 dpurdie 1118
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1119
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
1120
                          . ' --output-file ' .  $final
1121
                          . ';'); 
1122
        $io->PrtPart("\t\t" . 'else');
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'
1127
                          . ' --add-tracefile ' . $final
1128
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1129
                          . ';'); 
1130
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
1131
        $io->PrtPart("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . ';');
1132
        $io->PrtPart("\t\t" . 'fi' . ';');
1133
        $io->PrtLn  ("\t" . 'fi');
4778 dpurdie 1134
        $io->Newline();
4728 dpurdie 1135
    }
1136
}
1137
 
1138
 
1139
###############################################################################
1140
# Function        : ToolsetCollateTestResults
1141
#
1142
# Description     : 
1143
#
1144
# Inputs          : None
1145
#
1146
# Returns         : Nothing
1147
#
1148
# Output:         : Rules and recipes to run after unit test result 
1149
#                   postprocessing.
1150
#
1151
sub ToolsetCollateTestResults
1152
{
1153
    my ($io) = ToolsetPrinter::New();
1154
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1155
    {
4778 dpurdie 1156
        my $ruleName = 'collate_gcov_results';
4728 dpurdie 1157
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1158
        my $final=$finaldir . '/lcov-final.info';
4778 dpurdie 1159
 
1160
        ToolsetAddUnitTestCollateProcess($ruleName);
4728 dpurdie 1161
 
1162
        my $reportdir='$(PKGDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1163
        my $reportindex=$reportdir . '/index.html';
1164
 
4778 dpurdie 1165
        $io->PrtLn('.PHONY: ' . $ruleName );
1166
        $io->PrtLn($ruleName . ': ' . $reportindex);
4728 dpurdie 1167
        $io->Newline();
1168
        $io->PrtLn($reportindex . ': ' . $final);
1169
        $io->PrtLn("\t" . 'genhtml'
1170
                      . ' --frames'
1171
                      . ' --show-details'
1172
                      . ' --function-coverage'
1173
                      . ' --branch-coverage'
1174
                      . ' --output-directory ' . $reportdir
1175
                      . ' --legend'
1176
                      . ' --demangle-cpp'
1177
                      . ' ' . $final);
4778 dpurdie 1178
        $io->Newline();
4728 dpurdie 1179
    }
1180
}
1181
 
1182
 
1183
###############################################################################
1184
#   ToolsetARLINT( $name, \@args, \@objs )
1185
#       This subroutine takes the user options and builds the rules
1186
#       required to lint the static library 'name'.
1187
#
1188
#   Arguments:
1189
#       --xxx                   No arguments currently defined
1190
#
1191
#   Output:
1192
#       [ $(LIBDIR)/name$_lint:   .... ]
1193
#           $(ARLINT)
1194
#
1195
###############################################################################
1196
 
1197
sub ToolsetARLINT
1198
{
1199
    if ( $UseCppcheck )
1200
    {
1201
        CppcheckAR( @_ );
1202
    }
1203
}
1204
 
1205
 
1206
###############################################################################
1207
#   ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
1208
#       This subroutine takes the user options and builds the rules
1209
#       required to lint the shared library 'name'.
1210
#
1211
#   Arguments:
1212
#       (none)
1213
#
1214
#   Output:
1215
#       [ $(LIBDIR)/$name_lint:   .... ]
1216
#           $(SHLIBLINT)
1217
#
1218
###############################################################################
1219
 
1220
sub ToolsetSHLDLINT
1221
{
1222
    if ( $UseCppcheck )
1223
    {
1224
        CppcheckSHLD( @_ );
1225
    }
1226
}
1227
 
1228
 
1229
###############################################################################
1230
#   ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
1231
#       This subroutine takes the user options and builds the rules
1232
#       required to lint the program 'name'.
1233
#
1234
#   Arguments:
1235
#       (none)
1236
#
1237
#   Output:
1238
#       [ $(BINDIR)/$name_lint:   .... ]
1239
#           $(LDLINT)
1240
#
1241
###############################################################################
1242
 
1243
sub ToolsetLDLINT
1244
{
1245
    if ( $UseCppcheck )
1246
    {
1247
        CppcheckLD( @_ );
1248
    }
1249
}
1250
 
227 dpurdie 1251
########################################################################
1252
#
1253
#   Push standard "system" libraries. This is a helper function
1254
#   used within this toolset.
1255
#
1256
#   Arguments:
1257
#       $plib       Reference to library array.
1258
#
1259
########################################################################
1260
 
1261
sub ToolsetLibStd
1262
{
1263
}
1264
 
1265
 
1266
########################################################################
1267
#
1268
#   Generate a linker object recipe.  This is a helper function used 
1269
#   within this toolset.
1270
#
1271
#   Arguments:
1272
#       $io         I/O stream
1273
#
1274
#       $target     Name of the target
1275
#
1276
#       $obj        Library specification
1277
#
1278
########################################################################
1279
 
1280
sub ToolsetObjRecipe
1281
{
1282
    my ($io, $target, $obj) = @_;
1283
 
1284
    $io->Cmd( "\$(strip $obj).$::o" );
1285
}
1286
 
1287
 
1288
###############################################################################
1289
#
1290
#   Parse a linker lib list
1291
#   This is a helper function used within this toolset
1292
#
1293
#   Arguments:
1294
#       $target     Name of the target
1295
#
1296
#       $lib        Library specification
1297
#
1298
#       $tag        Tag (user specified)
1299
#
1300
#       $dp         If building a depend list, the full target name.
1301
#
1302
###############################################################################
1303
 
1304
sub ToolsetLibRecipe
1305
{
1306
    my ($io, $target, $lib, $dp) = @_;
1307
 
1308
    if ( ! defined($dp) ) {                     # linker
1309
        $lib =~ s/^lib//;                       # .. remove leading 'lib'
1310
        $io->Cmd( "-l$lib" );
1311
 
1312
    } else {                                    # depend
1313
        $io->Cmd( "$dp:\t@(vlib2,$lib,GCC_LIB)" );
1314
 
1315
    }
1316
}
1317
 
1318
#.. Successful termination
1319
1;
1320