| Build both objects under buck2, against the BuildBuddy cache 600f207 nandi 19d 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 | # Cache only, never remote execution. The toolchain in toolchains/BUCK points |
| 9 | # at absolute paths inside this checkout (see the note there about os.execl), |
| 10 | # which no RE worker will have. `remote_enabled = False` is the switch that |
| 11 | # says so; the cache is read and written over the network regardless, and |
| 12 | # every action still runs locally. |
| 13 | load("@prelude//cfg/exec_platform:marker.bzl", "get_exec_platform_marker") |
| 14 | |
| 15 | def _execution_platform_impl(ctx: AnalysisContext) -> list[Provider]: |
| 16 | constraints = dict() |
| 17 | constraints.update(ctx.attrs.cpu_configuration[ConfigurationInfo].constraints) |
| 18 | constraints.update(ctx.attrs.os_configuration[ConfigurationInfo].constraints) |
| 19 | cfg = ConfigurationInfo(constraints = constraints, values = {}) |
| 20 | |
| 21 | name = ctx.label.raw_target() |
| 22 | platform = ExecutionPlatformInfo( |
| 23 | label = name, |
| 24 | configuration = cfg, |
| 25 | executor_config = CommandExecutorConfig( |
| 26 | local_enabled = True, |
| 27 | remote_enabled = False, |
| 28 | remote_cache_enabled = True, |
| 29 | allow_cache_uploads = True, |
| 30 | use_windows_path_separators = ctx.attrs.use_windows_path_separators, |
| 31 | ), |
| 32 | ) |
| 33 | |
| 34 | return [ |
| 35 | DefaultInfo(), |
| 36 | platform, |
| 37 | PlatformInfo(label = str(name), configuration = cfg), |
| 38 | ExecutionPlatformRegistrationInfo( |
| 39 | platforms = [platform], |
| 40 | exec_marker_constraint = get_exec_platform_marker(), |
| 41 | ), |
| 42 | ] |
| 43 | |
| 44 | execution_platform = rule( |
| 45 | impl = _execution_platform_impl, |
| 46 | attrs = { |
| 47 | "cpu_configuration": attrs.dep(providers = [ConfigurationInfo]), |
| 48 | "os_configuration": attrs.dep(providers = [ConfigurationInfo]), |
| 49 | "use_windows_path_separators": attrs.bool(), |
| 50 | }, |
| 51 | ) |