main routine that processes the files
(prefix, search_path, files, cpp, debug=False)
| 135 | |
| 136 | |
| 137 | def doit(prefix, search_path, files, cpp, debug=False): |
| 138 | """ main routine that processes the files""" |
| 139 | |
| 140 | if debug: |
| 141 | df = io.open("dependencies.out", "w", encoding="latin-1") |
| 142 | |
| 143 | |
| 144 | # module_files is a dictionary where the keys are the name of the |
| 145 | # module (as it appears in Fortran code) and the value associated |
| 146 | # with the key is the name of the object file that provides the |
| 147 | # module. |
| 148 | module_files = {} |
| 149 | |
| 150 | # all_files is a list of SourceFile objects |
| 151 | all_files = [] |
| 152 | |
| 153 | # find the locations of all the files, given an (optional) search |
| 154 | # path and preprocess them if necessary |
| 155 | for cf in files: |
| 156 | |
| 157 | # find the file in the first part of the search path it exists |
| 158 | if len(search_path) > 0: |
| 159 | for p in search_path: |
| 160 | full_file = "{}/{}".format(p, cf) |
| 161 | if os.path.isfile(full_file): |
| 162 | break |
| 163 | else: |
| 164 | full_file = cf |
| 165 | |
| 166 | sf = SourceFile(full_file) |
| 167 | |
| 168 | # preprocess, if necessary |
| 169 | if sf.preprocess and cpp is not None: |
| 170 | command = cpp.preprocess(sf) |
| 171 | |
| 172 | if debug: |
| 173 | df.write("source file: {}\n".format(sf.name)) |
| 174 | if sf.preprocess: |
| 175 | df.write("preprocessed: {}\n".format(sf.cpp_name)) |
| 176 | df.write("\n") |
| 177 | |
| 178 | all_files.append(sf) |
| 179 | |
| 180 | # for each file, figure out what modules they define and add those to |
| 181 | # the module_files dictionary -- the module provided is the "key" and |
| 182 | # the value is the object file corresponding to the source file that |
| 183 | # holds the module definition |
| 184 | for sf in all_files: |
| 185 | provides = sf.defined_modules() |
| 186 | |
| 187 | for p in provides: |
| 188 | module_files[p] = sf.obj() |
| 189 | |
| 190 | if debug: |
| 191 | df.write("source file: {}\n".format(sf.name)) |
| 192 | df.write("provides:\n") |
| 193 | for p in provides: |
| 194 | df.write(" {}\n".format(p)) |
no test coverage detected