| 3839 |
dpurdie |
1 |
########################################################################
|
|
|
2 |
# Copyright (C) 1998-2013 Vix Technology, All rights reserved
|
|
|
3 |
#
|
|
|
4 |
# Module name : MakePax.pm
|
|
|
5 |
# Module type : Jats Plugin
|
|
|
6 |
# Compiler(s) : Perl
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description : This package extends the JATS toolset at build time
|
|
|
10 |
# It provides additional directives to the JATS makefiles
|
|
|
11 |
# to simplify the directives.
|
|
|
12 |
#
|
|
|
13 |
# The directive matches up with a run-time tool to
|
|
|
14 |
# do the bulk of the work.
|
|
|
15 |
#
|
|
|
16 |
# Operation : This package adds the JATS directive MakePax
|
|
|
17 |
# When used the directive will use GenerateFiles to invoke
|
|
|
18 |
# a shell program at make-time to actually do the hard work.
|
|
|
19 |
#
|
|
|
20 |
# Directives : MakePax (platform, ... )
|
|
|
21 |
#
|
|
|
22 |
#
|
|
|
23 |
#......................................................................#
|
|
|
24 |
|
|
|
25 |
use strict;
|
|
|
26 |
use warnings;
|
|
|
27 |
use JatsError;
|
|
|
28 |
use FileUtils;
|
|
|
29 |
|
|
|
30 |
#
|
|
|
31 |
# Jats Globals
|
|
|
32 |
#
|
|
|
33 |
our $ScmPlatform;
|
|
|
34 |
|
|
|
35 |
#
|
|
|
36 |
# Imported environment varibles
|
|
|
37 |
# These MUST exist. Existence will be tested
|
|
|
38 |
#
|
|
|
39 |
our $MRI_INTELLECT;
|
|
|
40 |
our $MKS6_1A;
|
|
|
41 |
our $JAVA_HOME_1_6;
|
|
|
42 |
our $USER;
|
|
|
43 |
|
|
|
44 |
#-------------------------------------------------------------------------------
|
|
|
45 |
# Function : WinPath
|
|
|
46 |
#
|
|
|
47 |
# Description : Simple function to convert a relative JATS path into
|
|
|
48 |
# a windows freindly full path
|
|
|
49 |
#
|
|
|
50 |
# Inputs : path - Relative path
|
|
|
51 |
# noQuote - True - No quoting
|
|
|
52 |
#
|
|
|
53 |
# Returns : Absolute Windows Path
|
|
|
54 |
# Quoted so that it can be used in a 'set'
|
|
|
55 |
#
|
|
|
56 |
sub WinPath
|
|
|
57 |
{
|
|
|
58 |
my ($path, $noQuote) = @_;
|
|
|
59 |
$path = FullPath($path);
|
|
|
60 |
$path =~ s~/~\\~g;
|
|
|
61 |
if ( $path =~ m~\s~ && ! $noQuote) {
|
|
|
62 |
$path = '"' . $path . '"';
|
|
|
63 |
}
|
|
|
64 |
return $path;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
#-------------------------------------------------------------------------------
|
|
|
69 |
# Function : MakePax
|
|
|
70 |
#
|
|
|
71 |
# Description : Invoke the PAx builder to build the package
|
|
|
72 |
#
|
|
|
73 |
# Inputs : platform - Standard Platform Specifier
|
|
|
74 |
# Options
|
|
|
75 |
# --Application=path - path to app base
|
|
|
76 |
# --Component=name - Created component name
|
|
|
77 |
# --Platform=name - Target platform. Default=ALL
|
|
|
78 |
# --Pkg=VarName::Component - Use external component
|
|
|
79 |
# --Verbose - Enable Make Verbosity
|
|
|
80 |
#
|
|
|
81 |
# Returns : Nothing
|
|
|
82 |
#
|
|
|
83 |
sub MakePax
|
|
|
84 |
{
|
|
|
85 |
my ($platforms, @uargs) = @_;
|
|
|
86 |
my $appRoot;
|
|
|
87 |
my $appPlatform;
|
|
|
88 |
my $appComponent;
|
|
|
89 |
my $appVerbose= '';
|
|
|
90 |
my %pkgList;
|
|
|
91 |
my %pkgData;
|
|
|
92 |
|
|
|
93 |
return if ( ! ActivePlatform($platforms) );
|
|
|
94 |
foreach ( @uargs )
|
|
|
95 |
{
|
|
|
96 |
#
|
|
|
97 |
# Specify the base of the application to build
|
|
|
98 |
# Only one allowed
|
|
|
99 |
# Must be a directory
|
|
|
100 |
# Must contain a 'makefile'
|
|
|
101 |
#
|
|
|
102 |
if ( m~--Application=(.+)~i ) {
|
|
|
103 |
Error ("MakePax: Application Root specified multiple times")
|
|
|
104 |
if ( defined $appRoot );
|
|
|
105 |
$appRoot = $1;
|
|
|
106 |
Error ("MakePax: Application root not a directory")
|
|
|
107 |
unless ( -d $appRoot );
|
|
|
108 |
Error ("MakePax: Application root does not contain a 'makefile'")
|
|
|
109 |
unless ( -f join('/', $appRoot, 'makefile') );
|
|
|
110 |
|
|
|
111 |
#
|
|
|
112 |
# Specify a platform to build
|
|
|
113 |
# Only one allowed
|
|
|
114 |
# Default - all
|
|
|
115 |
#
|
|
|
116 |
} elsif ( m~--Platform=(.+)~i ) {
|
|
|
117 |
Error ("MakePax: Target platform specified multiple times")
|
|
|
118 |
if ( defined $appPlatform );
|
|
|
119 |
$appPlatform = $1;
|
|
|
120 |
|
|
|
121 |
#
|
|
|
122 |
# Specify the component that is built
|
|
|
123 |
# Only one allowed
|
|
|
124 |
#
|
|
|
125 |
} elsif ( m~--Component=(.+)~i ) {
|
|
|
126 |
Error ("MakePax: Target component specified multiple times")
|
|
|
127 |
if ( defined $appComponent );
|
|
|
128 |
$appComponent = $1;
|
|
|
129 |
|
|
|
130 |
#
|
|
|
131 |
# Specify packages to be used - and definition to create
|
|
|
132 |
# Multiple allowed
|
|
|
133 |
#
|
|
|
134 |
#
|
|
|
135 |
} elsif ( m~--Pkg=(.+)~i ) {
|
|
|
136 |
my $parg = $1;
|
|
|
137 |
Error ("MakePax: Bad Pkg specification: $parg")
|
|
|
138 |
unless ( $parg =~ m~(\w+):(.*)~ );
|
|
|
139 |
my $pvar = $1;
|
|
|
140 |
my $pcomp = $2;
|
|
|
141 |
Error ("MakePax: Multiple definition of Package Root variable: $pvar")
|
|
|
142 |
if ( exists $pkgList{$pvar} );
|
|
|
143 |
$pkgList{$pvar}{pcomp} = $pcomp;
|
|
|
144 |
|
|
|
145 |
#
|
|
|
146 |
# Enable PAX Build Verbosity
|
|
|
147 |
#
|
|
|
148 |
} elsif ( m~--Verbose~i ) {
|
|
|
149 |
$appVerbose = '1';
|
|
|
150 |
|
|
|
151 |
} else {
|
|
|
152 |
Error ("MakePax: Unknown option: $_");
|
|
|
153 |
}
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
#
|
|
|
157 |
# Detect missing options and insert defaults
|
|
|
158 |
#
|
|
|
159 |
Error ("MakePax: No application base has been specified")
|
|
|
160 |
unless ( defined $appRoot );
|
|
|
161 |
Error ("MakePax: No target component name been specified")
|
|
|
162 |
unless ( defined $appComponent );
|
|
|
163 |
$appPlatform = '' unless ( defined $appPlatform );
|
|
|
164 |
|
|
|
165 |
#
|
|
|
166 |
# Process dependent packages
|
|
|
167 |
#
|
|
|
168 |
foreach my $entry ( getPackageList() )
|
|
|
169 |
{
|
|
|
170 |
my $base = $entry->getBase(2);
|
|
|
171 |
next unless ( defined $base );
|
|
|
172 |
|
|
|
173 |
#
|
|
|
174 |
# Scan for package componets
|
|
|
175 |
# Locate Pax portion within the package
|
|
|
176 |
#
|
|
|
177 |
foreach ( keys %pkgList )
|
|
|
178 |
{
|
|
|
179 |
my $ventry = $pkgList{$_};
|
|
|
180 |
next if ( exists $ventry->{path} );
|
|
|
181 |
|
|
|
182 |
my $path = join ('/', $base, 'pkg', $ventry->{pcomp} );
|
|
|
183 |
if ( -d $path )
|
|
|
184 |
{
|
|
|
185 |
$ventry->{path} = $path;
|
|
|
186 |
$ventry->{pname} = $entry->{NAME};
|
|
|
187 |
my $tpath = join ('/', $path, 'tools' );
|
|
|
188 |
$ventry->{tool} = $tpath
|
|
|
189 |
if ( -d $tpath );
|
|
|
190 |
}
|
|
|
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
#
|
|
|
195 |
# Report missing components
|
|
|
196 |
#
|
|
|
197 |
my @elist;
|
|
|
198 |
foreach ( keys %pkgList )
|
|
|
199 |
{
|
|
|
200 |
my $ventry = $pkgList{$_};
|
|
|
201 |
next if ( exists $ventry->{path} );
|
|
|
202 |
|
|
|
203 |
push @elist, $ventry->{pcomp};
|
|
|
204 |
}
|
|
|
205 |
Error("MakePax: Pax components not found within dependent packages", @elist)
|
|
|
206 |
if ( @elist );
|
|
|
207 |
|
|
|
208 |
#
|
|
|
209 |
# Need a temp work area
|
|
|
210 |
# Place it in the interface directory
|
|
|
211 |
# Must be absolute path in windows format - done later
|
|
|
212 |
#
|
|
|
213 |
my $tmpDir = join('/', $::ScmRoot, $::ScmInterface);
|
|
|
214 |
|
|
|
215 |
#
|
|
|
216 |
# Ensure mandatory envVars are available
|
|
|
217 |
#
|
|
|
218 |
EnvImport('MRI_INTELLECT');
|
|
|
219 |
EnvImport('MKS6_1A');
|
|
|
220 |
EnvImport('JAVA_HOME_1_6');
|
|
|
221 |
EnvImport('USER');
|
|
|
222 |
|
|
|
223 |
#
|
|
|
224 |
# Create a Windows Batch file
|
|
|
225 |
# The file will
|
|
|
226 |
# Define the PAX EnvVars required to drive the PAx Builder
|
|
|
227 |
# Allow command to be processed with the batch file
|
|
|
228 |
#
|
|
|
229 |
my $fname = "intellect.bat";
|
|
|
230 |
my $fh = ::ConfigurationFile::New( $fname, '--NoEof', '--Type=bat' );
|
|
|
231 |
$fh->WriteLn ( "\@echo off");
|
|
|
232 |
$fh->Header( "MakePax","Set Intellect specific environment variables" );
|
|
|
233 |
|
|
|
234 |
#
|
|
|
235 |
# Guard the batch file
|
|
|
236 |
# Prevent the path being extended forever
|
|
|
237 |
#
|
|
|
238 |
$fh->WriteLn ( "" );
|
|
|
239 |
$fh->Comment ( "Only do once\n" );
|
|
|
240 |
$fh->WriteLn ( "if defined PAXVARS goto PaxSet");
|
|
|
241 |
$fh->WriteLn ( "set PAXVARS=1" );
|
|
|
242 |
|
|
|
243 |
#
|
|
|
244 |
# Export Package Name and Version
|
|
|
245 |
#
|
|
|
246 |
$fh->WriteLn ( "" );
|
|
|
247 |
$fh->Comment ( "Package Version Information\n" );
|
|
|
248 |
$fh->WriteLn ( "set GBE_BUILDPKG=$::ScmBuildPackage" );
|
|
|
249 |
$fh->WriteLn ( "set GBE_BUILDVER=$::ScmBuildVersionFull" );
|
|
|
250 |
$fh->WriteLn ( "set GBE_BUILDVERNUM=$::ScmBuildVersion" );
|
|
|
251 |
$fh->WriteLn ( "set GBE_BUILDPRJ=$::ScmBuildProject" );
|
|
|
252 |
|
|
|
253 |
#
|
|
|
254 |
# Define the components discovered
|
|
|
255 |
#
|
|
|
256 |
$fh->WriteLn ( "" );
|
|
|
257 |
$fh->Comment ( "Pax Components\n" );
|
|
|
258 |
foreach my $vname ( keys %pkgList )
|
|
|
259 |
{
|
|
|
260 |
my $ventry = $pkgList{$vname};
|
|
|
261 |
$fh->WriteLn ( "set $vname=" . $ventry->{path} );
|
|
|
262 |
}
|
|
|
263 |
|
|
|
264 |
#
|
|
|
265 |
# Define MRI Compiler location
|
|
|
266 |
# Note: It doesn't like to be installed in a location with a long pathname
|
|
|
267 |
# Normally install on c:\...
|
|
|
268 |
# Location is exported as a part of the JATS environment
|
|
|
269 |
#
|
|
|
270 |
$fh->WriteLn ( "" );
|
|
|
271 |
$fh->Comment ( "MRI Compiler section\n" );
|
|
|
272 |
$fh->WriteLn ( "set MRIROOT=" . WinPath($MRI_INTELLECT));
|
|
|
273 |
|
|
|
274 |
#
|
|
|
275 |
# MKS Toolkit
|
|
|
276 |
#
|
|
|
277 |
$fh->WriteLn ( "" );
|
|
|
278 |
$fh->Comment ( "MKS section\n" );
|
|
|
279 |
$fh->WriteLn ( "set ROOTDIR=" . WinPath($MKS6_1A) );
|
|
|
280 |
$fh->WriteLn ( "set MKSBIN_PATH=%ROOTDIR%\\mksnt" );
|
|
|
281 |
$fh->WriteLn ( "set SHELL=%ROOTDIR%/mksnt/sh.exe" );
|
|
|
282 |
$fh->WriteLn ( "set HOME=%ROOTDIR%" );
|
|
|
283 |
$fh->WriteLn ( "set LOGNAME=" . $USER );
|
|
|
284 |
|
|
|
285 |
#
|
|
|
286 |
# Java Section
|
|
|
287 |
#
|
|
|
288 |
$fh->WriteLn ( "" );
|
|
|
289 |
$fh->Comment ( "Java Section\n" );
|
|
|
290 |
$fh->WriteLn ( "set JAVAROOT=" . WinPath($JAVA_HOME_1_6) );
|
|
|
291 |
|
|
|
292 |
#
|
|
|
293 |
# Misc
|
|
|
294 |
# Don't know what __COMPAT_LAYER does. Was in sample file
|
|
|
295 |
#
|
|
|
296 |
$fh->WriteLn ( "" );
|
|
|
297 |
$fh->Comment ( "Misc section\n" );
|
|
|
298 |
$fh->WriteLn ( "set TMPDIR=" . WinPath($tmpDir) );
|
|
|
299 |
$fh->WriteLn ( "set __COMPAT_LAYER=" );
|
|
|
300 |
|
|
|
301 |
#
|
|
|
302 |
# Extend the PATH
|
|
|
303 |
#
|
|
|
304 |
$fh->WriteLn ( "" );
|
|
|
305 |
$fh->Comment ( "Extend Path\n" );
|
|
|
306 |
$fh->WriteLn ( 'if not "%1"=="" setlocal' );
|
|
|
307 |
$fh->WriteLn ( "path=%MKSBIN_PATH%;%path%" );
|
|
|
308 |
|
|
|
309 |
foreach my $vname ( keys %pkgList )
|
|
|
310 |
{
|
|
|
311 |
my $ventry = $pkgList{$vname};
|
|
|
312 |
next unless ( $ventry->{tool} );
|
|
|
313 |
$fh->WriteLn ( 'path=%path%;' . WinPath($ventry->{tool},1) );
|
|
|
314 |
}
|
|
|
315 |
|
|
|
316 |
#
|
|
|
317 |
# Remove some JATS Make EnvVars that will upset the MKSToolkit
|
|
|
318 |
#
|
|
|
319 |
$fh->WriteLn ( "" );
|
|
|
320 |
$fh->Comment ( "Remove JATS Make EnvVars\n" );
|
|
|
321 |
$fh->WriteLn ( ":PaxSet" );
|
|
|
322 |
$fh->WriteLn ( "set MAKE=");
|
|
|
323 |
$fh->WriteLn ( "set MAKEFLAGS=");
|
|
|
324 |
$fh->WriteLn ( "set MAKELEVEL=");
|
|
|
325 |
$fh->WriteLn ( "set MAKEOVERRIDES=");
|
|
|
326 |
|
|
|
327 |
|
|
|
328 |
# Allow a command to be executed
|
|
|
329 |
#
|
|
|
330 |
$fh->WriteLn ( "" );
|
|
|
331 |
$fh->Comment ( "Execute command within context of this batch file\n" );
|
|
|
332 |
$fh->WriteLn ( 'if not "%1"=="" echo Cmd:intellect.bat %*' );
|
|
|
333 |
$fh->WriteLn ( "%*" );
|
|
|
334 |
$fh->WriteLn ( "" );
|
|
|
335 |
$fh->Comment ( "Force process exist code, not just batch exit code\n" );
|
|
|
336 |
$fh->WriteLn ( "%COMSPEC% /C exit %ERRORLEVEL% >nul");
|
|
|
337 |
$fh->Close();
|
|
|
338 |
|
|
|
339 |
#
|
|
|
340 |
# Generate a jats GenerateFiles directive to do the hard work
|
|
|
341 |
# Pass the bulk of the work off to a perl script run at make-time
|
|
|
342 |
# Done in a script so that we can wrap in several operations
|
|
|
343 |
# and a bit of sanity testing
|
|
|
344 |
#
|
|
|
345 |
GenerateFiles ('*', "--Tool=MakePax.pl", # Associated tool
|
|
|
346 |
"--NoGenerate", # Build During Generate Phase
|
|
|
347 |
"--UnknownPreq", # Always build
|
|
|
348 |
"--Clean", # Script supports jats clean
|
|
|
349 |
"--Text=PaxMake", # Display when building
|
|
|
350 |
|
|
|
351 |
'--Var(BuildName)', # Target Package
|
|
|
352 |
'--Var(BuildVersion)', # Target Version
|
|
|
353 |
|
|
|
354 |
'--Var(InterfaceDir)', # Interface Directory
|
|
|
355 |
'--Var(PackageDir)', # My Package
|
|
|
356 |
|
|
|
357 |
"--Platform=$appPlatform", # Target platform
|
|
|
358 |
"--Verbose=$appVerbose", # Build Verbosely
|
|
|
359 |
"--Component=$appComponent", # My Packages component
|
|
|
360 |
"--Src=$appRoot" # Application Root
|
|
|
361 |
);
|
|
|
362 |
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
1;
|