Esempio n. 1
0
def cleanMaker(project, out, maker, sources):
    global cancelBuild
    if cancelBuild:
        raise StopBuildException()

    sources = maker.filterSources(project, sources)
    targets = []

    if isinstance(maker, devon.maker.Preprocessor):
        for source in sources:
            if cancelBuild:
                raise StopBuildException()

            target = maker.getSourceTarget(project, source)
            if not target:
                targets.append(source)
            else:                
                targets.append(target)

                target = os.path.join(project.path, target)
                deleteTarget(target, out)

    elif isinstance(maker, devon.maker.MakerOneToOne):
        for source in sources:
            if cancelBuild:
                raise StopBuildException()
                
            target = maker.getSourceTarget(project, source)
            if not target:
                continue
                
            if source == project.pch:
                target = os.path.join(project.path, target)
            else:
                target = project.getBuildPath(target)

            targets.append(target)
            deleteTarget(target, out)
    
    elif isinstance(maker, devon.maker.MakerManyToOne):
        target = maker.getTarget(project)
        if not target:
            return
            
        target = project.getBuildPath(target)
        targets.append(target)
        deleteTarget(target, out)
    
    elif isinstance(maker, devon.maker.MakerOneToMany):
        for source in sources:
            if cancelBuild:
                raise StopBuildException()
                
            sourceTargets = maker.getSourceTargets(project, source)
            if not sourceTargets:
                continue
            
            for target in sourceTargets:   
                target = project.getBuildPath(target)
                targets.append(target)
                deleteTarget(target, out)

    return targets
Esempio n. 2
0
def buildMaker(project, out, maker, sources):
    global cancelBuild
    if cancelBuild:
        raise StopBuildException()

    sources = maker.filterSources(project, sources)
    targets = []
    if isinstance(maker, devon.maker.Preprocessor):
        for source in sources:
            if cancelBuild:
                raise StopBuildException()

            target = maker.getSourceTarget(project, source)
            if not target:
                targets.append(source)
            else:
            
                target = project.getBuildPath(target)
                              
                targets.append(target)

                if targetNeedsUpdate(source, target) \
                        or maker.needsUpdate(project, source, target):
                    maker.printAction(project, out, source, target)
    
                    status = maker.build(project, out, source, target)                    
                    if status > 0:
                        return -1

    elif isinstance(maker, devon.maker.MakerOneToOne):
        for source in sources:
            if cancelBuild:
                raise StopBuildException()

            target = maker.getSourceTarget(project, source)
            if not target:
                continue
                
            if source == project.pch:
                target = project.getAbsolutePath(target)
            else:
                target = project.getBuildPath(target)
                
            targets.append(target)
            
            targetDir = os.path.dirname(target)
            if not os.path.exists(targetDir):
                os.makedirs(targetDir)

            if targetNeedsUpdate(source, target) \
                    or maker.needsUpdate(project, source, target):
                maker.printAction(project, out, source, target)

                status = maker.build(project, out, source, target)                
                if status > 0:
                    return -1
    
    elif isinstance(maker, devon.maker.MakerManyToOne):
        target = maker.getTarget(project)
        if not target:
            return
                      
        target = project.getBuildPath(target)
        targets.append(target)

        targetDir = os.path.dirname(target)
        if not os.path.exists(targetDir):
            os.makedirs(targetDir)

        needUpdate = maker.needsUpdate(project, target)
        if not needUpdate:
            projectPath = os.path.join(project.path, devon.projects.projectFileName)
            if targetNeedsUpdate(projectPath, target):
                needUpdate = True   
            else:
                for source in sources:
                    if targetNeedsUpdate(source, target):
                        needUpdate = True
                        break

        global allDeps
        allDeps.append(project)
        
        # Before we build the project, ensure that its dependencies are up to date
        # XXXblake We could probably speed all this up quite a bit if we cached
        # certain things on the build session, such as the project's dependency list.
        for dep in maker.getDependencies(project):
            if isinstance(dep, devon.projects.DevonProject) and not dep in allDeps:
                allDeps.append(dep)
                
                cwd = os.getcwd()
                os.chdir(dep.path)
                result = build(dep, out)
                if not result == 0:
                    return result
                os.chdir(cwd)

            if not needUpdate:
                depTarget = dep.getBuildTarget()
                if depTarget and targetNeedsUpdate(depTarget, target):
                    needUpdate = True

        if needUpdate:
            maker.printAction(project, out, target)

            status = maker.build(project, out, sources, target)            
            if status > 0:
                return -1
    
    elif isinstance(maker, devon.maker.MakerOneToMany):
        for source in sources:
            if cancelBuild:
                raise StopBuildException()

            sourceTargets = maker.getSourceTargets(project, source)
            if not sourceTargets:
                continue
                
            for target in sourceTargets:
                target = project.getBuildPath(target)
                targets.append(target)
            
            targetDir = os.path.dirname(target)
            if not os.path.exists(targetDir):
                os.makedirs(targetDir)
            
            if targetNeedsUpdate(source, target) or maker.needsUpdate(project, source, target):
                maker.printAction(project, out, source, sourceTargets)

                status = maker.build(project, out, source, target)
                
                if status > 0:
                    return -1

    return targets