Subversion Repositories DevTools

Rev

Rev 227 | Rev 249 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 227 Rev 247
Line 27... Line 27...
27
use File::Copy;
27
use File::Copy;
28
 
28
 
29
#
29
#
30
#   Global data
30
#   Global data
31
#
31
#
32
my %Tiers;                             # Hash of Tiers already seen
32
my %Tiers;                              # Hash of Tiers already seen
-
 
33
my @ThxOnly;                            # Array of ThxOnly entries
33
my $verbose = 0;
34
my $verbose = 0;
34
 
35
 
35
MugInit();
36
MugInit();
36
 
37
 
37
#-------------------------------------------------------------------------------
38
#-------------------------------------------------------------------------------
38
# Function        : MugInit
39
# Function        : MugInit
39
#
40
#
40
# Description     : Module initialisation
41
# Description     : Module initialisation
41
#                   Setup and sanity testing.
-
 
42
#                   This function is run automaticlly when the package is loaded
42
#                   This function is run automaticlly when the package is loaded
43
#
43
#
44
# Inputs          :
44
# Inputs          :
45
#
45
#
46
# Returns         :
46
# Returns         :
47
#
47
#
48
sub MugInit
48
sub MugInit
49
{
49
{
-
 
50
}
-
 
51
 
-
 
52
#-------------------------------------------------------------------------------
-
 
53
# Function        : MugUtilities
-
 
54
#
-
 
55
# Description     : Ensure that required utilities can be located
-
 
56
#                   Only needs to be called if MugFiles are being created
-
 
57
#
-
 
58
# Inputs          : None
-
 
59
#
-
 
60
# Returns         : Will exit on error
-
 
61
#
-
 
62
sub MugUtilities
-
 
63
{
50
    #
64
    #
51
    #   Ensure that required utilities can be located
65
    #   Ensure that required utilities can be located
52
    #
66
    #
53
    my @not_found;
67
    my @not_found;
54
    foreach my $util ( qw(genappa.exe modcrc.exe) )
68
    foreach my $util ( qw(genappa.exe modcrc.exe) )
Line 59... Line 73...
59
        }
73
        }
60
    }
74
    }
61
 
75
 
62
    Error ("MugFiles: Required utility programs not found:", @not_found )
76
    Error ("MugFiles: Required utility programs not found:", @not_found )
63
        if ( @not_found );
77
        if ( @not_found );
64
 
-
 
65
}
78
}
66
 
79
 
-
 
80
 
67
#-------------------------------------------------------------------------------
81
#-------------------------------------------------------------------------------
68
# Function        : MugFiles
82
# Function        : MugFiles
69
#
83
#
70
# Description     : Collect MugFile information
84
# Description     : Collect MugFile information
71
#                   information
85
#                   information
Line 146... Line 160...
146
 
160
 
147
 
161
 
148
        } elsif ( m/^--ThxDir=(.*)/ ) {
162
        } elsif ( m/^--ThxDir=(.*)/ ) {
149
            $muginfo{'ThxCopyDir'} = $1;
163
            $muginfo{'ThxCopyDir'} = $1;
150
 
164
 
-
 
165
        } elsif ( m{^--NoMugFiles} || m{^--ThxOnly}  ) {
-
 
166
            $muginfo{'NoMug'} = 1;
-
 
167
 
151
        } else {
168
        } else {
152
            Error("Unknown option: $_ ");
169
            Error("Unknown option: $_ ");
153
        }
170
        }
154
    }
171
    }
155
 
172
 
156
    #
173
    #
157
    #   Ensure the user has provided all the parameters
174
    #   Ensure the user has provided all the parameters
158
    #
175
    #
159
    Error("No Device specified") unless ( $muginfo{'Device'} );
176
    unless ( $muginfo{'NoMug'} )
-
 
177
    {
160
    Error("No Name specified") unless ( $muginfo{'Name'} );
178
        Error("No Device specified") unless ( $muginfo{'Device'} );
161
    Error("No Tierspecified") unless ( $muginfo{'Tier'} );
179
        Error("No Name specified") unless ( $muginfo{'Name'} );
162
    Error("No Packages or directories specified") unless ( $muginfo{'Dirs'} );
180
        Error("No Tierspecified") unless ( $muginfo{'Tier'} );
163
    Error("Duplicated Tier: $tier") if ( exists $Tiers{$tier} );
181
        Error("Duplicated Tier: $tier") if ( exists $Tiers{$tier} );
164
 
-
 
165
    #
-
 
166
    #   Process Name
-
 
167
    #   It MUST be 4 characters padded with '-'
-
 
168
    #
-
 
169
    my $name = $muginfo{'Name'};
-
 
170
    Error( "Name too long. Must be less that 4: $name") if ( length($name) > 4 );
-
 
171
    $name .= '----';
-
 
172
    $name = substr($name,0,4);
-
 
173
    $muginfo{'Name'} = $name;
-
 
174
 
182
 
-
 
183
        #
-
 
184
        #   Process Name
-
 
185
        #   It MUST be 4 characters padded with '-'
-
 
186
        #
-
 
187
        my $name = $muginfo{'Name'};
-
 
188
        Error( "Name too long. Must be less that 4: $name") if ( length($name) > 4 );
-
 
189
        $name .= '----';
-
 
190
        $name = substr($name,0,4);
-
 
191
        $muginfo{'Name'} = $name;
175
    $Tiers{$tier} = \%muginfo;
192
        $Tiers{$tier} = \%muginfo;
-
 
193
    }
-
 
194
    else
-
 
195
    {
-
 
196
        push @ThxOnly, \%muginfo;
-
 
197
    }
-
 
198
    Error("No Packages or directories specified") unless ( $muginfo{'Dirs'} );
176
 
199
 
177
    DebugPop();
200
    DebugPop();
178
}
201
}
179
 
202
 
180
#-------------------------------------------------------------------------------
203
#-------------------------------------------------------------------------------
Line 191... Line 214...
191
#
214
#
192
 
215
 
193
sub MugGenerate
216
sub MugGenerate
194
{
217
{
195
    my (@args) = @_;
218
    my (@args) = @_;
-
 
219
    my @versions;
-
 
220
    my $version_hex;
-
 
221
    my $version_decimal;
-
 
222
 
196
    foreach ( @args )
223
    foreach ( @args )
197
    {
224
    {
198
        if ( /^--Debug$/ ) {
225
        if ( /^--Debug$/ ) {
199
            $verbose++;
226
            $verbose++;
200
 
227
 
Line 211... Line 238...
211
    #   These will be popped later
238
    #   These will be popped later
212
    #
239
    #
213
    $verbose = DebugPush("MugGenerate", $verbose);
240
    $verbose = DebugPush("MugGenerate", $verbose);
214
    Debug("Mugfiles: Set Verbosity: $verbose");
241
    Debug("Mugfiles: Set Verbosity: $verbose");
215
 
242
 
-
 
243
    if ( keys %Tiers )
216
    #
244
    {
-
 
245
        #
-
 
246
        #   Ensure that utilities are available
-
 
247
        #
-
 
248
        MugUtilities();
-
 
249
    
-
 
250
        #
217
    #   Determine the system version
251
        #   Determine the system version
218
    #   This is based on the Build Version ( XX.YY.ZZ )
252
        #   This is based on the Build Version ( XX.YY.ZZ )
219
    #   This is massaged into the required system version, which is required
253
        #   This is massaged into the required system version, which is required
220
    #   in two forms:
254
        #   in two forms:
221
    #       1) As hex XX.YY
255
        #       1) As hex XX.YY
222
    #       2) As the decimal version of 1)
256
        #       2) As the decimal version of 1)
223
    #
257
        #
224
    #   The version is held in two bytes so it is limited
258
        #   The version is held in two bytes so it is limited
225
    #
259
        #
226
    my @versions = split( /\./, $::ScmBuildVersion );
260
        @versions = split( /\./, $::ScmBuildVersion );
227
    Error ("MugFiles: Cannot encode versions with a patch number: $::ScmBuildVersion",
261
        Error ("MugFiles: Cannot encode versions with a patch number: $::ScmBuildVersion",
228
            "Major: $versions[0]",
262
                "Major: $versions[0]",
229
            "Minor: $versions[1]",
263
                "Minor: $versions[1]",
230
            "Patch: $versions[2]")
264
                "Patch: $versions[2]")
231
        if ( $versions[2] > 0 ) ;
265
            if ( $versions[2] > 0 ) ;
232
 
266
 
233
    my $version_hex = $versions[0] * 100 + $versions[1];
267
        $version_hex = $versions[0] * 100 + $versions[1];
234
    my $version_decimal = hex $version_hex;
268
        $version_decimal = hex $version_hex;
235
    Debug ("MugSet version: $version_decimal, HEX:$version_hex");
269
        Debug ("MugSet version: $version_decimal, HEX:$version_hex");
-
 
270
    }
236
 
271
 
237
    #
272
    #
238
    #   Create the list of THX files to be used for each device
273
    #   Create the list of THX files to be used for each device
239
    #   These files are calculated by:
274
    #   These files are calculated by:
240
    #       Merging all the THX files in the specified packages
275
    #       Merging all the THX files in the specified packages
241
    #       Excluding the specified files
276
    #       Excluding the specified files
242
    #
277
    #
243
    foreach my $mugref ( values %Tiers )
278
    foreach my $mugref ( values(%Tiers), @ThxOnly )
244
    {
279
    {
245
 
280
 
246
        #
281
        #
247
        #   If the user has specified a load file, then use it to provide
282
        #   If the user has specified a load file, then use it to provide
248
        #   the complete list of files to load
283
        #   the complete list of files to load
Line 334... Line 369...
334
        #
369
        #
335
        #   Generate the loadfull.ini file
370
        #   Generate the loadfull.ini file
336
        #   This file simply contains the full path names to all THXs
371
        #   This file simply contains the full path names to all THXs
337
        #   Unique INI files will be created in the "interface" directory
372
        #   Unique INI files will be created in the "interface" directory
338
        #
373
        #
339
        my $loadname = "$::ScmRoot/$::ScmInterface/load_$mugref->{'Tier'}.ini";
-
 
340
        $mugref->{'IniName'} = $loadname;
-
 
341
 
-
 
342
        Debug("Generating loadfile: $loadname" );
-
 
343
        open (INI, ">$loadname" ) || Error ("Cannot create: $loadname" );
-
 
344
        foreach ( @{$mugref->{'Files'}} )
374
        unless ( $mugref->{'NoMug'} )
345
        {
375
        {
-
 
376
            my $loadname = "$::ScmRoot/$::ScmInterface/load_$mugref->{'Tier'}.ini";
-
 
377
            $mugref->{'IniName'} = $loadname;
-
 
378
 
-
 
379
            Debug("Generating loadfile: $loadname" );
-
 
380
            open (INI, ">$loadname" ) || Error ("Cannot create: $loadname" );
-
 
381
            foreach ( @{$mugref->{'Files'}} )
-
 
382
            {
346
            (my $dos_path = $_) =~ s~/~\\~g;
383
                (my $dos_path = $_) =~ s~/~\\~g;
347
            print INI "e=o:$dos_path\n";
384
                print INI "e=o:$dos_path\n";
-
 
385
            }
-
 
386
            close INI;
348
        }
387
        }
349
        close INI;
-
 
350
 
388
 
351
 
389
 
352
        #
390
        #
353
        #   Transfer THX files into the package
391
        #   Transfer THX files into the package
354
        #
392
        #
Line 367... Line 405...
367
 
405
 
368
        DebugDumpData("Processed Mug", $mugref)
406
        DebugDumpData("Processed Mug", $mugref)
369
            if $verbose > 2;
407
            if $verbose > 2;
370
    }
408
    }
371
 
409
 
372
    #
-
 
373
    #   Create the master genappi.ini file
-
 
374
    #   This file will be created in the interface directory
-
 
375
    #
-
 
376
    my $genappa = "$::ScmRoot/$::ScmInterface/genappa.ini";
-
 
377
    Debug("Generating genappa control file: $genappa" );
-
 
378
    open (INI, ">$genappa" ) || Error ("Cannot create: $genappa" );
-
 
379
 
-
 
380
    #
-
 
381
    #   Insert the header
410
    if ( keys %Tiers )
382
    #
-
 
383
    print INI "[Header]\n";
-
 
384
    print INI "SystemVer                = ",$version_hex, "\n";
-
 
385
    print INI "NumDevTypes              = ", scalar keys %Tiers, "\n";
-
 
386
    print INI "\n";
-
 
387
 
-
 
388
    #
-
 
389
    #   Insert per device information
-
 
390
    #   This is performed in reverse Tier order
-
 
391
    #
-
 
392
    my $device_number = 0;
-
 
393
    foreach my $tier ( reverse sort keys %Tiers )
-
 
394
    {
411
    {
395
        $device_number++;
412
        #
396
        my $mugref = $Tiers{$tier};
413
        #   Create the master genappi.ini file
-
 
414
        #   This file will be created in the interface directory
-
 
415
        #
-
 
416
        my $genappa = "$::ScmRoot/$::ScmInterface/genappa.ini";
-
 
417
        Debug("Generating genappa control file: $genappa" );
-
 
418
        open (INI, ">$genappa" ) || Error ("Cannot create: $genappa" );
397
 
419
 
-
 
420
        #
398
        print INI "[DeviceType$device_number]\n";
421
        #   Insert the header
399
        print INI "Name                     = ", $mugref->{'Name'}, "\n";
422
        #
400
        print INI "Id                       = ", $mugref->{'Device'}, "\n";
423
        print INI "[Header]\n";
401
        print INI "Ver                      = ", $version_decimal, "\n";
424
        print INI "SystemVer                = ",$version_hex, "\n";
402
        print INI "Tier                     = ", $mugref->{'Tier'}, "\n";
425
        print INI "NumDevTypes              = ", scalar keys %Tiers, "\n";
403
        print INI "ModulesPath              = ", $mugref->{'IniName'}, "\n";
-
 
404
        print INI "ScanMemBackupSuper       = N\n";
-
 
405
        print INI "ScanMemBackupUserSuper   = N\n";
-
 
406
        print INI "ScanMemFlashSuper        = Y\n";
-
 
407
        print INI "ScanMemFlashUserSuper    = Y\n";
-
 
408
        print INI "\n";
426
        print INI "\n";
409
    }
-
 
410
 
427
 
-
 
428
        #
-
 
429
        #   Insert per device information
-
 
430
        #   This is performed in reverse Tier order
411
    #
431
        #
-
 
432
        my $device_number = 0;
-
 
433
        foreach my $tier ( reverse sort keys %Tiers )
-
 
434
        {
-
 
435
            $device_number++;
-
 
436
            my $mugref = $Tiers{$tier};
-
 
437
 
-
 
438
            print INI "[DeviceType$device_number]\n";
-
 
439
            print INI "Name                     = ", $mugref->{'Name'}, "\n";
-
 
440
            print INI "Id                       = ", $mugref->{'Device'}, "\n";
-
 
441
            print INI "Ver                      = ", $version_decimal, "\n";
-
 
442
            print INI "Tier                     = ", $mugref->{'Tier'}, "\n";
-
 
443
            print INI "ModulesPath              = ", $mugref->{'IniName'}, "\n";
-
 
444
            print INI "ScanMemBackupSuper       = N\n";
-
 
445
            print INI "ScanMemBackupUserSuper   = N\n";
-
 
446
            print INI "ScanMemFlashSuper        = Y\n";
-
 
447
            print INI "ScanMemFlashUserSuper    = Y\n";
-
 
448
            print INI "\n";
-
 
449
        }
-
 
450
 
-
 
451
        #
412
    #   Insert options
452
        #   Insert options
413
    #
453
        #
414
    print INI "[Options]\n";
454
        print INI "[Options]\n";
415
    print INI "SuppressCDHeader         = TRUE\n";
455
        print INI "SuppressCDHeader         = TRUE\n";
416
    print INI "\n";
456
        print INI "\n";
417
 
457
 
418
    
458
    
419
    close INI;
459
        close INI;
420
 
460
 
421
    #
461
        #
422
    #   Run the GENAPPA utility
462
        #   Run the GENAPPA utility
423
    #   This will create a directory full of MUG files
463
        #   This will create a directory full of MUG files
424
    #   Generate the files directly into the pkg subdirectory
464
        #   Generate the files directly into the pkg subdirectory
425
    #
465
        #
426
    my $mugdir = "$::ScmRoot/pkg/$::ScmBuildPackage/mug";
466
        my $mugdir = "$::ScmRoot/pkg/$::ScmBuildPackage/mug";
427
    Debug("Mugfiles will be placed in: $mugdir" );
467
        Debug("Mugfiles will be placed in: $mugdir" );
428
    mkpath( $mugdir );
468
        mkpath( $mugdir );
429
 
469
 
430
    #
470
        #
431
    #   Extend the PATH to include the toolset extensions
471
        #   Extend the PATH to include the toolset extensions
432
    #   to allow use to find genappa and modcrc
472
        #   to allow use to find genappa and modcrc
433
    #
473
        #
434
    my $PATH = join ';', ToolExtensionPaths(), $ENV{'PATH'};
474
        my $PATH = join ';', ToolExtensionPaths(), $ENV{'PATH'};
435
    $ENV{'PATH'} = $PATH;
475
        $ENV{'PATH'} = $PATH;
436
 
476
 
437
    my $opts = ($verbose > 1) ? " -d" : "";
477
        my $opts = ($verbose > 1) ? " -d" : "";
438
    Debug( "Running GENAPPA");
478
        Debug( "Running GENAPPA");
439
    System( "genappa $genappa$opts -o $mugdir" ) && Error( "Problem running genappa" );
479
        System( "genappa $genappa$opts -o $mugdir" ) && Error( "Problem running genappa" );
-
 
480
    }
440
 
481
 
441
    #
482
    #
442
    #   Cleanup the debugging interface
483
    #   Cleanup the debugging interface
443
    #
484
    #
444
    DebugPop();
485
    DebugPop();