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
    #   ld      Linker command file
736
    #   map     Map file
737
    #   pdb     Microsoft C/C++ program database
738
    #   ilk     Microsoft Linker Database
739
    #
740
        ToolsetGenerate( "\$(LIBDIR)/${lib}.ld" );
741
        ToolsetGenerate( "\$(LIBDIR)/${lib}.map" );
742
        ToolsetGenerate( "\$(LIBDIR)/${lib}.exp" );
743
        ToolsetGenerate( "\$(LIBDIR)/${lib}.ilk" );
744
        ToolsetGenerate( "\$(LIBDIR)/${full}" );
255 dpurdie 745
        ToolsetGenerate( "\$(LIBDIR)/${full}.manifest" ) if $toolset_info->{'GenManifest'};
227 dpurdie 746
 
747
    #.. Linker rules
748
    #
749
        my ($io) = ToolsetPrinter::New();
750
 
751
        my $import_lib;
752
        my $export_file;
753
 
754
        if ( $name && $def && ($mutual_dll || $stub_only ) )
755
        {
756
            #
757
            #   Creating an Export library from user .DEF file
758
            #   It is possible to create the stub library in the LIB phase
759
            #   which allows DLLs with mutual imports
760
            #
761
            $io->Label( "Import(stub) library for mutual exports", $name );
762
            $export_file = "\$(LIBDIR)/${name}.exp";
763
 
764
            #
765
            #   Rules and recipe to generate the stub library
766
            #
767
            $io->Prt( "\$(LIBDIR)/${name}.exp:\t\$(LIBDIR)/${name}.${a}\n" );
768
            $io->Prt( "\$(LIBDIR)/${name}.${a}:\tLIBDEF=$def\n" );
769
            $io->Prt( "\$(LIBDIR)/${name}.${a}:\tLIBNAME=$lib\n" );
770
            $io->Entry( "\$(LIBDIR)/${name}.${a}: \\\n\t\t\$(OBJDIR)/${base}",
771
                                            "", " \\\n\t\t", ".$::o", @$pObjs );
772
            $io->Prt( " \\\n\t\t$def" );
773
            $io->Prt( "\n\t\t\$(AR)\n" );
774
            $io->Newline();
775
 
776
            #
777
            #   Files to be cleanup up
778
            #
779
            ToolsetGenerate( "\$(LIBDIR)/${name}.exp" );
780
            ToolsetGenerate( "\$(LIBDIR)/${name}.${a}" );
781
 
782
            #
783
            #   If the DLL is being packaged/installed then add the static
784
            #   stub library to the packaging lists as a static library
785
            #   This will allow the stub library to be installed with the
786
            #   static libraries and thus allow DLL's with mutual imports
787
            #
788
            PackageShlibAddLibFiles ($base, "\$(LIBDIR)/${name}.${a}" )
789
                unless ($resource_only);
790
 
791
            #
792
            #   Add the stub library to the list of libraries being created
793
            #   Note: Don't do if not created with .DEF file
794
            #
795
            push @::LIBS, $base;
796
 
797
        }
798
        else
799
        {
800
            #
801
            #   The stub library is created as part of the DLL generation
802
            #   Whether we like it or not - so we need to control the name
803
            #   and location
804
            #
805
            my $slname = ($name) ? $name : $lib;
806
            $import_lib = "\$(LIBDIR)/${slname}.${a}";
807
 
808
            $io->Label( "Import(stub) library", $slname );
809
            $io->Prt( "$import_lib:\t\$(LIBDIR)/${full}\n" );
810
            $io->Newline();
811
 
812
            ToolsetGenerate( $import_lib );
813
            ToolsetGenerate( "\$(LIBDIR)/${slname}.exp" );
814
 
815
            #
816
            #   Package the generated stub library, if it is being
817
            #   created on request.
818
            #
819
            #   Package it with the shared libaries and not the static
820
            #   libraries as it will be created with the shared library
821
            #
822
            PackageShlibAddFiles ($base, $import_lib, 'Class=lib' )
823
                if ($name && ! $no_implib && ! $resource_only);
824
 
825
            #
826
            #   Indicate that we will be linking with a DEF file
827
            #
828
            $link_with_def = 1 if ( $def );
829
        }
830
 
831
        #
832
        #   If we are only creating a stub library, then the hard work has been
833
        #   done.
834
        #
835
        return
836
            if ($stub_only);
837
 
838
        $io->Label( "Shared library", $name );
839
 
840
        #
841
        #   The process of creating a DLL will generate PDB file
842
        #   Control the name of the PDB file
843
        #
844
        my $pdb_file = "\$(LIBDIR)/${lib}.pdb";
845
        unless( $no_pdb )
846
        {
847
            $io->Prt( "$pdb_file:\t\$(LIBDIR)/${full}\n" );
848
            ToolsetGenerate( $pdb_file );
849
        }
850
 
851
        #
852
        #   Package the PDB file up with the DLL
853
        #   Package the DLL - now that we know its proper name
854
        #
855
        PackageShlibAddFiles( $base, $pdb_file, 'Class=debug' ) unless $no_pdb ;
856
        PackageShlibAddFiles( $base, "\$(LIBDIR)/${full}" );
857
 
858
        #
859
        #   Generate Shared Library dependency information
860
        #
335 dpurdie 861
        my $dep = $io->SetShldTarget( $lib );
227 dpurdie 862
 
863
        #
864
        #   Generate rules and recipes to create the body of the shared
865
        #   library. Several build variables are overiden when creating
866
        #   a shared library.
867
        #
868
        $io->Prt( "\$(LIBDIR)/${full}:\tSHBASE=${lib}\n" );
869
        $io->Prt( "\$(LIBDIR)/${full}:\tSHNAME=${lib}\n" );
870
        $io->Prt( "\$(LIBDIR)/${full}:\tCFLAGS+=\$(SHCFLAGS)\n" );
871
        $io->Prt( "\$(LIBDIR)/${full}:\tCXXLAGS+=\$(SHCXXFLAGS)\n" );
872
        $io->Prt( "\$(LIBDIR)/${full}:\t$export_file\n" ) if ($export_file );
873
        $io->Prt( "\$(LIBDIR)/${full}:\t$res\n" ) if ( $res );
874
 
335 dpurdie 875
        $io->Entry( "\$(LIBDIR)/${full}: $dep \\\n\t\t\$(OBJDIR)/${base}",
227 dpurdie 876
            "", " \\\n\t\t", ".$::o", @$pObjs );
877
 
878
        $io->Prt( " \\\n\t\t$def" ) if ( $link_with_def );
261 dpurdie 879
        $io->Prt( "\n\t\$(SHLD)\n" );
227 dpurdie 880
 
881
        $io->Newline();
882
 
883
        #.. Linker command file
884
        #
885
        #       Now the fun part... piecing together a variable ${name}_shld
886
        #       which ends up in the command file.
887
        #
888
        $io->SetTag( "${lib}_shld" );          # command tag
889
 
890
        $io->Label( "Linker commands", $name ); # label
891
 
892
        $io->Cmd( "-dll" );
893
        $io->Cmd( "-noentry" )if ($resource_only);
291 dpurdie 894
        $io->Cmd( "-machine:X86" );
227 dpurdie 895
        $io->Cmd( "-base:0x10000000" );
896
        $io->Cmd( "-def:$def" ) if ($link_with_def);
897
        $io->Cmd( "-out:\$(subst /,\\\\,\$(LIBDIR)/${full})" );
898
        $io->Cmd( "-implib:\$(subst /,\\\\,$import_lib)" ) if ($import_lib);
899
        $io->Cmd( "-pdb:\$(subst /,\\\\,$pdb_file)" )       unless ( $no_pdb );
900
        $io->Cmd( "-debug:none" )                           if ($no_pdb);
901
        $io->Cmd( "-pdb:none" )                             if ($no_pdb);
902
        $io->Cmd( "-entry:$entry" )                         if ($entry);
903
        $io->Cmd( "-map:\$(subst /,\\\\,\$(LIBDIR)/${lib}).map" );
904
        $io->Cmd( "-nodefaultlib:LIBC" );
905
        $io->Cmd( "\$(subst /,\\\\,$res)" ) if ( $res );
906
        $io->Cmd( "\$(subst /,\\\\,$export_file)" ) if ( $export_file );
907
 
908
                                                # object list
909
        $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );
910
 
911
                                                # library list
912
        $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );
913
 
914
        $io->Newline();
915
 
916
        #.. Dependency link,
335 dpurdie 917
        #   Create a library dependency file
918
        #       Create command file to build applicaton dependency list
919
        #       from the list of dependent libraries
227 dpurdie 920
        #
335 dpurdie 921
        #       Create makefile directives to include the dependency
922
        #       list into the makefile.
227 dpurdie 923
        #
335 dpurdie 924
        $io->DepRules( $pLibs, \&ToolsetLibRecipe, "\$(LIBDIR)/${full}" );
925
        $io->SHLDDEPEND( $name, $lib );
227 dpurdie 926
    }
927
 
928
    ToolsetLibStd( $pLibs )                    # push standard libraries
929
        unless ( $noaddlibs );
930
 
931
    if ( $doimplib ) {
932
        #
933
        #   --Implib flavor will create
934
        #       a) Import library   $name$(GBE_TYPE).lib
935
        #       b) Versioned DLL    $name$(GBE_TYPE).xx.xx.xx.dll
936
        #
289 dpurdie 937
        $target_file_dll = "\$(LIBDIR)/$name\$(GBE_TYPE).$_ver.$::so";
227 dpurdie 938
        BuildSHLD(
289 dpurdie 939
            "$name",                        # Base Name
940
            "$name\$(GBE_TYPE)",            # Name of Export Lib
941
            "$name\$(GBE_TYPE).$_ver");      # Name of the DLL + PDB
227 dpurdie 942
 
943
    } else {
944
        #
945
        #   Original flavor will create
946
        #       a) Import library   $name$(GBE_TYPE).lib    ---+
947
        #       b) Unversioned DLL  $name$(GBE_TYPE).dll    <--+
948
        #       c) Versioned DLL    $name$(GBE_TYPE).xx.xx.xx.dll
949
        #
950
        MakePrint(
951
            "# .. Versioned image\n\n".
289 dpurdie 952
            "\$(LIBDIR)/${name}\$(GBE_TYPE).$_ver.$::so:\t".
227 dpurdie 953
            "\$(LIBDIR)/${name}\$(GBE_TYPE).$::so\n".
954
            "\n" );
955
 
956
        $target_file_dll = "\$(LIBDIR)/$name\$(GBE_TYPE).$::so";
289 dpurdie 957
        BuildSHLD( "$name", ""                  , "$name\$(GBE_TYPE).$_ver" );
227 dpurdie 958
        BuildSHLD( "$name", "$name\$(GBE_TYPE)" , "$name\$(GBE_TYPE)" );
959
    }
960
 
961
    #.. Resource File
962
    #
963
    ToolsetRCrecipe( $res, @reslist )
964
        if ( $res );
965
}
966
 
967
 
968
###############################################################################
969
#   ToolsetSHLDLINT $name, \@args, \@objs, \@libraries )
970
#       This subroutine takes the user options and builds the rules
971
#       required to lint the program 'name'.
972
#
973
#   Arguments:
974
#       (none)
975
#
976
#   Output:
977
#       [ $(LIBDIR)/$name_lint:   .... ]
978
#           $(SHLIBLINT)
979
#
980
###############################################################################
981
 
982
sub ToolsetSHLDLINT
983
{
984
    PCLintSHLIB( @_ );
985
}
986
 
987
###############################################################################
261 dpurdie 988
# Function        : ToolsetLD
227 dpurdie 989
#
261 dpurdie 990
# Description     : Takes the user options and builds the rules required to
991
#                   link the program 'name'.
227 dpurdie 992
#
261 dpurdie 993
# Inputs          : $name           - base name of the program
994
#                   $pArgs          - Ref to program arguments
995
#                   $pObjs          - Ref to program objects
996
#                   $pLibs          - Ref to program library list
227 dpurdie 997
#
261 dpurdie 998
# Returns         : Nothing
227 dpurdie 999
#
261 dpurdie 1000
# Output:         : Rules and recipes to create a program
1001
#                       Create program rules and recipes
1002
#                       Create linker input script
1003
#                       Create library dependency list
1004
#                       Include library dependency information
227 dpurdie 1005
#
1006
sub ToolsetLD
1007
{
1008
    my ( $name, $pArgs, $pObjs, $pLibs ) = @_;
1009
    my ( $res, @reslist );
1010
    my $no_pdb =$pdb_none;
1011
    our( $entry, $noaddlibs );
1012
 
1013
#.. Parse arguments
1014
#
1015
    foreach ( @$pArgs ) {
1016
        if (/^--Resource=(.*)/) {               # Resource definition
1017
            ($res, @reslist) = ToolsetRClist( $name, $1 );
1018
 
1019
        } elsif (/^--NoPDB$/) {
1020
            $no_pdb = 1;
1021
 
1022
        } elsif (/^--Entry=(.*)/) {
1023
            $entry = $1;
1024
 
1025
        } elsif (/^--NoAddLib/) {
1026
            $noaddlibs = 1;
1027
 
1028
        } else {
1029
            Message( "vcwin32 LD: unknown option $_ -- ignored\n" );
1030
 
1031
        }
1032
    }
1033
 
261 dpurdie 1034
#.. Names of important files
1035
#
1036
    my $base = "\$(BINDIR)/${name}";
1037
    my $full = $base . $::exe;
1038
    my $map  = $base . '.map';
1039
    my $pdb  = $base . '.pdb';
1040
 
1041
 
227 dpurdie 1042
#.. Cleanup rules
1043
#
255 dpurdie 1044
#   ld              Linker command file
1045
#   map             Map file
1046
#   pdb             Microsoft C/C++ program database
1047
#   ilk             Microsoft Linker Database
1048
#   res             Compiled resource script
261 dpurdie 1049
#   exe.manifest    Manifest file (VS2005)
227 dpurdie 1050
#
261 dpurdie 1051
    ToolsetGenerate( $map );
1052
    ToolsetGenerate( $pdb );
1053
    ToolsetGenerate( $base . '.ld' );
1054
    ToolsetGenerate( $base . '.ilk' );
1055
    ToolsetGenerate( $full . '.manifest' ) if $toolset_info->{'GenManifest'};
227 dpurdie 1056
 
335 dpurdie 1057
#.. Toolset Printer
227 dpurdie 1058
#
1059
    my ($io) = ToolsetPrinter::New();
335 dpurdie 1060
    my $dep = $io->SetLdTarget( $name );
227 dpurdie 1061
 
335 dpurdie 1062
#.. Linker command
1063
#
261 dpurdie 1064
    $io->Prt( "$full : $dep " );
1065
    $io->Entry( "", "", "\\\n\t", ".$::o ", @$pObjs );
1066
    $io->Prt( "\\\n\t$res " ) if ( $res );
1067
    $io->Prt( "\n\t\$(LD)\n\n" );
227 dpurdie 1068
 
1069
 
1070
#.. Linker command file
1071
#
1072
#       Now piece together a variable $(name_ld) which ends up in
1073
#       the command file linking the application.
1074
#
1075
    $io->SetTag( "${name}_ld" );                # macro tag
1076
 
1077
    $io->Label( "Linker commands", $name );     # label
1078
 
261 dpurdie 1079
    $io->Cmd( "-out:\$(subst /,\\\\,$full)" );
1080
    $io->Cmd( "-pdb:\$(subst /,\\\\,$pdb)" )        unless ($no_pdb);
1081
    $io->Cmd( "-debug:none" )                       if ($no_pdb);
1082
    $io->Cmd( "-pdb:none" )                         if ($no_pdb);
1083
    $io->Cmd( "-entry:$entry" )                     if ($entry);
1084
    $io->Cmd( "-map:\$(subst /,\\\\,$map)" );
227 dpurdie 1085
    $io->Cmd( "-nodefaultlib:LIBC" );
291 dpurdie 1086
    $io->Cmd( "-machine:X86" );
261 dpurdie 1087
    $io->Cmd( "\$(subst /,\\\\,$res)" )             if ( $res );
227 dpurdie 1088
 
261 dpurdie 1089
    ToolsetLibStd( $pLibs ) unless ( $noaddlibs );      # push standard libraries
1090
    $io->ObjList( $name, $pObjs, \&ToolsetObjRecipe );  # object list
1091
    $io->LibList( $name, $pLibs, \&ToolsetLibRecipe );  # library list
1092
    $io->Newline();
227 dpurdie 1093
 
335 dpurdie 1094
    #.. Dependency link,
1095
    #   Create a library dependency file
1096
    #       Create command file to build applicaton dependency list
1097
    #       from the list of dependent libraries
1098
    #
1099
    #       Create makefile directives to include the dependency
1100
    #       list into the makefile.
1101
    #
1102
    $io->DepRules( $pLibs, \&ToolsetLibRecipe, $full );
1103
    $io->LDDEPEND();
227 dpurdie 1104
 
1105
#.. Compile up the resource file
1106
#
1107
    ToolsetRCrecipe( $res, @reslist )
1108
        if ( $res );
1109
 
335 dpurdie 1110
#.. Package up the PDB file with the program
227 dpurdie 1111
#
261 dpurdie 1112
    PackageProgAddFiles ( $name, $full );
1113
    PackageProgAddFiles ( $name, $pdb, "Class=debug" ) unless ( $no_pdb );
227 dpurdie 1114
 
1115
#
1116
#   Track the name of the possible target file
1117
#   Used when creating Visual Studio projects
1118
#
261 dpurdie 1119
    $target_file_exe = $full;
227 dpurdie 1120
}
1121
 
1122
 
1123
###############################################################################
1124
#   ToolsetLD( $name, \@args, \@objs, \@libraries, \@csrc, \@cxxsrc )
1125
#       This subroutine takes the user options and builds the rules
1126
#       required to lint the program 'name'.
1127
#
1128
#   Arguments:
1129
#       (none)
1130
#
1131
#   Output:
1132
#       [ $(BINDIR)/$name_lint:   .... ]
1133
#           $(LDLINT)
1134
#
1135
###############################################################################
1136
 
1137
sub ToolsetLDLINT
1138
{
1139
    PCLintLD( @_ );
1140
}
1141
 
1142
 
1143
########################################################################
1144
#
1145
#   Push standard "system" libraries. This is a helper function
1146
#   used within this toolset.
1147
#
1148
#   Arguments:
1149
#       $plib       Reference to library array.
1150
#
1151
########################################################################
1152
 
1153
sub ToolsetLibStd
1154
{
1155
    my ($plib) = @_;
1156
 
1157
    #
1158
    #   Only add libraries if required
1159
    #
1160
    return unless( $::ScmCompilerOpts{'ADDLINKLIBS'} );
1161
 
1162
 
1163
    #
1164
    #   Appears to be a kludge that no one is happy to remove
1165
    #   If we are inluding cs or csx libraries then add some more
1166
    #
1167
    foreach (@$plib) {
1168
        if ( $_ eq 'csx$(GBE_TYPE)' || $_ eq 'cs$(GBE_TYPE)' )
1169
        {                                       # .. core services
1170
            UniquePush( $plib, "KERNEL32" );
1171
            UniquePush( $plib, "WINUX32\$(GBE_TYPE)" );
1172
            UniquePush( $plib, "WS2_32" );
1173
            last;
1174
        }
1175
    }
1176
 
1177
    #
1178
    #   Multithreaded DLL
1179
    #
1180
    push @$plib, "--ifeq=THREADMODE:D";
1181
    push @$plib, "--ifdebug";
1182
    push @$plib, "MSVCRTD";
1183
 
1184
    push @$plib, "--ifeq=THREADMODE:D";
1185
    push @$plib, "--ifprod";
1186
    push @$plib, "MSVCRT";
1187
 
1188
    #
1189
    #   Static Multithread library
1190
    #
1191
    push @$plib, "--ifeq=THREADMODE:T";
1192
    push @$plib, "--ifdebug";
1193
    push @$plib, "LIBCMTD";
1194
 
1195
    push @$plib, "--ifeq=THREADMODE:T";
1196
    push @$plib, "--ifprod";
1197
    push @$plib, "LIBCMT";
1198
 
1199
    #
1200
    #   User library
1201
    #
1202
    push @$plib, "USER32";
1203
}
1204
 
1205
 
1206
########################################################################
1207
#
1208
#   Generate a linker object recipe.  This is a helper function used 
1209
#   within this toolset.
1210
#
1211
#   Arguments:
1212
#       $io         I/O stream
1213
#
1214
#       $target     Name of the target
1215
#
1216
#       $obj        Library specification
1217
#
1218
########################################################################
1219
 
1220
sub ToolsetObjRecipe
1221
{
1222
    my ($io, $target, $obj) = @_;
1223
 
1224
    $io->Cmd( "\$(subst /,\\\\,\$(strip $obj)).$::o" );
1225
}
1226
 
1227
 
1228
########################################################################
1229
#
1230
#   Generate a linker/depend library recipe.  This is a helper function
1231
#   used within this toolset.
1232
#
1233
#   Arguments:
1234
#       $io         I/O stream
1235
#
1236
#       $target     Name of the target
1237
#
1238
#       $lib        Library specification
1239
#
1240
#       $dp         If building a depend list, the full target name.
1241
#
1242
########################################################################
1243
 
1244
sub ToolsetLibRecipe
1245
{
1246
    my ($io, $target, $lib, $dp) = @_;
1247
 
1248
    return                                      # ignore (compat)
1249
        if ( $lib eq "rt" ||        $lib eq "thread" ||
1250
             $lib eq "pthread" ||   $lib eq "nsl" ||
1251
             $lib eq "socket" );
1252
 
1253
    if ( !defined($dp) ) {                      # linker
1254
        $io->Cmd( "\$(subst /,\\\\,\$(strip $lib)).$::a" );
1255
 
1256
    } else {                                    # depend
1257
        $io->Cmd( "$dp:\t@(vlib2,$lib,LIB)" );
1258
    }
1259
}
1260
 
1261
 
1262
########################################################################
1263
#
1264
#   Parse resource file data
1265
#   This is a helper function used within this toolset
1266
#
1267
#   Arguments   : $1  BaseName
1268
#                 $2  The users resource list
1269
#                     This is a list of comma seperated files
1270
#                     The first file is the main resource script
1271
#
1272
#   Returns     : An array of resource files with full pathnames
1273
#                 [0] = The output file
1274
#                 [1] = The input file
1275
#                 [..] = Other input files
1276
#
1277
########################################################################
1278
 
1279
sub ToolsetRClist
1280
{
1281
    my ($name, $files) = @_;
1282
    my @result;
1283
 
1284
    #
1285
    #   Generate the name of the output file
1286
    #
1287
    push @result, "\$(OBJDIR)/$name.res";
1288
 
1289
    #
1290
    #   Process each user file
1291
    #
279 dpurdie 1292
    for (split( '\s*,\s*', $files ))
227 dpurdie 1293
    {
1294
        #
1295
        #   Locate the file.
1296
        #   If it is a generate file so it will be in the SRCS hash
1297
        #   Other wise the use will have to use Src to locate the file
1298
        #
1299
        push @result, MakeSrcResolve($_);
1300
    }
1301
 
1302
    #
1303
    #   Return the array to the user
1304
    #
1305
    return @result;
1306
}
1307
 
1308
 
1309
########################################################################
1310
#
1311
#   Generate a resource file recipe
1312
#   This is a helper function used within this tool
1313
#
1314
#   Arguments   : $1  Output resource file
1315
#                 ..  Input resource files
1316
#
1317
########################################################################
1318
 
1319
sub ToolsetRCrecipe
1320
{
1321
    my ($out, @in) = @_;
1322
 
1323
    #
1324
    #   Cleanup
1325
    #
1326
    ToolsetGenerate( $out );
1327
 
1328
    #
1329
    #   Recipe
1330
    #
1331
    MakePrint( "\n#.. Compile Resource file: $out\n\n" );
1332
    MakePrint( "$out:\t\$(GBE_PLATFORM).mk\n" );
1333
    MakeEntry( "$out:\t", "", "\\\n\t\t", " ", @in );
1334
    MakePrint( "\n\t\$(RC)\n" );
1335
    MakePrint( "\n" );
1336
}
1337
 
1338
########################################################################
1339
#
1340
#   Generate a project from the provided project solution file
1341
#   This is aimed at .NET work
1342
#
1343
#   Arguments   : $name             - Base name of the project
1344
#                 $solution         - Path to the solutionn file
1345
#                 $pArgs            - Project specific options
1346
#
1347
########################################################################
1348
 
1349
my $project_defines_done = 0;
1350
sub ToolsetPROJECT
1351
{
1352
    my( $name, $solution ,$pArgs ) = @_;
1353
    my $buildcmd = $toolset_info->{'buildcmd'};
1354
    my $cleancmd = $toolset_info->{'cleancmd'};
1355
 
1356
    #
1357
    #   Process options
1358
    #
1359
    foreach ( @$pArgs ) {
267 dpurdie 1360
        Message( "vcwin32 PROJECT: unknown option $_ -- ignored\n" );
227 dpurdie 1361
    }
1362
 
1363
    my ($io) = ToolsetPrinter::New();
1364
 
1365
    #
1366
    #   Setup toolset pecific difinitions. Once
1367
    #
1368
    unless( $project_defines_done )
1369
    {
1370
        $project_defines_done = 1;
1371
        $io->PrtLn( "ifeq \"\$(DEBUG)\" \"1\"");
1372
        $io->PrtLn( "PROJECT_CMD\t:= DEBUG");
1373
        $io->PrtLn( "else");
1374
        $io->PrtLn( "PROJECT_CMD\t:= RELEASE");
1375
        $io->PrtLn( "endif");
1376
        $io->Newline();
1377
    }
1378
 
1379
    #
1380
    #   Process the build and clean commands
1381
    #       Substitute arguments
1382
    #           =TYPE=
1383
    #           =LOG=
1384
    #           =DSW=
1385
    #
1386
    $buildcmd =~ s~=TYPE=~\$\(PROJECT_CMD)~g;
1387
    $buildcmd =~ s~=LOG=~$name\$(GBE_TYPE).log~g;
1388
    $buildcmd =~ s~=DSW=~$solution~g;
1389
 
1390
    $cleancmd =~ s~=TYPE=~\$\(PROJECT_CMD)~g;
1391
    $cleancmd =~ s~=LOG=~$name\$(GBE_TYPE).log~g;
1392
    $cleancmd =~ s~=DSW=~$solution~g;
1393
 
1394
    #
1395
    #   Generate the recipe to create the project
1396
    #   Use the set_WIN32.sh file to extend the DLL search path
1397
    #
1398
    $io->Label( "Build project", $name );
1399
    $io->PrtLn( "Project_$name: $solution \$(INTERFACEDIR)/set_$::ScmPlatform.sh" );
1400
 
1401
    $io->PrtLn( "\t\$(XX_PRE)( \$(rm) -f $name\$(GBE_TYPE).log; \\" );
1402
    $io->PrtLn( "\t. \$(INTERFACEDIR)/set_$::ScmPlatform.sh; \\" );
255 dpurdie 1403
    $io->PrtLn( "\t\$(show_environment); \\" );
227 dpurdie 1404
    $io->PrtLn( "\t$buildcmd; \\" );
1405
    $io->PrtLn( "\tret=\$\$?; \\" );
1406
    $io->PrtLn( "\t\$(GBE_BIN)/cat $name\$(GBE_TYPE).log; \\" );
1407
    $io->PrtLn( "\texit \$\$ret )" );
1408
    $io->Newline();
1409
 
1410
    #
1411
    #   Generate the recipe to clean the project
1412
    #
1413
    $io->Label( "Clean project", $name );
1414
    $io->PrtLn( "ProjectClean_$name: $solution" );
1415
    $io->PrtLn( "\t-\$(XX_PRE)$cleancmd" );
1416
    $io->PrtLn( "\t-\$(XX_PRE)\$(rm) -f $name\$(GBE_TYPE).log" );
1417
    $io->Newline();
1418
 
1419
}
1420
 
1421
 
1422
#.. Successful termination
1423
1;
1424