Subversion Repositories DevTools

Rev

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

Rev 7186 Rev 7201
Line 901... Line 901...
901
            //
901
            //
902
            //  This will provide our basic plan, before we consider adding new packages to the
902
            //  This will provide our basic plan, before we consider adding new packages to the
903
            //  mix, such as those from user WIPS and RIPPLE requests.
903
            //  mix, such as those from user WIPS and RIPPLE requests.
904
            //  
904
            //  
905
            PlanResults basicPlan = planCollection("Basic", mPackageCollection, true);
905
            PlanResults basicPlan = planCollection("Basic", mPackageCollection, true);
-
 
906
            addWipsAndRipples (basicPlan);
906
            
907
            
907
            //  Have not considered any of the WIP or RIPPLE packages
908
            //  Have not considered any of the WIP or RIPPLE packages
908
            //  If any of them are in the basic plan, then we can ignore them as we will build them
909
            //  If any of them are in the basic plan, then we can ignore them as we will build them
909
            //  when we build the basic plan
910
            //  when we build the basic plan
910
            //
911
            //
Line 1297... Line 1298...
1297
            }
1298
            }
1298
               
1299
               
1299
    
1300
    
1300
        }
1301
        }
1301
 
1302
 
-
 
1303
        /**
-
 
1304
         * Post process the basic plan to replace packages with WIPs and RIPPLES
-
 
1305
         * Done so that the displayed plan correctly indicates the time that these will be processed
-
 
1306
         * 
-
 
1307
         * @param basicPlan
-
 
1308
         */
-
 
1309
    private void addWipsAndRipples(PlanResults basicPlan) {
-
 
1310
        for (Iterator<PlannedPackage> it = basicPlan.planCollection.iterator(); it.hasNext(); )
-
 
1311
        {
-
 
1312
            PlannedPackage pkg = it.next();
-
 
1313
            Package p = mPackageCollectionWip.contains(pkg.mPkg.mAlias);
-
 
1314
            if (p == null ) {
-
 
1315
                p = mPackageCollectionRipple.contains(pkg.mPkg.mAlias); 
-
 
1316
            }
-
 
1317
            
-
 
1318
            //  Have a WIP/RIPPLE will be processed in the basic plan
-
 
1319
            //  If its eligible to be built then replace the package entry in the plan
-
 
1320
            
-
 
1321
            if (p != null && p.mBuildFile >= 0 ) {
-
 
1322
                mLogger.warn("WIP/RIPPLE consumed into basic plan: {}", p);
-
 
1323
                pkg.mPkg = p;
-
 
1324
            }
-
 
1325
        }    
-
 
1326
        
-
 
1327
    }
-
 
1328
 
1302
    /** Internal class to contain intermediate results
1329
    /** Internal class to contain intermediate results
1303
     */
1330
     */
1304
    class PlanResults {
1331
    class PlanResults {
1305
        int planTime = 0;
1332
        int planTime = 0;
1306
        ArrayList<PlannedPackage> planCollection = new ArrayList<PlannedPackage>(); 
1333
        ArrayList<PlannedPackage> planCollection = new ArrayList<PlannedPackage>(); 
Line 1419... Line 1446...
1419
            //
1446
            //
1420
            //  Daemon Mode
1447
            //  Daemon Mode
1421
            //  Generate the ripplePlan - collection of packages that we need to build in the current ripple
1448
            //  Generate the ripplePlan - collection of packages that we need to build in the current ripple
1422
            //
1449
            //
1423
            //  Determine if we have a reason to build anything in this collection of buildable packages
1450
            //  Determine if we have a reason to build anything in this collection of buildable packages
1424
            //      Reset the mCheckedCircularDependency - it will be used to detect  that we have processed a package
1451
            //      Reset mProcessed - it will be used to detect that we have processed a package
1425
            
1452
            
1426
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1453
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1427
            {
1454
            {
1428
                Package p = it.next();
1455
                Package p = it.next();
1429
                if (!p.mIsProcessed) {
1456
                if (!p.mIsProcessed) {
1430
                    PlannedPackage pPkg = new PlannedPackage(p); 
1457
                    PlannedPackage pPkg = new PlannedPackage(p); 
1431
                    
1458
                    
1432
                    results.planCollection.add(pPkg);
1459
                    results.planCollection.add(pPkg);
1433
                    pPkg.mPkg.mCheckedCircularDependency = false;
1460
                    pPkg.mProcessed = false;
1434
                    
1461
                    
1435
                    if (p.mBuildReason != null) {
1462
                    if (p.mBuildReason != null) {
1436
                        if (mode || ( !mode && p.mBuildReason != BuildReason.Ripple )) {
1463
                        if (mode || ( !mode && p.mBuildReason != BuildReason.Ripple )) {
1437
                            toBuild.add(pPkg);
1464
                            toBuild.add(pPkg);
1438
                        }
1465
                        }
Line 1451... Line 1478...
1451
                //      Sum the buildTimes of the packages that we add to the list
1478
                //      Sum the buildTimes of the packages that we add to the list
1452
                while ( ! toBuild.isEmpty())
1479
                while ( ! toBuild.isEmpty())
1453
                {
1480
                {
1454
                    PlannedPackage pkg = toBuild.remove(0);
1481
                    PlannedPackage pkg = toBuild.remove(0);
1455
                    
1482
                    
1456
                    if (pkg.mBuildLevel > 400 ) {
1483
                    if ( ! pkg.mProcessed )
1457
                        mLogger.error("Circular dependency detected - not handled well");
-
 
1458
                        break;
-
 
1459
                    }
-
 
1460
                    
-
 
1461
                    if ( ! pkg.mPkg.mCheckedCircularDependency )
-
 
1462
                    {
1484
                    {
1463
                        ripplePlan.add(pkg);
1485
                        ripplePlan.add(pkg);
1464
                        results.planTime += pkg.mPkg.mBuildTime;
1486
                        results.planTime += pkg.mPkg.mBuildTime;
1465
                        pkg.mPkg.mCheckedCircularDependency = true;
1487
                        pkg.mProcessed = true;
1466
                        
1488
                        
1467
                        // How do we handle duplicates ?
1489
                        // How do we handle duplicates ?
1468
                        ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection);
1490
                        ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection);
1469
                        toBuild.addAll(usedBy);
1491
                        toBuild.addAll(usedBy);
1470
                    }
1492
                    }
Line 1495... Line 1517...
1495
        //  
1517
        //  
1496
        //
1518
        //
1497
        for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1519
        for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1498
        {
1520
        {
1499
            PlannedPackage p = it.next();
1521
            PlannedPackage p = it.next();
1500
            p.mPkg.mCheckedCircularDependency = true;
1522
            p.mProcessed = true;
1501
            p.mBuildLevel = 0;
1523
            p.mBuildLevel = 0;
1502
        }
1524
        }
1503
        
1525
        
1504
        int buildLevel = 0;
1526
        int buildLevel = 0;
1505
        boolean more = true;
1527
        boolean more = true;
1506
        do  {
1528
        do  {
1507
            ArrayList<PlannedPackage> thisLevel = new ArrayList<PlannedPackage>();
1529
            ArrayList<PlannedPackage> thisLevel = new ArrayList<PlannedPackage>();
1508
            for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1530
            for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1509
            {
1531
            {
1510
                PlannedPackage p = it.next();
1532
                PlannedPackage p = it.next();
1511
                if ( p.mPkg.mCheckedCircularDependency )
1533
                if ( p.mProcessed )
1512
                {
1534
                {
1513
                    boolean found = false;
1535
                    boolean found = false;
1514
                    for (Iterator<PkgDependency> it2 = p.mPkg.mDependencyCollection.iterator(); !found && it2.hasNext(); )
1536
                    for (Iterator<PkgDependency> it2 = p.mPkg.mDependencyCollection.iterator(); !found && it2.hasNext(); )
1515
                    {
1537
                    {
1516
                        PkgDependency depEntry = it2.next();
1538
                        PkgDependency depEntry = it2.next();
1517
                        for (Iterator<PlannedPackage> it3 = ripplePlan.iterator(); !found && it3.hasNext(); )
1539
                        for (Iterator<PlannedPackage> it3 = ripplePlan.iterator(); !found && it3.hasNext(); )
1518
                        {
1540
                        {
1519
                            PlannedPackage pkg = it3.next();
1541
                            PlannedPackage pkg = it3.next();
1520
                            if (pkg.mPkg.mAlias.compareTo( depEntry.alias ) == 0)
1542
                            if (pkg.mPkg.mAlias.compareTo( depEntry.alias ) == 0)
1521
                            {
1543
                            {
1522
                                found = pkg.mPkg.mCheckedCircularDependency ;
1544
                                found = pkg.mProcessed ;
1523
                                break;
1545
                                break;
1524
                            }
1546
                            }
1525
                        }
1547
                        }
1526
                    }
1548
                    }
1527
                    
1549
                    
Line 1538... Line 1560...
1538
            //  Mark all the packages at this level as have been processed
1560
            //  Mark all the packages at this level as have been processed
1539
            //  Cannot do this while we are determining the packages in the level 
1561
            //  Cannot do this while we are determining the packages in the level 
1540
            for (Iterator<PlannedPackage> it = thisLevel.iterator(); it.hasNext(); )
1562
            for (Iterator<PlannedPackage> it = thisLevel.iterator(); it.hasNext(); )
1541
            {
1563
            {
1542
                PlannedPackage p = it.next();
1564
                PlannedPackage p = it.next();
1543
                p.mPkg.mCheckedCircularDependency = false;
1565
                p.mProcessed = false;
1544
            }
1566
            }
1545
            
1567
            
1546
            //
1568
            //
1547
            //  If any packages needed to be build at this level, then there might be a higher level
1569
            //  If any packages needed to be build at this level, then there might be a higher level
1548
            //  If no packages needed to be build at this level, then there is nothing to do.
1570
            //  If no packages needed to be build at this level, then there is nothing to do.
Line 1594... Line 1616...
1594
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1616
            for (Iterator<Package> it = buildCandidates.iterator(); it.hasNext(); )
1595
            {
1617
            {
1596
                Package p = it.next();
1618
                Package p = it.next();
1597
                if (p.mBuildFile >= 0)
1619
                if (p.mBuildFile >= 0)
1598
                {
1620
                {
-
 
1621
                    boolean include = true;
1599
                    if (!mode)
1622
                    if (!mode)
1600
                    {
1623
                    {
1601
                        //  Exclude packages that would have been processed in the basicPlan
1624
                        //  Exclude packages that would have been processed in the basicPlan
1602
                    	// TODO - Don't like scanning. SHould have a collection with a hash
-
 
1603
                        for (Iterator<PlannedPackage> it1 = basicPlan.planCollection.iterator(); it1.hasNext(); )
1625
                        for (Iterator<PlannedPackage> it1 = basicPlan.planCollection.iterator(); it1.hasNext(); )
1604
                        {
1626
                        {
1605
                            PlannedPackage pkg = it1.next();
1627
                            PlannedPackage pkg = it1.next();
1606
                            if (pkg.mPkg == p)
1628
                            if (pkg.mPkg == p)
1607
                            {
1629
                            {
1608
                                mLogger.warn("Test Plan without {}", p);
1630
                                mLogger.warn("Test Plan without {}", p);
-
 
1631
                                include = false;
1609
                                break;
1632
                                break;
1610
                            }
1633
                            }
1611
                        }
1634
                        }
1612
                    }
1635
                    }
1613
                    
1636
                    
1614
                    mLogger.warn("Test Plan with {}", p);
-
 
1615
                    fullPlanCollection.upsert(p);
1637
                    if( include )
1616
 
-
 
1617
                    Package.resetCircularDependency (fullPlanCollection);
-
 
1618
                    if ( p.hasCircularDependency( fullPlanCollection ) )
-
 
1619
                    {
1638
                    {
-
 
1639
                        mLogger.warn("Test Plan with {}", p);
-
 
1640
                        fullPlanCollection.upsert(p);
-
 
1641
    
-
 
1642
                        Package.resetCircularDependency (fullPlanCollection);
-
 
1643
                        if ( p.hasCircularDependency( fullPlanCollection ) )
-
 
1644
                        {
1620
                        mLogger.info("planRelease circular dependency detected {}", p);
1645
                            mLogger.info("planRelease circular dependency detected {}", p);
1621
                        
1646
                            
1622
                        //  Force this package to be marked as having a circular dependency - even if its been excluded
1647
                            //  Force this package to be marked as having a circular dependency - even if its been excluded
1623
                        p.mBuildFile = 0;
1648
                            p.mBuildFile = 0;
1624
                        
1649
                            
1625
                        // Exclude the package
1650
                            // Exclude the package
1626
                        // max 50 chars
1651
                            // max 50 chars
1627
                        rippleBuildExclude(p, p.mId, "Package has circular dependency", -6);
1652
                            rippleBuildExclude(p, p.mId, "Package has circular dependency", -6);
-
 
1653
                        }
1628
                    }
1654
                    }
1629
                }
1655
                }
1630
            }
1656
            }
1631
            
1657
            
1632
        }
1658
        }