Subversion Repositories DevTools

Rev

Rev 363 | Rev 5710 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
########################################################################
2
# Copyright ( C ) 2007 ERG Limited, All rights reserved
3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats build system
8
#
9
# Description   : Provide access to information from the Makefile.gbe file
10
#
11
#                 Designed to be called by utilities that process
12
#                 makefile data.
13
#
14
# Interface     : CreateMakeInfo            - Create MAkefile.gbe
15
#                 ReadMakeInfo              - Read Makefile.gbe
16
#                 TestMachType              - Validate Machine Type
17
#
18
#......................................................................#
19
 
255 dpurdie 20
require 5.006_001;
227 dpurdie 21
use strict;
22
use warnings;
23
 
24
#===============================================================================
25
 
26
 
27
package JatsMakeInfo;
28
 
29
use JatsError;
30
use ConfigurationFile;
31
 
32
# automatically export what we need into namespace of caller.
33
use Exporter();
34
our (@ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK, @EXPORT_BASIC);
35
@ISA         = qw(Exporter);
36
@EXPORT      = qw(  TestMachType
37
                    ReadMakeInfo
38
                    $ScmBuildMachType
39
                    $ScmRoot
40
                    $ScmInterface
363 dpurdie 41
                    $ScmBuildFilter
227 dpurdie 42
                );
43
@EXPORT_OK =  qw(
44
                    CreateMakeInfo
45
                    TestMachType
46
                );
47
@EXPORT_BASIC = qw(
48
                    TestMachType
49
                  );
50
 
51
%EXPORT_TAGS = (create => [@EXPORT_OK],
52
                basic  => [@EXPORT_BASIC]);
53
 
54
#-------------------------------------------------------------------------------
55
#   Global variables
56
#
273 dpurdie 57
#our $GBE_HOSTMACH;                          # Current machine type
227 dpurdie 58
our $ScmBuildMachType;                      # from Makefile.gbe
59
our $ScmRoot;                               # Built Root
60
our $ScmInterface;                          # Interface (relative to root)
61
 
62
#-------------------------------------------------------------------------------
63
# Function        : BEGIN
64
#
65
# Description     : Global initialisation
66
#                   Ensure required environment variables are present
67
#
68
# Inputs          : 
69
#
70
# Returns         : 
71
#
72
BEGIN
73
{
273 dpurdie 74
    $::GBE_HOSTMACH = $ENV{ GBE_HOSTMACH };
75
    Error( "Environment Variable 'GBE_HOSTMACH' not defined." )
76
            unless( defined $::GBE_HOSTMACH );
227 dpurdie 77
}
78
 
79
 
80
#-------------------------------------------------------------------------------
81
# Function        : CreateMakeInfo
82
#
83
# Description     : Create the Makefile.gbe file
84
#                   This contains sufficient info to locate:
85
#                       The build root
86
#                       The interface
87
#                   Designed to be required directly into a script
88
#
89
# Inputs          : EnvVars
90
#
91
# Returns         : 
92
#
93
sub CreateMakeInfo
94
{
95
    #
96
    #   Validate globals that are used
97
    #
98
    Error ("JatsMakeInfo - ScmRoot not defined") unless ( $::ScmRoot  );
99
    Error ("JatsMakeInfo - ScmInterface not defined") unless ( $::ScmInterface  );
273 dpurdie 100
    Error ("JatsMakeInfo - GBE_HOSTMACH not defined") unless ( $::GBE_HOSTMACH  );
227 dpurdie 101
 
102
    #
103
    #   Create Makefile.gbe in the current directory
104
    #
105
    my $fh = ConfigurationFile::New( "Makefile.gbe" );
106
    $fh->Header( $::ScmMakelib , 'Make Control Files');
273 dpurdie 107
    $fh->Write("\$ScmBuildMachType = \"$::GBE_HOSTMACH\";\n") ;
227 dpurdie 108
    $fh->Write("\$ScmRoot          = \"$::ScmRoot\";\n") ;
109
    $fh->Write("\$ScmInterface     = \"$::ScmInterface\";\n") ;
363 dpurdie 110
    $fh->Write("\$ScmBuildFilter   = \"$::GBE_BUILDFILTER\";\n") if ($::GBE_BUILDFILTER) ;
227 dpurdie 111
    $fh->Close();
3967 dpurdie 112
 
113
    ::ToolsetFile ("Makefile.gbe");
227 dpurdie 114
}
115
 
116
 
117
#-------------------------------------------------------------------------------
118
# Function        : ReadMakeInfo
119
#
120
# Description     : Reads in Makefile.gbe data in the current directory
121
#                   This is used to provide basic information including
122
#                   The path to the build root
123
#                   The path to the interface directory
124
#
125
# Inputs          :
126
#
127
# Returns         : Reference to a structure that contains the data
128
#
129
#
130
sub ReadMakeInfo
131
{
132
    #
133
    #   Read in the file
134
    #   Reads some global variables directly into the global variable space
135
    #
136
    my $tag_file = "Makefile.gbe";
137
    Error ("Expected config file not found: $tag_file") unless ( -f $tag_file );
138
    require $tag_file;
139
 
140
    #
141
    #   Sanity tests
142
    #
143
    Error ("Bad Makefile.gbe file. Rebuild required") unless ( $ScmBuildMachType );
144
    TestMachType ( $ScmBuildMachType, "Makefile.gbe" );
145
 
146
}
147
 
148
#-------------------------------------------------------------------------------
149
# Function        : TestMachType
150
#
151
# Description     : Validate the current machine type
152
#
153
# Inputs          : MachType to test
154
#                   Source of test
155
#
156
# Returns         : May not return
157
#
158
sub TestMachType
159
{
160
    my ($MachType, $src) = @_;
161
 
162
    Error ("Incorrect Machine Type in $src",
163
           "The build has been construct for a Machine Type of: $MachType",
273 dpurdie 164
           "Current Machine Type is: $::GBE_HOSTMACH",
165
           ) unless ( $MachType eq $::GBE_HOSTMACH );
227 dpurdie 166
}
167
 
168
#------------------------------------------------------------------------------
169
1;