From 6522b8ea09d992795ad01908bab5a0a96c70f3eb Mon Sep 17 00:00:00 2001 From: Milen Dzhumerov Date: Fri, 19 Jan 2024 01:58:21 -0800 Subject: [PATCH] Remove genrule validation functionality Summary: Removes the genrule validation functionality which is no longer needed. Reviewed By: d16r, blackm00n Differential Revision: D52869821 fbshipit-source-id: 7c15f96c5ec7c019bbb56042024b7ace305f6eb0 --- prelude/apple/apple_binary.bzl | 4 -- prelude/apple/apple_bundle.bzl | 4 -- prelude/apple/apple_genrule_deps.bzl | 47 ---------------------- prelude/apple/apple_library.bzl | 4 -- prelude/apple/apple_macro_layer.bzl | 5 --- prelude/apple/apple_rules_impl.bzl | 11 ----- prelude/apple/apple_rules_impl_utility.bzl | 13 ------ prelude/genrule.bzl | 9 ----- prelude/genrule_types.bzl | 12 ------ 9 files changed, 109 deletions(-) delete mode 100644 prelude/apple/apple_genrule_deps.bzl delete mode 100644 prelude/genrule_types.bzl diff --git a/prelude/apple/apple_binary.bzl b/prelude/apple/apple_binary.bzl index 7b0b9d50..f0712184 100644 --- a/prelude/apple/apple_binary.bzl +++ b/prelude/apple/apple_binary.bzl @@ -63,7 +63,6 @@ load(":apple_code_signing_types.bzl", "AppleEntitlementsInfo") load(":apple_dsym.bzl", "DSYM_SUBTARGET", "get_apple_dsym") load(":apple_entitlements.bzl", "entitlements_link_flags") load(":apple_frameworks.bzl", "get_framework_search_path_flags") -load(":apple_genrule_deps.bzl", "get_apple_build_genrule_deps_attr_value", "get_apple_genrule_deps_outputs") load(":apple_target_sdk_version.bzl", "get_min_deployment_version_for_node", "get_min_deployment_version_target_linker_flags", "get_min_deployment_version_target_preprocessor_flags") load(":apple_utility.bzl", "get_apple_cxx_headers_layout", "get_apple_stripped_attr_value_with_default_fallback") load(":apple_validation_deps.bzl", "get_apple_validation_deps_outputs") @@ -113,9 +112,6 @@ def apple_binary_impl(ctx: AnalysisContext) -> [list[Provider], Promise]: ) validation_deps_outputs = get_apple_validation_deps_outputs(ctx) - if get_apple_build_genrule_deps_attr_value(ctx): - validation_deps_outputs += get_apple_genrule_deps_outputs(cxx_attr_deps(ctx)) - stripped = get_apple_stripped_attr_value_with_default_fallback(ctx) constructor_params = CxxRuleConstructorParams( rule_type = "apple_binary", diff --git a/prelude/apple/apple_bundle.bzl b/prelude/apple/apple_bundle.bzl index 74afaf96..c7ecb179 100644 --- a/prelude/apple/apple_bundle.bzl +++ b/prelude/apple/apple_bundle.bzl @@ -61,7 +61,6 @@ load( ) load(":apple_bundle_utility.bzl", "get_bundle_min_target_version", "get_default_binary_dep", "get_flattened_binary_deps", "get_product_name") load(":apple_dsym.bzl", "DSYM_INFO_SUBTARGET", "DSYM_SUBTARGET", "get_apple_dsym", "get_apple_dsym_ext", "get_apple_dsym_info") -load(":apple_genrule_deps.bzl", "get_apple_build_genrule_deps_attr_value", "get_apple_genrule_deps_outputs") load(":apple_sdk.bzl", "get_apple_sdk_name") load(":apple_universal_binaries.bzl", "create_universal_binary") load(":apple_validation_deps.bzl", "get_apple_validation_deps_outputs") @@ -322,9 +321,6 @@ def apple_bundle_impl(ctx: AnalysisContext) -> list[Provider]: primary_binary_rel_path = get_apple_bundle_part_relative_destination_path(ctx, primary_binary_part) validation_deps_outputs = get_apple_validation_deps_outputs(ctx) - if get_apple_build_genrule_deps_attr_value(ctx): - validation_deps_outputs += get_apple_genrule_deps_outputs(ctx.attrs.deps) - sub_targets = assemble_bundle( ctx, bundle, diff --git a/prelude/apple/apple_genrule_deps.bzl b/prelude/apple/apple_genrule_deps.bzl deleted file mode 100644 index 756a5bdd..00000000 --- a/prelude/apple/apple_genrule_deps.bzl +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under both the MIT license found in the -# LICENSE-MIT file in the root directory of this source tree and the Apache -# License, Version 2.0 found in the LICENSE-APACHE file in the root directory -# of this source tree. - -load("@prelude//:genrule_types.bzl", "GENRULE_MARKER_SUBTARGET_NAME") - -def get_apple_genrule_deps_outputs(deps: list[Dependency]) -> list[Artifact]: - artifacts = [] - for dep in deps: - default_info = dep[DefaultInfo] - if GENRULE_MARKER_SUBTARGET_NAME in default_info.sub_targets: - artifacts += default_info.default_outputs - return artifacts - -def get_apple_build_genrule_deps_attr_value(ctx: AnalysisContext) -> bool: - build_genrule_deps = ctx.attrs.build_genrule_deps - if build_genrule_deps != None: - # `build_genrule_deps` present on a target takes priority - return build_genrule_deps - - # Fallback to the default value which is driven by buckconfig + select() - return ctx.attrs._build_genrule_deps - -def get_apple_build_genrule_deps_default_kwargs() -> dict[str, typing.Any]: - return { - APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_NAME: _build_genrule_deps_default_enabled(), - } - -def _build_genrule_deps_default_enabled() -> typing.Any: - buckconfig_value = read_root_config("apple", "build_genrule_deps", None) - if buckconfig_value != None: - return buckconfig_value.lower() == "true" - - return select({ - "DEFAULT": False, - # TODO(mgd): Make `config//` references possible from macro layer - "ovr_config//features/apple/constraints:build_genrule_deps_enabled": True, - }) - -APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_NAME = "_build_genrule_deps" -APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_TYPE = attrs.bool(default = False) - -APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME = "build_genrule_deps" -APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE = attrs.option(attrs.bool(), default = None) diff --git a/prelude/apple/apple_library.bzl b/prelude/apple/apple_library.bzl index 520f2a30..530bfc33 100644 --- a/prelude/apple/apple_library.bzl +++ b/prelude/apple/apple_library.bzl @@ -71,7 +71,6 @@ load("@prelude//utils:arglike.bzl", "ArgLike") load("@prelude//utils:expect.bzl", "expect") load(":apple_bundle_types.bzl", "AppleBundleLinkerMapInfo", "AppleMinDeploymentVersionInfo") load(":apple_frameworks.bzl", "get_framework_search_path_flags") -load(":apple_genrule_deps.bzl", "get_apple_build_genrule_deps_attr_value", "get_apple_genrule_deps_outputs") load(":apple_modular_utility.bzl", "MODULE_CACHE_PATH") load(":apple_target_sdk_version.bzl", "get_min_deployment_version_for_node", "get_min_deployment_version_target_linker_flags", "get_min_deployment_version_target_preprocessor_flags") load(":apple_utility.bzl", "get_apple_cxx_headers_layout", "get_apple_stripped_attr_value_with_default_fallback", "get_module_name") @@ -223,9 +222,6 @@ def apple_library_rule_constructor_params_and_swift_providers(ctx: AnalysisConte ) validation_deps_outputs = get_apple_validation_deps_outputs(ctx) - if get_apple_build_genrule_deps_attr_value(ctx): - validation_deps_outputs += get_apple_genrule_deps_outputs(cxx_attr_deps(ctx) + cxx_attr_exported_deps(ctx)) - return CxxRuleConstructorParams( rule_type = params.rule_type, is_test = (params.rule_type == "apple_test"), diff --git a/prelude/apple/apple_macro_layer.bzl b/prelude/apple/apple_macro_layer.bzl index faf2fab3..3d39921e 100644 --- a/prelude/apple/apple_macro_layer.bzl +++ b/prelude/apple/apple_macro_layer.bzl @@ -7,7 +7,6 @@ load(":apple_bundle_config.bzl", "apple_bundle_config") load(":apple_dsym_config.bzl", "apple_dsym_config") -load(":apple_genrule_deps.bzl", "get_apple_build_genrule_deps_default_kwargs") load(":apple_info_plist_substitutions_parsing.bzl", "parse_codesign_entitlements") load(":apple_package_config.bzl", "apple_package_config") load(":apple_resource_bundle.bzl", "make_resource_bundle_rule") @@ -76,7 +75,6 @@ def apple_test_macro_impl(apple_test_rule, apple_resource_bundle_rule, **kwargs) kwargs.update(apple_bundle_config()) kwargs.update(apple_dsym_config()) kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config(_APPLE_TEST_LOCAL_EXECUTION_OVERRIDES)) - kwargs.update(get_apple_build_genrule_deps_default_kwargs()) # `extension` is used both by `apple_test` and `apple_resource_bundle`, so provide default here kwargs["extension"] = kwargs.pop("extension", "xctest") @@ -89,7 +87,6 @@ def apple_bundle_macro_impl(apple_bundle_rule, apple_resource_bundle_rule, **kwa info_plist_substitutions = kwargs.get("info_plist_substitutions") kwargs.update(apple_bundle_config()) kwargs.update(apple_dsym_config()) - kwargs.update(get_apple_build_genrule_deps_default_kwargs()) apple_bundle_rule( _codesign_entitlements = parse_codesign_entitlements(info_plist_substitutions), _resource_bundle = make_resource_bundle_rule(apple_resource_bundle_rule, **kwargs), @@ -100,7 +97,6 @@ def apple_library_macro_impl(apple_library_rule = None, **kwargs): kwargs.update(apple_dsym_config()) kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config(_APPLE_LIBRARY_LOCAL_EXECUTION_OVERRIDES)) kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config([APPLE_STRIPPED_DEFAULT])) - kwargs.update(get_apple_build_genrule_deps_default_kwargs()) apple_library_rule(**kwargs) def apple_binary_macro_impl(apple_binary_rule = None, apple_universal_executable = None, **kwargs): @@ -108,7 +104,6 @@ def apple_binary_macro_impl(apple_binary_rule = None, apple_universal_executable kwargs.update(dsym_args) kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config(_APPLE_BINARY_LOCAL_EXECUTION_OVERRIDES)) kwargs.update(apple_macro_layer_set_bool_override_attrs_from_config([APPLE_STRIPPED_DEFAULT])) - kwargs.update(get_apple_build_genrule_deps_default_kwargs()) original_binary_name = kwargs.pop("name") diff --git a/prelude/apple/apple_rules_impl.bzl b/prelude/apple/apple_rules_impl.bzl index e593c13b..a3cef8fa 100644 --- a/prelude/apple/apple_rules_impl.bzl +++ b/prelude/apple/apple_rules_impl.bzl @@ -6,13 +6,6 @@ # of this source tree. load("@prelude//apple:apple_buck2_compatibility.bzl", "BUCK2_COMPATIBILITY_ATTRIB_NAME", "BUCK2_COMPATIBILITY_ATTRIB_TYPE") -load( - "@prelude//apple:apple_genrule_deps.bzl", - "APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_NAME", - "APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_TYPE", - "APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME", - "APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE", -) load("@prelude//apple/swift:swift_incremental_support.bzl", "SwiftCompilationMode") load("@prelude//apple/swift:swift_toolchain.bzl", "swift_toolchain_impl") load("@prelude//apple/swift:swift_toolchain_types.bzl", "SwiftObjectFormat") @@ -101,8 +94,6 @@ def _apple_binary_extra_attrs(): "_apple_xctoolchain": get_apple_xctoolchain_attr(), "_apple_xctoolchain_bundle_id": get_apple_xctoolchain_bundle_id_attr(), "_stripped_default": attrs.bool(default = False), - APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_TYPE, - APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE, BUCK2_COMPATIBILITY_ATTRIB_NAME: BUCK2_COMPATIBILITY_ATTRIB_TYPE, APPLE_VALIDATION_DEPS_ATTR_NAME: APPLE_VALIDATION_DEPS_ATTR_TYPE, } @@ -130,8 +121,6 @@ def _apple_library_extra_attrs(): "_apple_xctoolchain_bundle_id": get_apple_xctoolchain_bundle_id_attr(), "_stripped_default": attrs.bool(default = False), APPLE_ARCHIVE_OBJECTS_LOCALLY_OVERRIDE_ATTR_NAME: attrs.option(attrs.bool(), default = None), - APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_TYPE, - APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE, BUCK2_COMPATIBILITY_ATTRIB_NAME: BUCK2_COMPATIBILITY_ATTRIB_TYPE, APPLE_VALIDATION_DEPS_ATTR_NAME: APPLE_VALIDATION_DEPS_ATTR_TYPE, } diff --git a/prelude/apple/apple_rules_impl_utility.bzl b/prelude/apple/apple_rules_impl_utility.bzl index 2d21fc48..fcdc7726 100644 --- a/prelude/apple/apple_rules_impl_utility.bzl +++ b/prelude/apple/apple_rules_impl_utility.bzl @@ -9,13 +9,6 @@ load("@prelude//apple:apple_buck2_compatibility.bzl", "BUCK2_COMPATIBILITY_ATTRI load("@prelude//apple:apple_bundle_attrs.bzl", "get_apple_info_plist_build_system_identification_attrs") load("@prelude//apple:apple_bundle_types.bzl", "AppleBundleResourceInfo", "AppleBundleTypeAttributeType") load("@prelude//apple:apple_code_signing_types.bzl", "CodeSignType") -load( - "@prelude//apple:apple_genrule_deps.bzl", - "APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_NAME", - "APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_TYPE", - "APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME", - "APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE", -) load("@prelude//apple:apple_toolchain_types.bzl", "AppleToolchainInfo", "AppleToolsInfo") load("@prelude//apple/swift:swift_incremental_support.bzl", "SwiftCompilationMode") load("@prelude//apple/user:apple_selective_debugging.bzl", "AppleSelectiveDebuggingInfo") @@ -115,10 +108,6 @@ def apple_test_extra_attrs(): "_macos_idb_companion": attrs.transition_dep(cfg = apple_simulators_transition, default = "fbsource//xplat/buck2/platform/apple:macos_idb_companion", providers = [LocalResourceInfo]), } attribs.update(_apple_bundle_like_common_attrs()) - attribs.update({ - APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_TYPE, - APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE, - }) return attribs def apple_xcuitest_extra_attrs(): @@ -151,8 +140,6 @@ def apple_bundle_extra_attrs(): "universal": attrs.option(attrs.bool(), default = None), "_apple_toolchain": get_apple_bundle_toolchain_attr(), "_codesign_entitlements": attrs.option(attrs.source(), default = None), - APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_DEFAULT_ATTRIB_TYPE, - APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_NAME: APPLE_BUILD_GENRULE_DEPS_TARGET_ATTRIB_TYPE, } attribs.update(_apple_bundle_like_common_attrs()) return attribs diff --git a/prelude/genrule.bzl b/prelude/genrule.bzl index a4e1e633..a7963df8 100644 --- a/prelude/genrule.bzl +++ b/prelude/genrule.bzl @@ -10,11 +10,9 @@ load("@prelude//:cache_mode.bzl", "CacheModeInfo") load("@prelude//:genrule_local_labels.bzl", "genrule_labels_require_local") load("@prelude//:genrule_toolchain.bzl", "GenruleToolchainInfo") -load("@prelude//:genrule_types.bzl", "GENRULE_MARKER_SUBTARGET_NAME", "GenruleMarkerInfo") load("@prelude//:is_full_meta_repo.bzl", "is_full_meta_repo") load("@prelude//android:build_only_native_code.bzl", "is_build_only_native_code") load("@prelude//os_lookup:defs.bzl", "OsLookup") -load("@prelude//utils:expect.bzl", "expect") load("@prelude//utils:utils.bzl", "flatten", "value_or") GENRULE_OUT_DIR = "out" @@ -347,14 +345,7 @@ def process_genrule( **metadata_args ) - # Use a subtarget to insert a marker, as callsites make assumptions about - # the providers of `process_genrule()`. We want to have the marker in - # `DefaultInfo` rather than in `genrule_impl()` because we want to identify - # all classes of genrule-like rules. sub_targets = {k: [DefaultInfo(default_outputs = v)] for (k, v) in named_outputs.items()} - expect(GENRULE_MARKER_SUBTARGET_NAME not in sub_targets, "Conflicting private `{}` subtarget and named output".format(GENRULE_MARKER_SUBTARGET_NAME)) - sub_targets[GENRULE_MARKER_SUBTARGET_NAME] = [GenruleMarkerInfo()] - providers = [DefaultInfo( default_outputs = default_outputs, sub_targets = sub_targets, diff --git a/prelude/genrule_types.bzl b/prelude/genrule_types.bzl deleted file mode 100644 index 0793c705..00000000 --- a/prelude/genrule_types.bzl +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under both the MIT license found in the -# LICENSE-MIT file in the root directory of this source tree and the Apache -# License, Version 2.0 found in the LICENSE-APACHE file in the root directory -# of this source tree. - -# A provider that's used as a marker for `genrule()`, allows dependents -# to distinguish such outputs -GenruleMarkerInfo = provider(fields = {}) - -GENRULE_MARKER_SUBTARGET_NAME = "genrule_marker"