Subversion Repositories DevTools

Rev

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

Rev 7094 Rev 7095
Line 1417... Line 1417...
1417
                        }
1417
                        }
1418
                    }
1418
                    }
1419
                }
1419
                }
1420
            } while( !allDependenciesProcessed );
1420
            } while( !allDependenciesProcessed );
1421
            
1421
            
1422
            //  Have process all the packages that we can at the moment
1422
            //  Have process all the packages that we can build at the moment
1423
            //      Examine all the packages in the collection to see if there are more that need to be extracted
1423
            //      Examine all the packages in the collection to see if there are more that need to be extracted
1424
            //      These will be done at a different build-level
1424
            //      These will be done at a different build-level
1425
            //  
1425
            //  
1426
            allProcessed = true;
1426
            allProcessed = true;
1427
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
1427
            for (Iterator<Package> it = packageCollection.iterator(); it.hasNext(); )
Line 1448... Line 1448...
1448
        if (mDaemon)
1448
        if (mDaemon)
1449
        {
1449
        {
1450
            phase.setPhase("Calc Build Order");
1450
            phase.setPhase("Calc Build Order");
1451
            //
1451
            //
1452
            //  Determine if we have a reason to build anything in this collection of buildable packages
1452
            //  Determine if we have a reason to build anything in this collection of buildable packages
1453
            //  Reset the calculated buildLevel - It will be calculated again
1453
            //      Reset the calculated buildLevel - It will be calculated again
-
 
1454
            //      Reset the mProcessed - it will be used to detect  that we have processed a package
1454
            //
1455
            
1455
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
1456
            ArrayList<PlannedPackage> toBuild = new ArrayList<PlannedPackage>();
1456
            for (Iterator<PlannedPackage> it = results.planCollection.iterator(); it.hasNext(); )
1457
            for (Iterator<PlannedPackage> it = results.planCollection.iterator(); it.hasNext(); )
1457
            {
1458
            {
1458
                PlannedPackage p = it.next();
1459
                PlannedPackage p = it.next();
1459
                p.mBuildLevel = 0;
1460
                p.mBuildLevel = 0;
-
 
1461
                p.mPkg.mCheckedCircularDependency = false;
1460
                
1462
                
1461
                if (p.mPkg.mBuildReason != null) {
1463
                if (p.mPkg.mBuildReason != null) {
1462
                    if (mode || ( !mode && p.mPkg.mBuildReason != BuildReason.Ripple ))
1464
                    if (mode || ( !mode && p.mPkg.mBuildReason != BuildReason.Ripple ))
1463
                    {
1465
                    {
1464
                        toBuild.add(p);
1466
                        toBuild.add(p);
Line 1469... Line 1471...
1469
            //  Need (would like to) build stuff
1471
            //  Need (would like to) build stuff
1470
            //  Determine the packages that we need to build and the time that it will take
1472
            //  Determine the packages that we need to build and the time that it will take
1471
            //
1473
            //
1472
            if ( !toBuild.isEmpty() )
1474
            if ( !toBuild.isEmpty() )
1473
            {
1475
            {
1474
                results.planTime = 0;
-
 
1475
                             
-
 
1476
                
1476
                 
1477
                //  Need to add elements to the end of the list while processing
1477
                //  Need to add elements to the end of the list while processing
1478
                //  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
1479
                while ( ! toBuild.isEmpty())
1479
                while ( ! toBuild.isEmpty())
1480
                {
1480
                {
1481
                    PlannedPackage pkg = toBuild.remove(0);
1481
                    PlannedPackage pkg = toBuild.remove(0);
-
 
1482
                    mLogger.error("Proccessing {}", pkg.mPkg.mAlias);                       
1482
                    
1483
                    
1483
                    if (pkg.mBuildLevel > 100 ) {
1484
                    if (pkg.mBuildLevel > 400 ) {
1484
                        mLogger.error("Circular dependency detected - not handled well");
1485
                        mLogger.error("Circular dependency detected - not handled well");
1485
                        break;
1486
                        break;
1486
                    }
1487
                    }
1487
                    
1488
                    
1488
                    if ( ! ripplePlan.contains( pkg ))
1489
                    if ( ! pkg.mPkg.mCheckedCircularDependency )
1489
                    {
1490
                    {
1490
                        ripplePlan.add(pkg);
1491
                        ripplePlan.add(pkg);
1491
                        results.planTime += pkg.mPkg.mBuildTime;
1492
                        results.planTime += pkg.mPkg.mBuildTime;
-
 
1493
                        
-
 
1494
                        pkg.mPkg.mCheckedCircularDependency = true;
-
 
1495
                        
-
 
1496
                        ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection);
-
 
1497
                        toBuild.addAll(usedBy);
1492
                    }
1498
                    }
1493
                    
1499
                    
1494
                    ArrayList<PlannedPackage> usedBy = usedByPackages(pkg, results.planCollection, pkg.mBuildLevel + 1);
-
 
1495
                    toBuild.addAll(usedBy);
-
 
1496
                }
1500
                }
1497
                
1501
                
-
 
1502
                //
-
 
1503
                //  Now we have a collection of packages to build
-
 
1504
                //  Need to determine the order in which it can be done and assign build levels
-
 
1505
                //
-
 
1506
                for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1507
                {
-
 
1508
                    PlannedPackage p = it.next();
-
 
1509
                    p.mPkg.mCheckedCircularDependency = true;
-
 
1510
                    p.mBuildLevel = 0;
-
 
1511
                }
-
 
1512
                
-
 
1513
                buildLevel = 0;
-
 
1514
                boolean more = true;
-
 
1515
                do  {
-
 
1516
                    ArrayList<PlannedPackage> thisLevel = new ArrayList<PlannedPackage>();
-
 
1517
                    for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
-
 
1518
                    {
-
 
1519
                        PlannedPackage p = it.next();
-
 
1520
                        if ( p.mPkg.mCheckedCircularDependency )
-
 
1521
                        {
-
 
1522
                            boolean found = false;
-
 
1523
                            for (Iterator<String> it2 = p.mPkg.mDependencyCollection.iterator(); !found && it2.hasNext(); )
-
 
1524
                            {
-
 
1525
                                String alias = it2.next();
-
 
1526
                                for (Iterator<PlannedPackage> it3 = ripplePlan.iterator(); !found && it3.hasNext(); )
-
 
1527
                                {
-
 
1528
                                    PlannedPackage pkg = it3.next();
-
 
1529
                                    if (pkg.mPkg.mAlias.compareTo( alias ) == 0)
-
 
1530
                                    {
-
 
1531
                                        found = pkg.mPkg.mCheckedCircularDependency ;
-
 
1532
                                        break;
-
 
1533
                                    }
-
 
1534
                                }
-
 
1535
                            }
-
 
1536
                            
-
 
1537
                            if (!found)
-
 
1538
                            {
-
 
1539
                                //  None of this packages dependencies can be found in the collection of packages to build
-
 
1540
                                //  Thus we can build it - at the current level
-
 
1541
                                p.mBuildLevel = buildLevel;
-
 
1542
                                thisLevel.add(p);
-
 
1543
                            }
-
 
1544
                        }
-
 
1545
                    }
-
 
1546
                    
-
 
1547
                    //  Mark all the packages at this level as have been processed
-
 
1548
                    //  Cannot do this while we are determining the packages in the level 
-
 
1549
                    for (Iterator<PlannedPackage> it = thisLevel.iterator(); it.hasNext(); )
-
 
1550
                    {
-
 
1551
                        PlannedPackage p = it.next();
-
 
1552
                        p.mPkg.mCheckedCircularDependency = false;
-
 
1553
                    }
-
 
1554
                    
-
 
1555
                    more = !thisLevel.isEmpty(); 
-
 
1556
                    buildLevel++;
-
 
1557
                    
-
 
1558
                } while (more);
-
 
1559
                
1498
                //  Sort the packages by buildOrder and buildTime
1560
                //  Sort the packages by buildOrder and buildTime
-
 
1561
                phase.setPhase("Sort Plan");
1499
                Collections.sort(ripplePlan, PlannedPackage.BuildOrderComparitor);
1562
                Collections.sort(ripplePlan, PlannedPackage.BuildOrderComparitor);
1500
                
1563
                
1501
                phase.setPhase("Display Build Order");
1564
                phase.setPhase("Display Build Order");
1502
                mLogger.error("Plan Build {} Time: {}", name, results.planTime);
1565
                mLogger.error("Plan Build {} Time: {}", name, results.planTime);
1503
                for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
1566
                for (Iterator<PlannedPackage> it = ripplePlan.iterator(); it.hasNext(); )
Line 1589... Line 1652...
1589
     *      If the consumer is marked as advisoryRipple
1652
     *      If the consumer is marked as advisoryRipple
1590
     *      If the consumer cannot be built
1653
     *      If the consumer cannot be built
1591
     *   
1654
     *   
1592
     * @param pkg - Package to process
1655
     * @param pkg - Package to process
1593
     * @param planCollection - collection of packages to scan
1656
     * @param planCollection - collection of packages to scan
1594
     * @param rippleOrder - Set the ripple oder, if >= 0
-
 
1595
     *
1657
     *
1596
     * @return A collection of packages that actively 'use' the specified package
1658
     * @return A collection of packages that actively 'use' the specified package
1597
 
1659
 
1598
     */
1660
     */
1599
    private ArrayList<PlannedPackage> usedByPackages(PlannedPackage pkg, ArrayList<PlannedPackage> planCollection, int rippleOrder) {
1661
    private ArrayList<PlannedPackage> usedByPackages(PlannedPackage pkg, ArrayList<PlannedPackage> planCollection) {
1600
        
1662
        
1601
        ArrayList<PlannedPackage> usedBy = new ArrayList<PlannedPackage>();
1663
        ArrayList<PlannedPackage> usedBy = new ArrayList<PlannedPackage>();
1602
        
1664
        
1603
        for (Iterator<PlannedPackage> it = planCollection.iterator(); it.hasNext(); )
1665
        for (Iterator<PlannedPackage> it = planCollection.iterator(); it.hasNext(); )
1604
        {
1666
        {
Line 1611... Line 1673...
1611
                {
1673
                {
1612
                    String alias = it2.next();
1674
                    String alias = it2.next();
1613
                    if (  pkg.mPkg.mAlias.compareTo( alias ) == 0  ) {
1675
                    if (  pkg.mPkg.mAlias.compareTo( alias ) == 0  ) {
1614
                        //  Have found a consumer of 'pkg'
1676
                        //  Have found a consumer of 'pkg'
1615
                        usedBy.add(p);
1677
                        usedBy.add(p);
1616
                        if (rippleOrder >= 0)
-
 
1617
                            p.mBuildLevel = rippleOrder;
-
 
1618
                        break;
1678
                        break;
1619
                    }
1679
                    }
1620
                }
1680
                }
1621
            }
1681
            }
1622
        }
1682
        }