From 7c0a3bbee1c90c40abaa45274d9abb4fee506e4c Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 21 Mar 2024 15:44:09 -0700 Subject: [PATCH] Refactor action sets for consistency and simplicity BEGIN_PUBLIC Refactor action sets for consistency and simplicity * Remove the "CC" prefix on some of the actions, as we're already within the scope of rules_cc. * Remove the "all" prefix, since the plural "actions" should already imply this. * Ensure all action types sets end with "_actions" * Refactor some action type sets to be constructed from other (eg. link actions = link executables + link dynamic libraries). * Remove the redundant "all_compile_actions", since it was equivalent to "all_cc_compile_actions" END_PUBLIC PiperOrigin-RevId: 617985242 Change-Id: I9a3621a9d613ff604efdc5c86ba52e5c77f06731 --- cc/toolchains/actions.bzl | 2 +- cc/toolchains/actions/BUILD | 36 +++------- cc/toolchains/toolchain.bzl | 4 +- cc/toolchains/variables/BUILD | 130 +++++++++++++++++----------------- 4 files changed, 79 insertions(+), 93 deletions(-) diff --git a/cc/toolchains/actions.bzl b/cc/toolchains/actions.bzl index 31867dd..772e460 100644 --- a/cc/toolchains/actions.bzl +++ b/cc/toolchains/actions.bzl @@ -63,7 +63,7 @@ cc_action_type_set = rule( Example: cc_action_type_set( - name = "cc_link_executable_actions", + name = "link_executable_actions", actions = [ ":cpp_link_executable", ":lto_index_for_executable", diff --git a/cc/toolchains/actions/BUILD b/cc/toolchains/actions/BUILD index 13c14ee..1286999 100644 --- a/cc/toolchains/actions/BUILD +++ b/cc/toolchains/actions/BUILD @@ -139,12 +139,12 @@ cc_action_type( ) cc_action_type_set( - name = "all_ar_actions", + name = "ar_actions", actions = [":cpp_link_static_library"], ) cc_action_type_set( - name = "all_assembly_actions", + name = "assembly_actions", actions = [ ":preprocess_assemble", ":assemble", @@ -152,7 +152,7 @@ cc_action_type_set( ) cc_action_type_set( - name = "all_cpp_compile_actions", + name = "cpp_compile_actions", actions = [ ":linkstamp_compile", ":cpp_compile", @@ -165,37 +165,24 @@ cc_action_type_set( ) cc_action_type_set( - name = "all_cc_compile_actions", + name = "compile_actions", actions = [ - ":all_cpp_compile_actions", + ":cpp_compile_actions", ":c_compile", - ":preprocess_assemble", - ":assemble", + ":assembly_actions", ], ) cc_action_type_set( - name = "all_compile_actions", + name = "link_actions", actions = [ - ":all_cc_compile_actions", - ":all_cpp_compile_actions", + ":link_executable_actions", + ":dynamic_library_link_actions", ], ) cc_action_type_set( - name = "all_cc_link_actions", - actions = [ - ":cpp_link_executable", - ":cpp_link_dynamic_library", - ":cpp_link_nodeps_dynamic_library", - ":lto_index_for_executable", - ":lto_index_for_dynamic_library", - ":lto_index_for_nodeps_dynamic_library", - ], -) - -cc_action_type_set( - name = "cc_link_executable_actions", + name = "link_executable_actions", actions = [ ":cpp_link_executable", ":lto_index_for_executable", @@ -206,9 +193,8 @@ cc_action_type_set( name = "dynamic_library_link_actions", actions = [ ":cpp_link_dynamic_library", - ":cpp_link_nodeps_dynamic_library", ":lto_index_for_dynamic_library", - ":lto_index_for_nodeps_dynamic_library", + ":nodeps_dynamic_library_link_actions", ], ) diff --git a/cc/toolchains/toolchain.bzl b/cc/toolchains/toolchain.bzl index cbbcb53..0ce1abf 100644 --- a/cc/toolchains/toolchain.bzl +++ b/cc/toolchains/toolchain.bzl @@ -27,10 +27,10 @@ visibility("public") # work out what actions correspond to what file groups. _LEGACY_FILE_GROUPS = { "ar_files": [ - "@rules_cc//cc/toolchains/actions:all_ar_actions", # copybara-use-repo-external-label + "@rules_cc//cc/toolchains/actions:ar_actions", # copybara-use-repo-external-label ], "as_files": [ - "@rules_cc//cc/toolchains/actions:all_assembly_actions", # copybara-use-repo-external-label + "@rules_cc//cc/toolchains/actions:assembly_actions", # copybara-use-repo-external-label ], "compiler_files": [ "@rules_cc//cc/toolchains/actions:cc_flags_make_variable", # copybara-use-repo-external-label diff --git a/cc/toolchains/variables/BUILD b/cc/toolchains/variables/BUILD index d93083d..ec07287 100644 --- a/cc/toolchains/variables/BUILD +++ b/cc/toolchains/variables/BUILD @@ -5,98 +5,98 @@ package(default_visibility = ["//visibility:public"]) cc_variable( name = "cs_fdo_instrument_path", actions = [ - "//cc/toolchains/actions:all_cc_link_actions", - "//cc/toolchains/actions:all_compile_actions", + "//cc/toolchains/actions:link_actions", + "//cc/toolchains/actions:compile_actions", ], type = types.directory, ) cc_variable( name = "def_file_path", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.file), ) cc_variable( name = "dependency_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "dependent_module_map_files", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.list(types.file)), ) cc_variable( name = "external_include_paths", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.list(types.directory)), ) cc_variable( name = "fdo_instrument_path", actions = [ - "//cc/toolchains/actions:all_cc_link_actions", - "//cc/toolchains/actions:all_compile_actions", + "//cc/toolchains/actions:link_actions", + "//cc/toolchains/actions:compile_actions", ], type = types.directory, ) cc_variable( name = "fdo_prefetch_hints_path", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "fdo_profile_path", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "force_pic", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], # Provided when --force-pic is passed type = types.option(types.void), ) cc_variable( name = "framework_include_paths", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.directory), ) cc_variable( name = "gcov_gcno_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "generate_interface_library", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], # "yes" or "no" type = types.option(types.string), ) cc_variable( name = "include", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.file), ) cc_variable( name = "include_paths", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.directory), ) cc_variable( name = "includes", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.list(types.file)), ) @@ -108,55 +108,55 @@ cc_variable( cc_variable( name = "interface_library_builder_path", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], # Should be a file, but contains the string "ignored" when there's no value. type = types.option(types.string), ) cc_variable( name = "interface_library_input_path", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], # Should be a file, but contains the string "ignored" when there's no value. type = types.option(types.string), ) cc_variable( name = "interface_library_output_path", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], # Should be a file, but contains the string "ignored" when there's no value. type = types.option(types.string), ) cc_variable( name = "is_cc_test", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.bool), ) cc_variable( name = "is_using_fission", actions = [ - "//cc/toolchains/actions:all_cc_link_actions", - "//cc/toolchains/actions:all_compile_actions", + "//cc/toolchains/actions:link_actions", + "//cc/toolchains/actions:compile_actions", ], type = types.option(types.void), ) cc_variable( name = "legacy_compile_flags", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.string), ) cc_variable( name = "legacy_link_flags", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.list(types.string), ) cc_variable( name = "libraries_to_link", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.list(types.struct( shared_libraries = types.list(types.struct( name = types.string, @@ -170,164 +170,164 @@ cc_variable( cc_variable( name = "libraries_to_link.shared_libraries", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], # See :libraries_to_link. type = types.unknown, ) cc_variable( name = "libraries_to_link.shared_libraries.is_whole_archive", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.string, ) cc_variable( name = "libraries_to_link.shared_libraries.name", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.string, ) cc_variable( name = "libraries_to_link.shared_libraries.object_files", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.list(types.file), ) cc_variable( name = "libraries_to_link.shared_libraries.path", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.file, ) cc_variable( name = "libraries_to_link.shared_libraries.type", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.string, ) cc_variable( name = "library_search_directories", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.list(types.directory), ) cc_variable( name = "linker_param_file", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.file, ) cc_variable( name = "linkstamp_paths", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.list(types.directory), ) cc_variable( name = "lto_indexing_bitcode_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.file), ) cc_variable( name = "module_files", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.list(types.file)), ) cc_variable( name = "module_map_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.file), ) cc_variable( name = "module_name", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.string), ) cc_variable( name = "output_assembly_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "output_execpath", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.directory), ) cc_variable( name = "output_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "output_preprocess_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "per_object_debug_info_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "pic", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.void), ) cc_variable( name = "preprocessor_defines", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.string), ) cc_variable( name = "propellor_optimize_ld_path", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.file), ) cc_variable( name = "quote_include_paths", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.directory), ) cc_variable( name = "runtime_library_search_directories", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.list(types.directory)), ) cc_variable( name = "runtime_solib_name", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.string), ) cc_variable( name = "serialized_diagnostics_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.file), ) cc_variable( name = "source_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.file, ) cc_variable( name = "strip_debug_symbols", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.void), ) @@ -344,73 +344,73 @@ cc_variable( cc_variable( name = "system_include_paths", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.directory), ) cc_variable( name = "thinlto_index", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.string), ) cc_variable( name = "thinlto_indexing_param_file", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.string), ) cc_variable( name = "thinlto_input_bitcode_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.file), ) cc_variable( name = "thinlto_merged_object_file", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.file), ) cc_variable( name = "thinlto_object_suffix_replace", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.string), ) cc_variable( name = "thinlto_output_object_file", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.option(types.file), ) cc_variable( name = "thinlto_param_file", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.file), ) cc_variable( name = "thinlto_prefix_replace", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.option(types.string), ) cc_variable( name = "unfiltered_compile_flags", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.string), ) cc_variable( name = "user_compile_flags", - actions = ["//cc/toolchains/actions:all_compile_actions"], + actions = ["//cc/toolchains/actions:compile_actions"], type = types.list(types.string), ) cc_variable( name = "user_link_flags", - actions = ["//cc/toolchains/actions:all_cc_link_actions"], + actions = ["//cc/toolchains/actions:link_actions"], type = types.list(types.string), )