Skip to content

Commit

Permalink
feat: return the CcInfo provider for the Fortran rules (#172)
Browse files Browse the repository at this point in the history
This enables using Fortran targets as dependencies of C/C++ targets.
  • Loading branch information
f0rmiga committed Apr 29, 2024
1 parent cfcf13c commit eae225d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions rules_fortran/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ def _fortran_binary_impl(ctx):
providers.append(OutputGroupInfo(
dynamic_library = depset([output]),
))
providers.append(CcInfo(
linking_context = cc_common.create_linking_context(
linker_inputs = depset([
cc_common.create_linker_input(
owner = ctx.label,
libraries = depset([
cc_common.create_library_to_link(
actions = ctx.actions,
feature_configuration = feature_configuration,
cc_toolchain = fortran_toolchain,
dynamic_library = output,
),
]),
),
]),
),
))

return providers

Expand Down Expand Up @@ -144,6 +161,23 @@ def _fortran_library_impl(ctx):
archive = depset([output]),
includes = ctx.files.includes,
),
CcInfo(
linking_context = cc_common.create_linking_context(
linker_inputs = depset([
cc_common.create_linker_input(
owner = ctx.label,
libraries = depset([
cc_common.create_library_to_link(
actions = ctx.actions,
feature_configuration = feature_configuration,
cc_toolchain = fortran_toolchain,
static_library = output,
),
]),
),
]),
),
),
]

fortran_library = rule(
Expand Down

0 comments on commit eae225d

Please sign in to comment.