| 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 build.pl file as parsed
|
|
|
10 |
# by JATS. This is more complete than the parser in the
|
|
|
11 |
# "BuildFile.pm"
|
|
|
12 |
#
|
|
|
13 |
# The purpose of this module is to provide an interface
|
|
|
14 |
# between (essentially) internal data structures and user
|
|
|
15 |
# scripts that need to access the data. These are primarily
|
|
|
16 |
# deployment scripts.
|
|
|
17 |
#
|
|
|
18 |
# The 'All' tag is used for backward compatabilty. It simply
|
|
|
19 |
# exports all the known data structures. NOT to be used by new
|
|
|
20 |
# code.
|
|
|
21 |
#
|
|
|
22 |
#
|
|
|
23 |
#
|
|
|
24 |
# Interface : ReadBuildConfig - Initialise module
|
|
|
25 |
# getPlatformParts - Get a list of Platform parts
|
|
|
26 |
#
|
|
|
27 |
#......................................................................#
|
|
|
28 |
|
|
|
29 |
require 5.6.1;
|
|
|
30 |
use strict;
|
|
|
31 |
use warnings;
|
|
|
32 |
|
|
|
33 |
#===============================================================================
|
|
|
34 |
package ReadBuildConfig;
|
|
|
35 |
use JatsError;
|
|
|
36 |
use JatsMakeInfo qw(:basic);
|
|
|
37 |
|
|
|
38 |
# automatically export what we need into namespace of caller.
|
|
|
39 |
use Exporter();
|
|
|
40 |
our (@ISA, @EXPORT, %EXPORT_TAGS, @EXPORT_OK);
|
|
|
41 |
@ISA = qw(Exporter);
|
|
|
42 |
@EXPORT = qw( ReadBuildConfig
|
|
|
43 |
getPlatformParts
|
|
|
44 |
getPackagePaths
|
|
|
45 |
);
|
|
|
46 |
@EXPORT_OK = qw( $InterfaceVersion
|
|
|
47 |
$ScmBuildMachType
|
|
|
48 |
$ScmInterfaceVersion
|
|
|
49 |
$ScmBuildName
|
|
|
50 |
$ScmBuildPackage
|
|
|
51 |
$ScmBuildVersion
|
|
|
52 |
$ScmBuildProject
|
|
|
53 |
$ScmBuildVersionFull
|
|
|
54 |
$ScmBuildPreviousVersion
|
|
|
55 |
$ScmProjectSupport
|
|
|
56 |
$ScmSrcDir
|
|
|
57 |
$ScmLocal
|
|
|
58 |
$ScmDeploymentPatch
|
|
|
59 |
$ScmBuildSrc
|
|
|
60 |
$ScmExpert
|
|
|
61 |
%ScmBuildAliases
|
|
|
62 |
%ScmBuildProducts
|
|
|
63 |
%ScmBuildPlatforms
|
|
|
64 |
%ScmBuildPkgRules
|
|
|
65 |
@BUILDPLATFORMS
|
|
|
66 |
@DEFBUILDPLATFORMS
|
|
|
67 |
@BUILDTOOLSPATH
|
|
|
68 |
%BUILDPLATFORM_PARTS
|
|
|
69 |
%BUILDINFO
|
|
|
70 |
);
|
|
|
71 |
|
|
|
72 |
%EXPORT_TAGS = (All => [@EXPORT, @EXPORT_OK]);
|
|
|
73 |
|
|
|
74 |
#-------------------------------------------------------------------------------
|
|
|
75 |
# Global variables
|
|
|
76 |
#
|
|
|
77 |
|
|
|
78 |
my $interface;
|
|
|
79 |
my $platform;
|
|
|
80 |
|
|
|
81 |
#
|
|
|
82 |
# The $InterfaceVersion value is manually maintained
|
|
|
83 |
# The integer part should be changed to indicate a incompatible change
|
|
|
84 |
# to the JATS files created within the interface directory
|
|
|
85 |
#
|
|
|
86 |
# $InterfaceVersion is treated as a float. The fractional part can be
|
|
|
87 |
# used to indicate minor changes to the file format.
|
|
|
88 |
#
|
|
|
89 |
our $InterfaceVersion = "2.0"; # Change will issue error message
|
|
|
90 |
|
|
|
91 |
#
|
|
|
92 |
# The following varaibles are "read" in from the build.cfg file
|
|
|
93 |
# In order to access simply access we need to declare them
|
|
|
94 |
#
|
|
|
95 |
our %BUILDINFO;
|
|
|
96 |
our %BUILDPLATFORM_PARTS;
|
|
|
97 |
our $ScmInterfaceVersion;
|
|
|
98 |
our %ScmBuildPkgRules;
|
|
|
99 |
our $ScmBuildMachType;
|
|
|
100 |
|
|
|
101 |
#-------------------------------------------------------------------------------
|
|
|
102 |
# Function : ReadBuildConfig
|
|
|
103 |
#
|
|
|
104 |
# Description : Read in the build config information
|
|
|
105 |
# Read in build.cfg
|
|
|
106 |
#
|
|
|
107 |
# Inputs : $interface - Path to the interface directory
|
|
|
108 |
# $platform - Platform being processed
|
|
|
109 |
#
|
|
|
110 |
# Returns : Nothing
|
|
|
111 |
#
|
|
|
112 |
sub ReadBuildConfig
|
|
|
113 |
{
|
|
|
114 |
$interface = shift;
|
|
|
115 |
$platform = shift;
|
|
|
116 |
|
|
|
117 |
my $no_test;
|
|
|
118 |
foreach ( @_ )
|
|
|
119 |
{
|
|
|
120 |
if ( m/^--NoTest/i ) {
|
|
|
121 |
$no_test = 1;
|
|
|
122 |
} else {
|
|
|
123 |
Warning ("ReadBuildConfig, Unknown option: $_");
|
|
|
124 |
}
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
Debug("BuildConfig::Reading config, $interface");
|
|
|
128 |
my $cfgfile = "$interface/build.cfg";
|
|
|
129 |
Error ("JATS internal file missing. Rebuild required",
|
|
|
130 |
"BuildConfig: Cannot find file: $cfgfile" ) unless ( -f $cfgfile );
|
|
|
131 |
|
|
|
132 |
#
|
|
|
133 |
# Include the build.cfg data
|
|
|
134 |
#
|
|
|
135 |
require ( $cfgfile );
|
|
|
136 |
|
|
|
137 |
#
|
|
|
138 |
# Ensure that the version of the interface files can be consumed
|
|
|
139 |
# The $ScmInterfaceVersion is a written copy of $InterfaceVersion
|
|
|
140 |
#
|
|
|
141 |
# Allow build.cfg files that do not have a ScmInterfaceVersion
|
|
|
142 |
# Assume that these are at version 1.0.
|
|
|
143 |
#
|
|
|
144 |
$ScmInterfaceVersion = '1.0' unless ( $ScmInterfaceVersion );
|
|
|
145 |
Debug ("ReadBuildConfig: Version: $ScmInterfaceVersion, Need: $InterfaceVersion");
|
|
|
146 |
if ( int($ScmInterfaceVersion) != int($InterfaceVersion) )
|
|
|
147 |
{
|
|
|
148 |
Error ("JATS interface files are not compatible with this version of JATS",
|
|
|
149 |
"Rebuild required.",
|
|
|
150 |
"Current Interface Version: $ScmInterfaceVersion",
|
|
|
151 |
"JATS Interface Version : $InterfaceVersion" );
|
|
|
152 |
}
|
|
|
153 |
|
|
|
154 |
#
|
|
|
155 |
# Ensure that this config file is designed for this machine type
|
|
|
156 |
# At make-time this test may not be valid. It should have been
|
|
|
157 |
# validated before make-time.
|
|
|
158 |
#
|
|
|
159 |
TestMachType ($ScmBuildMachType, "build.cfg") unless $no_test;
|
|
|
160 |
|
|
|
161 |
#
|
|
|
162 |
# Remove some unused data
|
|
|
163 |
# Reduces the size of Makefile.cfg. Speeds up writting
|
|
|
164 |
#
|
|
|
165 |
if ( $platform )
|
|
|
166 |
{
|
|
|
167 |
for (keys %::ScmBuildPlatforms)
|
|
|
168 |
{
|
|
|
169 |
next if ($_ eq $platform );
|
|
|
170 |
delete ($::BUILDPLATFORM_PARTS{$_} );
|
|
|
171 |
delete ($::BUILDINFO{$_} );
|
|
|
172 |
delete ($::ScmBuildPkgRules{$_} );
|
|
|
173 |
}
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
# dump
|
|
|
177 |
#
|
|
|
178 |
Debug( "Aliases:" );
|
|
|
179 |
if ( ! defined(%::ScmBuildAliases) ) {
|
|
|
180 |
Debug( " undefined" );
|
|
|
181 |
|
|
|
182 |
} else {
|
|
|
183 |
foreach my $key (keys %::ScmBuildAliases) {
|
|
|
184 |
my( @value ) = split( ' ', $::ScmBuildAliases{ $key } );
|
|
|
185 |
Debug( " $key\t= @value" );
|
|
|
186 |
}
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
Debug( "Products:" );
|
|
|
190 |
if ( ! defined(%::ScmBuildProducts) ) {
|
|
|
191 |
Debug( " undefined" );
|
|
|
192 |
|
|
|
193 |
} else {
|
|
|
194 |
foreach my $key (keys %::ScmBuildProducts) {
|
|
|
195 |
my( @value ) = split( ',', $::ScmBuildProducts{ $key } );
|
|
|
196 |
Debug( " $key\t= @value" );
|
|
|
197 |
}
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
Debug( "Platforms:" );
|
|
|
201 |
if ( ! defined(%::ScmBuildPlatforms) ) {
|
|
|
202 |
Debug( " undefined" );
|
|
|
203 |
|
|
|
204 |
} else {
|
|
|
205 |
foreach my $key (keys %::ScmBuildPlatforms) {
|
|
|
206 |
my( @args ) = split( /$;/, $::ScmBuildPlatforms{ $key } );
|
|
|
207 |
Debug( " $key\t= @args" );
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
#-------------------------------------------------------------------------------
|
|
|
213 |
# Function : getPlatformParts
|
|
|
214 |
#
|
|
|
215 |
# Description : return a list of platform parts
|
|
|
216 |
#
|
|
|
217 |
# Inputs : None
|
|
|
218 |
#
|
|
|
219 |
# Returns : A list of platform parts to search in the interface
|
|
|
220 |
# directory, local directory or other
|
|
|
221 |
#
|
|
|
222 |
sub getPlatformParts
|
|
|
223 |
{
|
|
|
224 |
Error ("BuildConfig. Not initialised") unless ( $platform );
|
|
|
225 |
return @{$BUILDINFO{$platform}{PARTS}};
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
#-------------------------------------------------------------------------------
|
|
|
229 |
# Function : getPackagePaths
|
|
|
230 |
#
|
|
|
231 |
# Description : Return a list of all packages
|
|
|
232 |
# LinkPkgarchive packages will be provided as is
|
|
|
233 |
# BuildPkgArchive packages will be provided as a single
|
|
|
234 |
# reference to the interface directory
|
|
|
235 |
#
|
|
|
236 |
# Inputs : Options
|
|
|
237 |
# --Interface=xxxx Path to the interface dir
|
|
|
238 |
# If provided, then the path
|
|
|
239 |
# will be used for the first
|
|
|
240 |
# BuildPkgArchive
|
|
|
241 |
# --All All paths
|
|
|
242 |
# --Tools All Tools Paths
|
|
|
243 |
# --Gbe All Gbe paths
|
|
|
244 |
#
|
|
|
245 |
# Returns : An array of paths
|
|
|
246 |
#
|
|
|
247 |
sub getPackagePaths
|
|
|
248 |
{
|
|
|
249 |
Error ("BuildConfig. Not initialised") unless ( $platform );
|
|
|
250 |
|
|
|
251 |
my $interface;
|
|
|
252 |
my $all;
|
|
|
253 |
my $need;
|
|
|
254 |
my @result;
|
|
|
255 |
|
|
|
256 |
#
|
|
|
257 |
# Parse Options
|
|
|
258 |
#
|
|
|
259 |
foreach ( @_ )
|
|
|
260 |
{
|
|
|
261 |
if ( m~^--Interface=(.+)~ ) {
|
|
|
262 |
$interface = $1;
|
|
|
263 |
} elsif ( m~^--All~ ) {
|
|
|
264 |
$all = 1;
|
|
|
265 |
} elsif ( m~^--Tools~ ) {
|
|
|
266 |
$need = 'TOOLDIRS';
|
|
|
267 |
} elsif ( m~^--Gbe~ ) {
|
|
|
268 |
$need = 'CFGDIR';
|
|
|
269 |
} else {
|
|
|
270 |
Error ("BuildConfig. Unknown Option: $_");
|
|
|
271 |
}
|
|
|
272 |
}
|
|
|
273 |
|
|
|
274 |
#
|
|
|
275 |
# Locate rqeuired entries
|
|
|
276 |
#
|
|
|
277 |
for my $entry (@{$ScmBuildPkgRules{$platform} })
|
|
|
278 |
{
|
|
|
279 |
#
|
|
|
280 |
# Do we need this entry
|
|
|
281 |
# Select tools and gbe entries
|
|
|
282 |
#
|
|
|
283 |
my @subdirs = '/';
|
|
|
284 |
if ( $need )
|
|
|
285 |
{
|
|
|
286 |
next unless ( exists ($entry->{$need} ) );
|
|
|
287 |
my $subdir = $entry->{$need};
|
|
|
288 |
if ( ref($subdir) eq 'ARRAY' ) {
|
|
|
289 |
@subdirs = @{$subdir};
|
|
|
290 |
} else {
|
|
|
291 |
@subdirs = $subdir;
|
|
|
292 |
}
|
|
|
293 |
}
|
|
|
294 |
|
|
|
295 |
#
|
|
|
296 |
# If a BuildPkgArchive, then give the interface dir, unless
|
|
|
297 |
# we need all the true paths
|
|
|
298 |
#
|
|
|
299 |
if ( ($entry->{'TYPE'} eq 'build' ) && !$all )
|
|
|
300 |
{
|
|
|
301 |
if ( $interface )
|
|
|
302 |
{
|
|
|
303 |
push @result, $interface;
|
|
|
304 |
$interface = '';
|
|
|
305 |
}
|
|
|
306 |
}
|
|
|
307 |
else
|
|
|
308 |
{
|
|
|
309 |
foreach my $subdir ( @subdirs )
|
|
|
310 |
{
|
|
|
311 |
my $dir = $entry->{'ROOT'} . $subdir;
|
|
|
312 |
$dir =~ s~/+~/~g;
|
|
|
313 |
$dir =~ s~/+$~~g;
|
|
|
314 |
push @result, $dir;
|
|
|
315 |
}
|
|
|
316 |
}
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
return @result;
|
|
|
320 |
}
|
|
|
321 |
|
|
|
322 |
#------------------------------------------------------------------------------
|
|
|
323 |
1;
|