-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document mixed/heterogeneous builds across different operating systems #487
Comments
genrule(
name = "hello_from_windows",
out = "hello_from_windows.txt",
cmd = "echo Hello from Windows!!! >> $OUT & ver >> $OUT",
exec_compatible_with = ["config//os:windows"],
)
genrule(
name = "from_linux",
out = "hello_linux.txt",
cmd = "cat $(location :hello_from_windows) >> $OUT; uname -svr >> $OUT;",
exec_compatible_with = ["config//os:linux"],
) def _platforms(ctx: AnalysisContext) -> list[Provider]:
name = ctx.label.raw_target()
constraints_windows = dict()
constraints_windows.update(ctx.attrs.os_configuration_windows[ConfigurationInfo].constraints)
platform_windows = ExecutionPlatformInfo(
label = name,
configuration = ConfigurationInfo(
constraints = constraints_windows,
values = {},
),
executor_config = CommandExecutorConfig(
local_enabled = host_info().os.is_windows,
remote_enabled = True,
use_limited_hybrid = True,
remote_execution_properties = {
"OSFamily": "Windows",
},
remote_execution_use_case = "buck2-default",
use_windows_path_separators = True,
),
)
constraints2 = dict()
constraints2.update(ctx.attrs.os_configuration_linux[ConfigurationInfo].constraints)
platform1 = ExecutionPlatformInfo(
label = name,
configuration = ConfigurationInfo(
constraints = constraints2,
values = {},
),
executor_config = CommandExecutorConfig(
local_enabled = host_info().os.is_linux,
remote_enabled = True,
use_limited_hybrid = True,
remote_execution_properties = {
"OSFamily": "Linux",
},
remote_execution_use_case = "buck2-default",
use_windows_path_separators = False,
),
)
return [
DefaultInfo(),
ExecutionPlatformRegistrationInfo(platforms = [platform_windows, platform1]),
]
platforms = rule(
impl = _platforms,
attrs = {
"use_windows_path_separators": attrs.bool(default = False),
"os_configuration_windows": attrs.dep(
providers = [ConfigurationInfo],
default = "config//os:windows",
),
"os_configuration_linux": attrs.dep(
providers = [ConfigurationInfo],
default = "config//os:linux",
),
},
) |
So this does work and it is a feature that bazel does not have today. I am keeping this issue open for now because this feature deserves a bit more documentation / examples:
|
CC @lmvasquezg who is looking at documentation |
Is it possible to have a BUILD step automatically run on a remote host if the local OS is not target_compatible without having to use
--fake-host
?E.g I want to make something like this to work:
This is similar to the following bazel issues:
The text was updated successfully, but these errors were encountered: