Subversion Repositories DevTools

Rev

Rev 5708 | Rev 5716 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

########################################################################
# Copyright (c) VIX TECHNOLOGY (AUST) LTD
#
# Module name   : PLATFORM_CFG.PM
# Module type   : Makefile system
# Compiler(s)   : Perl
# Environment(s): jats
#
# Description   : Provides platform configuration information
#
#                 The main pupose of this configuration information is to
#                 prevent JATS from attempting to build software on
#                 a platform that does not support the required compilers
#
#                 ie: Its not possible to build PPC_302E on a windows
#                     Nor is it possbile to build WIN32 on a Sun Sparc
#
#                 This can be done via GBE_BUILDFILTER, but results in
#                 an unwieldy GBE_BUILDFILTER. Better to prune the
#                 targets at the start
#
#......................................................................#

require 5.008_002;
use strict;
use warnings;

package PlatformConfig;
use JatsError;

#
#   The following structure is a hash of arrays
#   The hash key is a supported machine type - one per machine
#   The data is an array of supported PLATFORMS
#
my %BuildAvailability = (
    'linux_i386' => [
        'ANDROIDARM',
        'ANDROIDMIPS',
        'ANDROIDX86',
        'ANDROID',
        'ARM9TDMI',
        'COBRA',
        'COBRA2',
        'HAMMERHEAD',
        'JAVA:NATIVE',
        'LINUX86',
        'LINUX_ARMV4',
        'LINUX_EMU',
        'LINUX_ETX',
        'LINUX_I386:NATIVE',
        'PPC_603E',
        'SK20',
        'SK20V41',
        'UBUNTU12:NATIVE',
        'UBUNTU12_INSTRUMENT:NATIVE',
        'VIPER2',
        ],

    'linux_x64' => [
        'LINUX_I386:NATIVE',
        'UBUNTU14:NATIVE',
        'UBUNTU14_INSTRUMENT:NATIVE',
        ],

    'solaris10_sparc32' => [
        'SOLARIS10_SPARC32:NATIVE',
        'SOLARIS10_SPARC64:NATIVE',
        'JAVA:NATIVE',
        ],

    'solaris10_x86' => [
        'SOLARIS10_X64:NATIVE',
        'SOLARIS10_X86',
        'JAVA',
        ],

    'sparc' => [
        'SOLARIS:NATIVE',
        'SOLARIS_I386',
        'SOLARIS_SPARC',
        'JAVA:NATIVE',
        ],

    'win32' => [
        'ANDROID',
        'ACEX',
        'AMX',
        'ARM_I5100',
        'AVR_IAR',
        'BORLAND',
        'CMOS386',
        'CMOS68K',
        'CORTEXM3_IAR',
        'CSHARP:NATIVE',
        'CSHARP2005:NATIVE',
        'CSHARP2008:NATIVE',
        'CSHARP2010:NATIVE',
        'CSHARP2012:NATIVE',
        'DAFBR_MOS',
        'DAFBR_WIN',
        'DELPHI7',
        'DF4OBE',
        'DOS16',
        'DOS32',
        'EEPP386',
        'EETP386',
        'EOS',
        'EOSM68K',
        'EOSP386',
        'GMPCA',
        'GO32',
        'H8S',
        'H400',
        'HK386PC',
        'HKAVM',
        'HKAVM2',
        'HKBCP',
        'HKDDU',
        'HKGAK',
        'HKMPR',
        'HKPCA',
        'INGEN',
        'INTELLECT',
        'JAVA:NATIVE',
        'MCR',
        'MERG',
        'MOS68K',
        'MOS68KRM',
        'MOSCF',
        'MPT',
        'VSDEVRC',
        'NGBCP',
        'NGDDU',
        'PHARLAP',
        'PHP',
        'RIORDS',
        'THYRON',
        'VB6',
        'VERIX',
        'VIXITP',
        'VS2003:NATIVE',
        'VS2005:NATIVE',
        'VS2008:NATIVE',
        'VS2010:NATIVE',
        'VS2012:NATIVE',
        'WCEIPA280',
        'WCEIT3000',
        'WCENAUTIZX5',
        'WCEPA961',
        'WCEPA962',
        'WCEPA962_500',
        'WCEPCM7220',
        'WCEPSION_420',
        'WCEPSION_500',
        'WCEPSION_500_emu',
        'WCEPSION_500_VS2005',
        'WCEPSPC_arm',
        'WCEPSPC_emu',
        'WCEX86A420',
        'WCEX86A500',
        'WCEX86A500_SOM4455',
        'WIN32:NATIVE',
        'VS2012_X64:NATIVE',
        ],

);

#
#   Convert Machine Type to Machine Class
#       These match the Release Manager and BuildTool definitions
#       Used for GENERIC Processing
#
my %MachineTypeToClass = (
      linux_i386        => 'LINUX',
      linux_x64         => 'LINUX',
      solaris10_sparc32 => 'SOLARIS',
      solaris10_x86     => 'SOLARIS',
      sparc             => 'SOLARIS',
      win32             => 'WIN32',
);
#
#   The above data will be reorganised and placed into the following
#   hash. This simplifies the data definition and lookup
#
my %BuildAvailabilityData;

#   A hash of 'special' known targets
#   Simply used to reduce JATS warnings about some psuedo targets
my %knownSpecial;

#   List of Native targets
my  @nativeTargets;

#-------------------------------------------------------------------------------
# Function        : InitData
#
# Description     : Init data structures
#                   Done once
#
#                   Convert the $BuildAvailability entry array into a hash to 
#                   simplify lookup. Add in thr three types of GENERIC target:
#                       GENERIC         - can be built on ANY machine
#                       GENERIC_XXX     - can be built on machine of class XXX
#                       MACH_YYY        - can be built on MACHTYPE YYY
#
# Inputs          : None
#
# Returns         : Nothing
#
sub InitData
{
    #
    #   Only do this work once
    #
    return if exists $BuildAvailabilityData{'GENERIC'};

    #
    #   Validate build machine
    #
    Error (__PACKAGE__ . " : Unknown build machine type: $::GBE_MACHTYPE")
        unless ( exists $BuildAvailability{$::GBE_MACHTYPE} );

    #
    #   Convert the array into a hash to speed up access later
    #
    $BuildAvailabilityData{'GENERIC'} = 2;
    foreach ( @{$BuildAvailability{$::GBE_MACHTYPE}}  )
    {
        my @data = split(':', $_ );
        $BuildAvailabilityData{$data[0]} = 1;
        if (grep(/^NATIVE$/i, @data))
        {
            push @nativeTargets, $data[0];
        }
    }

#   #
#   #   Insert GENERIC_<MachClass>
#   #
#   Error (__PACKAGE__ . " : Unknown build machine class: $::GBE_MACHTYPE")
#       unless ( exists $MachineTypeToClass{$::GBE_MACHTYPE} );
#   $BuildAvailabilityData{join('_','GENERIC', $MachineTypeToClass{$::GBE_MACHTYPE} )} = 2;
#
#   #
#   #   Insert MachType definition
#   #   These are of the form MACH_xxxx
#   #
#   $BuildAvailabilityData{join('_','MACH', uc($::GBE_MACHTYPE) )} = 2;
#
#   #
#   #   Create a hash of special 'known' targets
#   #
   $knownSpecial{'GENERIC'} = 2;
#   foreach my $machtype ( keys %MachineTypeToClass ) {
#       $knownSpecial{join('_','MACH', uc($machtype) )} = 2;
#       $knownSpecial{join('_','GENERIC', $MachineTypeToClass{$machtype} )} = 2;
#   }
}

#-------------------------------------------------------------------------------
# Function        : checkBuildAvailability
#
# Description     : Check that a given target can be be built on the
#                   current machine type. Also indicate if it is a GENERIC
#                   target; one that can always be built.
#
# Inputs          : $target             - Name of target platform
#
#
# Returns         : 0                   - target cannot be built
#                   1                   - target can be built, subject to build filter
#                   2                   - target can be built, is Generic           
#
sub checkBuildAvailability
{
    my ($target) = @_;
    Error("Internal: checkBuildAvailability. No argument specified") unless $target;

    InitData();
    if (exists $BuildAvailabilityData{$target})
    {
        return $BuildAvailabilityData{$target} ;
    }
    return 0;
}

#-------------------------------------------------------------------------------
# Function        : checkKnownSpecial
#
# Description     : Check that a given (special) target is known to JATS
#                   Used to suppress warnings about GENERIC targets not known
#                   to the current machine type.
#
# Inputs          : $target             - Name of target platform
#
#
# Returns         : 0                   - target not known
#                   1                   - target is known to JATS
#
sub checkKnownSpecial
{
    my ($target) = @_;
    Error("Internal: checkKnown. No argument specified") unless $target;

    InitData();
    if (exists $knownSpecial{$target})
    {
        return $knownSpecial{$target} ;
    }
    return 0;
}

#-------------------------------------------------------------------------------
# Function        : getNativeTargets 
#
# Description     : Fetch an array of build platforms that are native in the 
#                   current build .
#
#                   Native implies that programs compiled will run
#                   Used to create an ALIAS called NATIVE
#                   Used to simplify unit testing    
#
# Inputs          : 
#
# Returns         : 
#
sub getNativeTargets
{
    InitData();
    return @nativeTargets;
}


1;