From eae225d073db41b905a54ed5e76475cb8bd6ee5b Mon Sep 17 00:00:00 2001 From: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com> Date: Mon, 29 Apr 2024 10:53:43 -0700 Subject: [PATCH] feat: return the CcInfo provider for the Fortran rules (#172) This enables using Fortran targets as dependencies of C/C++ targets. --- rules_fortran/defs.bzl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/rules_fortran/defs.bzl b/rules_fortran/defs.bzl index 64ecefe..f4b8f39 100644 --- a/rules_fortran/defs.bzl +++ b/rules_fortran/defs.bzl @@ -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 @@ -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(