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

# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
dataset/ETHPy150Open joehewitt/devon/devon/make.py/cleanMaker/original