######################################################################## # Copyright ( C ) 2006 ERG Limited, All rights reserved # # Module name : jats.sh # Module type : Makefile system # Compiler(s) : n/a # Environment(s): jats build system # # Description : Provide access to information from the build.pl file as parsed # by JATS. This is more complete than the parser in the # "BuildFile.pm" # # This class is used by deploylib.pm, and we can ensure that JATS # has parsed the build.pl file # #......................................................................# require 5.006_001; use strict; use warnings; use Data::Dumper; #=============================================================================== package DeployUtils::BuildConfig; use JatsError; # automatically export what we need into namespace of caller. use Exporter(); our (@ISA, @EXPORT); @ISA = qw(Exporter); @EXPORT = qw( ); # # The following varaibles are "read" in from the build.cfg file # In order to access thme we need to declare them # our %ScmBuildPkgRules; our %BUILDPLATFORM_PARTS; #------------------------------------------------------------------------------- # Function : new constructor # # Description : Create a new instance of the BuildConfig class # # Inputs : $obclass - Class Name, # $buildFile - Path to the root directory # $Platform - Desirect target platform # # Returns : Class reference # sub new { my $obclass = shift; my $class = ref($obclass) || $obclass; my $buildPath = shift; my $Platform = shift; Debug("BuildFile::new Instantiating new object of class $class"); bless my $self = { _BUILDPATH => $buildPath, _PLATFORM => $Platform, _DPKGARCHIVE => {}, } => ( $class ); # # Insert required information # Read in the build.cfg file as parsed by JATS - this is the real deal # readCfg( $buildPath ); # $self->dumpSelf(); return($self); } # new #------------------------------------------------------------------------------- # Function : readCfg # # Description : Read in the build.cfg file # This file contains complete parse information from the JATS # build.pl file parser. This is much more complete than the # simplistic parser in BuildFile.pm # # build.cfg is read within the context of a package to contain # the variables that are added to the namespace. # # Inputs : RootDir - Root directory # Expect to find interface/build.cfg # # Returns : Nothing # sub readCfg { my ($RootDir) = @_; # # Current assumption is that the build.cfg file is within a directory # named 'inerface'. This is not strictly true as the name of the directory # is specified in the build.pl file. We could hunt for it. # my $cfgfile = "$RootDir/interface/build.cfg"; Error ("Cannot find file: $cfgfile" ) unless ( -f $cfgfile ); # # Include the build.cfg data # require ( $cfgfile ); } #------------------------------------------------------------------------------- # Function : getDpkgArchiveHash # # Description : Create a hash to describe the external packages as declared # with LinkPkgArchive or BuildPkgArchive directives # # This is a compatability function # The hash is usef by the user written deployfile.pl's # This is ugly, and not good, but that is what has been done # # Inputs : None # # Returns : A hash of the form: # # {$module}{type} # {$module}{version} # {$module}{versionFull} # {$module}{proj} # # sub getDpkgArchiveHash { my $self = shift; foreach my $entry ( @{$ScmBuildPkgRules{$self->{_PLATFORM}}} ) { my $module = $entry->{'DNAME'}; my $ref = $self->{_DPKGARCHIVE}; $ref->{$module}{'type'} = $entry->{'TYPE'} =~ /build/ ? 'BuildPkgArchive' : 'LinkPkgArchive'; $ref->{$module}{'version'} = $entry->{'DVERSION'}; $ref->{$module}{'versionFull'} = $entry->{'VERSION'}; $ref->{$module}{'proj'} = $entry->{'DPROJ'}; } return %{$self->{_DPKGARCHIVE}}; } #------------------------------------------------------------------------------- # Function : getDpkgArchiveInfo # # Description : Get the DpkgArchiveHash entry for a given module # # Inputs : $module - name of the module # # Returns : Entry # sub getDpkgArchiveInfo { my $self = shift; my $module = shift; if ( ! defined($module) || ! defined($self->{_DPKGARCHIVE}{$module}) ) { return undef; } else { return \%{$self->{_DPKGARCHIVE}{$module}}; } } #------------------------------------------------------------------------------- # Function : getDpkgArchiveList # # Description : returns a list of Modules in the DpkgArchive Hash # # Inputs : None # # Returns : A sorted list # sub getDpkgArchiveList { my $self = shift; return sort keys %{$self->{_DPKGARCHIVE}}; } #------------------------------------------------------------------------------- # Function : getPlatformParts # # Description : return a list of platform parts # # Inputs : None # # Returns : A list # sub getPlatformParts { my $self = shift; return @{$BUILDPLATFORM_PARTS{$self->{_PLATFORM}}}; } #------------------------------------------------------------------------------- # Function : getBuildPkgRules # # Description : Return a list of BuildPkgRules for the specified platform # # Description : return a list of platform parts # # Inputs : None # # Returns : A list # sub getBuildPkgRules { my $self = shift; return @{$ScmBuildPkgRules{$self->{_PLATFORM}}}; } #------------------------------------------------------------------------------- # Function : dumpSelf # # Description : Dump the class internals # # Inputs : None # # Returns : Nothing # sub dumpSelf { my $self = shift; print Data::Dumper->Dump([$self], [ref($self)]); } #------------------------------------------------------------------------------ 1;