| Build the APK with buck2, from pins rather than from a second checkout a71ef8f nandi 18d ago | 1 | # The stock prelude//platforms:default with its cache switches flipped on. |
| 2 | # |
| 3 | # The prelude's own `execution_platform` rule is static Starlark — there is no |
| 4 | # buckconfig key that turns caching on for it — so the rule is copied here and |
| 5 | # its CommandExecutorConfig changed. Everything else mirrors the original |
| 6 | # exactly, so this platform stays configuration-identical to the default. |
| 7 | # |
| 8 | # Whether actions may run on a worker is an attribute now rather than a |
| 9 | # constant. It was false because it had to be: the toolchain named absolute |
| 10 | # paths inside this checkout, which no worker would have. Both compilers are |
| 11 | # dependencies now, so there is something to ship. |
| 12 | load("@prelude//cfg/exec_platform:marker.bzl", "get_exec_platform_marker") |
| 13 | |
| 14 | def _execution_platform_impl(ctx: AnalysisContext) -> list[Provider]: |
| 15 | constraints = dict() |
| 16 | constraints.update(ctx.attrs.cpu_configuration[ConfigurationInfo].constraints) |
| 17 | constraints.update(ctx.attrs.os_configuration[ConfigurationInfo].constraints) |
| 18 | cfg = ConfigurationInfo(constraints = constraints, values = {}) |
| 19 | |
| 20 | name = ctx.label.raw_target() |
| 21 | platform = ExecutionPlatformInfo( |
| 22 | label = name, |
| 23 | configuration = cfg, |
| 24 | executor_config = CommandExecutorConfig( |
| 25 | local_enabled = ctx.attrs.local_enabled, |
| 26 | remote_enabled = ctx.attrs.remote_enabled, |
| 27 | remote_cache_enabled = True, |
| 28 | allow_cache_uploads = True, |
| 29 | remote_execution_properties = ctx.attrs.remote_execution_properties, |
| 30 | remote_execution_use_case = "buck2-default", |
| 31 | use_windows_path_separators = ctx.attrs.use_windows_path_separators, |
| 32 | ), |
| 33 | ) |
| 34 | |
| 35 | return [ |
| 36 | DefaultInfo(), |
| 37 | platform, |
| 38 | PlatformInfo(label = str(name), configuration = cfg), |
| 39 | ExecutionPlatformRegistrationInfo( |
| 40 | platforms = [platform], |
| 41 | exec_marker_constraint = get_exec_platform_marker(), |
| 42 | ), |
| 43 | ] |
| 44 | |
| 45 | execution_platform = rule( |
| 46 | impl = _execution_platform_impl, |
| 47 | attrs = { |
| 48 | "cpu_configuration": attrs.dep(providers = [ConfigurationInfo]), |
| 49 | "local_enabled": attrs.bool(default = True), |
| 50 | "remote_enabled": attrs.bool(default = False), |
| 51 | "remote_execution_properties": attrs.dict(attrs.string(), attrs.string(), default = {}), |
| 52 | "os_configuration": attrs.dep(providers = [ConfigurationInfo]), |
| 53 | "use_windows_path_separators": attrs.bool(), |
| 54 | }, |
| 55 | ) |