imgtools/buildrom/tools/experimental/metarombuild.pl
author lorewang
Wed, 24 Nov 2010 14:12:23 +0800
changeset 706 5221386d044b
parent 600 6d08f4a05d93
permissions -rw-r--r--
external tools cannot specify path.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
600
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     1
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     2
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     3
# All rights reserved.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     5
# under the terms of "Eclipse Public License v1.0"
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     8
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
     9
# Initial Contributors:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    11
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    12
# Contributors:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    13
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    14
# Description:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    15
#
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    16
#! perl
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    17
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    18
# This script builds ROMs which are specified in a supplied XML file
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    19
# To use this script \epoc32\tools\buildrom must be installed on the drive
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    20
# with \epoc32\tools in the path
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    21
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    22
# Note: The TargetBoard attribute is no longer used but is still needed because of the structure of this script!
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    23
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    24
use strict;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    25
use XML::Simple;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    26
use Getopt::Long;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    27
use Cwd;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    28
use Cwd 'abs_path';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    29
use File::Copy;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    30
use File::Path;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    31
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    32
# Get command line arguments
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    33
my ($romspec, $boards, $roms, $logdir, $buildnum, $publish, $help, $version) = ProcessCommandLine();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    34
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    35
Usage() if ($help);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    36
Version() if ($version);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    37
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    38
die "Romspec xml file must be specified using the -romspec option\n" if (!$romspec);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    39
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    40
# Construct arrays of boards and roms if they were specified
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    41
my @boards = split /,/, $boards if ($boards);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    42
my @roms = split /,/, $roms if ($roms);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    43
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    44
# Use the XML::Simple module to parse the romspec and pass the result
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    45
# into the $Roms hash reference
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    46
my $xml = new XML::Simple;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    47
my $Roms = $xml->XMLin($romspec);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    48
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    49
my $RomList = %$Roms->{'Rom'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    50
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    51
my $RomBuildStage = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    52
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    53
foreach my $rom (sort keys %$RomList)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    54
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    55
    my $board = $RomList->{$rom}->{'TargetBoard'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    56
    if( (@boards == 0 and @roms == 0) or grep $rom, @roms or grep $board, @boards)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    57
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    58
        BuildRom($RomBuildStage, $RomList, $rom, $logdir, $buildnum ,$publish);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    59
        $RomBuildStage++;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    60
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    61
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    62
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    63
#####################################################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    64
#### Run buildrom on the specified ROM using ########
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    65
#### info from the romspec.xml               ########
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    66
#####################################################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    67
sub BuildRom
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    68
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    69
    my $Stage = shift;  # BuildRom stage
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    70
    my $RomList = shift;  # Hash of the romspec.xml
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    71
    my $rom = shift;   # Rom to be built
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    72
    my $logdir = shift;  # logs directory
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    73
    my $buildnum = shift;  # build number
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    74
    my $publish = shift;   # Publish Location
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    75
    my $type = $ENV{Type}; # type of Build Master or Release
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    76
    my $builddir = $ENV{BuildDir}; # Build Directory
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    77
    my $Epocroot = $ENV{EPOCROOT}; # EpocRoot;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    78
    my $InFileList="";  # i.e. Platsec, Techview, obyfiles
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    79
    my $XmlFileList="";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    80
    my $MacroList="";   # for the buildrom -D option
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    81
    my $TargetBoard = $RomList->{$rom}->{'TargetBoard'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    82
    my $ImageFile = " -o".$RomList->{$rom}->{'ImageFile'}->{'name'}; # for the buildrom -o option
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    83
 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    84
    # Construct the list of InFiles to pass to buildrom
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    85
    my $InFiles = %$RomList->{$rom}->{'InFile'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    86
    foreach my $infile (sort keys %$InFiles)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    87
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    88
        if ($infile eq "name")
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    89
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    90
            $InFileList = " ".$InFiles->{'name'} unless (lc($InFiles->{'name'}) eq lc($TargetBoard));
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    91
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    92
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    93
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    94
            $InFileList .= " ".$infile unless(lc($infile) eq lc($TargetBoard));
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    95
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    96
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    97
    my $RomXmlFlag='-f';
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    98
    my $XmlFiles = %$RomList->{$rom}->{'XMLFile'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
    99
    foreach my $XmlFlags (keys %$XmlFiles)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   100
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   101
        if ($XmlFlags eq "flag")
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   102
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   103
          $RomXmlFlag= $XmlFiles->{'flag'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   104
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   105
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   106
    foreach my $XmlFile (keys %$XmlFiles)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   107
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   108
        if ($XmlFile eq "name")
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   109
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   110
            $XmlFileList = "$RomXmlFlag"."$Epocroot"."epoc32\\rom\\include\\".$XmlFiles->{'name'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   111
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   112
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   113
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   114
            $XmlFileList .= "$RomXmlFlag"."$Epocroot"."epoc32\\rom\\include\\".$XmlFile unless(lc($XmlFile) eq lc($TargetBoard));
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   115
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   116
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   117
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   118
    # Get the ROM macro if one is defined
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   119
    if ( defined $RomList->{$rom}->{'Macro'} )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   120
    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   121
        if (defined $RomList->{$rom}->{'Macro'}->{'name'} )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   122
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   123
            if ( $RomList->{$rom}->{'Macro'}->{'value'} ne "" )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   124
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   125
                $MacroList = " -D".$RomList->{$rom}->{'Macro'}->{'name'}."=".$RomList->{$rom}->{'Macro'}->{'value'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   126
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   127
            else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   128
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   129
                $MacroList = " -D".$RomList->{$rom}->{'Macro'}->{'name'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   130
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   131
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   132
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   133
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   134
            my $Macros = %$RomList->{$rom}->{'Macro'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   135
            foreach my $macro (keys %$Macros)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   136
            {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   137
                if ( $Macros->{$macro}->{'value'} ne "" )
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   138
                {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   139
                    $MacroList .= " -D".$macro."=".$Macros->{$macro}->{'value'};
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   140
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   141
                else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   142
                {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   143
                    $MacroList .= " -D".$macro;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   144
                }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   145
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   146
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   147
    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   148
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   149
    # Call buildrom
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   150
        my $buildrom_command = "buildrom $InFileList $MacroList $XmlFileList $ImageFile 2>&1";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   151
        my $gHiResTimer = 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   152
        if (eval "require Time::HiRes;")
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   153
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   154
            $gHiResTimer = 1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   155
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   156
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   157
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   158
            print "Cannot load HiResTimer Module\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   159
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   160
        open TVROMLOG, ">> $logdir\\techviewroms$buildnum.log";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   161
        print TVROMLOG "===------------------------------------------------\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   162
        print TVROMLOG "-- Stage=$Stage\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   163
        print TVROMLOG "===----------------------------------------------\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   164
        print TVROMLOG "-- Stage=$Stage started ".localtime()."\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   165
        print TVROMLOG "=== Stage=$Stage == Build $rom\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   166
        print TVROMLOG "-- Stage=$Stage == $TargetBoard $InFileList\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   167
        print TVROMLOG "-- $buildrom_command\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   168
        print TVROMLOG "-- MetaromBuild Executed ID $Stage $buildrom_command \n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   169
        print TVROMLOG "++ Started at ".localtime()."\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   170
        if ($gHiResTimer == 1)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   171
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   172
            print TVROMLOG "+++ HiRes Start ".Time::HiRes::time()."\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   173
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   174
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   175
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   176
            # Add the HiRes timer unavailable statement
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   177
            print TVROMLOG "+++ HiRes Time Unavailable\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   178
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   179
        my $command_output = `$buildrom_command`;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   180
        print TVROMLOG $command_output;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   181
        if ($?)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   182
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   183
            print TVROMLOG "ERROR: $buildrom_command returned an error code $?\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   184
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   185
        if (($command_output =~m/\d\sFile/g) and ($command_output!~/Failed/ig) and ($command_output!~/Unsucessful/ig))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   186
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   187
            print TVROMLOG "Rom Built Sucessfully\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   188
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   189
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   190
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   191
            print TVROMLOG "ERROR: $buildrom_command failed .Please check log techviewroms$buildnum.log for details\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   192
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   193
        if ($gHiResTimer == 1)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   194
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   195
            print TVROMLOG "+++ HiRes End ".Time::HiRes::time()."\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   196
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   197
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   198
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   199
            # Add the HiRes timer unavailable statement
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   200
            print TVROMLOG "+++ HiRes Time Unavailable\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   201
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   202
        print TVROMLOG "++ Finished at ".localtime()."\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   203
        print TVROMLOG "=== Stage=$Stage finished ".localtime()."\n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   204
        close TVROMLOG;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   205
        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   206
        # Publishing of Logs and Roms#####################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   207
        my $ImageFileXML = $ImageFile ;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   208
        $ImageFileXML =~s/^\s-o//i;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   209
        $ImageFileXML =~/(.*\d.techview)/;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   210
        my $ImageFileXMLresult = $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   211
        my $cwdir = abs_path ( $ENV { 'PWD' } );
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   212
        $cwdir =~s/\//\\/g;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   213
        $rom =~ /(\w+).*/;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   214
        my $data = $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   215
        if(($publish ne ""))
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   216
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   217
            if($rom =~ /(\w+).*/)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   218
            {   
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   219
                my $data = $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   220
                if(not -d "$publish\\$1")
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   221
                    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   222
                        mkpath "$publish\\$1" || die "ERROR: Cannot create $publish\\$1"; # If folder doesnt exist create it 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   223
                    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   224
                    opendir(DIR, $cwdir) || die "can't opendir $cwdir: $!";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   225
                    my @file_array =readdir(DIR);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   226
                foreach ($ImageFileXMLresult)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   227
                {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   228
                    foreach my $ImageFileConcat (@file_array)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   229
                    {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   230
                        $ImageFileConcat =~/(.*\d.techview)/;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   231
                        my  $Image = $1;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   232
                        
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   233
                        if ($ImageFileXMLresult eq $Image)
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   234
                        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   235
                            copy ("$cwdir\\$ImageFileConcat" , "$publish\\$data\\");# or die "Cannot copy file:$!";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   236
                        }                   
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   237
                    }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   238
                    closedir DIR;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   239
                }   
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   240
            }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   241
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   242
        else
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   243
        {
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   244
            print"Publish Option not used \n";
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   245
        }
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   246
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   247
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   248
########################################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   249
##### Process the command line #########
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   250
########################################
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   251
sub ProcessCommandLine
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   252
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   253
    my ($romspec, $boards, $roms, $publish, $help, $version);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   254
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   255
    GetOptions('romspec=s' => \$romspec,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   256
               'roms=s' => \$roms,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   257
               'boards=s' => \$boards,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   258
               'logdir=s' => \$logdir,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   259
               'buildnum=s' => \$buildnum,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   260
               'publish=s' => \$publish,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   261
               'help' => \$help,
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   262
               'version' => \$version)|| die Usage();
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   263
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   264
    return ($romspec, $boards, $roms, $logdir, $buildnum, $publish, $help, $version);
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   265
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   266
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   267
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   268
sub Usage
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   269
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   270
    print <<USAGE_EOF;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   271
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   272
Usage
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   273
-----
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   274
perl metarombuild.pl -romspec <romspec xml file> [options]
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   275
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   276
 When no options are specified, all ROMs specified in the romspec wil be built.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   277
 
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   278
 Options:
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   279
    -logdir <path to logs directory>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   280
    -buildnum <build number>
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   281
    -publish <location of path where rom logs will be published >
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   282
    -help
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   283
    -version
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   284
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   285
USAGE_EOF
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   286
exit 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   287
}
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   288
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   289
sub Version
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   290
{
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   291
    print <<VERSION_EOF;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   292
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   293
metarombuild.pl v1.0
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   294
Copyright (c) 2005-2009 Nokia Corporation. All rights reserved.
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   295
    
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   296
VERSION_EOF
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   297
exit 0;
6d08f4a05d93 add deprecated files
jjkang
parents:
diff changeset
   298
}