#! perl ######################################################################## # COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED. # # Module name : jats.sh # Module type : Perl Package # Compiler(s) : n/a # Environment(s): jats # # Description : This package contains functions to manipulate # the information required to create a DPACKAGE file # # The true name of the DPACKAGE file has a GBE_MACHTYPE # appended to allow multi-machine builds. # #......................................................................# use 5.006_001; use strict; use warnings; ################################################################################ # Global variables used by functions in this package # For historical reasons many of these variabeles are global # package JatsDPackage; use JatsError; use Data::Dumper; use ConfigurationFile; use FileUtils; use JatsEnv; our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION); use Exporter; $VERSION = 1.00; @ISA = qw(Exporter); # Symbols to autoexport (:DEFAULT tag) @EXPORT = qw( DPackageAdd DPackageSave ); # # Global data # our %DPackageLibraryData; our %DPackageLibraryDataStore; # # Local Data # my $data_added; #------------------------------------------------------------------------------- # Function : DPackageAdd # # Description : Called to insert new information into the data store # # Inputs : platform - This does not need to be an active platform # it is simply passed to the DPACKAGE builder # # using - The "using" target # # ... - Arguments for the Library directive # # Returns : # sub DPackageAdd { my ($platform, $using, @args ) = @_; Error ("Internal: DPackageAdd. ScmMakeUid is not defined") unless $::ScmMakeUid; push @{$DPackageLibraryData{$using}{$platform}}, @args; # Auto package the output file unless ($data_added) { $data_added = 1; ::PackageFile( '*',getDpkgName(), '--Strip', '--Gbe' ); } } #------------------------------------------------------------------------------- # Function : DPackageSave # # Description : Create a per-makefile file # Ensure the files don't have machine or time specific information # as they may be created at different time on multiple machines # Will be OK as long as the file contents are the same # # Create file names in an known order so they can be consumed # in the same order. # # Inputs : # # Returns : # sub DPackageSave { my $dPkgFile = getDpkgName(); Debug("DPackageSave: $dPkgFile"); # # Do not save if there is nothing to save and nothing has ever been saved # Must update if there is anything previously saved # unlink $dPkgFile; Verbose("DPackageSave Delete: $dPkgFile"); return unless ( $data_added ); Verbose("DPackageSave Creating: $dPkgFile"); mkpath ( StripFileExt($dPkgFile) ); my $fh = ConfigurationFile::New( $dPkgFile, '--NoTime' ); $fh->Header( "Auto-generated DPACKAGE", "JatsDPackage (version $VERSION)" ); $fh->Comment("Defined in : " . RelPath( $Cwd, AbsPath($::ScmRoot)) ); $fh->WriteLn(""); $fh->WriteLn("Version( 1, 0 ); # Interface version" ); $fh->WriteLn(""); # # Process each "Using" entry # Within each entry process the "platform" targets # and generate Libraries directives. # foreach my $using ( sort keys %DPackageLibraryData ) { my $uentry = $DPackageLibraryData{$using}; $fh->WriteLn( "Using( '$using' ); # Usage name" ); foreach my $platform ( sort keys %{$uentry} ) { my $pentry = $uentry->{$platform}; $fh->WriteLn( "\nLibraries('$platform'," ); foreach my $entry ( @{$pentry} ) { $fh->WriteLn( " '$entry'," ), } $fh->WriteLn( " );" ), } } $fh->Close(); # # Auto Package the file # } #------------------------------------------------------------------------------- # Function : getDpkgName # # Description : Internal function to return the name of the DPACKAGE file # generatde by this makefile # # The files are created in the 'interface/gbe' directory so that # that they can be automatically found by the process that loads # the definitions. ie: A makefile will be able to use the definitions # created within the same makefile. # # Use a 4 digit number so that the files can be ordered with a sort # # Inputs : None # # Returns : Name of the genetated file # my $dPkgFile; sub getDpkgName { unless ($dPkgFile) { $dPkgFile = "$::ScmRoot/$::ScmInterface/gbe/DPACKAGE_" . sprintf("%04d",$::ScmMakeUid) . ".cfg"; } return $dPkgFile; } 1;