From 7bb401c03f58b6db9dbfc6ef3f577e86aa60ae22 Mon Sep 17 00:00:00 2001 From: Vinnie Magro Date: Wed, 1 Nov 2023 16:51:48 -0700 Subject: [PATCH] [antlir2][bzl] plugins are just `provider` when used cross-cell Summary: This seems like a bug in the type system, will create a small repro and report to the buck2 team, but for now this unblocks cross-cell antlir2 users. Test Plan: Was able to `buck build` broken fbpkg from https://fb.workplace.com/groups/fbpkg/posts/25334351462853463 Reviewed By: justintrudell Differential Revision: D50508717 fbshipit-source-id: 28dbcf5d224d95dd2f7d92f0d5bf4cd77b69c506 --- antlir/antlir2/bzl/feature/clone.bzl | 4 ++-- antlir/antlir2/bzl/feature/dot_meta.bzl | 4 ++-- antlir/antlir2/bzl/feature/extract.bzl | 4 ++-- antlir/antlir2/bzl/feature/feature.bzl | 4 ++-- antlir/antlir2/bzl/feature/feature_info.bzl | 6 +++--- antlir/antlir2/bzl/feature/genrule.bzl | 4 ++-- antlir/antlir2/bzl/feature/install.bzl | 6 +++--- antlir/antlir2/bzl/feature/metakv.bzl | 4 ++-- antlir/antlir2/bzl/feature/mount.bzl | 4 ++-- antlir/antlir2/bzl/feature/rpms.bzl | 4 ++-- antlir/antlir2/bzl/feature/tarball.bzl | 4 ++-- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/antlir/antlir2/bzl/feature/clone.bzl b/antlir/antlir2/bzl/feature/clone.bzl index 8bb4dd21c20..da4a9b88970 100644 --- a/antlir/antlir2/bzl/feature/clone.bzl +++ b/antlir/antlir2/bzl/feature/clone.bzl @@ -5,7 +5,7 @@ load("//antlir/antlir2/bzl:macro_dep.bzl", "antlir2_dep") load("//antlir/antlir2/bzl:types.bzl", "LayerInfo") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load(":dependency_layer_info.bzl", "layer_dep", "layer_dep_analyze") load(":feature_info.bzl", "FeatureAnalysis", "ParseTimeDependency", "ParseTimeFeature") @@ -96,7 +96,7 @@ def clone_analyze( user: str | None, group: str | None, deps: dict[str, Dependency], - plugin: FeaturePluginInfo) -> FeatureAnalysis: + plugin: FeaturePluginInfo | Provider) -> FeatureAnalysis: omit_outer_dir = src_path.endswith("/") pre_existing_dest = dst_path.endswith("/") if omit_outer_dir and not pre_existing_dest: diff --git a/antlir/antlir2/bzl/feature/dot_meta.bzl b/antlir/antlir2/bzl/feature/dot_meta.bzl index 1f2298b876c..02da8c9754b 100644 --- a/antlir/antlir2/bzl/feature/dot_meta.bzl +++ b/antlir/antlir2/bzl/feature/dot_meta.bzl @@ -5,7 +5,7 @@ load("//antlir/antlir2/bzl:build_phase.bzl", "BuildPhase") load("//antlir/antlir2/bzl:macro_dep.bzl", "antlir2_dep") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load(":feature_info.bzl", "FeatureAnalysis", "ParseTimeFeature") def dot_meta( @@ -49,7 +49,7 @@ dot_meta_record = record( def dot_meta_analyze( build_info: [dict[str, typing.Any], None], - plugin: FeaturePluginInfo) -> FeatureAnalysis: + plugin: FeaturePluginInfo | Provider) -> FeatureAnalysis: return FeatureAnalysis( feature_type = "dot_meta", data = dot_meta_record( diff --git a/antlir/antlir2/bzl/feature/extract.bzl b/antlir/antlir2/bzl/feature/extract.bzl index fbf1b61c8d2..1c48f91b10a 100644 --- a/antlir/antlir2/bzl/feature/extract.bzl +++ b/antlir/antlir2/bzl/feature/extract.bzl @@ -28,7 +28,7 @@ load( "//antlir/antlir2/bzl/feature:feature_info.bzl", "AnalyzeFeatureContext", # @unused Used as type ) -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load("//antlir/buck2/bzl:ensure_single_output.bzl", "ensure_single_output") load("//antlir/bzl:constants.bzl", "REPO_CFG") load(":dependency_layer_info.bzl", "layer_dep", "layer_dep_analyze") @@ -98,7 +98,7 @@ extract_record = record( def extract_analyze( ctx: AnalyzeFeatureContext, - plugin: FeaturePluginInfo, + plugin: FeaturePluginInfo | Provider, source: str, deps: dict[str, Dependency], binaries: list[str] | None = None, diff --git a/antlir/antlir2/bzl/feature/feature.bzl b/antlir/antlir2/bzl/feature/feature.bzl index 7b106d1e2e1..149933c5a38 100644 --- a/antlir/antlir2/bzl/feature/feature.bzl +++ b/antlir/antlir2/bzl/feature/feature.bzl @@ -59,7 +59,7 @@ load("//antlir/antlir2/bzl:types.bzl", "FeatureInfo") # @oss-disable # @oss-disable # @oss-disable -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load("//antlir/antlir2/features/test_only_features:trace.bzl", "trace_analyze") load("//antlir/bzl:flatten.bzl", "flatten") load("//antlir/bzl:structs.bzl", "structs") @@ -86,7 +86,7 @@ feature_record = record( feature_type = str, label = TargetLabel, analysis = "FeatureAnalysis", - plugin = FeaturePluginInfo, + plugin = FeaturePluginInfo | Provider, ) def _feature_as_json(feat: feature_record) -> struct: diff --git a/antlir/antlir2/bzl/feature/feature_info.bzl b/antlir/antlir2/bzl/feature/feature_info.bzl index c88c1c4a9c3..b272fe0c25b 100644 --- a/antlir/antlir2/bzl/feature/feature_info.bzl +++ b/antlir/antlir2/bzl/feature/feature_info.bzl @@ -4,7 +4,7 @@ # LICENSE file in the root directory of this source tree. load("//antlir/antlir2/bzl:build_phase.bzl", "BuildPhase") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type # A dependency of a feature that is not yet resolved. This is of very limited # use at parse time, but allows the feature definition to inform the rule what @@ -59,7 +59,7 @@ ParseTimeFeature = record( FeatureAnalysis = record( feature_type = str, # Binary plugin implementation of this feature - plugin = FeaturePluginInfo, + plugin = FeaturePluginInfo | Provider, # Arbitrary feature record type (the antlir2 compiler must be able to # deserialize this) data = typing.Any, @@ -98,7 +98,7 @@ def data_only_feature_analysis_fn( record_type, feature_type: str, build_phase: BuildPhase = BuildPhase("compile")): - def inner(plugin: FeaturePluginInfo, **kwargs) -> FeatureAnalysis: + def inner(plugin: FeaturePluginInfo | Provider, **kwargs) -> FeatureAnalysis: return FeatureAnalysis( feature_type = feature_type, data = record_type(**kwargs), diff --git a/antlir/antlir2/bzl/feature/genrule.bzl b/antlir/antlir2/bzl/feature/genrule.bzl index 6cc89f82428..15c38bbaf9d 100644 --- a/antlir/antlir2/bzl/feature/genrule.bzl +++ b/antlir/antlir2/bzl/feature/genrule.bzl @@ -5,7 +5,7 @@ load("//antlir/antlir2/bzl:build_phase.bzl", "BuildPhase") load("//antlir/antlir2/bzl:macro_dep.bzl", "antlir2_dep") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load(":feature_info.bzl", "FeatureAnalysis", "ParseTimeFeature") def genrule( @@ -44,7 +44,7 @@ def genrule_analyze( bind_repo_ro: bool, mount_platform: bool, args: dict[str, str | ResolvedStringWithMacros], - plugin: FeaturePluginInfo) -> FeatureAnalysis: + plugin: FeaturePluginInfo | Provider) -> FeatureAnalysis: cmd = {int(key.removeprefix("cmd_")): val for key, val in args.items() if key.startswith("cmd_")} cmd = [val for _key, val in sorted(cmd.items())] return FeatureAnalysis( diff --git a/antlir/antlir2/bzl/feature/install.bzl b/antlir/antlir2/bzl/feature/install.bzl index 8e4a4869415..da7fb99a64f 100644 --- a/antlir/antlir2/bzl/feature/install.bzl +++ b/antlir/antlir2/bzl/feature/install.bzl @@ -5,7 +5,7 @@ load("//antlir/antlir2/bzl:debuginfo.bzl", "split_binary_anon") load("//antlir/antlir2/bzl:macro_dep.bzl", "antlir2_dep") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load("//antlir/buck2/bzl:ensure_single_output.bzl", "ensure_single_output") load("//antlir/bzl:constants.bzl", "REPO_CFG") load("//antlir/bzl:sha256.bzl", "sha256_b64") @@ -110,7 +110,7 @@ def get_feature_anaylsis_for_install( user: str, skip_debuginfo_split: bool, text: str | None, - plugin: FeaturePluginInfo): + plugin: FeaturePluginInfo | Provider): binary_info = None required_run_infos = [] required_artifacts = [] @@ -183,7 +183,7 @@ def get_feature_anaylsis_for_install( def install_analyze( ctx: AnalyzeFeatureContext, - plugin: FeaturePluginInfo, + plugin: FeaturePluginInfo | Provider, dst: str, group: str, mode: int | None, diff --git a/antlir/antlir2/bzl/feature/metakv.bzl b/antlir/antlir2/bzl/feature/metakv.bzl index aea1b51dc95..c953fb6c33b 100644 --- a/antlir/antlir2/bzl/feature/metakv.bzl +++ b/antlir/antlir2/bzl/feature/metakv.bzl @@ -4,7 +4,7 @@ # LICENSE file in the root directory of this source tree. load("//antlir/antlir2/bzl:macro_dep.bzl", "antlir2_dep") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load(":feature_info.bzl", "FeatureAnalysis", "ParseTimeFeature") def metakv_store( @@ -81,7 +81,7 @@ metakv_record = record( def metakv_analyze( *, - plugin: FeaturePluginInfo, + plugin: FeaturePluginInfo | Provider, store: dict[str, typing.Any] | None = None, remove: dict[str, typing.Any] | None = None) -> FeatureAnalysis: return FeatureAnalysis( diff --git a/antlir/antlir2/bzl/feature/mount.bzl b/antlir/antlir2/bzl/feature/mount.bzl index e42485d1c87..91f7816efb2 100644 --- a/antlir/antlir2/bzl/feature/mount.bzl +++ b/antlir/antlir2/bzl/feature/mount.bzl @@ -6,7 +6,7 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("//antlir/antlir2/bzl:macro_dep.bzl", "antlir2_dep") load("//antlir/antlir2/bzl:types.bzl", "LayerInfo") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load("//antlir/bzl:target_helpers.bzl", "antlir_dep") load("//antlir/bzl:types.bzl", "types") load(":dependency_layer_info.bzl", "layer_dep", "layer_dep_analyze") @@ -131,7 +131,7 @@ def mount_analyze( is_directory: bool | None, host_source: str | None, _implicit_from_antlir1: bool, - plugin: FeaturePluginInfo, + plugin: FeaturePluginInfo | Provider, deps: dict[str, Dependency] = {}, exec_deps: dict[str, Dependency] = {}) -> list[FeatureAnalysis]: features = [] diff --git a/antlir/antlir2/bzl/feature/rpms.bzl b/antlir/antlir2/bzl/feature/rpms.bzl index e10ee5f1574..0def357fd30 100644 --- a/antlir/antlir2/bzl/feature/rpms.bzl +++ b/antlir/antlir2/bzl/feature/rpms.bzl @@ -5,7 +5,7 @@ load("//antlir/antlir2/bzl:build_phase.bzl", "BuildPhase") load("//antlir/antlir2/bzl:macro_dep.bzl", "antlir2_dep") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load("//antlir/buck2/bzl:ensure_single_output.bzl", "ensure_single_output") load( ":feature_info.bzl", @@ -152,7 +152,7 @@ rpms_record = record( def rpms_analyze( *, ctx: AnalyzeFeatureContext, - plugin: FeaturePluginInfo, + plugin: FeaturePluginInfo | Provider, action: str, subjects: list[str], srcs: dict[str, Artifact] = {}, diff --git a/antlir/antlir2/bzl/feature/tarball.bzl b/antlir/antlir2/bzl/feature/tarball.bzl index 33df7baf7e4..333d3649546 100644 --- a/antlir/antlir2/bzl/feature/tarball.bzl +++ b/antlir/antlir2/bzl/feature/tarball.bzl @@ -4,7 +4,7 @@ # LICENSE file in the root directory of this source tree. load("//antlir/antlir2/bzl:macro_dep.bzl", "antlir2_dep") -load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") +load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo") # @unused Used as type load("//antlir/buck2/bzl:ensure_single_output.bzl", "ensure_single_output") load( ":feature_info.bzl", @@ -46,7 +46,7 @@ def tarball_analyze( user: str, group: str, srcs: dict[str, Artifact], - plugin: FeaturePluginInfo) -> FeatureAnalysis: + plugin: FeaturePluginInfo | Provider) -> FeatureAnalysis: tarball = srcs["source"] if user != "root" or group != "root":