Subversion Repositories DevTools

Rev

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

Rev 4003 Rev 4034
Line 11... Line 11...
11
#............................................................................#
11
#............................................................................#
12
 
12
 
13
use strict;
13
use strict;
14
use warnings;
14
use warnings;
15
 
15
 
-
 
16
our $ScmPlatform;
-
 
17
our $ScmNoToolsTest;
-
 
18
 
16
##############################################################################
19
##############################################################################
17
#   Configuration information
20
#   Configuration information
18
#   Cross reference from CrossCompiler Alias to actual paths
21
#   Cross reference from CrossCompiler Alias to actual paths
19
#   Structure:
22
#   Structure:
20
#   Hash reference: Array of toolchain information
23
#   Hash reference: Array of toolchain information
21
#       Mandatory
24
#       Mandatory
22
#          ROOT             => Root of compiler
25
#          ROOT             => Root of compiler
23
#          BASE             => Base for binaries
26
#          BASE             => Base for binaries
24
#       Optional
27
#       Optional
25
#          CC_OPTS          => Additonal Compiler options
28
#          CC_OPTS          => Additonal Compiler options
-
 
29
#          CC_OPTSP         => Production Compiler options
-
 
30
#          CC_OPTSD         => Debug Compiler options
26
#          UNCONTROLLED     => Boolean to create warning
31
#          UNCONTROLLED     => Boolean to create warning
27
#          PACKAGE_ARCH     => Packageing architecture
32
#          PACKAGE_ARCH     => Packageing architecture
28
#          VERSION          => Version reported by GCC
33
#          VERSION          => Version reported by GCC
29
#          MACHINE          => Machine reported by GCC
34
#          MACHINE          => Machine reported by GCC
-
 
35
#          COMPILER_OPTIONS => Toolset specific compiler initial options
-
 
36
#                              This is a comma seperated list
30
 
37
 
31
my %ToolsetConfig = (
38
my %ToolsetConfig = (
32
 
39
 
33
    'i386-unknown-linux-gnu'    => {
40
    'i386-unknown-linux-gnu'    => {
34
        ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/i586-unknown-linux-gnu',
41
        ROOT => '/opt/crosstool/gcc-4.1.1-glibc-2.5/i586-unknown-linux-gnu',
Line 119... Line 126...
119
 
126
 
120
ToolsetInit();
127
ToolsetInit();
121
 
128
 
122
sub ToolsetInit
129
sub ToolsetInit
123
{
130
{
124
    my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCFlags, $GCCObjCopy );
131
    my( $GCCTarget, $GCCToolchain, $GCCRoot, $GCCBin, $GCCAr, $GCCObjCopy );
-
 
132
    my( $GCCFlags,  $GCCFlagsP, $GCCFlagsD );
125
    my( $PkgArch);
133
    my( $PkgArch);
126
    my( $arg_alias, $tools_found );
134
    my( $arg_alias, $tools_found, $compiler_tool );
127
 
135
 
128
#.. Toolset configuration
136
#.. Toolset configuration
129
#
137
#
130
    $::ScmToolsetVersion = "1.0.0";             # our version
138
    $::ScmToolsetVersion = "1.0.0";             # our version
131
    $::ScmToolsetGenerate = 0;                  # GEN generate optional
139
    $::ScmToolsetGenerate = 0;                  # GEN generate optional
Line 148... Line 156...
148
            $GCCTarget = "$1";
156
            $GCCTarget = "$1";
149
 
157
 
150
        } elsif (/^--CrossAlias=(.*)/) {        # CrossCompiler target-alias
158
        } elsif (/^--CrossAlias=(.*)/) {        # CrossCompiler target-alias
151
            $arg_alias = $1;
159
            $arg_alias = $1;
152
 
160
 
-
 
161
        } elsif (/^--CompilerTool=(.*)/) {      # CrossCompiler located in package
-
 
162
            $compiler_tool = $1;
-
 
163
 
153
        } else {
164
        } else {
154
            Message( "gcc toolset: unknown option $_ -- ignored\n" );
165
            Message( "gcc toolset: unknown option $_ -- ignored\n" );
155
        }
166
        }
156
    }
167
    }
157
 
168
 
Line 164... Line 175...
164
    }
175
    }
165
 
176
 
166
    Error ("TOOLSET/gcc - Target undefined" )
177
    Error ("TOOLSET/gcc - Target undefined" )
167
        unless ($GCCTarget);
178
        unless ($GCCTarget);
168
 
179
 
-
 
180
    #
-
 
181
    #   If the toolset is not required, then do not process any futher
-
 
182
    #   We may not find the compiler
-
 
183
    #
-
 
184
    return
-
 
185
        if ($ScmNoToolsTest);
-
 
186
 
-
 
187
#.. Cross compile support
-
 
188
#   Compiler provided in package, rather than install on machine
-
 
189
#
-
 
190
if ( $compiler_tool  )
-
 
191
{
-
 
192
    #
-
 
193
    #   The GCC toolset will handle a compiler provided within a package
-
 
194
    #   Initial requirement was for ANDROID NDKs where the compiler is
-
 
195
    #   a part of the NDK and will change.
-
 
196
    #
-
 
197
    #   Compilers in packages will have a file in gbe/COMPILERS/<compiler_tool>
-
 
198
    #   that contains data specifically designed for this toolset
-
 
199
    #
-
 
200
    Verbose("Locate compiler in package: $compiler_tool");
-
 
201
    my @toolList;
-
 
202
    my $toolPath;
-
 
203
    my $toolPkg;
-
 
204
    for my $entry (@{$::ScmBuildPkgRules{$ScmPlatform} })
-
 
205
    {
-
 
206
        my $tpath = join('/', $entry->{ROOT}, 'gbe', 'COMPILERS' , $compiler_tool);
-
 
207
        if ( -f $tpath  )
-
 
208
        {
-
 
209
            push @toolList, $entry->{NAME};
-
 
210
            $toolPath = $tpath;
-
 
211
            $toolPkg = $entry;
-
 
212
        }
-
 
213
    }
-
 
214
    Error ("Multiple packages provide required compiler:", @toolList)
-
 
215
        if ( scalar(@toolList) > 1 );
-
 
216
    Error ("Required compiler not found in any package", "Compiler: $compiler_tool")
-
 
217
        unless ( scalar(@toolList) == 1 );
-
 
218
 
-
 
219
    #
-
 
220
    #   Process the compiler info file
-
 
221
    #   Rip out the data and create a hash of item/values
-
 
222
    #   File format:
-
 
223
    #       '#' is a line comment
-
 
224
    #       item=value
-
 
225
    #
-
 
226
    my %data;
-
 
227
    open (my $DATA, '<', $toolPath ) || Error("Cannot open compiler datafile. $!", "File: $toolPath");
-
 
228
    while ( <$DATA> )
-
 
229
    {
-
 
230
        $_ =~ s~\s+$~~;
-
 
231
        next if ( m~^#~ );
-
 
232
        m~(.*?)\s*=\s*(.*)~;
-
 
233
        $data{$1} = $2;
-
 
234
    }
-
 
235
    close $DATA;
-
 
236
 
-
 
237
    #
-
 
238
    #   Force this compilers data into the ToolsetConfig hash
-
 
239
    #
-
 
240
    $arg_alias = $compiler_tool;
-
 
241
    %ToolsetConfig = ();
-
 
242
 
-
 
243
    $ToolsetConfig{$arg_alias}{ROOT} = join('/', $toolPkg->{ROOT}, $data{ROOT} );
-
 
244
    $ToolsetConfig{$arg_alias}{BASE} = $data{BASE} . '-';
-
 
245
    $ToolsetConfig{$arg_alias}{CC_OPTS} = $data{CFLAGS};
-
 
246
    $ToolsetConfig{$arg_alias}{CC_OPTSP} = $data{CFLAGSP};
-
 
247
    $ToolsetConfig{$arg_alias}{CC_OPTSD} = $data{CFLAGSD};
-
 
248
    $ToolsetConfig{$arg_alias}{VERSION} = $data{VERSION};
-
 
249
    $ToolsetConfig{$arg_alias}{MACHINE} = $data{MACHINE};
-
 
250
    $ToolsetConfig{$arg_alias}{COMPILER_OPTIONS} = $data{COMPILER_OPTIONS};
-
 
251
}
-
 
252
 
169
#.. Cross compile support
253
#.. Cross compile support
170
#
254
#
171
#   Toolchain=root,[bin]
255
#   Toolchain=root,[bin]
172
#
256
#
173
    if ( $arg_alias )
257
    if ( $arg_alias )
Line 216... Line 300...
216
        #
300
        #
217
        #   Parse GCCToolchain. Potential parts to create
301
        #   Parse GCCToolchain. Potential parts to create
218
        #       GCCRoot     - Location to find the effective /usr/include directory
302
        #       GCCRoot     - Location to find the effective /usr/include directory
219
        #       GCCBin      - Path to the gcc executable
303
        #       GCCBin      - Path to the gcc executable
220
        #       GCCAr       - Path to the ar executable
304
        #       GCCAr       - Path to the ar executable
221
        #       GCCFlags    - Additional compiler flags
305
        #       GCCFlags    - Additional compiler flags. Also Production and Debug
222
        #
306
        #
223
        $GCCRoot = $GCCToolchain->{ROOT};
307
        $GCCRoot = $GCCToolchain->{ROOT};
224
        $GCCBin = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'gcc';
308
        $GCCBin = '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'gcc';
225
        $GCCAr =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'ar';
309
        $GCCAr =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'ar';
226
        $GCCObjCopy =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'objcopy';
310
        $GCCObjCopy =  '${GCC_ROOT}/' . $GCCToolchain->{BASE} . 'objcopy';
227
        $GCCFlags = $GCCToolchain->{CC_OPTS};
311
        $GCCFlags = $GCCToolchain->{CC_OPTS};
-
 
312
        $GCCFlagsP = $GCCToolchain->{CC_OPTSP};
-
 
313
        $GCCFlagsD = $GCCToolchain->{CC_OPTSD};
228
        $PkgArch = $GCCToolchain->{PACKAGE_ARCH};
314
        $PkgArch = $GCCToolchain->{PACKAGE_ARCH};
229
    }
315
    }
230
    else
316
    else
231
    {
317
    {
232
        $GCCRoot = '/usr';
318
        $GCCRoot = '/usr';
Line 246... Line 332...
246
    PlatformDefine( "GCC_ROOT           := $GCCRoot" );
332
    PlatformDefine( "GCC_ROOT           := $GCCRoot" );
247
    PlatformDefine( "GCC_CC             := $GCCBin" );
333
    PlatformDefine( "GCC_CC             := $GCCBin" );
248
    PlatformDefine( "GCC_AR             := $GCCAr" );
334
    PlatformDefine( "GCC_AR             := $GCCAr" );
249
    PlatformDefine( "GCC_OBJCOPY        := $GCCObjCopy" );
335
    PlatformDefine( "GCC_OBJCOPY        := $GCCObjCopy" );
250
    PlatformDefine( "GCC_CFLAGS         := $GCCFlags" ) if defined $GCCFlags;
336
    PlatformDefine( "GCC_CFLAGS         := $GCCFlags" ) if defined $GCCFlags;
-
 
337
    PlatformDefine( "GCC_CFLAGSP        := $GCCFlagsP" ) if defined $GCCFlagsP;
-
 
338
    PlatformDefine( "GCC_CFLAGSD        := $GCCFlagsD" ) if defined $GCCFlagsD;
251
 
339
 
252
    #
340
    #
253
    #   Required since this toolset advertises: ScmToolsetCompilerPath
341
    #   Required since this toolset advertises: ScmToolsetCompilerPath
254
    #
342
    #
255
    PlatformDefine( "SCM_COMPILERPATH   := \$\{GCC_CC\}" );
343
    PlatformDefine( "SCM_COMPILERPATH   := \$\{GCC_CC\}" );
Line 285... Line 373...
285
        #   Control the thread model to use
373
        #   Control the thread model to use
286
        #   This will affect the compiler options and the linker options
374
        #   This will affect the compiler options and the linker options
287
        #
375
        #
288
        'staticprogs'        => { 'STATIC_PROGS' , '1' },      # Progams link staticlly
376
        'staticprogs'        => { 'STATIC_PROGS' , '1' },      # Progams link staticlly
289
        'no_staticprogs'     => { 'STATIC_PROGS' , undef },    # Default
377
        'no_staticprogs'     => { 'STATIC_PROGS' , undef },    # Default
-
 
378
        'noversiondll'       => { 'NO_VERSIONED_DLLS', 1 },    # Matches usage elsewhere
290
    );
379
    );
291
 
380
 
292
    #
381
    #
293
    #   Set default options
382
    #   Set default options
294
    #
383
    #
295
    $::ScmCompilerOpts{'STATIC_PROGS'} = undef;
384
    $::ScmCompilerOpts{'STATIC_PROGS'} = undef;
-
 
385
    $::ScmCompilerOpts{'NO_VERSIONED_DLLS'} = undef;
-
 
386
 
-
 
387
    #
-
 
388
    #   Process toolset-specfic compiler options
-
 
389
    #
-
 
390
    if ( exists $GCCToolchain->{COMPILER_OPTIONS} )
-
 
391
    {
-
 
392
        CompileOptions('*', split(',',$GCCToolchain->{COMPILER_OPTIONS}) );
-
 
393
    }
296
}
394
}
297
 
395
 
298
 
396
 
299
###############################################################################
397
###############################################################################
300
#   ToolsetCC( $source, $obj, \@args )
398
#   ToolsetCC( $source, $obj, \@args )
Line 503... Line 601...
503
 
601
 
504
sub ToolsetSHLD
602
sub ToolsetSHLD
505
{
603
{
506
    my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
604
    my( $name, $pArgs, $pObjs, $pLibs, $ver ) = @_;
507
    my( $linkname, $soname, $shared, $dbgname, $def, $def_pref, $multi_scan );
605
    my( $linkname, $soname, $shared, $dbgname, $def, $def_pref, $multi_scan );
508
    my $sosuffix = '.' . $ver;
606
    my $sosuffix;
-
 
607
    my $noVersionedLib = $::ScmCompilerOpts{'NO_VERSIONED_DLLS'};
-
 
608
 
509
 
609
 
510
#.. Parse arguments
610
#.. Parse arguments
511
#
611
#
512
    foreach $_ ( @$pArgs )
612
    foreach $_ ( @$pArgs )
513
    {
613
    {
Line 529... Line 629...
529
            $multi_scan = 0;
629
            $multi_scan = 0;
530
 
630
 
531
        } elsif ( /^--SoNameSuffix=(.*)/i ) {
631
        } elsif ( /^--SoNameSuffix=(.*)/i ) {
532
            $sosuffix = $1;
632
            $sosuffix = $1;
533
 
633
 
-
 
634
        } elsif (/^--NoVersionDll/i) {
-
 
635
            $noVersionedLib = 1;
-
 
636
 
534
        } else {
637
        } else {
535
            Message( "SHLD: unknown option $_ -- ignored\n" );
638
            Message( "SHLD: unknown option $_ -- ignored\n" );
536
        }
639
        }
537
    }
640
    }
538
 
641
 
-
 
642
    #
-
 
643
    # Determine the 'soname' in none has been provided
-
 
644
    #
-
 
645
    $sosuffix = '.' . $ver
-
 
646
        unless ( defined $sosuffix );
-
 
647
    $sosuffix = ''
-
 
648
        if ( $noVersionedLib );
-
 
649
 
539
#.. Various library names
650
#.. Various library names
540
#
651
#
541
    $linkname = "$name\$(GBE_TYPE).$::so";
652
    $linkname = "$name\$(GBE_TYPE).$::so";
542
    $shared = "$linkname.$ver";
653
    $shared = $noVersionedLib ? $linkname : "$linkname.$ver";
543
    $soname = "$linkname$sosuffix";
654
    $soname = "$linkname$sosuffix";
544
    
655
 
545
    my $shared_path = "\$(LIBDIR)/${shared}";
656
    my $shared_path = "\$(LIBDIR)/${shared}";
546
    my $dbg_path =  $shared_path . '.dbg';
657
    my $dbg_path =  $shared_path . '.dbg';
547
 
658
 
548
#.. Cleanup rules
659
#.. Cleanup rules
549
#
660
#
Line 564... Line 675...
564
    my $dep = $io->SetShldTarget($shared);
675
    my $dep = $io->SetShldTarget($shared);
565
 
676
 
566
    $io->Label( "Shared library", $name );
677
    $io->Label( "Shared library", $name );
567
    PackageShlibAddFiles( $name, "\$(LIBDIR)/$shared" );
678
    PackageShlibAddFiles( $name, "\$(LIBDIR)/$shared" );
568
    PackageShlibAddFiles( $name, $dbg_path );
679
    PackageShlibAddFiles( $name, $dbg_path );
569
    
680
 
570
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
681
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHBASE=${name}\n" );
571
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
682
    $io->Prt( "\$(LIBDIR)/${shared}:\tSHNAME=${soname}\n" );
572
    $io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
683
    $io->Prt( "\$(LIBDIR)/${shared}: \\\n\t\t${dep}" );
573
    $io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
684
    $io->Entry( "", "", " \\\n\t\t", ".$::o", @$pObjs );
574
    $io->Prt( "\\\n\t\t$def" ) if($def);
685
    $io->Prt( "\\\n\t\t$def" ) if($def);
Line 579... Line 690...
579
#   Create soft links
690
#   Create soft links
580
#       'Real Name' to its 'Link Name'
691
#       'Real Name' to its 'Link Name'
581
#       'Real Name' to 'SoName' in the BINDIR (for testing I think)
692
#       'Real Name' to 'SoName' in the BINDIR (for testing I think)
582
#       'Real Name' to 'SoName' in the LIBDIR (if different)
693
#       'Real Name' to 'SoName' in the LIBDIR (if different)
583
#
694
#
-
 
695
    if ( $shared ne $linkname)
-
 
696
    {
584
    $io->Label( "Shared library Symbolic Links", $name );
697
        $io->Label( "Shared library Symbolic Links", $name );
585
    PackageShlibAddFiles( $name, "\$(LIBDIR)/$linkname" );
698
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$linkname" );
586
    $io->Prt( "\$(LIBDIR)/$linkname:\t\\\n" .
699
        $io->Prt( "\$(LIBDIR)/$linkname:\t\\\n" .
-
 
700
                  "\t\t\$(GBE_BINDIR)\\\n" .
-
 
701
                  "\t\t\$(LIBDIR)/${shared}\n" .
-
 
702
                  "\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n\n" );
-
 
703
    }
-
 
704
 
-
 
705
    $io->Label( "Shared library BINDIR Symbolic Links", $name );
-
 
706
    PackageShlibAddFiles( $name, "\$(BINDIR)/$soname" );
-
 
707
    $io->Prt( "\$(BINDIR)/$soname:\t\\\n" .
587
              "\t\t\$(GBE_BINDIR)\\\n" .
708
              "\t\t\$(GBE_BINDIR)\\\n" .
588
              "\t\t\$(LIBDIR)/${shared}\n" .
709
              "\t\t\$(LIBDIR)/${shared}\n" .
589
              "\t\$(AA_PRE)(rm -f \$@; ln -s ./$shared \$@)\n" .
710
              "\t\$(AA_PRE)(rm -f \$@; ln -s ../\$(LIBDIR)/$shared \$@)\n\n" );
590
              "\t\$(AA_PRE)(rm -f \$(BINDIR)/$soname; ln -s ../\$(LIBDIR)/$shared \$(BINDIR)/$soname)\n\n" );
-
 
591
 
711
 
592
    if ( $soname ne $shared && $soname ne $linkname)
712
    if ( $soname ne $shared )
593
    {
713
    {
594
        $io->Label( "Shared library SoName Symbolic Links", $name );
714
        $io->Label( "Shared library SoName Symbolic Links", $name );
595
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$soname" );
715
        PackageShlibAddFiles( $name, "\$(LIBDIR)/$soname" );
596
        $io->Prt( "\$(LIBDIR)/$soname:\t\\\n" .
716
        $io->Prt( "\$(LIBDIR)/$soname:\t\\\n" .
597
                  "\t\t\$(GBE_LIBDIR)\\\n" .
717
                  "\t\t\$(GBE_LIBDIR)\\\n" .