Skip to content

Commit

Permalink
[antlir/metalos][oss] fixups to get metalos/bootloader evaluating
Browse files Browse the repository at this point in the history
Summary:
X-link: facebookincubator/metalos#10

We don't have any kernels in OSS yet, and even the internal code is a bit of a
mess. This diff fixes up enough of the macro layer so that the BUCK file for
`metalos/bootloader` at least evaluates.

Test Plan:
```
❯ arc skycastle run //tools/skycastle/workflows2/metalos/oss/metalos-oss-tests.sky:test_target_graph
```
https://www.internalfb.com/sandcastle/workflow/2675138178661370002

Reviewed By: epilatow

Differential Revision: D59073165

fbshipit-source-id: 2df0aeb7b790dd96478612b9975415e4a1ef36fa
  • Loading branch information
vmagro authored and facebook-github-bot committed Jun 27, 2024
1 parent 49a29c6 commit 947e11f
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 21 deletions.
2 changes: 1 addition & 1 deletion antlir/antlir2/antlir2_vm/bzl/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ load("//antlir/antlir2/bzl:types.bzl", "LayerInfo")
load("//antlir/antlir2/testing:image_test.bzl", "HIDE_TEST_LABELS")
load("//antlir/bzl:build_defs.bzl", "add_test_framework_label", "buck_sh_test", "cpp_unittest", "python_unittest", "rust_unittest")

load("//antlir/bzl:oss_shim.bzl", "special_tags") # @oss-enable
load("//antlir/bzl:oss_shim.bzl", "NAMING_ROLLOUT_LABEL", "special_tags", "fully_qualified_test_name_rollout") # @oss-enable
load(":types.bzl", "VMHostInfo")

def _impl(ctx: AnalysisContext) -> list[Provider]:
Expand Down
4 changes: 2 additions & 2 deletions antlir/bzl/build_defs_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ def _antlir_buck_env():
return "buck2"

def _python_unittest(*args, **kwargs):
main_module = kwargs.get("main_module")

env = kwargs.get("env", {})
env["ANTLIR_BUCK"] = _antlir_buck_env()
kwargs["env"] = env
Expand All @@ -191,13 +189,15 @@ def _python_unittest(*args, **kwargs):
_wrap_internal(native.python_test, args, kwargs)

def _rust_unittest(*args, **kwargs):
kwargs.pop("nodefaultlibs", None)
_wrap_internal(native.rust_test, args, kwargs)

def _rust_binary(*, name: str, **kwargs):
unittests = kwargs.pop("unittests", True)
if unittests:
_rust_unittest(name = name + "-unittests", **kwargs)
kwargs["name"] = name
kwargs.pop("nodefaultlibs", None)
_wrap_internal(native.rust_binary, [], kwargs)

def _rust_library(*, name: str, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion antlir/bzl/kernel_shim.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

load("//third-party/fedora33/kernel:kernels.bzl", real_kernels = "kernels")
load("//third-party/kernel:kernels.bzl", real_kernels = "kernels")

kernels = real_kernels
26 changes: 13 additions & 13 deletions antlir/bzl/linux/release.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,23 @@ def _release_file_macro(
name: str,
**kwargs):
kwargs.setdefault("os_id", selects.or_({
("//antlir/antlir2/os:centos8", "//antlir/antlir2/os:centos9"): "centos",
"//antlir/antlir2/os:eln": "fedora",
("antlir//antlir/antlir2/os:centos8", "antlir//antlir/antlir2/os:centos9"): "centos",
"antlir//antlir/antlir2/os:eln": "fedora",
}))
kwargs.setdefault("os_name", selects.or_({
("//antlir/antlir2/os:centos8", "//antlir/antlir2/os:centos9"): "CentOS Stream",
"//antlir/antlir2/os:eln": "Fedora Linux",
("antlir//antlir/antlir2/os:centos8", "antlir//antlir/antlir2/os:centos9"): "CentOS Stream",
"antlir//antlir/antlir2/os:eln": "Fedora Linux",
}))
eln_version = "40"
kwargs.setdefault("os_version", select({
"//antlir/antlir2/os:centos8": "8",
"//antlir/antlir2/os:centos9": "9",
"//antlir/antlir2/os:eln": eln_version,
"antlir//antlir/antlir2/os:centos8": "8",
"antlir//antlir/antlir2/os:centos9": "9",
"antlir//antlir/antlir2/os:eln": eln_version,
}))
kwargs.setdefault("os_version_id", select({
"//antlir/antlir2/os:centos8": "8",
"//antlir/antlir2/os:centos9": "9",
"//antlir/antlir2/os:eln": eln_version,
"antlir//antlir/antlir2/os:centos8": "8",
"antlir//antlir/antlir2/os:centos9": "9",
"antlir//antlir/antlir2/os:eln": eln_version,
}))

_release_file(
Expand Down Expand Up @@ -238,9 +238,9 @@ def _install(
vcs_rev = vcs_rev or native.read_config("build_info", "revision", "local"),
vcs_rev_time = vcs_rev_time or int(native.read_config("build_info", "revision_epochtime", 0)),
compatible_with = [
"//antlir/antlir2/os:centos8",
"//antlir/antlir2/os:centos9",
"//antlir/antlir2/os:eln",
"antlir//antlir/antlir2/os:centos8",
"antlir//antlir/antlir2/os:centos9",
"antlir//antlir/antlir2/os:eln",
],
visibility = ["PUBLIC"],
**kwargs
Expand Down
7 changes: 7 additions & 0 deletions antlir/bzl/oss_shim.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ def ret_empty_list(*args, **kwargs):
return []

empty_dict = {}
empty_list = []

none = None

special_tags = struct(
run_as_bundle = "OSS_NO_OP",
enable_artifact_reporting = "OSS_NO_OP",
)

fully_qualified_test_name_rollout = struct(
use_fully_qualified_name = lambda: False,
)

NAMING_ROLLOUT_LABEL = "OSS_NO_OP"
6 changes: 3 additions & 3 deletions antlir/bzl/systemd.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _enable_impl(
# systemctl enable [email protected] creates a
# getty.target.wants/[email protected] link to [email protected].
name_prefix, suffix = paths.split_extension(unit)
unit_name, sep, instance_name = name_prefix.rpartition("@")
unit_name, sep, _instance_name = name_prefix.rpartition("@")
link_target = unit_name + sep + suffix
else:
fail("unit contains too many @ characters: " + unit)
Expand Down Expand Up @@ -398,11 +398,11 @@ def _mount_unit_file(name, mount):
return shape.render_template(
name = name,
instance = mount,
template = "//antlir/bzl/linux/systemd:mount",
template = "antlir//antlir/bzl/linux/systemd:mount",
)

def _skip_unit(unit, force = False):
return _install_dropin("//antlir/bzl:99-skip-unit.conf", unit, force = force)
return _install_dropin("antlir//antlir/bzl:99-skip-unit.conf", unit, force = force)

def _unskip_unit(unit):
return _remove_dropin(unit, "99-skip-unit.conf")
Expand Down
13 changes: 13 additions & 0 deletions third-party/kernel/kernels.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def _get(kernel_or_alias, arch = "x86_64"):
print("TODO: kernels.get({}, {})".format(kernel_or_alias, arch))

def _selection(name, query, oncall):
print("TODO: kernels.selection({}, {}, {})".format(name, query, oncall))

kernels = struct(
get = _get,
select = struct(
selection = _selection,
),
all_kernels = [],
)
2 changes: 1 addition & 1 deletion third-party/rust/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ load(":defs.bzl", "third_party_rust_cxx_library")
git_fetch(
name = "fbthrift-d83134f25cdb7b98.git",
repo = "https://github.com/facebook/fbthrift.git",
rev = "86b71e6975c1db14ac41fa8043c394b46c3f8691",
rev = "cf71641e7fd6dbcba3f4819f26eb2a765c970f90",
visibility = [],
)

Expand Down

0 comments on commit 947e11f

Please sign in to comment.