Makes a couple of changes to make Clang modules work better with generated libraries. Namely:
Only include public files in generated modulemap files. Previously it would include every header, which would A) potentially add headers from other modules (eg in React where multiple modules share a source directory) or include headers that aren't supposed to be compileable externally (eg all of Yoga's public headers handle both C and C++, but its internal ones assume C++ and would break when being used from a C translation unit).
Generate module maps for each target, not just the top-level target, since they will (likely) have different sources from the top-level one.
Populate the module_map attribute in the objc_library rule so Bazel doesn't generate its own module map.
Explicitly specify -fmodules if we have modules enabled. I'm not sure why, but I was running into cases where Bazel wouldn't pass that flag to Clang even when modules were enabled.
Only generate gen_module_map rule if module map generation is on.
Makes a couple of changes to make Clang modules work better with generated libraries. Namely:
module_map
attribute in theobjc_library
rule so Bazel doesn't generate its own module map.-fmodules
if we have modules enabled. I'm not sure why, but I was running into cases where Bazel wouldn't pass that flag to Clang even when modules were enabled.gen_module_map
rule if module map generation is on.