mdep-idea-2.diff

Lakie, 2011-03-21 16:04

Download (1.97 KB)

View differences:

scripts/mdep.py Sat Mar 19 17:41:45 2011 +0000
43 43

  
44 44
existing_files = set() #: Files that are known to exist.
45 45

  
46
def check_existence(include_dirs, depnames):
46
def check_existence(include_dirs, depnames, cwdir = None):
47 47
    """
48 48
    Normalize the path of a file so we can find double entries.
49 49

  
......
56 56
    @param depnames: Files to resolve.
57 57
    @type  depnames: C{iter} of C{str}
58 58

  
59
    @param cwdir: Current working directory of the file.
60
    @type  cwdir: C{str}
61

  
59 62
    @return: Set of existing files, and a set of non-existing files.
60 63
    @rtype:  C{tuple} of (C{set} of C{str}, C{set} of C{str})
61 64
    """
......
86 89
                found = True
87 90
                break
88 91

  
92
        if not found and cwdir != None:
93
            fname = os.path.normpath(os.path.join(cwdir, dep))
94
            if os.path.isdir(os.path.dirname(fname)):
95
                # If the folder exists, assume we will be using this one (as
96
                #   gcc will) instead of the base of the make system
97
                if os.path.isfile(fname):
98
                    existing_files.add(fname)
99
                    good_files.add(fname)
100
                else:
101
                    bad_files.add(fname)
102
                continue
103

  
89 104
        if not found:
90 105
            # File does not exist, add it as bad file in the root
91 106
            bad_files.add(dep)
......
118 133
    # Collect files.
119 134
    while notdone:
120 135
        fname = notdone.pop()
136
        dname = os.path.dirname(fname)
121 137
        includes, graphics = scan_file(fname)
122
        good_inc, bad_inc = check_existence(opt_dict['include_dirs'], includes)
138
        good_inc, bad_inc = check_existence(opt_dict['include_dirs'], includes, dname)
123 139
        good_gfx, bad_gfx = check_existence(opt_dict['include_dirs'], graphics)
124 140
        dependencies[fname] = good_inc.union(bad_inc) \
125 141
                              .union(good_gfx).union(bad_gfx)