Public API for rules_fortran.
fortran_binary
fortran_binary(name, deps, srcs, hdrs, copts, defines, includes, linkopts)
Compiles and links Fortran sources into an executable.
This rule compiles Fortran source files and links them with dependencies into an executable binary.
Example: fortran_binary( name = "myapp", srcs = ["main.f90"], deps = [":mylib"], linkopts = ["-llapack"], )
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | List of fortran_library or cc_library targets to link against. | List of labels | optional | [] |
| srcs | List of Fortran source files to compile. | List of labels | optional | [] |
| hdrs | Header/include files (.inc, .mod) for INCLUDE statements and pre-built modules. | List of labels | optional | [] |
| copts | Additional compiler options. | List of strings | optional | [] |
| defines | Preprocessor defines for .F files (e.g., ['_OPENMP', 'USE_MPI']). | List of strings | optional | [] |
| includes | List of include directories to add to the compile line. | List of strings | optional | [] |
| linkopts | Additional linker options. | List of strings | optional | [] |
fortran_library
fortran_library(name, deps, srcs, hdrs, copts, defines, includes, linkopts)
Compiles Fortran sources into a static library.
Examples: fortran_library( name = "math", srcs = ["module.f90", "utils.f90"], )
fortran_library(
name = "advanced",
srcs = ["solver.f90"],
deps = [":math"],
copts = ["-O2"],
)
fortran_library(
name = "all",
deps = [":math", ":advanced"],
)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | List of fortran_library or cc_library targets that this library depends on. | List of labels | optional | [] |
| srcs | List of Fortran source files to compile. | List of labels | optional | [] |
| hdrs | Header/include files (.inc, .mod) for INCLUDE statements and pre-built modules. | List of labels | optional | [] |
| copts | Additional compiler options to pass to the Fortran compiler. | List of strings | optional | [] |
| defines | Preprocessor defines for .F files (e.g., ['_OPENMP', 'USE_MPI']). | List of strings | optional | [] |
| includes | List of include directories to add to the compile line. | List of strings | optional | [] |
| linkopts | Additional linker options (propagated to binaries). | List of strings | optional | [] |
fortran_test
fortran_test(name, deps, srcs, hdrs, copts, defines, includes, linkopts)
Compiles and links Fortran sources into a test executable.
This rule is similar to fortran_binary but is used for test targets. The resulting executable will be run as part of bazel test.
Example: fortran_test( name = "mytest", srcs = ["test.f90"], deps = [":mylib"], )
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | List of fortran_library or cc_library targets to link against. | List of labels | optional | [] |
| srcs | List of Fortran test source files. | List of labels | optional | [] |
| hdrs | Header/include files (.inc, .mod) for INCLUDE statements and pre-built modules. | List of labels | optional | [] |
| copts | Additional compiler options. | List of strings | optional | [] |
| defines | Preprocessor defines for .F files (e.g., ['_OPENMP', 'USE_MPI']). | List of strings | optional | [] |
| includes | List of include directories to add to the compile line. | List of strings | optional | [] |
| linkopts | Additional linker options. | List of strings | optional | [] |
FortranInfo
FortranInfo(transitive_sources, transitive_modules, transitive_objects, transitive_libraries, module_map, compile_flags, link_flags)
Provider for Fortran compilation information.
This provider is used to propagate information about compiled Fortran code, including module files, object files, and transitive dependencies.
FIELDS