Skip to content

Commit

Permalink
Revert D49553996: [antlir2][buck] new configuration settings for flav…
Browse files Browse the repository at this point in the history
…or/os

Test Plan: revert-hammer

Differential Revision:
D49553996

Original commit changeset: c8d219a3e789

Original Phabricator Diff: D49553996

fbshipit-source-id: 96cd35f84ccd72530b320dbab22994cf6eff8e1e
  • Loading branch information
Joshua Selbo authored and facebook-github-bot committed Oct 20, 2023
1 parent b93764a commit 12cf5db
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 370 deletions.
71 changes: 4 additions & 67 deletions antlir/antlir2/bzl/image/cfg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,8 @@ Currently this supports reconfiguring the target cpu architecture.
"""

load("//antlir/antlir2/bzl/image/facebook:fb_cfg.bzl", "fbcode_platform_refs", "transition_fbcode_platform")
load("//antlir/antlir2/os:defs.bzl", "OsVersionInfo")
load("//antlir/bzl:build_defs.bzl", "is_facebook")

def cfg_attrs():
return {
"default_os": attrs.option(attrs.string(), default = None, doc = """
Reconfigure the layer when no antlir2 os has been set yet, so that
each intermediate layer can be passed to `buck build` and give a
reasonable default.
For more details, see:
https://www.internalfb.com/intern/staticdocs/antlir2/docs/recipes/multi-os-images/
"""),
"target_arch": attrs.option(
attrs.enum(["x86_64", "aarch64"]),
default = None,
doc = "Build this image for a specific target arch without using `buck -c`",
),
}

def _impl(platform: PlatformInfo, refs: struct, attrs: struct) -> PlatformInfo:
constraints = platform.configuration.constraints

Expand All @@ -40,26 +23,6 @@ def _impl(platform: PlatformInfo, refs: struct, attrs: struct) -> PlatformInfo:
if is_facebook:
constraints = transition_fbcode_platform(refs, attrs, constraints)

if attrs.default_os:
os = getattr(refs, "os." + attrs.default_os)[OsVersionInfo]
os_constraint = os.constraint[ConstraintValueInfo]
family = os.family[ConstraintValueInfo]

# The rule transition to set the default antlir2 OS only happens if the
# target has not been configured for a specific OS yet. This way the dep
# transition takes precedence - in other words, the default_os attribute of
# the leaf image being built is always respected and reconfigures all layers
# along the parent_layer chain
if os_constraint.setting.label not in constraints:
constraints[os_constraint.setting.label] = os_constraint
constraints[family.setting.label] = family

# If a build appliance is being built, we must remove the OS configuration
# constraint to avoid circular dependencies.
if attrs.antlir_internal_build_appliance:
constraints.pop(refs.os_constraint[ConstraintSettingInfo].label, None)
constraints.pop(refs.os_family_constraint[ConstraintSettingInfo].label, None)

label = platform.label

# if we made any changes, change the label
Expand All @@ -79,39 +42,13 @@ layer_cfg = transition(
refs = {
"arch.aarch64": "ovr_config//cpu/constraints:arm64",
"arch.x86_64": "ovr_config//cpu/constraints:x86_64",
"os.centos8": "//antlir/antlir2/os:centos8",
"os.centos9": "//antlir/antlir2/os:centos9",
"os.eln": "//antlir/antlir2/os:eln",
"os.none": "//antlir/antlir2/os:none",
"os_constraint": "//antlir/antlir2/os:os",
"os_family_constraint": "//antlir/antlir2/os/family:family",
} | (
# @oss-disable
# @oss-enable {}
),
attrs = cfg_attrs().keys() + [
# Build appliances are very low level and cannot depend on a flavor, so
# they are just not transitioned to an os configuration
"antlir_internal_build_appliance",
attrs = [
# target_arch on image.layer is read to reconfigure for the target cpu
# arch without having to use -c fbcode.arch
"target_arch",
],
)

def _remove_os_impl(platform: PlatformInfo, refs: struct) -> PlatformInfo:
constraints = platform.configuration.constraints
constraints.pop(refs.os_constraint[ConstraintSettingInfo].label, None)
constraints.pop(refs.os_family_constraint[ConstraintSettingInfo].label, None)
return PlatformInfo(
label = platform.label,
configuration = ConfigurationInfo(
constraints = constraints,
values = platform.configuration.values,
),
)

remove_os_constraint = transition(
impl = _remove_os_impl,
refs = {
"os_constraint": "//antlir/antlir2/os:os",
"os_family_constraint": "//antlir/antlir2/os/family:family",
},
)
21 changes: 7 additions & 14 deletions antlir/antlir2/bzl/image/layer.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ load(
)
# @oss-disable
# @oss-disable
load("//antlir/antlir2/os:package.bzl", "get_default_os_for_package", "should_all_images_in_package_use_default_os")
load("//antlir/bzl:build_defs.bzl", "alias", "is_facebook")
load("//antlir/bzl:constants.bzl", "REPO_CFG")
load("//antlir/bzl:types.bzl", "types")
load("//antlir/rpm/dnf2buck:repo.bzl", "RepoInfo", "RepoSetInfo")
# @oss-disable
load("//antlir/bzl/build_defs.bzl", "config", "get_visibility")
load(":cfg.bzl", "cfg_attrs", "layer_cfg", "remove_os_constraint")
load(":cfg.bzl", "layer_cfg")
load(":depgraph.bzl", "build_depgraph")
load(":mounts.bzl", "all_mounts", "container_mount_args")

Expand Down Expand Up @@ -452,7 +451,7 @@ _layer_attrs = {
"antlir2": attrs.exec_dep(default = "//antlir/antlir2/antlir2:antlir2"),
"antlir_internal_build_appliance": attrs.bool(default = False, doc = "mark if this image is a build appliance and is allowed to not have a flavor"),
"build_appliance": attrs.option(
attrs.transition_dep(providers = [LayerInfo], cfg = remove_os_constraint),
attrs.dep(providers = [LayerInfo]),
default = None,
),
"default_mountpoint": attrs.option(attrs.string(), default = None),
Expand Down Expand Up @@ -498,6 +497,11 @@ _layer_attrs = {
attrs.dep(providers = [LayerInfo]),
default = None,
),
"target_arch": attrs.option(
attrs.enum(["x86_64", "aarch64"]),
default = None,
doc = "Build this image for a specific target arch",
),
"_implicit_image_test": attrs.option(
attrs.exec_dep(providers = [ExternalRunnerTestInfo]),
default = None,
Expand All @@ -511,8 +515,6 @@ _layer_attrs = {
)),
}

_layer_attrs.update(cfg_attrs())

_layer_attrs.update(
{
"_feature_" + key: val
Expand All @@ -535,9 +537,6 @@ def layer(
# by a type hint inside feature.bzl. Feature targets or
# InlineFeatureInfo providers are accepted, at any level of nesting
features = [],
default_os: str | None = None,
# TODO: remove this flag when all images are using this new mechanism
use_default_os_from_package: bool | None = None,
# We'll implicitly forward some users to antlir2, so any hacks for them
# should be confined behind this flag
implicit_antlir2: bool = False,
Expand All @@ -552,11 +551,6 @@ def layer(
flavor = kwargs.pop("flavor", None)
kwargs["flavor"] = compat.from_antlir1_flavor(flavor) if flavor else None

if use_default_os_from_package == None:
use_default_os_from_package = should_all_images_in_package_use_default_os()
if use_default_os_from_package:
default_os = default_os or get_default_os_for_package()

kwargs.update({"_feature_" + key: val for key, val in feature_attrs(features).items()})

if is_facebook:
Expand Down Expand Up @@ -585,7 +579,6 @@ def layer(

return layer_rule(
name = name,
default_os = default_os,
visibility = get_visibility(visibility),
_implicit_image_test = "//antlir/antlir2/testing/implicit_image_test:implicit_image_test",
**kwargs
Expand Down
27 changes: 0 additions & 27 deletions antlir/antlir2/os/BUCK

This file was deleted.

53 changes: 0 additions & 53 deletions antlir/antlir2/os/defs.bzl

This file was deleted.

25 changes: 0 additions & 25 deletions antlir/antlir2/os/family/BUCK

This file was deleted.

26 changes: 0 additions & 26 deletions antlir/antlir2/os/package.bzl

This file was deleted.

74 changes: 0 additions & 74 deletions antlir/antlir2/test_images/cfg/os/BUCK

This file was deleted.

16 changes: 0 additions & 16 deletions antlir/antlir2/test_images/cfg/os/defs.bzl

This file was deleted.

Loading

0 comments on commit 12cf5db

Please sign in to comment.