All Projects → ZedThree → fort_depend.py

ZedThree / fort_depend.py

Licence: MIT license
A python script to generate dependencies for Fortran projects

Programming Languages

python
139335 projects - #7 most used programming language
fortran
972 projects
Makefile
30231 projects

Projects that are alternatives of or similar to fort depend.py

llmk
Light LaTeX Make
Stars: ✭ 93 (+165.71%)
Mutual labels:  build-tool
proguard-core
Library to read, write, analyze, and process java bytecode
Stars: ✭ 215 (+514.29%)
Mutual labels:  build-tool
psh
PSH - PHP shell helper
Stars: ✭ 60 (+71.43%)
Mutual labels:  build-tool
construi
Use Docker to define your build environment.
Stars: ✭ 24 (-31.43%)
Mutual labels:  build-tool
dockerized-cli
Containerized development environments using Docker
Stars: ✭ 55 (+57.14%)
Mutual labels:  build-tool
qb
Zero-configuration build system to very quickly build C/C++ projects.
Stars: ✭ 201 (+474.29%)
Mutual labels:  build-tool
build-nginx
Fetches nginx and any optional third-party modules and dependencies you specify, such as openssl and PCRE and then configures and builds.
Stars: ✭ 48 (+37.14%)
Mutual labels:  build-tool
up
UP - Ultimate Provisioner CLI
Stars: ✭ 43 (+22.86%)
Mutual labels:  build-tool
Calcifer
Calcifer
Stars: ✭ 72 (+105.71%)
Mutual labels:  build-tool
taiga-stats
Generate statistics from Taiga and produce burnup diagrams, CFDs, dependency graphs and more.
Stars: ✭ 40 (+14.29%)
Mutual labels:  dependency-graph
gow
Missing watch mode for Go commands. Watch Go files and execute a command like "go run" or "go test"
Stars: ✭ 343 (+880%)
Mutual labels:  build-tool
cargo-supply-chain
Gather author, contributor and publisher data on crates in your dependency graph.
Stars: ✭ 287 (+720%)
Mutual labels:  dependency-graph
alfons
🚀 Task runner for Lua and MoonScript.
Stars: ✭ 17 (-51.43%)
Mutual labels:  build-tool
Fortran-Tools
Fortran compilers, preprocessors, static analyzers, transpilers, IDEs, build systems, etc.
Stars: ✭ 31 (-11.43%)
Mutual labels:  build-tool
metahelm
Install dependency graphs of Kubernetes Helm Charts
Stars: ✭ 70 (+100%)
Mutual labels:  dependency-graph
ukor
A Roku build tool with support for build flavors
Stars: ✭ 45 (+28.57%)
Mutual labels:  build-tool
angular-build-info
🛠 A CLI to generate an easily importable `build.ts` file containing various details about the application build
Stars: ✭ 25 (-28.57%)
Mutual labels:  build-tool
ycm
Extra CMake Modules for YARP and friends
Stars: ✭ 42 (+20%)
Mutual labels:  build-tool
UnityBuildManager
Utility for running builds sequence & pushing them to markets & keeping changelog
Stars: ✭ 53 (+51.43%)
Mutual labels:  build-tool
eclipse
Eclipse For Bazel (deprecated, see https://github.com/salesforce/bazel-eclipse instead)
Stars: ✭ 31 (-11.43%)
Mutual labels:  build-tool

fortdepend

Build Status codecov

A python script to automatically generate Fortran dependencies.

Given a set of files, fortdepend automatically constructs the dependency graph for the programs and files and can write a dependency file suitable for Makefiles. fortdepend now uses pcpp, a preprocessor written in Python, so it can determine which modules will actually be used when you compile.

You can even use fortdepend to draw the graph of the module dependencies (requires graphviz)!

Complete documentation is available on ReadTheDocs.

Original script by D. Dickinson

Installation

You can install fortdepend with pip:

pip3 install --user fortdepend

Limitations

fortdepend requires Python 3.

fortdepend works by looking for matching pairs of program <name>/end program <name> and module <name>/end module <name>, and so will not work on Fortran 77-style files that just use end without the appropriate label.

Usage

Basic usage:

fortdepend -o Makefile.dep

This will look for all files ending in .f90 or .F90 in the current directory and write the output to Makefile.dep. The output will something like this:

test :  \
        moduleA.o \
        moduleB.o \
        moduleC.o \
        moduleD.o \
        programTest.o

moduleA.o :

moduleB.o :  \
        moduleA.o

moduleC.o :  \
        moduleA.o \
        moduleB.o

moduleD.o :  \
        moduleC.o

You could then get a basic makefile working by putting the following in Makefile:

.f90.o:
    gfortran -c $<

test:
    gfortran $^ -o $@

include Makefile.dep

And make test will magically build everything in the correct order!

Move advanced use

You can specify preprocessor macros with -D and search paths with -I:

fortdepend -DMACRO=42 -Isome/include/dir -o Makefile.dep

will replace instances of MACRO with 42 according to the usual C99 preprocessor rules. This can be used to conditionally use some modules or change which module is used at compile time.

Full command line arguments:

$ fortdepend --help
usage: fortdepend [-h] [-f FILES [FILES ...]] [-D NAME[=DESCRIPTION]
                  [NAME[=DESCRIPTION] ...]] [-b BUILD] [-o OUTPUT] [-g] [-v]
                  [-w] [-c] [-e EXCLUDE_FILES [EXCLUDE_FILES ...]]
                  [-i IGNORE_MODULES [IGNORE_MODULES ...]]

Generate Fortran dependencies

optional arguments:
  -h, --help            show this help message and exit
  -f FILES [FILES ...], --files FILES [FILES ...]
                        Files to process
  -D NAME[=DESCRIPTION] [NAME[=DESCRIPTION] ...]
                        Preprocessor define statements
  -I dir                Add dir to the preprocessor search path
  -b BUILD, --build BUILD
                        Build Directory (prepended to all files in output)
  -o OUTPUT, --output OUTPUT
                        Output file
  -g, --graph           Make a graph of the project
  -v, --verbose         explain what is done
  -w, --overwrite       Overwrite output file without warning
  -c, --colour          Print in colour
  -e EXCLUDE_FILES [EXCLUDE_FILES ...], --exclude-files EXCLUDE_FILES [EXCLUDE_FILES ...]
                        Files to exclude
  -i IGNORE_MODULES [IGNORE_MODULES ...], --ignore-modules IGNORE_MODULES [IGNORE_MODULES ...]
                        Modules to ignore
  --skip-programs       Don't include programs in the output file
  -n, --no-preprocessor
                        Don't use the preprocessor

Here's a slightly more advanced example of how to use fortdepend in your makefiles:

# Script to generate the dependencies
MAKEDEPEND=/path/to/fortdepend

# $(DEP_FILE) is a .dep file generated by fortdepend
DEP_FILE = my_project.dep

# Source files to compile
OBJECTS = mod_file1.f90 \
          mod_file2.f90

# Make sure everything depends on the .dep file
all: $(actual_executable) $(DEP_FILE)

# Make dependencies
.PHONY: depend
depend: $(DEP_FILE)

# The .dep file depends on the source files, so it automatically gets updated
# when you change your source
$(DEP_FILE): $(OBJECTS)
    @echo "Making dependencies!"
    cd $(SRCPATH) && $(MAKEDEPEND) -w -o /path/to/$(DEP_FILE) -f $(OBJECTS)

include $(DEP_FILE)

This will automatically rebuild the dependency file if any of the source files change. You might not like to do this if you have a lot of files and need to preprocess them!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].