bazel-contrib / rules_foreign_cc

Build rules for interfacing with "foreign" (non-Bazel) build systems (CMake, configure-make, GNU Make, boost, ninja, Meson)
https://bazel-contrib.github.io/rules_foreign_cc
Apache License 2.0
679 stars 249 forks source link

RFC: Add support for `CPPFLAGS` and clean up `CxxFlagsInfo` #1231

Open allsey87 opened 4 months ago

allsey87 commented 4 months ago

While working on #1230, it came to my attention that if CPPFLAGS is included in the env of a configure_make rule, they are also ignored. I think this should be supported like the other xxxFLAGS variables and would like to get feedback on a PR that touches the code as follows:

  1. Add CPPFLAGS to _MAKE_FLAGS: https://github.com/bazelbuild/rules_foreign_cc/blob/9d5727d5e51bf1be8423dff7996bdb4d847b47e6/foreign_cc/private/make_env_vars.bzl#L79-L88

  2. Add cpp to CxxFlagsInfo provider struct: https://github.com/bazelbuild/rules_foreign_cc/blob/9d5727d5e51bf1be8423dff7996bdb4d847b47e6/foreign_cc/private/cc_toolchain_util.bzl#L28-L38

I would also like to clean up the names of the variables inside CxxFlagsInfo since they are quite misleading and inconsistent. Linked flags are language in dependent. Would the following be acceptable? I think this provider is just used internally so it would not be a breaking change, right?

CFlagsInfo = provider( 
     doc = "Flags for the C/C++ tools, taken from the toolchain", 
     fields = dict( 
         c = "C compiler flags", 
         cxx = "C++ compiler flags",
         cpp = "C/C++ preprocessor flags",
         linker_shared = "Linker flags when linking shared library", 
         linker_static = "Linker flags when linking static library", 
         linker_executable = "Linker flags when linking executable", 
         asm = "Assembler flags", 
     ), 
 )