Exemple #1
0
    def gen_pkg(self, pkg):
        pkgsrcs = dict()
        for lang in LANGS:
            pkgsrcs[lang] = []
        for root, dirs, files in os.walk(os.path.join(self.petsc_dir, "src", pkg)):
            makefile = os.path.join(root, "makefile")
            if not os.path.exists(makefile):
                dirs[:] = []
                continue
            mklines = open(makefile)
            conditions = set(tuple(stripsplit(line)) for line in mklines if line.startswith("#requires"))
            mklines.close()
            if not all(self.inconf(key, val) for key, val in conditions):
                dirs[:] = []
                continue
            makevars = parse_makefile(makefile)
            mdirs = makevars.get("DIRS", "").split()  # Directories specified in the makefile
            self.mistakes.compareDirLists(root, mdirs, dirs)  # diagnostic output to find unused directories
            candidates = set(mdirs).union(AUTODIRS).difference(SKIPDIRS)
            dirs[:] = list(candidates.intersection(dirs))
            allsource = []

            def mkrel(src):
                return self.relpath(root, src)

            source = self.get_sources(makevars)
            for lang, s in source.items():
                pkgsrcs[lang] += map(mkrel, s)
                allsource += s
            self.mistakes.compareSourceLists(root, allsource, files)  # Diagnostic output about unused source files
            self.gendeps.append(self.relpath(root, "makefile"))
        return pkgsrcs
Exemple #2
0
 def gen_pkg(self, pkg):
     pkgsrcs = dict()
     for lang in LANGS:
         pkgsrcs[lang] = []
     for root, dirs, files in os.walk(os.path.join(self.petsc_dir, 'src', pkg)):
         dirs.sort()
         files.sort()
         makefile = os.path.join(root,'makefile')
         if not os.path.exists(makefile):
             dirs[:] = []
             continue
         mklines = open(makefile)
         conditions = set(tuple(stripsplit(line)) for line in mklines if line.startswith('#requires'))
         mklines.close()
         if not all(self.inconf(key, val) for key, val in conditions):
             dirs[:] = []
             continue
         makevars = parse_makefile(makefile)
         mdirs = makevars.get('DIRS','').split() # Directories specified in the makefile
         self.mistakes.compareDirLists(root, mdirs, dirs) # diagnostic output to find unused directories
         candidates = set(mdirs).union(AUTODIRS).difference(SKIPDIRS)
         dirs[:] = list(candidates.intersection(dirs))
         allsource = []
         def mkrel(src):
             return self.relpath(root, src)
         source = self.get_sources(makevars)
         for lang, s in source.items():
             pkgsrcs[lang] += [mkrel(t) for t in s]
             allsource += s
         self.mistakes.compareSourceLists(root, allsource, files) # Diagnostic output about unused source files
         self.gendeps.append(self.relpath(root, 'makefile'))
     return pkgsrcs