65 $useinterpretsis = 0; |
65 $useinterpretsis = 0; |
66 } |
66 } |
67 my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. |
67 my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. |
68 |
68 |
69 my $BuildromMajorVersion = 3 ; |
69 my $BuildromMajorVersion = 3 ; |
70 my $BuildromMinorVersion = 31; |
70 my $BuildromMinorVersion = 32; |
71 my $BuildromPatchVersion = 0; |
71 my $BuildromPatchVersion = 0; |
72 |
72 |
73 |
73 |
74 sub print_usage |
74 sub print_usage |
75 { |
75 { |
76 |
76 |
77 # Option "-fm" will be supported instead of option "-f|fr" if SYMBIAN_FEATURE_MANAGER macro is defined. |
77 # Option "-fm" will be supported instead of option "-f|fr" if SYMBIAN_FEATURE_MANAGER macro is defined. |
78 my $featuresOptionUsage = "-ffeatureuids or -fr=featureuids -- feature registry database XML file name"; |
78 my $featuresOptionUsage = "-ffeatureuids or -fr=featureuids -- [obsolete] Feature registry database XML file name\n". |
|
79 " Please use featureconfigurator.pl to configurate features.\n\n". |
|
80 " -nofm -- Don't perform feature configuration \n\n"; |
79 if ($enforceFeatureManager) |
81 if ($enforceFeatureManager) |
80 { |
82 { |
81 $featuresOptionUsage = "-fm=featuredatabasefile -- feature manager/feature registry database XML file name.\n". |
83 $featuresOptionUsage = "-fm=featuredatabasefile -- [obsolete] Feature manager/feature registry database XML file name.\n". |
82 "\t\t\t\t Multiple XML files can be passed seperated by commas.\n". |
84 " Multiple XML files can be passed seperated by commas.\n". |
83 " -nofm=featuresdatafile -- don't generate features data file.". |
85 " Please use featureconfigurator.pl to configurate features.\n\n". |
84 " Instead use pre-built features data file."; |
86 " -nofm=featuresdatafile -- [obsolete] Don't generate features data file.\n". |
|
87 " Use pre-built features data file instead.\n". |
|
88 " Please use featureconfigurator.pl to configurate features.\n\n". |
|
89 " -nofm -- Don't perform feature configuration\n\n"; |
85 } |
90 } |
86 |
91 |
87 #........1.........2.........3.........4.........5.........6.........7..... |
92 #........1.........2.........3.........4.........5.........6.........7..... |
88 print <<USAGE_EOF; |
93 print <<USAGE_EOF; |
89 |
94 |
115 -oimagename -- ROM image name, overriding any ROMNAME statement |
120 -oimagename -- ROM image name, overriding any ROMNAME statement |
116 -s -- strict option, any missing files will stop buildrom |
121 -s -- strict option, any missing files will stop buildrom |
117 -p -- preserves the intermediate files pertaining to data drive, Z drive and BMCONV |
122 -p -- preserves the intermediate files pertaining to data drive, Z drive and BMCONV |
118 -spi -- enable producing SPI files |
123 -spi -- enable producing SPI files |
119 -spiplacement -- enable positioning of spi file |
124 -spiplacement -- enable positioning of spi file |
120 -w -- warn if file has been selected from a different directory |
125 -w -- warn if file has been selected from a different directory |
|
126 |
121 $featuresOptionUsage |
127 $featuresOptionUsage |
122 -etool -- external tool specification (xx is tool's perl module) |
128 -etool -- external tool specification (xx is tool's perl module) |
123 -compress -- compression type of ROM image: |
129 -compress -- compression type of ROM image: |
124 -compress compress whole ROM image. |
130 -compress compress whole ROM image. |
125 -compress=paged compress paged section in the ROM image only. |
131 -compress=paged compress paged section in the ROM image only. |
157 the result will be checkcase.log, this option is only valid on windows. |
163 the result will be checkcase.log, this option is only valid on windows. |
158 -workdir=xxx -- specify a directory to contain generated files. |
164 -workdir=xxx -- specify a directory to contain generated files. |
159 -prependepocroot -- if there is no EPOCROOT## before /epoc32/, prepend EPOCROOT## to epoc32. |
165 -prependepocroot -- if there is no EPOCROOT## before /epoc32/, prepend EPOCROOT## to epoc32. |
160 -stdcpp -- ignore symbian customized cpp and try to find another cpp in the PATH.(for Windows only) |
166 -stdcpp -- ignore symbian customized cpp and try to find another cpp in the PATH.(for Windows only) |
161 -cpp=xxx -- specify a CPP preprocessor used by Buildrom. |
167 -cpp=xxx -- specify a CPP preprocessor used by Buildrom. |
162 -xiponly -- just create the XIP ROM image without creating the ROFS image. |
168 -xiponly -- just create the XIP ROM image without creating the ROFS image. |
|
169 -nopreprocess -- Input oby files have been or don't need to be preprocessed, |
|
170 don't preprocess the input oby files. |
163 -inputoby=<finalOBYfile> -- Ignore BUILDROM config phase, invoke Rombuild/Rofsbuild using <finalOBYfile>. |
171 -inputoby=<finalOBYfile> -- Ignore BUILDROM config phase, invoke Rombuild/Rofsbuild using <finalOBYfile>. |
164 <finalOBYfile> must contain one and ONLY one of romsize/rofssize/dataimagename/imagename keywords, |
172 <finalOBYfile> must contain one and ONLY one of romsize/rofssize/dataimagename/imagename keywords, |
165 The keywords will be used to identify the OBY type. |
173 The keywords will be used to identify the OBY type. |
166 |
174 |
167 Popular -D defines to use include |
175 Popular -D defines to use include |
1048 if ($arg =~ /^-checkcase_test$/) |
1066 if ($arg =~ /^-checkcase_test$/) |
1049 { |
1067 { |
1050 $checkcase_test=1; |
1068 $checkcase_test=1; |
1051 next; |
1069 next; |
1052 } |
1070 } |
1053 if ($arg =~ /^-workdir=(.*)/) |
1071 |
1054 { |
1072 if ($arg =~ /^-stdcpp$/) |
|
1073 { |
|
1074 if($nopreprocess) { |
|
1075 print STDERR "Warning: -stdcpp option is invalid because the -nopreprocess option set.\n"; |
|
1076 } |
|
1077 else { |
|
1078 if (&is_linux) |
|
1079 { |
|
1080 print "Warning: option -stdcpp only apply for Windows\n"; |
|
1081 next; |
|
1082 } |
|
1083 if ($cppoption) |
|
1084 { |
|
1085 die "Error: -stdcpp option and -cpp=xxx option cannot be used at the same time.\n"; |
|
1086 } |
|
1087 $stdcpp = 1; |
|
1088 } |
1055 next; |
1089 next; |
1056 } |
1090 } |
1057 if ($arg =~ /^-stdcpp$/) |
|
1058 { |
|
1059 if (&is_linux) |
|
1060 { |
|
1061 print "Warning: option -stdcpp only apply for Windows\n"; |
|
1062 next; |
|
1063 } |
|
1064 if ($cppoption) |
|
1065 { |
|
1066 die "Error: -stdcpp option and -cpp=xxx option cannot be used at the same time.\n"; |
|
1067 } |
|
1068 $stdcpp = 1; |
|
1069 next; |
|
1070 } |
|
1071 if ($arg =~ /^-cpp=(.*)/) |
1091 if ($arg =~ /^-cpp=(.*)/) |
1072 { |
1092 { |
1073 if ($stdcpp) |
1093 if($nopreprocess) { |
1074 { |
1094 print STDERR "Warning: -cpp option is invalid because the -nopreprocess option set.\n"; |
1075 die "Error: -stdcpp option and -cpp=xxx option cannot be used at the same time.\n"; |
1095 } |
1076 } |
1096 else { |
1077 if ($cppoption) |
1097 if ($stdcpp) |
1078 { |
1098 { |
1079 print "Warning: -cpp option has been set before. The previous configuration will be overwritten!\n"; |
1099 die "Error: -stdcpp option and -cpp=xxx option cannot be used at the same time.\n"; |
1080 } |
1100 } |
1081 $cppoption = 1; |
1101 if ($cppoption) |
1082 $preprocessor = $1; |
1102 { |
1083 $preprocessor =~ s-\\-\/-g; |
1103 print "Warning: -cpp option has been set before. The previous configuration will be overwritten!\n"; |
1084 $preprocessor =~ s-EPOCROOT##\/?-$epocroot-g; |
1104 } |
1085 if (-d $preprocessor) |
1105 $cppoption = 1; |
1086 { |
1106 $preprocessor = $1; |
1087 $preprocessor .= "\/" unless $preprocessor =~ /\/$/; |
1107 $preprocessor =~ s-\\-\/-g; |
1088 $preprocessor .= "cpp"; |
1108 $preprocessor =~ s-EPOCROOT##\/?-$epocroot-g; |
|
1109 if (-d $preprocessor) |
|
1110 { |
|
1111 $preprocessor .= "\/" unless $preprocessor =~ /\/$/; |
|
1112 $preprocessor .= "cpp"; |
|
1113 } |
1089 } |
1114 } |
1090 next; |
1115 next; |
1091 } |
1116 } |
1092 |
1117 |
1093 if ($arg =~ /^-prependepocroot$/) |
1118 if ($arg =~ /^-prependepocroot$/) |
1389 # Concatentate the specified .oby files and pass them through cpp |
1409 # Concatentate the specified .oby files and pass them through cpp |
1390 # to get the raw ROM specification in tmp1.oby |
1410 # to get the raw ROM specification in tmp1.oby |
1391 |
1411 |
1392 sub preprocessing_phase |
1412 sub preprocessing_phase |
1393 { |
1413 { |
1394 my $temp1OBYFile = $thisdir."tmp1.oby"; |
1414 if($nopreprocess == 0) { |
1395 unlink "$temp1OBYFile"; |
1415 my $temp1OBYFile = $thisdir."tmp1.oby"; |
1396 |
1416 unlink "$temp1OBYFile"; |
1397 # Macro "ROM_FEATURE_MANAGEMENT" is defined when "-f|fr" or "-fm" is used |
1417 |
1398 if (defined ($featureXml)) |
1418 # Macro "ROM_FEATURE_MANAGEMENT" is defined when "-f|fr" or "-fm" is used |
1399 { |
1419 if (defined ($featureXml)) |
1400 $cppargs .= " -DROM_FEATURE_MANAGEMENT "; |
1420 { |
1401 } |
1421 $cppargs .= " -DROM_FEATURE_MANAGEMENT "; |
1402 |
1422 } |
1403 # add pre-include file and include directories for feature variants |
1423 |
1404 if ($featureVariant{'VALID'}) |
1424 # add pre-include file and include directories for feature variants |
1405 { |
1425 if ($featureVariant{'VALID'}) |
1406 $cppargs .= " -I."; |
1426 { |
1407 my $incRef = $featureVariant{'ROM_INCLUDES'}; |
1427 $cppargs .= " -I."; |
1408 if ($incRef) |
1428 my $incRef = $featureVariant{'ROM_INCLUDES'}; |
1409 { |
1429 if ($incRef) |
1410 foreach (@$incRef) |
1430 { |
1411 { |
1431 foreach (@$incRef) |
1412 $cppargs .= " -I \"$_\""; |
1432 { |
1413 } |
1433 $cppargs .= " -I \"$_\""; |
1414 } |
1434 } |
1415 my $HRH = $featureVariant{'VARIANT_HRH'}; |
1435 } |
1416 if ($HRH) |
1436 my $HRH = $featureVariant{'VARIANT_HRH'}; |
1417 { |
1437 if ($HRH) |
1418 $cppargs .= " -include \"$HRH\""; |
1438 { |
1419 } |
1439 $cppargs .= " -include \"$HRH\""; |
1420 } |
1440 } |
1421 else |
1441 } |
1422 { |
1442 else |
1423 # no feature variant so use the standard includes |
1443 { |
1424 $cppargs .= " -I. -I \"$rominclude\""; |
1444 # no feature variant so use the standard includes |
1425 } |
1445 $cppargs .= " -I. -I \"$rominclude\""; |
1426 |
1446 } |
1427 if ($stdcpp) |
1447 |
1428 { |
1448 if ($stdcpp) |
1429 $preprocessor = find_stdcpp(); |
1449 { |
1430 } |
1450 $preprocessor = find_stdcpp(); |
1431 print "* $preprocessor -Wno-endif-labels -o $temp1OBYFile $cppargs\n" if ($opt_v); |
1451 } |
1432 |
1452 print "* $preprocessor -Wno-endif-labels -o $temp1OBYFile $cppargs\n" if ($opt_v); |
1433 is_existinpath("$preprocessor", romutl::DIE_NOT_FOUND); |
|
1434 $errors = 0; |
|
1435 open CPP, "| $preprocessor -Wno-endif-labels -o $temp1OBYFile $cppargs" or die "* Can't execute cpp"; |
|
1436 foreach my $arg (@obyfiles) |
|
1437 { |
|
1438 print CPP "\n#line 1 \"$arg\"\n"; |
|
1439 |
|
1440 if(open(OBY, $arg)) { |
|
1441 print "* reading $arg\n" if ($opt_v); |
|
1442 while ($line=<OBY>) { |
|
1443 print CPP $line; |
|
1444 } |
|
1445 close OBY; |
|
1446 } |
|
1447 else { |
|
1448 print STDERR "* Can't open $arg\n"; |
|
1449 if(!$opt_k){ |
|
1450 close CPP; |
|
1451 exit(1); |
|
1452 } |
|
1453 } |
|
1454 } |
|
1455 close CPP; |
|
1456 my $cpp_status = $?; |
|
1457 die "* cpp failed\n" if ($cpp_status != 0 || !-f "$temp1OBYFile"); |
|
1458 |
|
1459 if( defined ($image_content)) |
|
1460 { |
|
1461 #Read the OBY file that was generated by the pre-processor |
|
1462 &ReadPreprocessedFile($temp1OBYFile); |
|
1463 |
|
1464 # Check if the static dependencies of the OBY binaries are resolved. |
|
1465 &ImageContentHandler::UpdateObyBinaryStaticDep(); |
|
1466 |
1453 |
1467 #Now append the files collected from cdfs. |
1454 is_existinpath("$preprocessor", romutl::DIE_NOT_FOUND); |
1468 &ImageContentHandler::GenObyFile($temp1OBYFile); |
1455 $errors = 0; |
1469 } |
1456 open CPP, "| $preprocessor -Wno-endif-labels -o $temp1OBYFile $cppargs" or die "* Can't execute cpp"; |
1470 |
1457 foreach my $arg (@obyfiles) |
1471 # Setup default rom configuration |
1458 { |
1472 $romimage[0] = {xip=>1, compress=>0, extension=>0, composite=>"none",uncompress=>0 }; |
1459 print CPP "\n#line 1 \"$arg\"\n"; |
1473 if($obycharset =~ /utf-?8/i) |
1460 |
1474 { |
1461 if(open(OBY, $arg)) { |
1475 my $utf8file = $thisdir."tmp1utf8.oby"; |
1462 print "* reading $arg\n" if ($opt_v); |
1476 open INFILE, "<$temp1OBYFile" or die "* Can't open file $temp1OBYFile"; |
1463 while ($line=<OBY>) { |
1477 open CHARSETTRAN, "| charsettran -to=hostcharset > $utf8file" or die "* Can't execute charsetran"; |
1464 print CPP $line; |
1478 while(<INFILE>) |
1465 } |
1479 { |
1466 close OBY; |
1480 print CHARSETTRAN $_; |
1467 } |
1481 } |
1468 else { |
1482 close CHARSETTRAN; |
1469 print STDERR "* Can't open $arg\n"; |
1483 close INFILE; |
1470 if(!$opt_k){ |
1484 unlink $temp1OBYFile or die "* Can't remove file $temp1OBYFile"; |
1471 close CPP; |
1485 rename $utf8file, $temp1OBYFile or die "* Can't rename file $utf8file to file $temp1OBYFile"; |
1472 exit(1); |
|
1473 } |
|
1474 } |
|
1475 } |
|
1476 close CPP; |
|
1477 my $cpp_status = $?; |
|
1478 die "* cpp failed\n" if ($cpp_status != 0 || !-f "$temp1OBYFile"); |
|
1479 |
|
1480 if( defined ($image_content)) |
|
1481 { |
|
1482 #Read the OBY file that was generated by the pre-processor |
|
1483 &ReadPreprocessedFile($temp1OBYFile); |
|
1484 |
|
1485 # Check if the static dependencies of the OBY binaries are resolved. |
|
1486 &ImageContentHandler::UpdateObyBinaryStaticDep(); |
|
1487 |
|
1488 #Now append the files collected from cdfs. |
|
1489 &ImageContentHandler::GenObyFile($temp1OBYFile); |
|
1490 } |
|
1491 |
|
1492 if($obycharset =~ /utf-?8/i) |
|
1493 { |
|
1494 my $utf8file = $thisdir."tmp1utf8.oby"; |
|
1495 open INFILE, "<$temp1OBYFile" or die "* Can't open file $temp1OBYFile"; |
|
1496 open CHARSETTRAN, "| charsettran -to=hostcharset > $utf8file" or die "* Can't execute charsetran"; |
|
1497 while(<INFILE>) |
|
1498 { |
|
1499 print CHARSETTRAN $_; |
|
1500 } |
|
1501 close CHARSETTRAN; |
|
1502 close INFILE; |
|
1503 unlink $temp1OBYFile or die "* Can't remove file $temp1OBYFile"; |
|
1504 rename $utf8file, $temp1OBYFile or die "* Can't rename file $utf8file to file $temp1OBYFile"; |
|
1505 } |
|
1506 @obydata = (); |
|
1507 # load tmp1.oby here |
|
1508 open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n"); |
|
1509 while(<TMP1>) { |
|
1510 push @obydata,$_; |
|
1511 } |
|
1512 close TMP1 ; |
|
1513 } |
|
1514 else { |
|
1515 foreach my $arg (@obyfiles) { |
|
1516 if(open(OBY, $arg)) { |
|
1517 print "* reading $arg\n" if ($opt_v); |
|
1518 while (<OBY>) { |
|
1519 push @obydata,$_; |
|
1520 } |
|
1521 close OBY; |
|
1522 } |
|
1523 else { |
|
1524 print STDERR "* Can't open $arg\n"; |
|
1525 if(!$opt_k){ |
|
1526 exit(1); |
|
1527 } |
|
1528 } |
|
1529 } |
1486 } |
1530 } |
1487 } |
1531 } |
1488 |
1532 |
1489 sub ReadPreprocessedFile |
1533 sub ReadPreprocessedFile |
1490 { |
1534 { |
1551 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); |
1595 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); |
1552 $substitutionData{"TODAY"} = sprintf("%02d/%02d/%04d", $mday, $mon+1, $year+1900); |
1596 $substitutionData{"TODAY"} = sprintf("%02d/%02d/%04d", $mday, $mon+1, $year+1900); |
1553 $substitutionData{"RIGHT_NOW"} = sprintf("%02d/%02d/%04d %02d:%02d:%02d", $mday, $mon+1, $year+1900, $hour, $min, $sec); |
1597 $substitutionData{"RIGHT_NOW"} = sprintf("%02d/%02d/%04d %02d:%02d:%02d", $mday, $mon+1, $year+1900, $hour, $min, $sec); |
1554 $substitutionData{"EPOCROOT"} = $epocroot; |
1598 $substitutionData{"EPOCROOT"} = $epocroot; |
1555 @substitutionOrder = ("TODAY", "RIGHT_NOW", "EPOCROOT"); |
1599 @substitutionOrder = ("TODAY", "RIGHT_NOW", "EPOCROOT"); |
1556 } |
1600 } |
1557 |
1601 |
1558 my $temp1OBYFile = $thisdir."tmp1.oby"; |
1602 foreach $line(@obydata) { |
1559 |
1603 if(($line =~ /^\s*romsize\s*=/i) || ( $line=~ /^\s*rom_image/i) || ($line =~ /^\s*data_image/i)) { |
1560 open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n"); |
|
1561 while ($line=<TMP1>) |
|
1562 { |
|
1563 if(($line =~ /^\s*romsize\s*=/i) || ( $line=~ /^\s*rom_image/i) || ($line =~ /^\s*data_image/i)) |
|
1564 { |
|
1565 $onlysmrimage = 0; |
1604 $onlysmrimage = 0; |
1566 last; |
1605 last; |
1567 } |
1606 } |
1568 } |
1607 } |
1569 close TMP1; |
1608 if($noFeatureConf == 0) { |
1570 if ($enforceFeatureManager && (!$featuremanager) && (!$noFeatureManager) ) |
1609 if ($enforceFeatureManager && (!$featuremanager) && (!$noFeatureManager) ) { |
1571 { |
1610 my $defaultFeatureDbFlag = 0; |
1572 my $defaultFeatureDbFlag = 0; |
1611 foreach $line(@obydata) { |
1573 open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n"); |
1612 if ($line=~/^\s*defaultfeaturedb\s*=?\s*(\S+)/i) |
1574 while ($line=<TMP1>) |
1613 { |
1575 { |
1614 # Get the default value for featuredatabasefile |
1576 if ($line=~/^\s*defaultfeaturedb\s*=?\s*(\S+)/i) |
1615 |
1577 { |
1616 $featureXml = "$epocroot$1"; |
1578 # Get the default value for featuredatabasefile |
1617 $featureXml =~ s-\\-\/-g; |
1579 |
1618 $featuremanager = 1; |
1580 $featureXml = "$epocroot$1"; |
1619 $defaultFeatureDbFlag = 1; |
1581 $featureXml =~ s-\\-\/-g; |
1620 load_featuresutil(); |
1582 $featuremanager = 1; |
1621 last; |
1583 $defaultFeatureDbFlag = 1; |
1622 } |
1584 load_featuresutil(); |
1623 } |
1585 last; |
1624 |
1586 } |
1625 |
1587 } |
1626 if(!$defaultFeatureDbFlag && !$onlysmrimage) |
1588 close TMP1; |
1627 { |
1589 |
1628 print "Error: Neither option \"-fm|-nofm\" nor default value for featuredatabase file is provided.\n"; |
1590 if(!$defaultFeatureDbFlag && !$onlysmrimage) |
1629 exit(1); |
1591 { |
1630 } |
1592 print "Error: Neither option \"-fm|-nofm\" nor default value for featuredatabase file is provided.\n"; |
1631 } |
1593 exit(1); |
1632 } |
1594 } |
1633 |
1595 } |
1634 # Setup default rom configuration |
1596 |
1635 $romimage[0] = {xip=>1, compress=>0, extension=>0, composite=>"none",uncompress=>0 }; |
1597 open TMP1, "$temp1OBYFile" or die("* Can't open $temp1OBYFile\n"); |
1636 |
1598 while ($line=<TMP1>) |
1637 my @savedObyData = @obydata; |
1599 { |
1638 @obydata = (); |
|
1639 foreach $line(@savedObyData) { |
1600 track_source($line); |
1640 track_source($line); |
1601 $line =~ s-\\-\/-g; |
1641 $line =~ s-\\-\/-g; |
1602 |
1642 |
1603 if ($prependepocroot) |
1643 if ($prependepocroot) |
1604 { |
1644 { |
2657 my @datafiles; #array of hashes, stores all the data files which are to go into the spi files |
2697 my @datafiles; #array of hashes, stores all the data files which are to go into the spi files |
2658 my @hidedatafiles; #array of hashes, stores all the data files which are to be hidden in the spi files |
2698 my @hidedatafiles; #array of hashes, stores all the data files which are to be hidden in the spi files |
2659 my $spicount=0; #counts number of spi files in each rom image |
2699 my $spicount=0; #counts number of spi files in each rom image |
2660 my $filescount=0; #counts number of data files |
2700 my $filescount=0; #counts number of data files |
2661 my $hidefilescount=0; #counts number of data files to be hidden |
2701 my $hidefilescount=0; #counts number of data files to be hidden |
2662 my $romimage=0; #number of rom image currently working with |
2702 my $romimagecount=0; #number of rom image currently working with |
2663 |
2703 |
2664 sub locateexisting |
2704 sub locateexisting |
2665 { # if an SPI file of this type exists in a base image then returns name of SPI file from the array |
2705 { # if an SPI file of this type exists in a base image then returns name of SPI file from the array |
2666 my ($romimage, $spifile, $base) =@_; |
2706 my ($index, $spifile, $base) =@_; |
2667 my $i=0; |
2707 my $i=0; |
2668 while(defined $spiarray[$base][$i]) { |
2708 while(defined $spiarray[$base][$i]) { |
2669 if($spiarray[$base][$i]{spi} eq $spiarray[$romimage][$spifile]{spi}) { |
2709 if($spiarray[$base][$i]{spi} eq $spiarray[$index][$spifile]{spi}) { |
2670 my $spiname; |
2710 my $spiname; |
2671 my $spiextension; |
2711 my $spiextension; |
2672 if($spiarray[$base][$i]{spifile} =~ /(.*)\.(.*)$/) { |
2712 if($spiarray[$base][$i]{spifile} =~ /(.*)\.(.*)$/) { |
2673 $spiname=$1; |
2713 $spiname=$1; |
2674 $spiextension=$2; |
2714 $spiextension=$2; |
2682 return ""; |
2722 return ""; |
2683 } |
2723 } |
2684 |
2724 |
2685 sub create |
2725 sub create |
2686 { #called to create SPI file and store in specified directory |
2726 { #called to create SPI file and store in specified directory |
2687 my ($romimage, $spifile, $base) =@_; #$romimage = current rom image number, $spifile = current spifile number, $base=number of rom image basing on |
2727 my ($index, $spifile, $base) =@_; #$index = current rom image number, $spifile = current spifile number, $base=number of rom image basing on |
2688 my $existingspi = ""; |
2728 my $existingspi = ""; |
2689 if(defined($base)) { # checks core image for an existing SPI file of this type, if an existing file exists then $existingspi is set to -i<name of existing spi file> which will later be passed to spitool.pm |
2729 if(defined($base)) { # checks core image for an existing SPI file of this type, if an existing file exists then $existingspi is set to -i<name of existing spi file> which will later be passed to spitool.pm |
2690 $existingspi = locateexisting($romimage, $spifile, $base); |
2730 $existingspi = locateexisting($index, $spifile, $base); |
2691 if($existingspi ne "") { |
2731 if($existingspi ne "") { |
2692 $existingspi = "-i$existingspi"; |
2732 $existingspi = "-i$existingspi"; |
2693 |
2733 |
2694 } |
2734 } |
2695 } |
2735 } |
2696 if($spiarray[$romimage][$spifile]{spifile} =~ /(.+)\.(.*)$/) { |
2736 if($spiarray[$index][$spifile]{spifile} =~ /(.+)\.(.*)$/) { |
2697 my $targetspi="$1-$romimage-$spifile\.$2"; #add romimage number and identifier for spi file to spi file name to distinguish from other spi files |
2737 my $targetspi="$1-$index-$spifile\.$2"; #add romimage number and identifier for spi file to spi file name to distinguish from other spi files |
2698 my @dataforspi; # array to store names of data files to include in spi file |
2738 my @dataforspi; # array to store names of data files to include in spi file |
2699 my @hidedatainspi; # array to store names of data files that are to be hidden in spi file |
2739 my @hidedatainspi; # array to store names of data files that are to be hidden in spi file |
2700 for(my $k=0;$k<scalar @datafiles;$k++) { |
2740 for(my $k=0;$k<scalar @datafiles;$k++) { |
2701 if($datafiles[$k]{rom}==$romimage && $datafiles[$k]{spifile} == $spifile) { |
2741 if($datafiles[$k]{rom}==$index && $datafiles[$k]{spifile} == $spifile) { |
2702 push @dataforspi, $datafiles[$k]{data}; #push name of data file onto array if correct romimage and spi type |
2742 push @dataforspi, $datafiles[$k]{data}; #push name of data file onto array if correct romimage and spi type |
2703 } |
2743 } |
2704 } |
2744 } |
2705 |
2745 |
2706 for(my $j=0;$j<scalar @hidedatafiles;$j++) { |
2746 for(my $j=0;$j<scalar @hidedatafiles;$j++) { |
2707 if($hidedatafiles[$j]{rom}==$romimage && $hidedatafiles[$j]{spifile} == $spifile) |
2747 if($hidedatafiles[$j]{rom}==$index && $hidedatafiles[$j]{spifile} == $spifile) |
2708 { |
2748 { |
2709 push @hidedatainspi, $hidedatafiles[$j]{data}; #push name of data file to be hidden onto array if correct romimage and spi type |
2749 push @hidedatainspi, $hidedatafiles[$j]{data}; #push name of data file to be hidden onto array if correct romimage and spi type |
2710 } |
2750 } |
2711 } |
2751 } |
2712 my @spiargs; #arguments passed to createSpi |
2752 my @spiargs; #arguments passed to createSpi |
2738 |
2778 |
2739 foreach $line (@obydata) |
2779 foreach $line (@obydata) |
2740 { |
2780 { |
2741 if ($line=~/^\s*REM \s*ROM_IMAGE\[(\d)\]/) # specify which romimage following lines are part of |
2781 if ($line=~/^\s*REM \s*ROM_IMAGE\[(\d)\]/) # specify which romimage following lines are part of |
2742 { |
2782 { |
2743 $romimage=$1; |
2783 $romimagecount=$1; |
2744 $spicount=0; |
2784 $spicount=0; |
2745 } elsif ($line =~ /^\s*REM/i) |
2785 } elsif ($line =~ /^\s*REM/i) |
2746 { |
2786 { |
2747 # ignore any other REM statements |
2787 # ignore any other REM statements |
2748 } elsif ($line=~/^\s*spidata\s*=\s*(\S+)\s+(\S+)\s+(\S+)\s(\S+)\s*$/) { |
2788 } elsif ($line=~/^\s*spidata\s*=\s*(\S+)\s+(\S+)\s+(\S+)\s(\S+)\s*$/) { |
2749 #spidata=\epoc32\data\Z\Resource\Plugins\Obexclasscontroller.RSC Resource\Plugins\Obexclasscontroller.RSC ecom.spi \private\10003a3f\ |
2789 #spidata=\epoc32\data\Z\Resource\Plugins\Obexclasscontroller.RSC Resource\Plugins\Obexclasscontroller.RSC ecom.spi \private\10003a3f\ |
2750 my $targetspi=$4.$3; |
2790 my $targetspi=$4.$3; |
2751 my $flag=1; |
2791 my $flag=1; |
2752 my $i; |
2792 my $i; |
2753 for($i=0;$i<$spicount && $flag;$i++) { #loop to see if name of spi file already added to this romimage in array |
2793 for($i=0;$i<$spicount && $flag;$i++) { #loop to see if name of spi file already added to this romimage in array |
2754 if($spiarray[$romimage][$i]{spi} eq $targetspi) { |
2794 if($spiarray[$romimagecount][$i]{spi} eq $targetspi) { |
2755 $flag=0; |
2795 $flag=0; |
2756 } |
2796 } |
2757 } |
2797 } |
2758 |
2798 |
2759 if($flag) { # adds spi file if not yet listed for this romimage in array |
2799 if($flag) { # adds spi file if not yet listed for this romimage in array |
2760 $spiarray[$romimage][$spicount++]={spifile=>$3, spidir=>$4, spi=>$4.$3}; |
2800 $spiarray[$romimagecount][$spicount++]={spifile=>$3, spidir=>$4, spi=>$4.$3}; |
2761 $i=$spicount; |
2801 $i=$spicount; |
2762 } |
2802 } |
2763 $datafiles[$filescount++]= {data=>$1, rom=>$romimage, spifile=>$i-1}; |
2803 $datafiles[$filescount++]= {data=>$1, rom=>$romimagecount, spifile=>$i-1}; |
2764 } elsif ($spiplacement && $line =~/^\s*SPI_POSITION/i){ |
2804 } elsif ($spiplacement && $line =~/^\s*SPI_POSITION/i){ |
2765 # mark the image index at which the SPI_POSITION keyword has occured in order to avoid writing duplicate |
2805 # mark the image index at which the SPI_POSITION keyword has occured in order to avoid writing duplicate |
2766 # entries of the spi file. |
2806 # entries of the spi file. |
2767 $spipositionflag{$romimage} = 1; |
2807 $spipositionflag{$romimagecount} = 1; |
2768 } elsif ($line=~/^\s*spidatahide\s*=\s*(\S+)\s+(\S+)\s(\S+)\s*$/) { |
2808 } elsif ($line=~/^\s*spidatahide\s*=\s*(\S+)\s+(\S+)\s(\S+)\s*$/) { |
2769 #spidatahide=\epoc32\data\Z\Resource\Plugins\Obexclasscontroller.RSC ecom.spi \private\10003a3f\ |
2809 #spidatahide=\epoc32\data\Z\Resource\Plugins\Obexclasscontroller.RSC ecom.spi \private\10003a3f\ |
2770 my $targetspi=$3.$2; |
2810 my $targetspi=$3.$2; |
2771 my $flag=1; |
2811 my $flag=1; |
2772 my $i; |
2812 my $i; |
2773 for($i=0;$i<$spicount && $flag;$i++) { #loop to see if name of spi file already added to this romimage in array |
2813 for($i=0;$i<$spicount && $flag;$i++) { #loop to see if name of spi file already added to this romimage in array |
2774 if($spiarray[$romimage][$i]{spi} eq $targetspi) { |
2814 if($spiarray[$romimagecount][$i]{spi} eq $targetspi) { |
2775 $flag=0; |
2815 $flag=0; |
2776 } |
2816 } |
2777 } |
2817 } |
2778 |
2818 |
2779 if($flag) { # adds spi file if not yet listed for this romimage in array |
2819 if($flag) { # adds spi file if not yet listed for this romimage in array |
2780 $spiarray[$romimage][$spicount++]={spifile=>$2, spidir=>$3, spi=>$3.$2}; |
2820 $spiarray[$romimagecount][$spicount++]={spifile=>$2, spidir=>$3, spi=>$3.$2}; |
2781 $i=$spicount; |
2821 $i=$spicount; |
2782 } |
2822 } |
2783 $hidedatafiles[$hidefilescount++]= {data=>$1, rom=>$romimage, spifile=>$i-1}; |
2823 $hidedatafiles[$hidefilescount++]= {data=>$1, rom=>$romimagecount, spifile=>$i-1}; |
2784 } |
2824 } |
2785 |
2825 |
2786 } |
2826 } |
2787 |
2827 |
2788 for(my $i=0;$i<8 && $composite_secondary<0;$i++) { # loop to set $composite_secondary value |
2828 for(my $i=0;$i<8 && $composite_secondary<0;$i++) { # loop to set $composite_secondary value |