Subversion Repositories DevTools

Rev

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

Rev 4003 Rev 4324
Line 32... Line 32...
32
 
32
 
33
#===============================================================================
33
#===============================================================================
34
package ReadBuildConfig;
34
package ReadBuildConfig;
35
use JatsError;
35
use JatsError;
36
use JatsMakeInfo qw(:basic);
36
use JatsMakeInfo qw(:basic);
-
 
37
use FileUtils;
37
 
38
 
38
# automatically export what we need into namespace of caller.
39
# automatically export what we need into namespace of caller.
39
use Exporter();
40
use Exporter();
40
our (@ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK);
41
our (@ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK);
41
@ISA         = qw(Exporter);
42
@ISA         = qw(Exporter);
42
@EXPORT      = qw(  ReadBuildConfig
43
@EXPORT      = qw(  ReadBuildConfig
43
                    getPlatformParts
44
                    getPlatformParts
44
                    getPackagePaths
45
                    getPackagePaths
45
                    getPackageList
46
                    getPackageList
-
 
47
                    getToolInfo
46
                );
48
                );
47
@EXPORT_OK =  qw(   $InterfaceVersion
49
@EXPORT_OK =  qw(   $InterfaceVersion
48
                    $ScmBuildMachType
50
                    $ScmBuildMachType
49
                    $ScmInterfaceVersion
51
                    $ScmInterfaceVersion
50
                    $ScmBuildName
52
                    $ScmBuildName
Line 324... Line 326...
324
 
326
 
325
#-------------------------------------------------------------------------------
327
#-------------------------------------------------------------------------------
326
# Function        : getPackageList
328
# Function        : getPackageList
327
#
329
#
328
# Description     : Returns a list of package entries
330
# Description     : Returns a list of package entries
329
#                   Only real use of the returnd values is to iterate over it
331
#                   Only real use of the returned values is to iterate over it
330
#                   and pass the values into other functiosn within this
332
#                   and pass the values into other functions within this
331
#                   class.
333
#                   class.
332
#
334
#
333
# Inputs          : Nothing
335
# Inputs          : Nothing
334
#
336
#
335
# Returns         : A list of refs to package data
337
# Returns         : A list of refs to package data
Line 346... Line 348...
346
        push @result, bless $_, "PackageEntry";
348
        push @result, bless $_, "PackageEntry";
347
    }
349
    }
348
    return ( @result );
350
    return ( @result );
349
}
351
}
350
 
352
 
-
 
353
#-------------------------------------------------------------------------------
-
 
354
# Function        : getToolInfo 
-
 
355
#
-
 
356
# Description     : Locate and load the tool information for the named tool
-
 
357
#
-
 
358
# Inputs          : $toolname           - tool to locate
-
 
359
#                   ...                 - Optional,Names of fields to expect in the package
-
 
360
#                                         If any of the required fields ar missing an error
-
 
361
#                                         will be reported
-
 
362
#
-
 
363
# Returns         : A hash of Tool info
-
 
364
#
-
 
365
sub getToolInfo
-
 
366
{
-
 
367
    my ($toolname, @fnames) = @_;
-
 
368
    my $toolroot;
-
 
369
    my $toolinfo;
-
 
370
    my $pentry;
-
 
371
    my %data;
-
 
372
    my @searchPath;
-
 
373
 
-
 
374
    foreach my $entry ( getPackageList() )
-
 
375
    {
-
 
376
        my $path = $entry->getBase(2);
-
 
377
        Verbose("getToolInfo: $path");
-
 
378
        #   Generic
-
 
379
        $toolinfo = catdir($path, 'gbe', 'INFO', 'info.' . $toolname . '.generic');
-
 
380
        push @searchPath, $toolinfo;
-
 
381
        if ( -f $toolinfo )
-
 
382
        {
-
 
383
            $toolroot = $path;
-
 
384
            $pentry = $entry;
-
 
385
            last;
-
 
386
        }
-
 
387
        #   Machine specific
-
 
388
        $toolinfo = catdir($path, 'gbe', 'INFO', 'info.' . $toolname . '.'. $ENV{GBE_HOSTMACH});
-
 
389
        push @searchPath, $toolinfo;
-
 
390
        if ( -f $toolinfo )
-
 
391
        {
-
 
392
            $toolroot = $path;
-
 
393
            $pentry = $entry;
-
 
394
            last;
-
 
395
        }
-
 
396
    }
-
 
397
    if (defined $toolroot)
-
 
398
    {
-
 
399
        open (my $DATA, '<', $toolinfo ) || Error("Cannot open tool info file. $!", "File: $toolinfo");
-
 
400
        while ( <$DATA> )
-
 
401
        {
-
 
402
            $_ =~ s~\s+$~~;
-
 
403
            next if ( m~^#~ );
-
 
404
            next if length($_) < 1;
-
 
405
            m~(.*?)\s*=\s*(.*)~;
-
 
406
            $data{$1} = $2;
-
 
407
        }
-
 
408
        close $DATA;
-
 
409
        $data{PKGBASE} = $toolroot;
-
 
410
        $data{PKGENTRY} = $pentry;
-
 
411
#DebugDumpData("Data", \%data);
-
 
412
 
-
 
413
        #
-
 
414
        #   Ensure that the required fields are in the info file
-
 
415
        #   These will be a mix of mandatory and user fields
-
 
416
        #
-
 
417
        my @missing;
-
 
418
        for my $fname ('TOOLNAME','TOOLROOT', @fnames)
-
 
419
        {
-
 
420
            next if defined $data{$fname};
-
 
421
            push @missing, $fname;
-
 
422
        }
-
 
423
        if (@missing)
-
 
424
        {
-
 
425
            Error("Tool Package '$toolname' is missing required fields:", @missing);
-
 
426
        }
-
 
427
        return \%data;
-
 
428
    }
-
 
429
 
-
 
430
    #   Didn't find the required tool
-
 
431
    Error ("Cannot find required tool in any package: $toolname", "Search Path:", @searchPath);
-
 
432
}
-
 
433
 
-
 
434
 
351
################################################################################
435
################################################################################
352
#   PackageEntry
436
#   PackageEntry
353
################################################################################
437
################################################################################
354
#
438
#
355
#   A class to access the data embedded into $ScmBuildPkgRules
439
#   A class to access the data embedded into $ScmBuildPkgRules