Skip to content

Commit

Permalink
[antlir2][bzl] plugins are just provider when used cross-cell
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vmagro authored and facebook-github-bot committed Nov 1, 2023
1 parent 49f6ca5 commit 7bb401c
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/clone.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/dot_meta.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/extract.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/feature.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions antlir/antlir2/bzl/feature/feature_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/genrule.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions antlir/antlir2/bzl/feature/install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/metakv.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/mount.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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 = []
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/rpms.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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] = {},
Expand Down
4 changes: 2 additions & 2 deletions antlir/antlir2/bzl/feature/tarball.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 7bb401c

Please sign in to comment.