def needs(self): """Returns a list of all the modules that this executable needs to run correctly.""" if self._needs is None: from fortpy.code import order_module_dependencies self._needs = order_module_dependencies(self.writer.uses(), self.parser) return self._needs
def generate(parser, coderoot, stagedir, compiler=None, debug=False, profile=False, strict=False, docompile=True): """Generates the f90 module file for all members referenced in the parser's modules list. """ import fortpy from fortpy.utility import get_fortpy_templates_dir from fortpy.testing.elements import AutoClasser members = _find_members(parser, coderoot) folder = "filename" classers = [AutoClasser(m, folder, m.name, [], coderoot, True) for m in members] from os import path templates = get_fortpy_templates_dir() statpath = path.join(templates, "fpy_auxiliary.f90") with open(statpath) as f: static = f.read() from fortpy.printing.formatting import present_params xnames, modcode, routines, modules = _generate_single(classers) from fortpy.code import order_module_dependencies modules = order_module_dependencies(modules, parser) from os import mkdir, path if docompile: auxdir = path.join(stagedir, "fortpy.aux") if not path.isdir(auxdir): mkdir(auxdir) else: auxdir = coderoot if docompile and not _should_recompile(auxdir, parser, modules, compiler): msg.okay("The current version of fpy_auxiliary.f90 is up-to-date.") from fortpy.testing.compilers import replace target = replace(auxdir + ".[c]", compiler) return (0, True, target) static = static.replace("__auxsave__", present_params(xnames, 21)) static = static.replace("__aux_uses__", '\n'.join(modcode)) static = static.replace("__version__", fortpy.__version__) static = static.replace("__fxauxsave__", '\n'.join(routines)) xnames, modcode, routines, dmods = _generate_single(classers, False) static = static.replace("__auxread__", present_params(xnames, 21)) static = static.replace("__fxauxread__", '\n'.join(routines)) fortpath = path.join(auxdir, "fpy_auxiliary.f90") with open(fortpath, 'w') as f: f.write(static) if docompile: _prepare_dir(parser, modules, auxdir) return _compile(auxdir, compiler, debug, profile)