Subversion Repositories DevTools

Rev

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

Rev Author Line No. Line
392 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
392 dpurdie 3
#
4
# Module name   : new_toolset_def.pl
5
# Module type   : JATS Utility
6
# Compiler(s)   : Perl
7
# Environment(s): JATS
8
#
9
# Description   :
10
#
11
# Usage:
12
#
13
#
14
#......................................................................#
15
 
16
require 5.008_002;
17
use strict;
18
use warnings;
19
 
20
use JatsError;
21
 
22
my %ToolsetData;
23
 
24
sub ToolsetName
25
{
26
    ( $ToolsetData{name},$ToolsetData{long}, $ToolsetData{tag} ) = @_;
27
}
28
 
29
sub ToolsetSuffix
30
{
31
    foreach  ( @_ )
32
    {
33
        my ($tag,$value) = split( /\s*=\s*/, $_ );
34
        $ToolsetData{suffix}{$tag} = $value;
35
    }
36
}
37
 
38
sub ToolsetVar
39
{
40
    my $name = shift;
41
    Error ("ToolsetVar. No variable name") unless $name;
42
    foreach  ( @_ )
43
    {
44
        if ( m~^--Default=(.+)~i ) {
45
            $ToolsetData{ENV}{$name}{default} = $1;
46
        } elsif ( m~^--Value=(.+)~i ) {
47
            $ToolsetData{ENV}{$name}{value} = $1;
48
        } else {
49
            Error ("ToolsetVar. Unknown option: $_");
50
        }
51
    }
52
}
53
 
54
sub ToolsetPath
55
{
56
    push @{$ToolsetData{PATH}}, @_;
57
}
58
 
59
sub ToolsetInclude
60
{
61
    push @{$ToolsetData{INCLUDE}}, @_;
62
}
63
 
64
sub ToolsetLib
65
{
66
    push @{$ToolsetData{LIB}}, @_;
67
}
68
 
69
sub ToolsetRpcGen
70
{
71
    foreach ( @_)
72
    {
73
        if ( m~^--cpp=(.+)~i ) {
74
            $ToolsetData{RPCGEN}{CPP} = $1;
75
 
76
        } elsif ( m~^--flags=(.+)~i ) {
77
            $ToolsetData{RPCGEN}{FLAGS} = $1;
78
 
79
        } else {
80
            Error ("ToolsetRpcGen. Unknown option: $_");
81
        }
82
    }
83
}
84
 
85
sub ToolsetDef
86
{
87
    my ($name, $value ) = @_;
88
    push @{$ToolsetData{DEF}}, [ $name, $value ];
89
 
90
    push @{$ToolsetData{DEFORDER}}, $name;
91
    $ToolsetData{DEFDATA}{$name} = $value;
92
 
93
}
94
 
95
 
96
ToolsetName ( 'PHARLAP', 'Phar Lap ETS 10.1', 'vcwin32' );
97
 
98
ToolsetSuffix ( 'object=obj', 'assembler=asm', 'library=lib', 'program=.exe' );
99
 
100
ToolsetVar  ('PROGRAMFILES', '--Default=C:/Program Files' );
101
ToolsetVar  ('VSCommonDir',  '--Default=$(PROGRAMFILES)\Microsoft Visual Studio\Common' );
102
ToolsetVar  ('MSDevDir',     '--Default=$(PROGRAMFILES)\Microsoft Visual Studio\Common\MSDev98' );
103
ToolsetVar  ('MSVCDir',      '--Default=$(PROGRAMFILES)\Microsoft Visual Studio\VC98' );
104
ToolsetVar  ('VcOsDir',      '--Default=WINNT' );
105
ToolsetVar  ('PHARLAP_HOME', '--Default=c:/pharemb' );
106
#ToolsetVar  ('TEST', '--Default=c:/pharemb/$(JILL)' );
107
#ToolsetVar  ('TEST2', '--Default=c:/pharemb/$(JILL)/aaaa/$(JILL)' );
108
#ToolsetVar  ('TEST3', '--Default=c:/pharemb/$(TEST4)/aaaa/$(JILL)' );
109
#ToolsetVar  ('TEST4', '--Default=c:/pharemb/$(TEST3)/aaaa/$(JILL)' );
110
#ToolsetVar  ('JILL', '--Default=ThisIsJill' );
111
ToolsetVar  ('JILL', '--Value=ThisIsJill' );
112
 
113
ToolsetPath ( '$(PHARLAP_HOME)\bin' );
114
ToolsetPath ( '$(MSDevDir)\BIN' );
115
ToolsetPath ( '$(MSVCDir)\BIN' );
116
ToolsetPath ( '$(VSCommonDir)\TOOLS\$(VcOsDir)' );
117
ToolsetPath ( '$(VSCommonDir)\TOOLS' );
118
 
119
ToolsetInclude ('$(PHARLAP_HOME)\include' );
120
ToolsetInclude ('$(MSVCDir)\ATL\INCLUDE' );
121
ToolsetInclude ('$(MSVCDir)\INCLUDE' );
122
ToolsetInclude ('$(MSVCDir)\MFC\INCLUDE' );
123
 
124
ToolsetLib ('$(PHARLAP_HOME)\lib' );
125
ToolsetLib ('$(PHARLAP_HOME)\lib\vclib' );
126
ToolsetLib ('$(MSVCDir)\LIB' );
127
ToolsetLib ('$(MSVCDir)\MFC\LIB' );
128
 
129
ToolsetRpcGen ('--Cpp=c1','--Flags=-EP');
130
 
131
ToolsetDef ('VISUALC', '$(subst \,/,$(strip $(MSVCDir)))');
132
ToolsetDef ('visualc', '$(subst $(space),$(spacealt),$(subst \,/,$(strip $(MSVCDir))))');
133
 
134
 
135
DebugDumpData("Toolset BASE", \%ToolsetData );
136
 
137
#
138
#   Post process the ENV data
139
#       Extract real values from the environment
140
#       Determine real values
141
#           Keep symbolic values as well as physical values
142
#
143
foreach  ( keys %{$ToolsetData{ENV}} )
144
{
145
    next unless (  exists($ToolsetData{ENV}{$_}{default}) );
146
    if ( exists ($ENV{$_}) )
147
    {
148
        $ToolsetData{ENV}{$_}{value} = $ENV{$_};
149
    }
150
    else
151
    {
152
        $ToolsetData{ENV}{$_}{value} = $ToolsetData{ENV}{$_}{default};
153
    }
154
}
155
 
156
my $more = 1;
157
my %need;
158
while ( $more )
159
{
160
    $more = 0;
161
    %need = ();
162
    foreach  ( keys %{$ToolsetData{ENV}} )
163
    {
164
        next if ( exists $ToolsetData{ENV}{$_}{eval} );
165
        my $data = $ToolsetData{ENV}{$_}{value};
166
        if ( $data =~ m~\$\(([^\)]+)\)~ )
167
        {
168
            my $tag = $1;
169
            if ( exists $ToolsetData{ENV}{$tag} && exists $ToolsetData{ENV}{$tag}{eval} )
170
            {
171
                $data =~ s~\$\($tag\)~$ToolsetData{ENV}{$tag}{eval}~g;
172
                $ToolsetData{ENV}{$_}{value} = $data;
173
                $more = 1;
174
            }
175
            else
176
            {
177
                $need{$tag} = 1;
178
            }
179
        }
180
        else
181
        {
182
            $ToolsetData{ENV}{$_}{eval} = $data;
183
            push @{$ToolsetData{ENVORDER}}, $_;
184
 
185
        }
186
    }
187
 
188
}
189
 
190
if ( keys %need )
191
{
192
    Error ("Cannot resolve symbolic variables: ", sort keys %need );
193
}
194
 
195
sub expand
196
{
197
    my ($var) = @_;
198
    my $orginal = $var;
199
 
200
    while ( $var =~ m~\$\(([^\)]+)\)~ )
201
    {
202
        my $tag = $1;
203
        Error ("Cannot expand: $orginal. Unknown tag: $tag")
204
            unless ( exists $ToolsetData{ENV}{$tag} );
205
 
206
        $var =~ s~\$\($tag\)~$ToolsetData{ENV}{$tag}{eval}~g;
207
    }
208
 
209
   return $var;
210
}
211
 
212
DebugDumpData("Toolset", \%ToolsetData );
213
 
214
foreach  ( @{$ToolsetData{PATH}}, @{$ToolsetData{LIB}}, @{$ToolsetData{INCLUDE}}  )
215
{
216
    my $data = expand ($_);
217
    print "$_ => $data\n";
218
    Warning ("$_ does not exist") unless ( -d $data );
219
}
220
 
221
################################################################################
222
#   Create the makefile DEF file for this toolset
223
#
224
print "toolset = $ToolsetData{tag}\n";
225
 
226
foreach  ('object', 'library' ,'program', 'assembler' )
227
{
228
    my $data = '';
229
    $data = $ToolsetData{suffix}{$_} if ( exists $ToolsetData{suffix}{$_}  );
230
 
231
    print "$_ = $data\n" if $data;
232
}
233
 
234
#
235
#   Setup the environment defaults
236
#
237
foreach  ( @{$ToolsetData{ENVORDER}} )
238
{
239
    if ( exists $ToolsetData{ENV}{$_}{default} )
240
    {
241
        print "$_ ?= $ToolsetData{ENV}{$_}{default}\n";
242
    }
243
    else
244
    {
245
        print "$_  = $ToolsetData{ENV}{$_}{value}\n";
246
    }
247
}
248
 
249
#
250
#   Create a recipe to test the vality of the toolsets directories
251
#
252
print ".PHONY: $ToolsetData{tag}\n";
253
print "$ToolsetData{tag}:\n";
254
print "  ifndef GBE_NOTOOLSTEST\n";
6177 dpurdie 255
print "\@\$(echo) '[Toolset $ToolsetData{name} - $ToolsetData{long}]';";
392 dpurdie 256
foreach my $dir ( @{$ToolsetData{ENVORDER}} )
257
{
258
    print " \\\n";
259
    print "\t\tif [ -z \"\$\$$dir\" ]; then echo \"$dir env var not set\"; exit 2; fi;";
260
    print " \\\n";
261
    print "\t\tif [ ! -d \"\$($dir)\" ]; then echo \"Directory $dir does not exist: \$($dir)\"; exit 2; fi;";
262
}
263
print "\n";
264
print "  endif\n";
265
 
266
#
267
#   Set up the PATH
268
#
269
foreach  ( @{$ToolsetData{PATH}} )
270
{
271
    print "PATH := \$(PATH);$_\n";
272
}
273
print "Path := \$(PATH)\n";
274
print "export PATH Path\n";
275
 
276
#
277
#   Set up the INCLUDE variable
278
#
279
print "INCLUDE :=\n";
280
foreach  ( @{$ToolsetData{INCLUDE}} )
281
{
282
    print "INCLUDE := \$(INCLUDE);$_\n";
283
}
284
print "export INCLUDE\n";
285
 
286
#
287
#   Set up the LIB variable
288
#
289
print "LIB :=\n";
290
foreach  ( @{$ToolsetData{LIB}} )
291
{
292
    print "LIB := \$(LIB);$_\n";
293
}
294
print "export LIB\n";
295
 
296
#
297
#   Setup the RPC exports
298
#
299
print "RPCGEN_CPP	:= $ToolsetData{RPCGEN}{CPP}\n";
300
print "RPCGEN_CFLAGS	:= $ToolsetData{RPCGEN}{FLAGS}\n";
301
print "export RPCGEN_CPP RPCGEN_CFLAGS\n";
302
 
303
#
304
#   Any ad-hoc definitions
305
#
306
foreach my $name ( @{$ToolsetData{DEFORDER}} )
307
{
308
    print "$name := $ToolsetData{DEFDATA}{$name}\n";
309
}