rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #!/usr/bin/perl
|
| 2 | #
|
| 3 | # Copyright Statement:
|
| 4 | # --------------------
|
| 5 | # This software is protected by Copyright and the information contained
|
| 6 | # herein is confidential. The software may not be copied and the information
|
| 7 | # contained herein may not be used or disclosed except with the written
|
| 8 | # permission of MediaTek Inc. (C) 2006
|
| 9 | #
|
| 10 | # BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
|
| 11 | # THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
|
| 12 | # RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
|
| 13 | # AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
|
| 14 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
|
| 15 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
|
| 16 | # NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
|
| 17 | # SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
|
| 18 | # SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
|
| 19 | # THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
|
| 20 | # NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
|
| 21 | # SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
|
| 22 | #
|
| 23 | # BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
|
| 24 | # LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
|
| 25 | # AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
|
| 26 | # OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
|
| 27 | # MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
|
| 28 | #
|
| 29 | # THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
|
| 30 | # WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
|
| 31 | # LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
|
| 32 | # RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
|
| 33 | # THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
|
| 34 | #
|
| 35 | #*****************************************************************************
|
| 36 | #*
|
| 37 | #* Filename:
|
| 38 | #* ---------
|
| 39 | #* objListGen.pl
|
| 40 | #*
|
| 41 | #* Project:
|
| 42 | #* --------
|
| 43 | #* Maui_Software
|
| 44 | #*
|
| 45 | #* Description:
|
| 46 | #* ------------
|
| 47 | #* This file generate the object list for scatter file including.
|
| 48 | #*
|
| 49 | #*
|
| 50 | #* Author:
|
| 51 | #* -------
|
| 52 | #* Ke-Ting Chen (mtk03141)
|
| 53 | #*
|
| 54 | #*****************************************************************************
|
| 55 |
|
| 56 | #****************************************************************************
|
| 57 | # Included Modules
|
| 58 | #****************************************************************************
|
| 59 | use strict;
|
| 60 | use warnings;
|
| 61 | BEGIN { push @INC, "pcore/" , './pcore/tools/' } # add additional library path
|
| 62 | use File::Copy;
|
| 63 | use File::Basename;
|
| 64 | use File::Path;
|
| 65 | use Storable qw/lock_retrieve lock_nstore/;
|
| 66 | use objListHelper;
|
| 67 | use FileInfoParser;
|
| 68 | use tools::pack_dep_gen;
|
| 69 |
|
| 70 | PrintDependModule();
|
| 71 |
|
| 72 | #****************************************************************************
|
| 73 | # History
|
| 74 | #****************************************************************************
|
| 75 | my $OBJ_LIST_GEN_VERNO = " v1.01";
|
| 76 | # v1.02: Phase in PrintDependency
|
| 77 | # v1.01: Phase in BOOT_ZIMAGE
|
| 78 | # v1.00: Phase in object list generate mechanism
|
| 79 |
|
| 80 | #****************************************************************************
|
| 81 | # Constants
|
| 82 | #****************************************************************************
|
| 83 | my $DEBUG = 1;
|
| 84 | my $templateFolderPath = "pcore/custom/system/Template";
|
| 85 | my $objectListGenFolderPath = "scat_config/FeatureBased/ObjListGen";
|
| 86 |
|
| 87 | # Feature option
|
| 88 | my $featureOptionBackupFileName = "object.list.backup";
|
| 89 |
|
| 90 | # Source
|
| 91 | my $aliceForbidListFileName = "AliceForbidList.csv";
|
| 92 | my $bootZImageForbidListFileName = "BootZImageForbidList.csv";
|
| 93 | my $zImageForbidListFileName = "ZImageForbidList.csv";
|
| 94 |
|
| 95 | # Source backup
|
| 96 | my $aliceForbidListBackupFileName = "AliceForbidList.csv.backup";
|
| 97 | my $bootZImageForbidListBackupFileName = "BootZImageForbidList.csv.backup";
|
| 98 | my $zImageForbidListBackupFileName = "ZImageForbidList.csv.backup";
|
| 99 |
|
| 100 | # Normal scatter
|
| 101 | my $objectROM1ListFileName = "objectROM1.list";
|
| 102 | my $objectBootZImageListFileName = "objectBOOT_ZIMAGE.list";
|
| 103 | my $objectZImageListFileName = "objectZIMAGE.list";
|
| 104 | my $objectAliceListFileName = "objectALICE.list";
|
| 105 |
|
| 106 | # Dummy scatter
|
| 107 | my $objectROM1DummyListFileName = "objectROM1_dummy.list";
|
| 108 | my $objectBootZImageDummyListFileName = "objectBOOT_ZIMAGE_dummy.list";
|
| 109 | my $objectZImageDummyListFileName = "objectZIMAGE_dummy.list";
|
| 110 | my $objectAliceDummyListFileName = "objectALICE_dummy.list";
|
| 111 | my $objectAliceForbidDummyListFileName = "objectALICE_FORBID_dummy.list";
|
| 112 |
|
| 113 | my $separateLine = "=============================================================";
|
| 114 |
|
| 115 | #****************************************************************************
|
| 116 | # Arguments
|
| 117 | #****************************************************************************
|
| 118 | &objListHelper::ErrorHandler("Insufficient arguments! ".scalar(@ARGV), __LINE__, __FILE__)
|
| 119 | unless scalar(@ARGV) >= 2;
|
| 120 |
|
| 121 | my $customFolder = $ARGV[0];
|
| 122 | my $makefilePath = $ARGV[1];
|
| 123 | my $forceDummyScatter = $ARGV[2];
|
| 124 | $forceDummyScatter = "FALSE" unless defined $forceDummyScatter;
|
| 125 |
|
| 126 | # To align error message file name format
|
| 127 | $customFolder =~ s/^.\/|^\///;
|
| 128 | $makefilePath =~ s/^.\/|^\///;
|
| 129 |
|
| 130 | # Print out the arguments
|
| 131 | printLog($separateLine);
|
| 132 | printLog("Arguments:");
|
| 133 | printLog("Custom Folder: $customFolder");
|
| 134 | printLog("Makefile: $makefilePath");
|
| 135 | printLog("Force Dummy Scatter: $forceDummyScatter");
|
| 136 | printLog("");
|
| 137 |
|
| 138 | #****************************************************************************
|
| 139 | # Variables
|
| 140 | #****************************************************************************
|
| 141 | # Files
|
| 142 | my $sourceCSVFolder = "$templateFolderPath/$objectListGenFolderPath";
|
| 143 | my $destinationListFolder = "$customFolder/$objectListGenFolderPath";
|
| 144 |
|
| 145 | # Source files
|
| 146 | my $aliceForbidListFile = "$sourceCSVFolder/$aliceForbidListFileName";
|
| 147 | my $bootZImageForbidListFile = "$sourceCSVFolder/$bootZImageForbidListFileName";
|
| 148 | my $zImageForbidListFile = "$sourceCSVFolder/$zImageForbidListFileName";
|
| 149 |
|
| 150 | # Source backup files
|
| 151 | my $featureOptionBackupFile = "$sourceCSVFolder/$featureOptionBackupFileName";
|
| 152 | my $aliceForbidListBackupFile = "$sourceCSVFolder/$aliceForbidListBackupFileName";
|
| 153 | my $bootZImageForbidListBackupFile = "$sourceCSVFolder/$bootZImageForbidListBackupFileName";
|
| 154 | my $zImageForbidListBackupFile = "$sourceCSVFolder/$zImageForbidListBackupFileName";
|
| 155 |
|
| 156 | # Normal scatter
|
| 157 | my $objectROM1ListFile = "$destinationListFolder/$objectROM1ListFileName";
|
| 158 | my $objectBootZImageListFile = "$destinationListFolder/$objectBootZImageListFileName";
|
| 159 | my $objectZImageListFile = "$destinationListFolder/$objectZImageListFileName";
|
| 160 | my $objectAliceListFile = "$destinationListFolder/$objectAliceListFileName";
|
| 161 |
|
| 162 | # Dummy scatter
|
| 163 | my $objectROM1DummyListFile = "$destinationListFolder/$objectROM1DummyListFileName";
|
| 164 | my $objectBootZImageDummyListFile = "$destinationListFolder/$objectBootZImageDummyListFileName";
|
| 165 | my $objectZImageDummyListFile = "$destinationListFolder/$objectZImageDummyListFileName";
|
| 166 | my $objectAliceDummyListFile = "$destinationListFolder/$objectAliceDummyListFileName";
|
| 167 | my $objectAliceForbidDummyListFile = "$destinationListFolder/$objectAliceForbidDummyListFileName";
|
| 168 |
|
| 169 | # Feature switches
|
| 170 | my $aliceEnabled = 0;
|
| 171 | my $bootZImageEnabled = 0;
|
| 172 | my $zImageEnabled = 0;
|
| 173 |
|
| 174 | my $isDummyScatter = 0;
|
| 175 |
|
| 176 | # Source file changed
|
| 177 | my $aliceForbidListFileChanged = 0;
|
| 178 | my $bootZImageForbidListFileChanged = 0;
|
| 179 | my $zImageForbidListFileChanged = 0;
|
| 180 |
|
| 181 | # Source object lists
|
| 182 | my @aliceForbidList;
|
| 183 | my @bootZImageForbidList;
|
| 184 | my @zImageForbidList;
|
| 185 |
|
| 186 | # Output object lists
|
| 187 | my %outputObjectLists =
|
| 188 | (
|
| 189 | "ROM1" => {"list" => [], "generate" => 0, "list_file" => $objectROM1ListFile},
|
| 190 | "BOOT_ZIMAGE" => {"list" => [], "generate" => 0, "list_file" => $objectBootZImageListFile},
|
| 191 | "ZIMAGE" => {"list" => [], "generate" => 0, "list_file" => $objectZImageListFile},
|
| 192 | "ALICE" => {"list" => [], "generate" => 0, "list_file" => $objectAliceListFile},
|
| 193 | "ROM1_DUMMY" => {"list" => [], "generate" => 0, "list_file" => $objectROM1DummyListFile},
|
| 194 | "BOOT_ZIMAGE_DUMMY" => {"list" => [], "generate" => 0, "list_file" => $objectBootZImageDummyListFile},
|
| 195 | "ZIMAGE_DUMMY" => {"list" => [], "generate" => 0, "list_file" => $objectZImageDummyListFile},
|
| 196 | "ALICE_DUMMY" => {"list" => [], "generate" => 0, "list_file" => $objectAliceDummyListFile},
|
| 197 | "ALICE_FORBID_DUMMY" => {"list" => [], "generate" => 0, "list_file" => $objectAliceForbidDummyListFile}
|
| 198 | );
|
| 199 |
|
| 200 | exit 0;
|
| 201 |
|
| 202 | #****************************************************************************
|
| 203 | # Initialize
|
| 204 | #****************************************************************************
|
| 205 | printLog($separateLine);
|
| 206 | printLog("[Start initializing stage]");
|
| 207 |
|
| 208 | # Initialize the environment
|
| 209 | &initialize();
|
| 210 |
|
| 211 | printLog("[End initializing stage]\n");
|
| 212 |
|
| 213 | #****************************************************************************
|
| 214 | # Process ALICE Forbid List
|
| 215 | #****************************************************************************
|
| 216 | printLog($separateLine);
|
| 217 | printLog("[Start processing ALICE forbid list stage]");
|
| 218 |
|
| 219 | if (&processAliceForbidList())
|
| 220 | {
|
| 221 | printLog("Process completed");
|
| 222 | }
|
| 223 | else
|
| 224 | {
|
| 225 | printLog("Process skipped");
|
| 226 | }
|
| 227 |
|
| 228 | printLog("[End processing ALICE forbid list stage]\n");
|
| 229 |
|
| 230 | #****************************************************************************
|
| 231 | # Process ZIMAGE Forbid List
|
| 232 | #****************************************************************************
|
| 233 | printLog($separateLine);
|
| 234 | printLog("[Start prcoessing ZIMAGE forbid list stage]");
|
| 235 |
|
| 236 | if (&processZImageForbidList())
|
| 237 | {
|
| 238 | printLog("Process completed");
|
| 239 | }
|
| 240 | else
|
| 241 | {
|
| 242 | printLog("Process skipped");
|
| 243 | }
|
| 244 |
|
| 245 | printLog("[End prcoessing ZIMAGE fobid list stage]\n");
|
| 246 |
|
| 247 | #****************************************************************************
|
| 248 | # Process BOOT_ZIMAGE Forbid List
|
| 249 | #****************************************************************************
|
| 250 | printLog($separateLine);
|
| 251 | printLog("[Start processing BOOT_ZIMAGE forbid list stage]");
|
| 252 |
|
| 253 | if (&processBootZImageForbidList())
|
| 254 | {
|
| 255 | printLog("Process completed");
|
| 256 | }
|
| 257 | else
|
| 258 | {
|
| 259 | printLog("Process skipped");
|
| 260 | }
|
| 261 |
|
| 262 | printLog("[End processing BOOT_ZIMAGE forbid list stage]\n");
|
| 263 |
|
| 264 | #****************************************************************************
|
| 265 | # Output to files
|
| 266 | #****************************************************************************
|
| 267 | printLog($separateLine);
|
| 268 | printLog("[Start outputing stage]");
|
| 269 | {
|
| 270 | foreach my $objectList (values %outputObjectLists)
|
| 271 | {
|
| 272 | if ($objectList->{"generate"})
|
| 273 | {
|
| 274 | my @filename = fileparse($objectList->{"list_file"});
|
| 275 | printLog("Generate $filename[0]");
|
| 276 | &objListHelper::SortObjectListByCategory($objectList->{"list"});
|
| 277 | &objListHelper::OutputObjectListToObjListFile($objectList->{"list_file"}, $objectList->{"list"}, " ");
|
| 278 | }
|
| 279 | #elsif (-e $objectList->{"list_file"} and not $objectList->{"manual_modified"})
|
| 280 | #{
|
| 281 | # unlink $objectList->{"list_file"} or
|
| 282 | # &objListHelper::ErrorHandler("Fail to delete file $objectList->{list_file} $!", __FILE__, __LINE__);
|
| 283 | #}
|
| 284 | }
|
| 285 | }
|
| 286 | printLog("[End outputing stage]\n");
|
| 287 |
|
| 288 |
|
| 289 | sub initialize
|
| 290 | {
|
| 291 | my %makefileOptions;
|
| 292 |
|
| 293 | # Check the feature set
|
| 294 | {
|
| 295 | printLog("Checking feature set...");
|
| 296 |
|
| 297 | # Parse makefile
|
| 298 | if (0 == &FileInfo::Parse_MAKEFILE($makefilePath, \%makefileOptions))
|
| 299 | {
|
| 300 | &objListHelper::ErrorHandler("Fail to parse makefile $makefilePath $!", __FILE__, __LINE__);
|
| 301 | }
|
| 302 |
|
| 303 | $aliceEnabled = &_checkFeatureOption("ALICE", "ALICE_SUPPORT", "TRUE", \%makefileOptions);
|
| 304 | $bootZImageEnabled = &_checkFeatureOption("BOOT_ZIMAGE", "BOOT_ZIMAGE_SUPPORT", "TRUE", \%makefileOptions);
|
| 305 | $zImageEnabled = &_checkFeatureOption("ZIMAGE", "ZIMAGE_SUPPORT", "TRUE", \%makefileOptions);
|
| 306 |
|
| 307 | # Check dummy scatter
|
| 308 | {
|
| 309 | my $option = $makefileOptions{"DUMMY_SCATTER_ENABLE"};
|
| 310 | if ((defined $option and $option eq "TRUE") or ($forceDummyScatter eq "TRUE"))
|
| 311 | {
|
| 312 | debugLog("DUMMY_SCATTER is enabled");
|
| 313 | $isDummyScatter = 1;
|
| 314 | }
|
| 315 | }
|
| 316 |
|
| 317 | # Check if the feature options are changed
|
| 318 | {
|
| 319 | my $featureOptionChanged = 0;
|
| 320 |
|
| 321 | if (-e $featureOptionBackupFile)
|
| 322 | {
|
| 323 | $featureOptionChanged = 1 if not &_isFileContentMatch($makefilePath, $featureOptionBackupFile);
|
| 324 | }
|
| 325 | else
|
| 326 | {
|
| 327 | $featureOptionChanged = 1;
|
| 328 | }
|
| 329 |
|
| 330 | if ($featureOptionChanged)
|
| 331 | {
|
| 332 | copy($makefilePath, $featureOptionBackupFile) or
|
| 333 | &objListHelper::ErrorHandler("Fail to backup file $makefilePath $!", __FILE__, __LINE__);
|
| 334 | _removeObjectLists();
|
| 335 | }
|
| 336 | }
|
| 337 | }
|
| 338 |
|
| 339 | # Parse source object lists
|
| 340 | {
|
| 341 | printLog("Parsing source object lists...");
|
| 342 |
|
| 343 | if ($aliceEnabled)
|
| 344 | {
|
| 345 | $aliceForbidListFileChanged =
|
| 346 | &_getSourceObjectList("ALICE Forbidden List", $aliceForbidListFile, \@aliceForbidList,
|
| 347 | \%makefileOptions, $aliceForbidListBackupFile);
|
| 348 | }
|
| 349 |
|
| 350 | if ($bootZImageEnabled)
|
| 351 | {
|
| 352 | $bootZImageForbidListFileChanged =
|
| 353 | &_getSourceObjectList("BOOT_ZIMAGE Forbidden List", $bootZImageForbidListFile, \@bootZImageForbidList,
|
| 354 | \%makefileOptions, $bootZImageForbidListBackupFile);
|
| 355 | }
|
| 356 |
|
| 357 | if ($zImageEnabled)
|
| 358 | {
|
| 359 | $zImageForbidListFileChanged =
|
| 360 | &_getSourceObjectList("ZIMAGE Forbidden List", $zImageForbidListFile, \@zImageForbidList,
|
| 361 | \%makefileOptions, $zImageForbidListBackupFile);
|
| 362 | }
|
| 363 | }
|
| 364 |
|
| 365 | # Check manual checking of output object lists
|
| 366 | #{
|
| 367 | # printLog("Check manual modification of output object lists...");
|
| 368 | #
|
| 369 | # foreach my $objectList (values %outputObjectLists)
|
| 370 | # {
|
| 371 | # if (&objListHelper::IsManualModified($objectList->{"list_file"}))
|
| 372 | # {
|
| 373 | # my @filename = fileparse($objectList->{"list_file"});
|
| 374 | # debugLog("$filename[0] was manual modified");
|
| 375 | #
|
| 376 | # $objectList->{"manual_modified"} = 1;
|
| 377 | # }
|
| 378 | # }
|
| 379 | #}
|
| 380 |
|
| 381 | # Generate ObjListGenPath: scat_config\FeatureBased\ObjListGen
|
| 382 | unless (-d $destinationListFolder)
|
| 383 | {
|
| 384 | mkpath($destinationListFolder)
|
| 385 | or &objListHelper::ErrorHandler("Fail to create folder $destinationListFolder $!", __FILE__, __LINE__);
|
| 386 | }
|
| 387 | }
|
| 388 |
|
| 389 | sub _checkFeatureOption
|
| 390 | {
|
| 391 | my $featureName = shift;
|
| 392 | my $featureOption = shift;
|
| 393 | my $featureEnableValue = shift;
|
| 394 | my $makefileOptions = shift;
|
| 395 |
|
| 396 | my $result = 0;
|
| 397 |
|
| 398 | my $option = $makefileOptions->{$featureOption};
|
| 399 | if (defined $option and $option eq $featureEnableValue)
|
| 400 | {
|
| 401 | debugLog("$featureName is enabled");
|
| 402 | $result = 1;
|
| 403 | }
|
| 404 |
|
| 405 | return $result;
|
| 406 | }
|
| 407 |
|
| 408 | sub _isFileContentMatch
|
| 409 | {
|
| 410 | my $firstFile = shift;
|
| 411 | my $secondFile = shift;
|
| 412 |
|
| 413 | if (&__getFileContent($firstFile) eq &__getFileContent($secondFile))
|
| 414 | {
|
| 415 | return 1;
|
| 416 | }
|
| 417 | else
|
| 418 | {
|
| 419 | return 0;
|
| 420 | }
|
| 421 | }
|
| 422 |
|
| 423 | sub __getFileContent
|
| 424 | {
|
| 425 | my $sourceFile = shift;
|
| 426 | my $content;
|
| 427 | open FILE, "<$sourceFile" or
|
| 428 | &objListHelper::ErrorHandler("Fail to open file $sourceFile $!", __FILE__, __LINE__);
|
| 429 | {
|
| 430 | local $/;
|
| 431 | $content = <FILE>;
|
| 432 | }
|
| 433 | close FILE;
|
| 434 | chomp($content);
|
| 435 | return $content;
|
| 436 | }
|
| 437 |
|
| 438 | sub _getSourceObjectList
|
| 439 | {
|
| 440 | my $listName = shift;
|
| 441 | my $sourceFile = shift;
|
| 442 | my $listRef = shift;
|
| 443 | my $makefileOptions = shift;
|
| 444 | my $backupFile = shift;
|
| 445 | my $sourceFileChanged = 0;
|
| 446 |
|
| 447 | debugLog("Get $listName");
|
| 448 | &objListHelper::InputObjectListFromCSVFile($sourceFile, $listRef, $makefileOptions);
|
| 449 | PrintDependency($sourceFile);
|
| 450 |
|
| 451 | if (-e $backupFile)
|
| 452 | {
|
| 453 | #my @backupList;
|
| 454 | #&objListHelper::InputObjectListFromCSVFile($backupFile, \@backupList, $makefileOptions);
|
| 455 |
|
| 456 | #if (0 != &objListHelper::CompareObjectList($listRef, \@backupList))
|
| 457 | unless (&_isFileContentMatch($sourceFile, $backupFile))
|
| 458 | {
|
| 459 | $sourceFileChanged = 1;
|
| 460 |
|
| 461 | copy($sourceFile, $backupFile) or
|
| 462 | &objListHelper::ErrorHandler("Fail to backup file $sourceFile $!", __FILE__, __LINE__);
|
| 463 | }
|
| 464 | }
|
| 465 | else
|
| 466 | {
|
| 467 | copy($sourceFile, $backupFile) or
|
| 468 | &objListHelper::ErrorHandler("Fail to backup file $sourceFile $!", __FILE__, __LINE__);
|
| 469 |
|
| 470 | $sourceFileChanged = 1;
|
| 471 | }
|
| 472 |
|
| 473 | if ($sourceFileChanged)
|
| 474 | {
|
| 475 | debugLog("$listName changed");
|
| 476 | _removeObjectLists();
|
| 477 | }
|
| 478 | else
|
| 479 | {
|
| 480 | debugLog("$listName not changed");
|
| 481 | }
|
| 482 |
|
| 483 | return $sourceFileChanged;
|
| 484 | }
|
| 485 |
|
| 486 | sub _removeObjectLists
|
| 487 | {
|
| 488 | debugLog("Delete object lists");
|
| 489 | unlink $_->{"list_file"} foreach (values %outputObjectLists);
|
| 490 | }
|
| 491 |
|
| 492 | sub processAliceForbidList
|
| 493 | {
|
| 494 | if ($aliceEnabled)
|
| 495 | {
|
| 496 | if ($zImageEnabled)
|
| 497 | {
|
| 498 | my @afList;
|
| 499 | my @afOverlapList;
|
| 500 | my @afzfList;
|
| 501 |
|
| 502 | &objListHelper::SplitObjectListByCheckList(\@aliceForbidList, \@zImageForbidList, \@afzfList, \@afOverlapList, \@afList);
|
| 503 |
|
| 504 | &objListHelper::ChangeObjectListAttributeList(\@afList, "+RO");
|
| 505 | &objListHelper::ChangeObjectListAttributeList(\@afOverlapList, "+RO-CODE");
|
| 506 | &objListHelper::ChangeObjectListAttributeList(\@afzfList, "+RO-CODE, +RO-DATA");
|
| 507 |
|
| 508 | my $isSourceChanged = $aliceForbidListFileChanged || $zImageForbidListFileChanged;
|
| 509 |
|
| 510 | if ($isDummyScatter)
|
| 511 | {
|
| 512 | &_pushToOutputObjectList("ALICE_FORBID_DUMMY", \@afList, $isSourceChanged);
|
| 513 | &_pushToOutputObjectList("ROM1_DUMMY", \@afOverlapList, $isSourceChanged);
|
| 514 | &_pushToOutputObjectList("ROM1_DUMMY", \@afzfList, $isSourceChanged);
|
| 515 | &_pushToOutputObjectList("ALICE_DUMMY", [], $isSourceChanged);
|
| 516 | }
|
| 517 | else
|
| 518 | {
|
| 519 | &_pushToOutputObjectList("ZIMAGE", \@afList, $isSourceChanged);
|
| 520 | &_pushToOutputObjectList("ROM1", \@afOverlapList, $isSourceChanged);
|
| 521 | &_pushToOutputObjectList("ROM1", \@afzfList, $isSourceChanged);
|
| 522 | &_pushToOutputObjectList("ALICE", [], $isSourceChanged);
|
| 523 | }
|
| 524 | }
|
| 525 | else
|
| 526 | {
|
| 527 | my $isSourceChanged = $aliceForbidListFileChanged;
|
| 528 |
|
| 529 | if ($isDummyScatter)
|
| 530 | {
|
| 531 | &_pushToOutputObjectList("ROM1_DUMMY", \@aliceForbidList, $isSourceChanged);
|
| 532 | &_pushToOutputObjectList("ALICE_DUMMY", [], $isSourceChanged);
|
| 533 | }
|
| 534 | else
|
| 535 | {
|
| 536 | &_pushToOutputObjectList("ROM1", \@aliceForbidList, $isSourceChanged);
|
| 537 | &_pushToOutputObjectList("ALICE", [], $isSourceChanged);
|
| 538 | }
|
| 539 | }
|
| 540 |
|
| 541 | return 1;
|
| 542 | }
|
| 543 | else
|
| 544 | {
|
| 545 | return 0;
|
| 546 | }
|
| 547 | }
|
| 548 |
|
| 549 | sub processZImageForbidList
|
| 550 | {
|
| 551 | if ($zImageEnabled)
|
| 552 | {
|
| 553 | if ($aliceEnabled)
|
| 554 | {
|
| 555 | my @zfUnmatchedList = grep((not $_->{"matched"}), @zImageForbidList);
|
| 556 |
|
| 557 | my @zf_RList;
|
| 558 | my @zf_AList;
|
| 559 | my @zfafList;
|
| 560 | my @zfOverlapList;
|
| 561 | my @zfOnlyList;
|
| 562 |
|
| 563 | &objListHelper::SplitObjectListByCheckList(\@zfUnmatchedList, \@aliceForbidList, \@zfafList, \@zfOverlapList, \@zfOnlyList);
|
| 564 |
|
| 565 | # ZFAF list should have been empty if there were no wildcard symbol
|
| 566 | # Append this list to ZF only list since the priority is lower for wildcard
|
| 567 | push @zfOnlyList, @zfafList;
|
| 568 | &objListHelper::SortObjectListByCategory(\@zfOnlyList);
|
| 569 |
|
| 570 | # Specify the ZF overlap list to ROM1 with +RO-CODE, +RO-DATA since the libraries include them are in AF list
|
| 571 | foreach my $object (@zfOverlapList)
|
| 572 | {
|
| 573 | if ($object->{"attributes"}[0] eq "+RO")
|
| 574 | {
|
| 575 | $object->{"attributes"}[0] = "+RO-CODE";
|
| 576 | $object->{"attributes"}[1] = "+RO-DATA";
|
| 577 | push @zf_RList, $object;
|
| 578 | }
|
| 579 | else
|
| 580 | {
|
| 581 | push @zf_RList, $object;
|
| 582 | }
|
| 583 | }
|
| 584 |
|
| 585 | # The data part is in ROM1 and code part is in ALICE for ZF only list
|
| 586 | foreach my $object (@zfOnlyList)
|
| 587 | {
|
| 588 | if ($object->{"attributes"}[0] eq "+RO")
|
| 589 | {
|
| 590 | my %newObject = %$object;
|
| 591 | $object->{"attributes"}[0] = "+RO-DATA";
|
| 592 | push @zf_RList, $object;
|
| 593 |
|
| 594 | $newObject{"attributes"} = ["+RO"];
|
| 595 | push @zf_AList, \%newObject;
|
| 596 | }
|
| 597 | elsif ($object->{"attributes"}[0] eq "+RO-CODE")
|
| 598 | {
|
| 599 | push @zf_AList, $object;
|
| 600 |
|
| 601 | if (defined $object->{"attributes"}[1] and $object->{"attributes"}[1] eq "+RO-DATA")
|
| 602 | {
|
| 603 | my %newObject = %$object;
|
| 604 | $newObject{"attributes"} = ["+RO-DATA"];
|
| 605 | push @zf_RList, \%newObject;
|
| 606 | splice @{$object->{"attributes"}}, -1;
|
| 607 | }
|
| 608 | }
|
| 609 | else
|
| 610 | {
|
| 611 | push @zf_RList, $object;
|
| 612 | }
|
| 613 | }
|
| 614 |
|
| 615 | my $isSourceChanged = $zImageForbidListFileChanged || $aliceForbidListFileChanged;
|
| 616 |
|
| 617 | if ($isDummyScatter)
|
| 618 | {
|
| 619 | &_pushToOutputObjectList("ROM1_DUMMY", \@zf_RList, $isSourceChanged);
|
| 620 | &_pushToOutputObjectList("ALICE_DUMMY", \@zf_AList, $isSourceChanged);
|
| 621 |
|
| 622 | &_pushToOutputObjectList("ZIMAGE_DUMMY", [], $isSourceChanged);
|
| 623 | }
|
| 624 | else
|
| 625 | {
|
| 626 | &_pushToOutputObjectList("ROM1", \@zf_RList, $isSourceChanged);
|
| 627 | &_pushToOutputObjectList("ALICE", \@zf_AList, $isSourceChanged);
|
| 628 |
|
| 629 | &_pushToOutputObjectList("ZIMAGE", [], $isSourceChanged);
|
| 630 | }
|
| 631 | }
|
| 632 | else
|
| 633 | {
|
| 634 | my $isSourceChanged = $zImageForbidListFileChanged;
|
| 635 |
|
| 636 | if ($isDummyScatter)
|
| 637 | {
|
| 638 | &_pushToOutputObjectList("ROM1_DUMMY", \@zImageForbidList, $isSourceChanged);
|
| 639 | &_pushToOutputObjectList("ZIMAGE_DUMMY", [], $isSourceChanged);
|
| 640 | }
|
| 641 | else
|
| 642 | {
|
| 643 | &_pushToOutputObjectList("ROM1", \@zImageForbidList, $isSourceChanged);
|
| 644 | &_pushToOutputObjectList("ZIMAGE", [], $isSourceChanged);
|
| 645 | }
|
| 646 | }
|
| 647 |
|
| 648 | return 1;
|
| 649 | }
|
| 650 | else
|
| 651 | {
|
| 652 | return 0;
|
| 653 | }
|
| 654 | }
|
| 655 |
|
| 656 | sub processBootZImageForbidList
|
| 657 | {
|
| 658 | if ($bootZImageEnabled)
|
| 659 | {
|
| 660 | my @bzList;
|
| 661 | my @afzfbzfList;
|
| 662 | my @afzfbzfOverlapList;
|
| 663 |
|
| 664 | my $isSourceChanged = $bootZImageForbidListFileChanged;
|
| 665 |
|
| 666 | # BOOT_ZIMAGE library problem workaround
|
| 667 | my @bootZImageNormalForbidList;
|
| 668 | my @bootZImageWorkaroundForbidList;
|
| 669 |
|
| 670 | foreach my $object (@bootZImageForbidList)
|
| 671 | {
|
| 672 | if ($object->{"category"} eq "Workaround")
|
| 673 | {
|
| 674 | push @bootZImageWorkaroundForbidList, $object;
|
| 675 | }
|
| 676 | else
|
| 677 | {
|
| 678 | push @bootZImageNormalForbidList, $object;
|
| 679 | }
|
| 680 | }
|
| 681 |
|
| 682 | if ($isDummyScatter)
|
| 683 | {
|
| 684 | #&objListHelper::SplitObjectListByCheckList(\@{$outputObjectLists{"ROM1_DUMMY"}{"list"}}, \@bootZImageForbidList, \@afzfbzfList, \@afzfbzfOverlapList, \@bzList);
|
| 685 | &objListHelper::SplitObjectListByCheckList(\@{$outputObjectLists{"ROM1_DUMMY"}{"list"}}, \@bootZImageNormalForbidList, \@afzfbzfList, \@afzfbzfOverlapList, \@bzList);
|
| 686 | }
|
| 687 | else
|
| 688 | {
|
| 689 | #&objListHelper::SplitObjectListByCheckList(\@{$outputObjectLists{"ROM1"}{"list"}}, \@bootZImageForbidList, \@afzfbzfList, \@afzfbzfOverlapList, \@bzList);
|
| 690 | &objListHelper::SplitObjectListByCheckList(\@{$outputObjectLists{"ROM1"}{"list"}}, \@bootZImageNormalForbidList, \@afzfbzfList, \@afzfbzfOverlapList, \@bzList);
|
| 691 | }
|
| 692 |
|
| 693 | # BOOT_ZIMAGE library problem workaround
|
| 694 | {
|
| 695 | # Force the workaround libraries to ROM1
|
| 696 | my %bootZImageWorkaourndForbidHash = map { $_->{"name"} => 1 } @bootZImageWorkaroundForbidList;;
|
| 697 | my @tempBZList = @bzList;
|
| 698 | @bzList = ();
|
| 699 |
|
| 700 | foreach my $object (@tempBZList)
|
| 701 | {
|
| 702 | if (exists $bootZImageWorkaourndForbidHash{$object->{"name"}})
|
| 703 | {
|
| 704 | push @afzfbzfList, $object;
|
| 705 | }
|
| 706 | else
|
| 707 | {
|
| 708 | push @bzList, $object;
|
| 709 | }
|
| 710 | }
|
| 711 | }
|
| 712 |
|
| 713 | if ($isDummyScatter)
|
| 714 | {
|
| 715 | &_pushToOutputObjectList("BOOT_ZIMAGE_DUMMY", \@bzList, $isSourceChanged);
|
| 716 |
|
| 717 | @{$outputObjectLists{"ROM1_DUMMY"}{"list"}} = ();
|
| 718 | &_pushToOutputObjectList("ROM1_DUMMY", \@afzfbzfList, $isSourceChanged);
|
| 719 | &_pushToOutputObjectList("ROM1_DUMMY", \@afzfbzfOverlapList, $isSourceChanged);
|
| 720 | }
|
| 721 | else
|
| 722 | {
|
| 723 |
|
| 724 | &_pushToOutputObjectList("BOOT_ZIMAGE", \@bzList, $isSourceChanged);
|
| 725 |
|
| 726 | @{$outputObjectLists{"ROM1"}{"list"}} = ();
|
| 727 | &_pushToOutputObjectList("ROM1", \@afzfbzfList, $isSourceChanged);
|
| 728 | &_pushToOutputObjectList("ROM1", \@afzfbzfOverlapList, $isSourceChanged);
|
| 729 | }
|
| 730 |
|
| 731 | return 1;
|
| 732 | }
|
| 733 | else
|
| 734 | {
|
| 735 | return 0;
|
| 736 | }
|
| 737 | }
|
| 738 |
|
| 739 | sub _pushToOutputObjectList
|
| 740 | {
|
| 741 | my $objectListName = shift;
|
| 742 | my $objectListRef = shift;
|
| 743 | my $isSourceChanged = shift;
|
| 744 |
|
| 745 | push @{$outputObjectLists{$objectListName}{"list"}}, @$objectListRef;
|
| 746 |
|
| 747 | if (-e $outputObjectLists{$objectListName}{"list_file"})
|
| 748 | {
|
| 749 | #if ($isSourceChanged)
|
| 750 | #{
|
| 751 | # $outputObjectLists{$objectListName}{"generate"} = 1;
|
| 752 | #}
|
| 753 | }
|
| 754 | else
|
| 755 | {
|
| 756 | $outputObjectLists{$objectListName}{"generate"} = 1;
|
| 757 | }
|
| 758 | }
|
| 759 |
|
| 760 | sub printLog
|
| 761 | {
|
| 762 | print "$_[0]\n";
|
| 763 | }
|
| 764 |
|
| 765 | sub debugLog
|
| 766 | {
|
| 767 | if ($DEBUG)
|
| 768 | {
|
| 769 | printLog("\t$_[0]");
|
| 770 | }
|
| 771 | }
|