Vendor dependencies

Let's see how I like this workflow.
This commit is contained in:
John Doty 2022-12-19 08:27:18 -08:00
parent 34d1830413
commit 9c435dc440
7500 changed files with 1665121 additions and 99 deletions

View file

@ -0,0 +1,11 @@
# Used by open source projects to provide a simple platform setting
load(":defs.bzl", "execution_platform")
execution_platform(
name = "default",
cpu_configuration = "//cpu:arm64" if host_info().arch.is_aarch64 else "//cpu:x86_64",
os_configuration =
"//os:macos" if host_info().os.is_macos else "//os:windows" if host_info().os.is_windows else "//os:linux",
use_windows_path_separators = host_info().os.is_windows,
)

View file

@ -0,0 +1,39 @@
# 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.
def _execution_platform_impl(ctx: "context") -> ["provider"]:
constraints = dict()
constraints.update(ctx.attrs.cpu_configuration[ConfigurationInfo].constraints)
constraints.update(ctx.attrs.os_configuration[ConfigurationInfo].constraints)
cfg = ConfigurationInfo(constraints = constraints, values = {})
name = ctx.label.raw_target()
platform = ExecutionPlatformInfo(
label = name,
configuration = cfg,
executor_config = CommandExecutorConfig(
local_enabled = True,
remote_enabled = False,
use_windows_path_separators = ctx.attrs.use_windows_path_separators,
),
)
return [
DefaultInfo(),
platform,
PlatformInfo(label = str(name), configuration = cfg),
ExecutionPlatformRegistrationInfo(platforms = [platform]),
]
execution_platform = rule(
impl = _execution_platform_impl,
attrs = {
"cpu_configuration": attrs.dep(providers = [ConfigurationInfo]),
"os_configuration": attrs.dep(providers = [ConfigurationInfo]),
"use_windows_path_separators": attrs.bool(),
},
)