Subversion Repositories DevTools

Rev

Rev 6294 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
#! perl
2
########################################################################
6177 dpurdie 3
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
227 dpurdie 4
#
5
# Module name   : jats.sh
6
# Module type   : Perl Package
7
# Compiler(s)   : n/a
8
# Environment(s): jats
9
#
10
# Description   : This package contains functions to manipulate
11
#                 the information required to create a DPACKAGE file
12
#
299 dpurdie 13
#                 The true name of the DPACKAGE file has a GBE_MACHTYPE
14
#                 appended to allow multi-machine builds.
15
#
227 dpurdie 16
#......................................................................#
17
 
255 dpurdie 18
use 5.006_001;
227 dpurdie 19
use strict;
20
use warnings;
21
 
22
################################################################################
23
#   Global variables used by functions in this package
24
#   For historical reasons many of these variabeles are global
25
#
26
 
27
package JatsDPackage;
28
use JatsError;
29
use Data::Dumper;
30
use ConfigurationFile;
285 dpurdie 31
use FileUtils;
299 dpurdie 32
use JatsEnv;
227 dpurdie 33
 
34
our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION);
35
use Exporter;
36
 
37
$VERSION = 1.00;
38
@ISA = qw(Exporter);
39
 
40
# Symbols to autoexport (:DEFAULT tag)
41
@EXPORT = qw(
42
                DPackageAdd
43
                DPackageSave
44
            );
45
 
46
#
47
#   Global data
48
#
49
our %DPackageLibraryData;
50
our %DPackageLibraryDataStore;
51
 
52
#
53
#   Local Data
54
#
55
my $data_added;
56
 
57
#-------------------------------------------------------------------------------
58
# Function        : DPackageAdd
59
#
60
# Description     : Called to insert new information into the data store
61
#
62
# Inputs          : platform    - This does not need to be an active platform
63
#                                 it is simply passed to the DPACKAGE builder
64
#
65
#                   using       - The "using" target
66
#
67
#                   ...         - Arguments for the Library directive
68
#
69
# Returns         :
70
#
71
sub DPackageAdd
72
{
73
    my ($platform, $using, @args ) = @_;
7352 dpurdie 74
    Error ("Internal: DPackageAdd. ScmMakeUid is not defined") unless $::ScmMakeUid;
227 dpurdie 75
    push @{$DPackageLibraryData{$using}{$platform}}, @args;
7352 dpurdie 76
 
77
    # Auto package the output file
78
    unless ($data_added) {
79
        $data_added = 1;
80
        ::PackageFile( '*',getDpkgName(), '--Strip', '--Gbe' );
81
    }
227 dpurdie 82
}
83
 
84
#-------------------------------------------------------------------------------
85
# Function        : DPackageSave
86
#
7352 dpurdie 87
# Description     : Create a per-makefile file
88
#                   Ensure the files don't have machine or time specific information
89
#                   as they may be created at different time on multiple machines
90
#                   Will be OK as long as the file contents are the same
91
#                   
92
#                   Create file names in an known order so they can be consumed
93
#                   in the same order. 
227 dpurdie 94
#
95
# Inputs          :
96
#
97
# Returns         :
98
#
99
sub DPackageSave
100
{
7352 dpurdie 101
    my $dPkgFile = getDpkgName();
102
    Debug("DPackageSave: $dPkgFile");
227 dpurdie 103
    #
104
    #   Do not save if there is nothing to save and nothing has ever been saved
105
    #   Must update if there is anything previously saved
106
    #
7352 dpurdie 107
    unlink $dPkgFile;
108
    Verbose("DPackageSave Delete: $dPkgFile");
227 dpurdie 109
    return unless ( $data_added );
7352 dpurdie 110
    Verbose("DPackageSave Creating: $dPkgFile");
111
    mkpath ( StripFileExt($dPkgFile) );
112
 
113
    my $fh = ConfigurationFile::New( $dPkgFile, '--NoTime' );
114
    $fh->Header( "Auto-generated DPACKAGE", "JatsDPackage (version $VERSION)" );
115
    $fh->Comment("Defined in : " . RelPath( $Cwd, AbsPath($::ScmRoot)) );
116
    $fh->WriteLn("");
117
    $fh->WriteLn("Version( 1, 0 );    # Interface version" );
118
    $fh->WriteLn("");
227 dpurdie 119
    #
7352 dpurdie 120
    #   Process each "Using" entry
121
    #   Within each entry process the "platform" targets
122
    #   and generate Libraries directives.
227 dpurdie 123
    #
7352 dpurdie 124
    foreach my $using ( sort keys %DPackageLibraryData ) {
125
        my $uentry = $DPackageLibraryData{$using};
126
        $fh->WriteLn( "Using( '$using' );    # Usage name" );
227 dpurdie 127
 
7352 dpurdie 128
        foreach my $platform ( sort keys %{$uentry} ) {
129
            my $pentry = $uentry->{$platform};
130
            $fh->WriteLn( "\nLibraries('$platform'," );
131
            foreach my $entry ( @{$pentry} ) {
132
                $fh->WriteLn( "        '$entry'," ),
133
            }
227 dpurdie 134
 
7352 dpurdie 135
            $fh->WriteLn( "        );" ),
227 dpurdie 136
        }
137
    }
7352 dpurdie 138
    $fh->Close();
227 dpurdie 139
 
140
    #
7352 dpurdie 141
    #   Auto Package the file
142
    #   
227 dpurdie 143
}
144
 
145
#-------------------------------------------------------------------------------
7352 dpurdie 146
# Function        : getDpkgName 
227 dpurdie 147
#
7352 dpurdie 148
# Description     : Internal function to return the name of the DPACKAGE file
149
#                   generatde by this makefile
150
#                   
151
#                   The files are created in the 'interface/gbe' directory so that
152
#                   that they can be automatically found by the process that loads
153
#                   the definitions. ie: A makefile will be able to use the definitions 
154
#                   created within the same makefile.
155
#                   
156
#                   Use a 4 digit number so that the files can be ordered with a sort
227 dpurdie 157
#
158
# Inputs          : None
159
#
7352 dpurdie 160
# Returns         : Name of the genetated file 
227 dpurdie 161
#
7352 dpurdie 162
my $dPkgFile;
163
sub getDpkgName {
164
    unless ($dPkgFile) {
165
        $dPkgFile = "$::ScmRoot/$::ScmInterface/gbe/DPACKAGE_" . sprintf("%04d",$::ScmMakeUid) . ".cfg";
227 dpurdie 166
    }
7352 dpurdie 167
    return $dPkgFile;
227 dpurdie 168
}
169
1;
170