39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
# 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(),
|
|
},
|
|
)
|