Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
227 dpurdie 1
#
2
# Module name   : vcwin32
3
# Module type   : Makefile system
4
# Compiler(s)   : ANSI C
5
# Environment(s): WIN32
6
#
7
# Description:
8
#       Visual C/C++ for WIN32
9
#
10
#............................................................................#
11
 
12
use strict;
13
use warnings;
14
 
15
#
16
#   Global data
17
#
18
my $pdb_file = "\$(GBE_PBASE)";
19
my $pdb_first_lib;
20
my $target_file_lib;
21
my $target_file_dll;
22
my $target_file_exe;
23
my $pdb_none;
24
 
25
##############################################################################
26
#   Version information
27
#
28
my $toolset_info;
29
my $toolset_version = 'MSVC6';
30
my %ToolsetVersion =
31
    (
255 dpurdie 32
        'MSVC6'      =>  { 'def'        => 'vcwin32.def' ,
33
                           'buildcmd'   => 'msdev =DSW= /make "ALL - =TYPE=" /useenv /out =LOG=' ,
34
                           'cleancmd'   => 'msdev =DSW= /make "ALL - =TYPE=" /clean /useenv' ,
35
                           'tmp'        => 'vc60',
36
                           'VSCOMPILER' => '1',
37
                           },
227 dpurdie 38
 
255 dpurdie 39
        'MS.NET2003' =>  { 'def'        => 'vcwin32_net2003.def' ,
40
                           'buildcmd'   => 'devenv =DSW= /build =TYPE= /useenv /out =LOG=' ,
41
                           'cleancmd'   => 'devenv =DSW= /clean =TYPE= /useenv' ,
42
                           'tmp'        => 'vc70',
43
                           'VSCOMPILER' => '2',
44
                           },
45
 
46
        'MS.NET2005' =>  { 'def'        => 'vcwin32_net2005.def' ,
47
                           'buildcmd'   => 'devenv =DSW= /build =TYPE= /useenv /out =LOG=' ,
48
                           'cleancmd'   => 'devenv =DSW= /clean =TYPE= /useenv' ,
49
                           'tmp'        => 'vc80',
50
                           'VSCOMPILER' => '3',
51
                           'GenManifest' => '1',
52
                           },
291 dpurdie 53
 
54
        'MS.NET2008' =>  { 'def'        => 'vcwin32_net2008.def' ,
55
                           'buildcmd'   => 'devenv =DSW= /build =TYPE= /useenv /out =LOG=' ,
56
                           'cleancmd'   => 'devenv =DSW= /clean =TYPE= /useenv' ,
57
                           'tmp'        => 'vc90',
58
                           'VSCOMPILER' => '3',
59
                           'GenManifest' => '1',
60
                           },
61
 
227 dpurdie 62
    );
63
 
64
 
65
##############################################################################
66
#   ToolsetInit()
67
#       Runtime initialisation
68
#
69
##############################################################################
70
 
71
ToolsetInit();
72
 
73
sub ToolsetInit
74
{
75
 
76
#.. Parse arguments (Toolset arguments)
77
#
78
    Debug( "vcwin32(@::ScmToolsetArgs)" );
79
 
80
    foreach $_ ( @::ScmToolsetArgs ) {
81
        if (/^--Version=(.*)/) {           # MS SDK Version
82
            $toolset_version = $1;
83
 
84
        } else {
85
            Message( "vcwin32 toolset: unknown option $_ -- ignored\n" );
86
        }
87
    }
88
 
89
#.. Parse arguments (platform arguments)
90
#
91
    Debug( "vcwin32(@::ScmPlatformArgs)" );
92
 
93
    foreach $_ ( @::ScmPlatformArgs ) {
94
        if (/^--product=(.*)/) {                # GBE product
95
 
96
        } elsif (/^--Version=(.*)/) {           # MS SDK Version
97
            $toolset_version = $1;
98
 
99
        } elsif (/^--NoDinkumware/) {           # Dinkumware package test
100
 
101
        } else {
102
            Message( "vcwin32 toolset: unknown platform argument $_ -- ignored\n" );
103
        }
104
    }
105
 
106
#.. Validate SDK version
255 dpurdie 107
#   Currently three versions are supported
227 dpurdie 108
#       1) MSVC6            - As provided via Visual Studio
109
#       2) MSVS.net 2003    - Used to create .NET applications
255 dpurdie 110
#       2) MSVS.net 2005    - Used to create .NET applications
227 dpurdie 111
#
112
    $toolset_info = $ToolsetVersion{$toolset_version};
113
    Error( "Unknown version: $toolset_version" ) unless ( defined $toolset_info );
114
 
115
 
116
#.. Standard.rul requirements
117
#
118
    $::s = 'asm';
119
    $::o = 'obj';
120
    $::a = 'lib';
121
    $::so = 'dll';
122
    $::exe = '.exe';
123
 
124
#.. Toolset configuration
125
#
126
    $::ScmToolsetVersion = "1.0.0";             # our version
127
    $::ScmToolsetGenerate = 0;                  # generate optional
261 dpurdie 128
    $::ScmToolsetProgDependancies = 0;          # handle Prog dependancies myself
227 dpurdie 129
 
130
#.. define Visual C/C+ environment
131
    Init( "visualc" );
132
    ToolsetDefines( $toolset_info->{'def'} );
255 dpurdie 133
    PlatformDefine ("VSCOMPILER\t= $toolset_info->{'VSCOMPILER'}" );
227 dpurdie 134
    ToolsetRequire( "exctags" );                # and Exuberant Ctags
135
    ToolsetRules( "vcwin32.rul" );
136
    ToolsetRules( "standard.rul" );
137
 
138
#.. define PCLint envrionment
139
    ToolsetRequire( "pclint" );                 # using pclint
140
    PlatformDefine ("LINT_COFILE\t= co-msc60.lnt");
141
    PlatformDefine ("LINT_PRJ_FILE\t=lint.visualc");
142
 
143
#.. Cleanup rules
144
#
145
    ToolsetGenerate( "\$(OBJDIR)/$toolset_info->{'tmp'}.idb" );     # vc60.idb
146
    ToolsetGenerate( "\$(OBJDIR)/$toolset_info->{'tmp'}.pch" );
147
    ToolsetGenerate( "\$(OBJDIR)/$toolset_info->{'tmp'}.pdb" );
148
    ToolsetGenerate( "\$(PDB)" );
149
    ToolsetGenerate( "\$(PDB).tmp" );
150
 
151
 
152
#
153
#   The PDB files need to be compiled up with absolute paths to the source files
154
#   The easiest way to do this is with the makefile rules created with absolute
155
#   paths. Set a global flag to enable this option
156
#
157
    $::UseAbsObjects = 1;
158
 
159
 
160
#.. Extend the CompilerOption directive
161
#   Create a standard data structure
162
#   This is a hash of hashes
163
#       The first hash is keyed by CompileOption keyword
164
#       The second hash contains pairs of values to set or remove
165
#
166
    %::ScmToolsetCompilerOptions =
167
    (
168
        #
169
        #   Control the thread model to use
170
        #   This will affect the compiler options and the linker options
171
        #
172
        'multithread_static' => { 'THREADMODE' , 'T' },      # -MT
173
        'multithread_dll'    => { 'THREADMODE' , 'D' },      # -MD Default
174
        'multithread_none'   => { 'THREADMODE' , 'L' },      # -ML
175
 
176
        'subsystem:windows'  => { 'LDSUBSYSTEM' , 'windows' },
177
        'subsystem:console'  => { 'LDSUBSYSTEM' , 'console' },
178
 
179
        'rtti'               => { 'USE_RTTI', 1 },
180
        'nopdb'              => { 'PDB_NONE', 1 },
181
        'pdb'                => { 'PDB_NONE', undef },
182
        'noaddlibs'          => { 'ADDLINKLIBS' , undef },      # Don't add link libs
183
        'addlibs'            => { 'ADDLINKLIBS' , '1' },        # default
184
        'noprecompilehdrs'   => { 'PRECOMPILEHDRS' , undef },   # Don't precompile headers
185
        'precompilehdrs'     => { 'PRECOMPILEHDRS' , '1' },     # default
186
 
187
        #
188
        #   Mimic some of the behavior of version-1 JATS
189
        #
190
        'jats_v1'            => { 'USE_JATS_V1' => '1' },
191
    );
192
 
193
    #
194
    #   Set default options
195
    #
196
    $::ScmCompilerOpts{'THREADMODE'} = 'D';
197
    $::ScmCompilerOpts{'ADDLINKLIBS'} = '1';
198
    $::ScmCompilerOpts{'PRECOMPILEHDRS'} = '1';
199
}
200
 
201
##############################################################################
202
#   ToolsetPreprocess()
203
#       Process collected data before the makefile is generated
204
#       This, optional, routine is called from within MakefileGenerate()
205
#       It allows the toolset to massage any of the collected data before
206
#       the makefile is created
207
#
208
##############################################################################
209
sub ToolsetPreprocess
210
{
211
    #
212
    #   Extract the current state of PDB_NONE
213
    #   Are PDB files to be constructed.
214
    #
215
    $pdb_none = $::ScmCompilerOpts{'PDB_NONE'};
216
}
217
 
218
##############################################################################
219
#   ToolsetPostprocess
220
#       Process collected data as the makefile is generated
221
#       This, optional, routine is called from within MakefileGenerate()
222
#       It allows the toolset to massage any of the collected data before
223
#       the makefile is finally closed created
224
#
225
##############################################################################
226
 
227
sub ToolsetPostprocess
228
{
267 dpurdie 229
    MakeHeader('Toolset Postprocessed Information');
227 dpurdie 230
 
231
    #
232
    #   Specify the name of the global PDB file. This is used for all
233
    #   compiles other than those associated with building a DLL
234
    #
235
    #   The name of the PDB will be based on either
236
    #       The name of base package
237
    #       The name of the first static library created
238
    #
239
 
240
MakePrint("
241
#
242
#   Export the name of the common PDB file
243
#   All compiler information will be placed in this file
244
#   The name of the file MUST be the same as the name of the output library
245
#
246
PDB		= \$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb
247
" );
248
 
249
    #
250
    #   Add values to the perl environment
251
    #   May be used by post processing tools to create Visual Studio Projects
252
    #
253
    $::TS_pdb_file = "\$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb" unless( $pdb_none );
254
    $::TS_sbr_support = 1;
255
 
256
    #
257
    #   Prioritorise target: EXE, DLL, LIB
258
    #
259
    for my $tgt ( $target_file_exe, $target_file_dll, $target_file_lib  )
260
    {
261
        if ( $tgt )
262
        {
263
            $::TS_target_file = $tgt;
264
            last;
265
        }
266
    }
267
}
268
 
269
 
270
###############################################################################
271
#   ToolsetCTAGS()
272
#       This subroutine takes the user options and builds the rules
273
#       required to build the CTAGS database.
274
#
275
#   Arguments:
276
#       --xxx                   No arguments currently defined
277
#
278
#   Output:
279
#       [ctags:]
280
#           $(EXCTAGS)
281
#
282
###############################################################################
283
 
284
sub ToolsetCTAGS
285
{
286
    EXCTAGS( @_ );
287
}
288
 
289
 
290
###############################################################################
291
#   ToolsetCC( $source, $obj, \@args )
292
#       This subroutine takes the user options and builds the rule(s)
293
#       required to compile the source file 'source' to 'obj'
294
#
295
###############################################################################
296
 
297
sub ToolsetCC
298
{
299
    ToolsetCC_common( "CC", @_ );
300
}
301
 
302
sub ToolsetCC_common
303
{
304
    my( $name, $source, $obj, $pArgs ) = @_;
305
    my( $cflags, $pdb );
306
 
307
    foreach $_ ( @$pArgs ) {
308
        if (/--Shared$/) {                      # Building a 'shared' object
309
            $cflags = "$cflags \$(SHCFLAGS)";
310
            $pdb = $::SHOBJ_LIB{$obj}
311
                if (exists $::SHOBJ_LIB{$obj} );
312
 
313
        } else {
314
            Message( "vcwin32 $name: unknown option $_ -- ignored\n" );
315
        }
316
    }
317
 
318
    MakePrint( "\n\t\$($name)\n" );
319
    MakePadded( 4, "\$(OBJDIR)/$obj.$::o:", "\tCFLAGS +=$cflags\n" )
320
        if ( $cflags );                         # object specific CFLAGS
321
 
322
    if ( $pdb && !$pdb_none )
323
    {
324
        #
325
        #   Determine the name of the PDB file
326
        #   If we are building a shared library then the name of the PDB
327
        #   MUST NOT be the same as the name of the library as there is
328
        #   some stange interaction with the linker ( 50% of the time )
329
        #   This is OK as the file will not be published
330
        #
331
        #   If building a static library then create a PDB of the same
332
        #   name as it may be published directly.
333
        #
334
        my $pdb_file;
335
        if ($cflags )
336
        {
337
            $pdb_file = "\$(OBJDIR)/${pdb}\$(GBE_TYPE)_shlib.pdb";
338
        }
339
        else
340
        {
341
            $pdb_file = "\$(OBJDIR)/${pdb}\$(GBE_TYPE).pdb";
342
        }    
343
 
344
        MakePadded( 4, "\$(OBJDIR)/$obj.$::o:", "\tPDB = $pdb_file\n" );
345
        ToolsetGenerate( $pdb_file );
346
        ToolsetGenerate( $pdb_file . ".tmp" );
347
    }
348
 
349
    #
350
    #   Remove possible Source Browser Files
351
    #
352
    ToolsetGenerate( "\$(OBJDIR)/$obj.sbr" );
353
    MakePrint( "\n" );
354
}
355
 
356
 
357
###############################################################################
358
#   ToolsetCCDepend( $depend, \@sources )
359
#       This subroutine takes the user options and builds the
360
#       rule(s) required to build the dependencies for the source
361
#       files 'sources' to 'depend'.
362
#
363
###############################################################################
364
 
365
sub ToolsetCCDepend
366
{
367
    MakePrint( "\t\$(CCDEPEND)\n" );
368
}
369
 
370
 
371
###############################################################################
372
#   ToolsetCXX( $source, $obj, \@args )
373
#       This subroutine takes the user options and builds the rule(s)
374
#       required to compile the source file 'source' to 'obj'
375
#
376
###############################################################################
377
 
378
sub ToolsetCXX
379
{
380
    ToolsetCC_common( "CXX", @_ );
381
}
382
 
383
###############################################################################
384
#   ToolsetCXXDepend( $depend, \@sources )
385
#       This subroutine takes the user options and builds the
386
#       rule(s) required to build the dependencies for the source
387
#       files 'sources' to 'depend'.
388
#
389
###############################################################################
390
 
391
sub ToolsetCXXDepend
392
{
287 dpurdie 393
    ToolsetCCDepend();
227 dpurdie 394
}
395
 
396
 
397
###############################################################################
398
#   ToolsetAS( $source, $obj, \@args )
399
#       This subroutine takes the user options and builds the rule(s)
400
#       required to compile the source file 'source' to 'obj'
401
#
402
###############################################################################
403
 
404
sub ToolsetAS
405
{
406
    MakePrint( "\n\t\$(AS)\n" );
407
}
408
 
409
sub ToolsetASDepend
410
{
411
}
412
 
413
###############################################################################
414
#   ToolsetAR( $name, \@args, \@objs )
415
#       This subroutine takes the user options and builds the rules
416
#       required to build the library 'name'.
417
#
418
#   Arguments:
419
#       --Def=name              Library definition module
420
#
421
#   Output:
422
#       [ $(LIBDIR)/name$.${a}:   .... ]
423
#           $(AR)
424
#
425
###############################################################################
426
 
427
sub ToolsetAR
428
{
429
    my( $name, $pArgs, $pObjs ) = @_;
430
    my( $def );
431
    my ( $res, @reslist );
432
    my $lib_base = "\$(LIBDIR)/${name}\$(GBE_TYPE)";
433
    my $lib_name = "$lib_base.${a}";
434
 
435
 
436
#.. Parse arguments
437
#
438
    $def = "";                                  # options
439
    $res = "";
440
 
441
    foreach $_ ( @$pArgs ) {
442
        if (/^--Def=(.*)/) {                    # library definition
443
            $def = "$1";
444
 
445
        } elsif (/^--Resource=(.*)/) {          # Resource definition
446
            ($res, @reslist) = ToolsetRClist( "$name", $1 );
447
 
448
        } else {                                # unknown
449
            Message( "vcwin32 AR: unknown option $_ -- ignored\n" );
450
        }
451
    }
452
 
453
#.. Resource Creation
454
#
455
    MakePrint( "#.. Library Resource ($name)\n\n" );
456
    ToolsetRCrecipe( $res, @reslist )
457
        if ( $res );
458
 
459
#.. Target
460
#
461
    MakePrint( "#.. Library ($name)\n\n" );     # label
462
 
463
    MakePrint( "$lib_name:\tLIBDEF=$def\n" ) if ($def);
464
    MakeEntry( "$lib_name:\t", "", "\\\n\t\t", ".$::o", @$pObjs );
465
    MakePrint( "\\\n\t\t$def" ) if ($def);
466
    MakePrint( "\\\n\t\t$res" ) if ($res);
467
    MakePrint( "\n\t\$(AR)" );
468
 
469
#
470
#   Track the name of the possible target file
471
#   Used when creating Visual Studio projects
472
#
473
    $target_file_lib = $lib_name;
474
 
475
#
476
#   To assist in debugging the static library it is nice to
477
#   keep the PDB file used to build the library, with the library.
478
#
479
#   If the library is being packaged or installed then add the PDB
480
#   file to the package / installation
481
#
482
#   NOTE: Due to the limitations of JATS/MicroSoft only one static
483
#   library can be built with a PDB file. The name of the PDB file
484
#   will be taken from the first static library encountered
485
#
486
    unless ( $pdb_first_lib )
487
    {
488
        $pdb_first_lib = $name;
489
        $pdb_file = $name;
490
    }
491
    else
492
    {
493
        Warning( "Multiple static libraries created with a common PDB file: $pdb_file, $name" )
494
            unless( $pdb_none );
495
    }
496
 
497
    PackageLibAddFiles( $name, "\$(OBJDIR)/$pdb_file\$(GBE_TYPE).pdb", "Class=debug" )
498
        unless( $pdb_none );
499
}
500
 
501
 
502
###############################################################################
503
#   ToolsetARLINT( $name, \@args, \@objs )
504
#       This subroutine takes the user options and builds the rules
505
#       required to build the library 'name'.
506
#
507
#   Arguments:
508
#       --xxx                   No arguments currently defined
509
#
510
#   Output:
511
#       [ $(LIBDIR)/name$_lint:   .... ]
512
#           $(ARLINT)
513
#
514
###############################################################################
515
 
516
sub ToolsetARLINT
517
{
518
    PCLintAR( @_ );
519
}
520
 
521
 
522
###############################################################################
523
#   ToolsetARMerge( $name, \@args, \@libs )
524
#       This subroutine takes the user options and builds the rules
525
#       required to build the library 'name' by merging the specified
526
#       libaries
527
#
528
#   Arguments:
529
#       --xxx                   No arguments currently defined
530
#
531
#   Output:
532
#       [ $(LIBDIR)/name$.${a}:   .... ]
533
#           ...
534
#
535
###############################################################################
536
 
537
sub ToolsetARMerge
538
{
539
    my ($name, $pArgs, $pLibs) = @_;
540
    MakePrint( "\n\t\$(ARMERGE)\n\n" );
541
 
542
    #
543
    #   Package up the PDB's with the library
544
    #   Note: The PDBs will be found in the OBJDIR
545
    #
546
    unless( $pdb_none )
547
    {
548
        for ( @{$pLibs} )
549
        {
550
            s~\$\(LIBDIR\)~\$(OBJDIR)~;
551
            PackageLibAddFiles( $name, "$_\$(GBE_TYPE).pdb", "Class=debug" );
552
        }
553
    }
554
}
555
 
556
 
557
###############################################################################
289 dpurdie 558
#   ToolsetSHLD $name, \@args, \@objs, \@libraries, $_ver )
227 dpurdie 559
#       This subroutine takes the user options and builds the rules
560
#       required to link a shared library
561
#
562
#   Arguments:
563
#       --Def=xxxx.def[,opts]           # Definition file
564
#           --MutualDll                 # SubOption: Generate a Mutual DLL
565
#       --MutualDll                     # Generate a Mutual DLL (requires --Def=xxx)
566
#       --StubOnly                      # Only generate the stub library (requires --Def=xxx)
567
#       --Resource=xxxx.rc              # Resource file
568
#       --ResourceOnly                  # Only resources in this DLL
569
#       --Implib                        # Alternate ruleset
570
#       --NoPDB                         # Do not package the PDB file
571
#       --NoImplib                      # Do not package the import library
572
#       --Entry=xxxxx                   # Entry point
573
#       --NoAddLibs                     # Do not add libraries
574
#
575
#   Output:
576
#
577
#       There is two supported rule sets differentiated by --Implib
578
#       The two are very similar and generated exportable files of:
579
#
580
#       --Implib
581
#           ${name}.lib         - Stub lib adresses the versioned DLL
582
#           ${name}.${ver}.dll
583
#
584
#       Default
585
#           ${name}.lib         - Stub lib addresses UN-versioned DLL
586
#           ${name}.dll
587
#           ${name}.${ver}.dll
588
#
589
#       Note: Each DLL has an associated PDB file
590
#
591
#       Generation is identical for both rulesets. The default form does
592
#       not export any stub library associated with the versioned DLL.
593
#
594
#   Implementation notes
595
#   The process of creating a DLL and associated import library (LIB) is
596
#
597
#           ${name}.${ver}.dep
598
#           ${name}.${ver}.pdb          - Exported
599
#           ${name}.${ver}.ilk
600
#           ${name}.${ver}.dll          - Exported
601
#           ${name}.${ver}.map
602
#           ${name}.lib                 - Exported + Optional
603
#           ${name}.exp
604
#
605
#       Where:    lib = name
606
#
607
#       #.. Rules ($lib)
608
#
609
#       $(LIBDIR)/${lib}.lib:               $(LIBDIR)/${lib}.${ver}.dll
610
#       $(LIBDIR)/${lib}.pdb:               $(LIBDIR)/${lib}.${ver}.dll
611
#       $(LIBDIR)/${lib}.${ver}.pdb:        $(LIBDIR)/${lib}.${ver}.dll
612
#
613
#       $(LIBDIR)/${lib}.${ver}.dep:        SHBASE=${name}
614
#       $(LIBDIR)/${lib}.${ver}.dep:        SHNAME=${lib}.${ver}
615
#       $(LIBDIR)/${lib}.${ver}.dep:        \$(LIBDIR)
616
#       $(LIBDIR)/${lib}.${ver}.dep:        Makefile
617
#           $(SHLDDEPEND)
618
#
619
#       $(LIBDIR)/${lib}.${ver}.${so}:      SHBASE=${name}
620
#       $(LIBDIR)/${lib}.${ver}.${so}:      SHNAME=${lib}.${ver}
621
#       $(LIBDIR)/${lib}.${ver}.${so}:      CFLAGS+=$(SHCFLAGS)
622
#       $(LIBDIR)/${lib}.${ver}.${so}:      CXXLAGS+=$(SHCXXFLAGS)
623
#       $(LIBDIR)/${lib}.${ver}.${so}:      ${def}
624
#       $(LIBDIR)/${lib}.${ver}.${so}:      $(OBJDIR)/${name} \
625
#                       object list ... \
626
#                       $(LIBDIR)/${lib}.${ver}.dep
627
#           $(SHLD)
628
#           @$(cp) -f $(LIBDIR)/${lib}.${ver}.pdb $(LIBDIR)/${lib}.pdb
629
#
630
#       ifneq "$(findstring $(IFLAG),23)" ""
631
#       -include        "$(LIBDIR)/${lib}.${ver}.dep"
632
#       endif
633
#
634
#       #.. Linker commands ($lib)
635
#
636
#       ${lib}_ld       += ...
637
#               standard flags                          \
638
#               -implib:$${lib}.lib
639
#
640
#       #.. Linker commands ($lib)
641
#
642
#       ${lib}_shdp     += ...
643
#
644
###############################################################################
645
 
646
sub ToolsetSHLD
647
{
289 dpurdie 648
    our( $name, $pArgs, $pObjs, $pLibs, $_ver ) = @_;
227 dpurdie 649
    our( $def, $mutual_dll, $res, @reslist, $doimplib, $stub_only );
650
    our( $no_implib, $no_pdb, $resource_only );
651
    our( $entry, $noaddlibs );
652
 
653
#.. Parse arguments
654
#
655
    $def = "";                                  # options
656
    $doimplib = 0;
657
    $res = "";
658
    $no_pdb = $pdb_none;
659
 
660
    foreach $_ ( @$pArgs ) {
661
        if (/^--Def=(.*?)(\,(.*))?$/) {         # Library definition
662
            #
663
            #   Locate the Def file.
664
            #   If it is a generate file so it will be in the SRCS hash
665
            #   Otherwise the user will have to use Src to locate the file
666
            #
667
            $def = MakeSrcResolve($1);
668
 
669
            #
670
            #   Process sub options to --Def
671
            #
672
            next unless ($2);
673
            if ( $3 =~ /^--MutualDll$/ ) {
674
                $mutual_dll = 1;
675
            } else {
676
                Message( "vcwin32 SHLD: unknown option $_ -- ignored\n" );
677
            }
678
 
679
        } elsif (/^--Resource=(.*)/) {          # Resource definition
680
            ($res, @reslist) = ToolsetRClist( "$name/$name", $1 );
681
 
682
        } elsif (/^--ResourceOnly/) {          # Resource definition
683
            $resource_only = 1;
684
 
685
        } elsif (/^--Implib$/) {
686
            $doimplib = 1;
687
 
688
        } elsif (/^--NoImplib$/) {
689
            $no_implib = 1;
690
 
691
        } elsif (/^--NoPDB$/) {
692
            $no_pdb = 1;
693
 
694
        } elsif (/^--Entry=(.*)/) {
695
            $entry = $1;
696
 
697
        } elsif (/^--NoAddLib/) {
698
            $noaddlibs = 1;
699
 
700
        } elsif (/^--MutualDll$/) {
701
            $mutual_dll = 1;
702
 
703
        } elsif (/^--Stubonly/) {
704
            $stub_only = 1;
705
        } else {                                # unknown
706
            Message( "vcwin32 SHLD: unknown option $_ -- ignored\n" );
707
        }
708
    }
709
 
710
    #
711
    #   Sanity test
712
    #
713
    Error ("vcwin32 SHLD:Stubonly option requires --Def=file ")
714
        if ( $stub_only && ! $def );
715
 
716
    Error ("vcwin32 SHLD:MutualDll option requires --Def=file ")
717
        if ( $mutual_dll && ! $def );
718
 
719
 
720
 
721
#.. Build rules
722
#
723
#   base    -   Basic name of the DLL
724
#   name    -   Name of the Export library (Optional)
725
#   lib     -   Name of the DLL
726
#
727
    sub BuildSHLD
728
    {
729
        my ($base, $name, $lib) = @_;
730
        my $full = $lib.".$::so";
731
        my $link_with_def;
732
 
733
    #.. Cleanup rules
734
    #
735
    #   dep     Dependency file
736
    #   ld      Linker command file
737
    #   map     Map file
738
    #   pdb     Microsoft C/C++ program database
739
    #   ilk     Microsoft Linker Database
740
    #
741
        ToolsetGenerate( "\$(LIBDIR)/${lib}.ld" );
742
        ToolsetGenerate( "\$(LIBDIR)/${lib}.dep" );
743
        ToolsetGenerate( "\$(LIBDIR)/${lib}.map" );
744
        ToolsetGenerate( "\$(LIBDIR)/${lib}.exp" );
745
        ToolsetGenerate( "\$(LIBDIR)/${lib}.ilk" );
746
        ToolsetGenerate( "\$(LIBDIR)/${full}" );
255 dpurdie 747
        ToolsetGenerate( "\$(LIBDIR)/${full}.manifest" ) if $toolset_info->{'GenManifest'};
227 dpurdie 748
 
749
    #.. Linker rules
750
    #
751
        my ($io) = ToolsetPrinter::New();
752
 
753
        my $import_lib;
754
        my $export_file;
755
 
756
        if ( $name && $def && ($mutual_dll || $stub_only ) )
757
        {
758
            #
759
            #   Creating an Export library from user .DEF file
760
            #   It is possible to create the stub library in the LIB phase
761
            #   which allows DLLs with mutual imports
762
            #
763
            $io->Label( "Import(stub) library for mutual exports", $name );
764
            $export_file = "\$(LIBDIR)/${name}.exp";
765
 
766
            #
767
            #   Rules and recipe to generate the stub library
768
            #
769
            $io->Prt( "\$(LIBDIR)/${name}.exp:\t\$(LIBDIR)/${name}.${a}\n" );
770
            $io->Prt( "\$(LIBDIR)/${name}.${a}:\tLIBDEF=$def\n" );
771
            $io->Prt( "\$(LIBDIR)/${name}.${a}:\tLIBNAME=$lib\n" );
772
            $io->Entry( "\$(LIBDIR)/${name}.${a}: \\\n\t\t\$(OBJDIR)/${base}",
773
                                            "", " \\\n\t\t", ".$::o", @$pObjs );
774
            $io->Prt( " \\\n\t\t$def" );
775
            $io->Prt( "\n\t\t\$(AR)\n" );
776
            $io->Newline();
777
 
778
            #
779
            #   Files to be cleanup up
780
            #
781
            ToolsetGenerate( "\$(LIBDIR)/${name}.exp" );
782
            ToolsetGenerate( "\$(LIBDIR)/${name}.${a}" );
783
 
784
            #
785
            #   If the DLL is being packaged/installed then add the static
786
            #   stub library to the packaging lists as a static library
787
            #   This will allow the stub library to be installed with the
788
            #   static libraries and thus allow DLL's with mutual imports
789
            #
790
            PackageShlibAddLibFiles ($base, "\$(LIBDIR)/${name}.${a}" )
791
                unless ($resource_only);
792
 
793
            #
794
            #   Add the stub library to the list of libraries being created
795
            #   Note: Don't do if not created with .DEF file
796
            #
797
            push @::LIBS, $base;
798
 
799
        }
800
        else
801
        {
802
            #
803
            #   The stub library is created as part of the DLL generation
804
            #   Whether we like it or not - so we need to control the name
805
            #   and location
806
            #
807
            my $slname = ($name) ? $name : $lib;
808
            $import_lib = "\$(LIBDIR)/${slname}.${a}";
809
 
810
            $io->Label( "Import(stub) library", $slname );
811
            $io->Prt( "$import_lib:\t\$(LIBDIR)/${full}\n" );
812
            $io->Newline();
813
 
814
            ToolsetGenerate( $import_lib );
815
            ToolsetGenerate( "\$(LIBDIR)/${slname}.exp" );
816
 
817
            #
818
            #   Package the generated stub library, if it is being
819
            #   created on request.
820
            #
821
            #   Package it with the shared libaries and not the static
822
            #   libraries as it will be created with the shared library
823
            #
824
            PackageShlibAddFiles ($base, $import_lib, 'Class=lib' )
825
                if ($name && ! $no_implib && ! $resource_only);
826
 
827
            #
828
            #   Indicate that we will be linking with a DEF file
829
            #
830
            $link_with_def = 1 if ( $def );
831
        }
832
 
833
        #
834
        #   If we are only creating a stub library, then the hard work has been
835
        #   done.
836
        #
837
        return
838
            if ($stub_only);
839
 
840
        $io->Label( "Shared library", $name );
841
 
842
        #
843
        #   The process of creating a DLL will generate PDB file
844
        #   Control the name of the PDB file
845
        #
846
        my $pdb_file = "\$(LIBDIR)/${lib}.pdb";
847
        unless( $no_pdb )
848
        {
849
            $io->Prt( "$pdb_file:\t\$(LIBDIR)/${full}\n" );
850
            ToolsetGenerate( $pdb_file );
851
        }
852
 
853
        #
854
        #   Package the PDB file up with the DLL
855
        #   Package the DLL - now that we know its proper name
856
        #
857
        PackageShlibAddFiles( $base, $pdb_file, 'Class=debug' ) unless $no_pdb ;
858
        PackageShlibAddFiles( $base, "\$(LIBDIR)/${full}" );
859
 
860
        #
861
        #   Generate Shared Library dependency information
862
        #
863
        $io->SHLDDEPEND( $lib, $name, $lib );   # std SHLDDEPEND rules
864
 
865
        #
866
        #   Generate rules and recipes to create the body of the shared
867
        #   library. Several build variables are overiden when creating
868
        #   a shared library.
869
        #
870
        $io->Prt( "\$(LIBDIR)/${full}:\tSHBASE=${lib}\n" );
871
        $io->Prt( "\$(LIBDIR)/${full}:\tSHNAME=${lib}\n" );
872
        $io->Prt( "\$(LIBDIR)/${full}:\tCFLAGS+=\$(SHCFLAGS)\n" );
873
        $io->Prt( "\$(LIBDIR)/${full}:\tCXXLAGS+=\$(SHCXXFLAGS)\n" );
874
        $io->Prt( "\$(LIBDIR)/${full}:\t$export_file\n" ) if ($export_file );
875
        $io->Prt( "\$(LIBDIR)/${full}:\t$res\n" ) if ( $res );
876
 
261 dpurdie 877
        $io->Entry( "\$(LIBDIR)/${full}: \$(LIBDIR)/${lib}.dep \\\n\t\t\$(OBJDIR)/${base}",
227 dpurdie 878
            "", " \\\n\t\t", ".$::o", @$pObjs );
879
 
880
        $io->Prt( " \\\n\t\t$def" ) if ( $link_with_def );
261 dpurdie 881
        $io->Prt( "\n\t\$(SHLD)\n" );
227 dpurdie 882
 
883
        $io->Newline();
884
 
885
        #.. Linker command file
886
        #
887
        #       Now the fun part... piecing together a variable ${name}_shld
888
        #       which ends up in the command file.
889
        #
890
        $io->SetTag( "${lib}_shld" );          # command tag
891
 
892
        $io->Label( "Linker commands", $name ); # label
893
 
894
        $io->Cmd( "-dll" );
895
        $io->Cmd( "-noentry" )if ($resource_only);
291 dpurdie 896
        $io->Cmd( "-machine:X86" );
227 dpurdie 897
        $io->Cmd( "-base:0x10000000" );
898
        $io->Cmd( "-def:$def" ) if ($link_with_def);
899
        $io->Cmd( "-out:\$(subst /,\\\\,\$(LIBDIR)/${full})" );
900
        $io->Cmd( "-implib:\$(subst /,\\\\,$import_lib)" ) if ($import_lib);
901
        $io->Cmd( "-pdb:\$(subst /,\\\\,$pdb_file)" )       unless ( $no_pdb );
902
        $io->Cmd( "-debug:none" )                           if ($no_pdb);
903
        $io->Cmd( "-pdb:none" )                             if ($no_pdb);
904
        $io->Cmd( "-entry:$entry" )                         if ($entry);
905
        $io->Cmd( "-map:\$(subst /,\\\\,\$(LIBDIR)/${lib}).map" );
906
        $io->Cmd( "-nodefaultlib:LIBC" );
907
        $io->Cmd( "\$(subst /,\\\\,$res)" ) if ( $res );
908
        $io->Cmd( "\$(subst /,\\\\,$export_file)" ) if ( $export_file );
909
 
910
                                                # object list
911
        $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
912
 
913
                                                # library list
914
        $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
915
 
916
        $io->Newline();
917
 
918
        #.. Dependency link,
919
        #
920
        #       Now piece together a variable $(name_dp) which ends up in
921
        #       the command file building the application dependency list.
922
        #
923
        $io->SetTag( "${lib}_shdp" );          # command tag
924
 
925
        $io->DepRules( $name, $pLibs,           # library depends rules
926
            \&ToolsetLibRecipe, "\$(LIBDIR)/${full}" );
927
 
928
        $io->Newline();
929
    }
930
 
931
    ToolsetLibStd( $pLibs )                    # push standard libraries
932
        unless ( $noaddlibs );
933
 
934
    if ( $doimplib ) {
935
        #
936
        #   --Implib flavor will create
937
        #       a) Import library   $name$(GBE_TYPE).lib
938
        #       b) Versioned DLL    $name$(GBE_TYPE).xx.xx.xx.dll
939
        #
289 dpurdie 940
        $target_file_dll = "\$(LIBDIR)/$name\$(GBE_TYPE).$_ver.$::so";
227 dpurdie 941
        BuildSHLD(
289 dpurdie 942
            "$name",                        # Base Name
943
            "$name\$(GBE_TYPE)",            # Name of Export Lib
944
            "$name\$(GBE_TYPE).$_ver");      # Name of the DLL + PDB
227 dpurdie 945
 
946
    } else {
947
        #
948
        #   Original flavor will create
949
        #       a) Import library   $name$(GBE_TYPE).lib    ---+
950
        #       b) Unversioned DLL  $name$(GBE_TYPE).dll    <--+
951
        #       c) Versioned DLL    $name$(GBE_TYPE).xx.xx.xx.dll
952
        #
953
        MakePrint(
954
            "# .. Versioned image\n\n".
289 dpurdie 955
            "\$(LIBDIR)/${name}\$(GBE_TYPE).$_ver.$::so:\t".
227 dpurdie 956
            "\$(LIBDIR)/${name}\$(GBE_TYPE).$::so\n".
957
            "\n" );
958
 
959
        $target_file_dll = "\$(LIBDIR)/$name\$(GBE_TYPE).$::so";
289 dpurdie 960
        BuildSHLD( "$name", ""                  , "$name\$(GBE_TYPE).$_ver" );
227 dpurdie 961
        BuildSHLD( "$name", "$name\$(GBE_TYPE)" , "$name\$(GBE_TYPE)" );
962
    }
963
 
964
    #.. Resource File
965
    #
966
    ToolsetRCrecipe( $res, @reslist )
967
        if ( $res );
968
}
969
 
970
 
971
###############################################################################
972
#   ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
973
#       This subroutine takes the user options and builds the rules
974
#       required to lint the program 'name'.
975
#
976
#   Arguments:
977
#       (none)
978
#
979
#   Output:
980
#       [ $(LIBDIR)/$name_lint:   .... ]
981
#           $(SHLIBLINT)
982
#
983
###############################################################################
984
 
985
sub ToolsetSHLDLINT
986
{
987
    PCLintSHLIB( @_ );
988
}
989
 
990
###############################################################################
261 dpurdie 991
# Function        : ToolsetLD
227 dpurdie 992
#
261 dpurdie 993
# Description     : Takes the user options and builds the rules required to
994
#                   link the program 'name'.
227 dpurdie 995
#
261 dpurdie 996
# Inputs          : $name           - base name of the program
997
#                   $pArgs          - Ref to program arguments
998
#                   $pObjs          - Ref to program objects
999
#                   $pLibs          - Ref to program library list
227 dpurdie 1000
#
261 dpurdie 1001
# Returns         : Nothing
227 dpurdie 1002
#
261 dpurdie 1003
# Output:         : Rules and recipes to create a program
1004
#                       Create program rules and recipes
1005
#                       Create linker input script
1006
#                       Create library dependency list
1007
#                       Include library dependency information
227 dpurdie 1008
#
1009
sub ToolsetLD
1010
{
1011
    my ( $name, $pArgs, $pObjs, $pLibs ) = @_;
1012
    my ( $res, @reslist );
1013
    my $no_pdb =$pdb_none;
1014
    our( $entry, $noaddlibs );
1015
 
1016
#.. Parse arguments
1017
#
1018
    foreach ( @$pArgs ) {
1019
        if (/^--Resource=(.*)/) {               # Resource definition
1020
            ($res, @reslist) = ToolsetRClist( $name, $1 );
1021
 
1022
        } elsif (/^--NoPDB$/) {
1023
            $no_pdb = 1;
1024
 
1025
        } elsif (/^--Entry=(.*)/) {
1026
            $entry = $1;
1027
 
1028
        } elsif (/^--NoAddLib/) {
1029
            $noaddlibs = 1;
1030
 
1031
        } else {
1032
            Message( "vcwin32 LD: unknown option $_ -- ignored\n" );
1033
 
1034
        }
1035
    }
1036
 
261 dpurdie 1037
#.. Names of important files
1038
#
1039
    my $base = "\$(BINDIR)/${name}";
1040
    my $full = $base . $::exe;
1041
    my $map  = $base . '.map';
1042
    my $pdb  = $base . '.pdb';
1043
    my $dep  = $base . '.dep';
1044
 
1045
 
227 dpurdie 1046
#.. Cleanup rules
1047
#
255 dpurdie 1048
#   dep             Dependency file
1049
#   ld              Linker command file
1050
#   map             Map file
1051
#   pdb             Microsoft C/C++ program database
1052
#   ilk             Microsoft Linker Database
1053
#   res             Compiled resource script
261 dpurdie 1054
#   exe.manifest    Manifest file (VS2005)
227 dpurdie 1055
#
261 dpurdie 1056
    ToolsetGenerate( $dep );
1057
    ToolsetGenerate( $map );
1058
    ToolsetGenerate( $pdb );
1059
    ToolsetGenerate( $base . '.ld' );
1060
    ToolsetGenerate( $base . '.ilk' );
1061
    ToolsetGenerate( $full . '.manifest' ) if $toolset_info->{'GenManifest'};
227 dpurdie 1062
 
1063
#.. Linker command
1064
#
1065
    my ($io) = ToolsetPrinter::New();
1066
 
261 dpurdie 1067
    $io->Prt( "$full : $dep " );
1068
    $io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
1069
    $io->Prt( "\\\n\t$res " ) if ( $res );
1070
    $io->Prt( "\n\t\$(LD)\n\n" );
227 dpurdie 1071
 
1072
 
1073
#.. Linker command file
1074
#
1075
#       Now piece together a variable $(name_ld) which ends up in
1076
#       the command file linking the application.
1077
#
1078
    $io->SetTag( "${name}_ld" );                # macro tag
1079
 
1080
    $io->Label( "Linker commands", $name );     # label
1081
 
261 dpurdie 1082
    $io->Cmd( "-out:\$(subst /,\\\\,$full)" );
1083
    $io->Cmd( "-pdb:\$(subst /,\\\\,$pdb)" )        unless ($no_pdb);
1084
    $io->Cmd( "-debug:none" )                       if ($no_pdb);
1085
    $io->Cmd( "-pdb:none" )                         if ($no_pdb);
1086
    $io->Cmd( "-entry:$entry" )                     if ($entry);
1087
    $io->Cmd( "-map:\$(subst /,\\\\,$map)" );
227 dpurdie 1088
    $io->Cmd( "-nodefaultlib:LIBC" );
291 dpurdie 1089
    $io->Cmd( "-machine:X86" );
261 dpurdie 1090
    $io->Cmd( "\$(subst /,\\\\,$res)" )             if ( $res );
227 dpurdie 1091
 
261 dpurdie 1092
    ToolsetLibStd( $pLibs ) unless ( $noaddlibs );      # push standard libraries
1093
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );  # object list
1094
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );  # library list
1095
    $io->Newline();
227 dpurdie 1096
 
261 dpurdie 1097
#.. Library dependency information
1098
#   Rules to include a .dep file when required
1099
#
1100
    $io->LDDEPEND( $name );
227 dpurdie 1101
 
1102
#.. Dependencies
1103
#
1104
#       Now piece together a variable $(name_dp) which ends up in
1105
#       the command file building the application dependency list.
1106
#
261 dpurdie 1107
    $io->SetTag( "${name}_dp" );                                # macro tag
1108
    $io->DepRules( $name, $pLibs, \&ToolsetLibRecipe, $full );  # library depends rules
227 dpurdie 1109
    $io->Newline();
1110
 
1111
#.. Compile up the resource file
1112
#
1113
    ToolsetRCrecipe( $res, @reslist )
1114
        if ( $res );
1115
 
261 dpurdie 1116
#.. Package up the program and the PDB
227 dpurdie 1117
#
261 dpurdie 1118
    PackageProgAddFiles ( $name, $full );
1119
    PackageProgAddFiles ( $name, $pdb, "Class=debug" ) unless ( $no_pdb );
227 dpurdie 1120
 
1121
#
1122
#   Track the name of the possible target file
1123
#   Used when creating Visual Studio projects
1124
#
261 dpurdie 1125
    $target_file_exe = $full;
227 dpurdie 1126
}
1127
 
1128
 
1129
###############################################################################
1130
#   ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
1131
#       This subroutine takes the user options and builds the rules
1132
#       required to lint the program 'name'.
1133
#
1134
#   Arguments:
1135
#       (none)
1136
#
1137
#   Output:
1138
#       [ $(BINDIR)/$name_lint:   .... ]
1139
#           $(LDLINT)
1140
#
1141
###############################################################################
1142
 
1143
sub ToolsetLDLINT
1144
{
1145
    PCLintLD( @_ );
1146
}
1147
 
1148
 
1149
########################################################################
1150
#
1151
#   Push standard "system" libraries. This is a helper function
1152
#   used within this toolset.
1153
#
1154
#   Arguments:
1155
#       $plib       Reference to library array.
1156
#
1157
########################################################################
1158
 
1159
sub ToolsetLibStd
1160
{
1161
    my ($plib) = @_;
1162
 
1163
    #
1164
    #   Only add libraries if required
1165
    #
1166
    return unless( $::ScmCompilerOpts{'ADDLINKLIBS'} );
1167
 
1168
 
1169
    #
1170
    #   Appears to be a kludge that no one is happy to remove
1171
    #   If we are inluding cs or csx libraries then add some more
1172
    #
1173
    foreach (@$plib) {
1174
        if ( $_ eq 'csx$(GBE_TYPE)' || $_ eq 'cs$(GBE_TYPE)' )
1175
        {                                       # .. core services
1176
            UniquePush( $plib, "KERNEL32" );
1177
            UniquePush( $plib, "WINUX32\$(GBE_TYPE)" );
1178
            UniquePush( $plib, "WS2_32" );
1179
            last;
1180
        }
1181
    }
1182
 
1183
    #
1184
    #   Multithreaded DLL
1185
    #
1186
    push @$plib, "--ifeq=THREADMODE:D";
1187
    push @$plib, "--ifdebug";
1188
    push @$plib, "MSVCRTD";
1189
 
1190
    push @$plib, "--ifeq=THREADMODE:D";
1191
    push @$plib, "--ifprod";
1192
    push @$plib, "MSVCRT";
1193
 
1194
    #
1195
    #   Static Multithread library
1196
    #
1197
    push @$plib, "--ifeq=THREADMODE:T";
1198
    push @$plib, "--ifdebug";
1199
    push @$plib, "LIBCMTD";
1200
 
1201
    push @$plib, "--ifeq=THREADMODE:T";
1202
    push @$plib, "--ifprod";
1203
    push @$plib, "LIBCMT";
1204
 
1205
    #
1206
    #   User library
1207
    #
1208
    push @$plib, "USER32";
1209
}
1210
 
1211
 
1212
########################################################################
1213
#
1214
#   Generate a linker object recipe.  This is a helper function used 
1215
#   within this toolset.
1216
#
1217
#   Arguments:
1218
#       $io         I/O stream
1219
#
1220
#       $target     Name of the target
1221
#
1222
#       $obj        Library specification
1223
#
1224
########################################################################
1225
 
1226
sub ToolsetObjRecipe
1227
{
1228
    my ($io, $target, $obj) = @_;
1229
 
1230
    $io->Cmd( "\$(subst /,\\\\,\$(strip $obj)).$::o" );
1231
}
1232
 
1233
 
1234
########################################################################
1235
#
1236
#   Generate a linker/depend library recipe.  This is a helper function
1237
#   used within this toolset.
1238
#
1239
#   Arguments:
1240
#       $io         I/O stream
1241
#
1242
#       $target     Name of the target
1243
#
1244
#       $lib        Library specification
1245
#
1246
#       $dp         If building a depend list, the full target name.
1247
#
1248
########################################################################
1249
 
1250
sub ToolsetLibRecipe
1251
{
1252
    my ($io, $target, $lib, $dp) = @_;
1253
 
1254
    return                                      # ignore (compat)
1255
        if ( $lib eq "rt" ||        $lib eq "thread" ||
1256
             $lib eq "pthread" ||   $lib eq "nsl" ||
1257
             $lib eq "socket" );
1258
 
1259
    if ( !defined($dp) ) {                      # linker
1260
        $io->Cmd( "\$(subst /,\\\\,\$(strip $lib)).$::a" );
1261
 
1262
    } else {                                    # depend
1263
        $io->Cmd( "$dp:\t@(vlib2,$lib,LIB)" );
1264
    }
1265
}
1266
 
1267
 
1268
########################################################################
1269
#
1270
#   Parse resource file data
1271
#   This is a helper function used within this toolset
1272
#
1273
#   Arguments   : $1  BaseName
1274
#                 $2  The users resource list
1275
#                     This is a list of comma seperated files
1276
#                     The first file is the main resource script
1277
#
1278
#   Returns     : An array of resource files with full pathnames
1279
#                 [0] = The output file
1280
#                 [1] = The input file
1281
#                 [..] = Other input files
1282
#
1283
########################################################################
1284
 
1285
sub ToolsetRClist
1286
{
1287
    my ($name, $files) = @_;
1288
    my @result;
1289
 
1290
    #
1291
    #   Generate the name of the output file
1292
    #
1293
    push @result, "\$(OBJDIR)/$name.res";
1294
 
1295
    #
1296
    #   Process each user file
1297
    #
279 dpurdie 1298
    for (split( '\s*,\s*', $files ))
227 dpurdie 1299
    {
1300
        #
1301
        #   Locate the file.
1302
        #   If it is a generate file so it will be in the SRCS hash
1303
        #   Other wise the use will have to use Src to locate the file
1304
        #
1305
        push @result, MakeSrcResolve($_);
1306
    }
1307
 
1308
    #
1309
    #   Return the array to the user
1310
    #
1311
    return @result;
1312
}
1313
 
1314
 
1315
########################################################################
1316
#
1317
#   Generate a resource file recipe
1318
#   This is a helper function used within this tool
1319
#
1320
#   Arguments   : $1  Output resource file
1321
#                 ..  Input resource files
1322
#
1323
########################################################################
1324
 
1325
sub ToolsetRCrecipe
1326
{
1327
    my ($out, @in) = @_;
1328
 
1329
    #
1330
    #   Cleanup
1331
    #
1332
    ToolsetGenerate( $out );
1333
 
1334
    #
1335
    #   Recipe
1336
    #
1337
    MakePrint( "\n#.. Compile Resource file: $out\n\n" );
1338
    MakePrint( "$out:\t\$(GBE_PLATFORM).mk\n" );
1339
    MakeEntry( "$out:\t", "", "\\\n\t\t", " ", @in );
1340
    MakePrint( "\n\t\$(RC)\n" );
1341
    MakePrint( "\n" );
1342
}
1343
 
1344
########################################################################
1345
#
1346
#   Generate a project from the provided project solution file
1347
#   This is aimed at .NET work
1348
#
1349
#   Arguments   : $name             - Base name of the project
1350
#                 $solution         - Path to the solutionn file
1351
#                 $pArgs            - Project specific options
1352
#
1353
########################################################################
1354
 
1355
my $project_defines_done = 0;
1356
sub ToolsetPROJECT
1357
{
1358
    my( $name, $solution ,$pArgs ) = @_;
1359
    my $buildcmd = $toolset_info->{'buildcmd'};
1360
    my $cleancmd = $toolset_info->{'cleancmd'};
1361
 
1362
    #
1363
    #   Process options
1364
    #
1365
    foreach ( @$pArgs ) {
267 dpurdie 1366
        Message( "vcwin32 PROJECT: unknown option $_ -- ignored\n" );
227 dpurdie 1367
    }
1368
 
1369
    my ($io) = ToolsetPrinter::New();
1370
 
1371
    #
1372
    #   Setup toolset pecific difinitions. Once
1373
    #
1374
    unless( $project_defines_done )
1375
    {
1376
        $project_defines_done = 1;
1377
        $io->PrtLn( "ifeq \"\$(DEBUG)\" \"1\"");
1378
        $io->PrtLn( "PROJECT_CMD\t:= DEBUG");
1379
        $io->PrtLn( "else");
1380
        $io->PrtLn( "PROJECT_CMD\t:= RELEASE");
1381
        $io->PrtLn( "endif");
1382
        $io->Newline();
1383
    }
1384
 
1385
    #
1386
    #   Process the build and clean commands
1387
    #       Substitute arguments
1388
    #           =TYPE=
1389
    #           =LOG=
1390
    #           =DSW=
1391
    #
1392
    $buildcmd =~ s~=TYPE=~\$\(PROJECT_CMD)~g;
1393
    $buildcmd =~ s~=LOG=~$name\$(GBE_TYPE).log~g;
1394
    $buildcmd =~ s~=DSW=~$solution~g;
1395
 
1396
    $cleancmd =~ s~=TYPE=~\$\(PROJECT_CMD)~g;
1397
    $cleancmd =~ s~=LOG=~$name\$(GBE_TYPE).log~g;
1398
    $cleancmd =~ s~=DSW=~$solution~g;
1399
 
1400
    #
1401
    #   Generate the recipe to create the project
1402
    #   Use the set_WIN32.sh file to extend the DLL search path
1403
    #
1404
    $io->Label( "Build project", $name );
1405
    $io->PrtLn( "Project_$name: $solution \$(INTERFACEDIR)/set_$::ScmPlatform.sh" );
1406
 
1407
    $io->PrtLn( "\t\$(XX_PRE)( \$(rm) -f $name\$(GBE_TYPE).log; \\" );
1408
    $io->PrtLn( "\t. \$(INTERFACEDIR)/set_$::ScmPlatform.sh; \\" );
255 dpurdie 1409
    $io->PrtLn( "\t\$(show_environment); \\" );
227 dpurdie 1410
    $io->PrtLn( "\t$buildcmd; \\" );
1411
    $io->PrtLn( "\tret=\$\$?; \\" );
1412
    $io->PrtLn( "\t\$(GBE_BIN)/cat $name\$(GBE_TYPE).log; \\" );
1413
    $io->PrtLn( "\texit \$\$ret )" );
1414
    $io->Newline();
1415
 
1416
    #
1417
    #   Generate the recipe to clean the project
1418
    #
1419
    $io->Label( "Clean project", $name );
1420
    $io->PrtLn( "ProjectClean_$name: $solution" );
1421
    $io->PrtLn( "\t-\$(XX_PRE)$cleancmd" );
1422
    $io->PrtLn( "\t-\$(XX_PRE)\$(rm) -f $name\$(GBE_TYPE).log" );
1423
    $io->Newline();
1424
 
1425
}
1426
 
1427
 
1428
#.. Successful termination
1429
1;
1430