Last active
December 2, 2020 22:50
-
-
Save det/46724828d1143332b29c0642691b24a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable cppmap availability for each library/binary. | |
modules_maps_feature = feature(name = "module_maps", enabled = True) | |
# This doesn't seem relevant to compiling with modules, but just used by the layering check. | |
# Does any other action need the dependent cppmap files listed on the command line? | |
use_module_maps_feature = feature( | |
name = "use_module_maps", | |
requires = [feature_set(features = ["module_maps"])], | |
flag_sets = [ | |
flag_set( | |
actions = [ | |
ACTION_NAMES.c_compile, | |
ACTION_NAMES.cpp_compile, | |
ACTION_NAMES.cpp_header_parsing, | |
ACTION_NAMES.cpp_module_compile, | |
], | |
flag_groups = [ | |
flag_group( | |
flags = [ | |
"-fmodule-name=%{module_name}", | |
"-fmodule-map-file=%{module_map_file}", | |
], | |
), | |
], | |
), | |
], | |
) | |
# This doesn't seem relevant to compiling with modules, but just an extra check you can | |
# enable for non-modular code. | |
layering_check_feature = feature( | |
name = "layering_check", | |
implies = ["use_module_maps"], | |
flag_sets = [ | |
flag_set( | |
actions = [ | |
ACTION_NAMES.c_compile, | |
ACTION_NAMES.cpp_compile, | |
ACTION_NAMES.cpp_header_parsing, | |
ACTION_NAMES.cpp_module_compile, | |
], | |
flag_groups = [ | |
flag_group(flags = [ | |
"-fmodules-strict-decluse", | |
"-Wprivate-header", | |
]), | |
flag_group( | |
iterate_over = "dependent_module_map_files", | |
flags = [ | |
"-fmodule-map-file=%{dependent_module_map_files}", | |
], | |
), | |
], | |
), | |
], | |
) | |
# This passes all pcm files to compilations that depend on them. | |
use_header_modules_feature = feature( | |
name = "use_header_modules", | |
flag_sets = [ | |
flag_set( | |
actions = [ | |
ACTION_NAMES.c_compile, | |
ACTION_NAMES.cpp_compile, | |
ACTION_NAMES.cpp_header_parsing, | |
ACTION_NAMES.cpp_module_compile, | |
], | |
flag_groups = [ | |
flag_group( | |
iterate_over = "module_files", | |
flags = [ | |
"-fmodule-file=%{module_files}", | |
], | |
), | |
# Pre-compiled crosstool.cppmap, yay or nay? | |
# flag_group( | |
# flags = [ | |
# "-fmodule-file=path/to/crosstool.pcm", | |
# ], | |
# ), | |
], | |
), | |
], | |
) | |
# How to compile a cppmap into a pcm file. | |
header_module_compile_feature = feature( | |
name = "header_module_compile", | |
enabled = True, | |
implies = ["module_maps"], | |
flag_sets = [ | |
flag_set( | |
actions = [ACTION_NAMES.cpp_module_compile], | |
flag_groups = [ | |
flag_group( | |
flags = [ | |
"-xc++", | |
"-fmodules", | |
"-Xclang", "-emit-module", | |
"-fmodule-name=%{module_name}", | |
# These options are probably dependent on your setup and not core to | |
# a bazel with clang submodules setup. | |
"-Xclang", "-fmodules-embed-all-files", | |
"-Xclang", "-fmodules-local-submodule-visibility", | |
"-fno-builtin-module-map", | |
"-fno-implicit-module-maps", | |
], | |
), | |
], | |
), | |
], | |
) | |
# Optional feature you can enable to get modular codegen, this means that each pcm file is also | |
# compiled into a .o file with things like functions declared in headers. | |
header_module_codegen_feature = feature( | |
name = "header_module_codegen", | |
implies = ["header_modules"], | |
flag_sets = [ | |
flag_set( | |
actions = [ACTION_NAMES.cpp_module_compile], | |
flag_groups = [ | |
flag_group( | |
flags = [ | |
"-Xclang", "-fmodules-codegen", | |
], | |
), | |
], | |
), | |
], | |
) | |
# Blanket feature to enable whats needed for header modules. | |
header_modules_feature = feature( | |
name = "header_modules", | |
implies = ["use_header_modules", "header_module_compile"], | |
) | |
# Use paths from the root instead of relative paths in cppmap files. Seems more bazeleque so why not. | |
# Should this be on? | |
module_map_home_cwd_feature = feature( | |
name = "module_map_home_cwd", | |
enabled = True, | |
flag_sets = [ | |
flag_set( | |
actions = [ACTION_NAMES.cpp_module_compile], | |
flag_groups = [ | |
flag_group( | |
flags = [ | |
"-Xclang", "-fmodule-map-file-home-is-cwd", | |
], | |
), | |
], | |
), | |
], | |
) | |
# Text from bazel source: | |
# This features is a transitional feature; enabling it means that generated module maps will | |
# not have "extern module" declarations inside them; instead, the module maps need to be passed | |
# via the dependent_module_map_files build variable. | |
# This variable is phrased negatively to aid the roll-out: currently, the default is that | |
# "extern module" declarations are generated. | |
# | |
# Seems like only the layering check would need this but already passes cppmaps on the command | |
# line so we should enable this? | |
module_map_without_extern_module_feature = feature( | |
enabled = True, | |
name = "module_map_without_extern_module", | |
) | |
# The rest are just options that are just listed for completeness. | |
# Text from bazel source: | |
# This feature is only used temporarily to make the switch to using submodules easier. With | |
# submodules, each header of a cc_library is placed into a submodule of the module generated for | |
# the appropriate target. As this influences the layering_check semantics and needs to be synced | |
# with a clang release, we want to be able to switch back and forth easily. | |
generate_submodules_feature = feature( | |
name = "generate_submodules" | |
) | |
# Self-explanatory. | |
exclude_private_headers_in_module_maps_feature = feature( | |
name = "exclude_private_headers_in_module_maps" | |
) | |
# Self-explanatory. | |
only_doth_headers_in_module_maps_feature = feature( | |
name = "only_doth_headers_in_module_maps" | |
) | |
# Not sure what this does, seems like it forces module compilation even if you aren't enabling modules? | |
compile_all_modules_feature = feature( | |
name = "compile_all_modules" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment