Skip to content

Interface for defining compilation outputs in the toolchain #826

Description

@lilygorsheneva

A large portion of compile.bzl is dedicated to passing input/output files that are feature or toolchain-specific; while this is not necessarily a problem, adding them one-by-one is a bit tedious (see #772); ideally the toolchain should be able to define output files without editing rules_cc itself.

A generic implementation will need to be able to do the following:

  • be defined in a toolchain
  • be conditional on some aspect of the feature configuration
  • declare one or more files, potentially in relation to other files
  • add files to output groups

Discussion of PR/772 seems to lean towards callbacks; I propose the following interface for something that would get called (based on feature configuration) in _create_compile_source_action (e.g. how _maybe_declare_trace_file is called in #772)

def callback(
   ctx,               # rule context object. requires committing to keeping ctx in the cc_common.compile API 
   feature_configuration,
   cc_internal, # an object allowing access to file declaration api. Not a good name for it
) -> {"output_group_name":[files]}

When defining a toolchain, add a map or set of these callbacks to CcToolchainInfo (I'm insufficiently familiar with the rules-based-toolchain API to have a proposal for how this should look).

@keith @13steinj @trybka thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions