|
| 1 | +# The custom platform for SI. This is taken from the prelude, but includes our customizations for |
| 2 | +# rust build flags. |
| 3 | +# |
| 4 | +# Essentially, we should be adding any custom configuration into root//config, and then plumbing it |
| 5 | +# through the execution_platform defined below. |
| 6 | +# |
| 7 | +# To actually add new configuration, you'll extend the relevant python function to output the |
| 8 | +# correct configuration info, and then you can use it in a select() statement at will. |
| 9 | + |
| 10 | +load(":defs.bzl", "execution_platform", "host_configuration") |
| 11 | + |
| 12 | +prelude = native |
| 13 | + |
| 14 | +_rust_build_mode = read_root_config("rustc", "mode", "build_debug") |
| 15 | +_rust_build_mode_constraint = "root//config:" + _rust_build_mode |
| 16 | + |
| 17 | +execution_platform( |
| 18 | + name = "default", |
| 19 | + cpu_configuration = host_configuration.cpu, |
| 20 | + os_configuration = host_configuration.os, |
| 21 | + rust_build_mode = _rust_build_mode_constraint, |
| 22 | + use_windows_path_separators = host_info().os.is_windows, |
| 23 | +) |
| 24 | + |
| 25 | +prelude.constraint_setting( |
| 26 | + name = "runs_remote", |
| 27 | +) |
| 28 | + |
| 29 | +prelude.constraint_value( |
| 30 | + name = "may_run_remote", |
| 31 | + constraint_setting = ":runs_remote", |
| 32 | + visibility = ["PUBLIC"], |
| 33 | +) |
| 34 | + |
| 35 | +prelude.constraint_setting( |
| 36 | + name = "runs_local", |
| 37 | + visibility = ["PUBLIC"], |
| 38 | +) |
| 39 | + |
| 40 | +prelude.constraint_value( |
| 41 | + name = "may_run_local", |
| 42 | + constraint_setting = ":runs_local", |
| 43 | + visibility = ["PUBLIC"], |
| 44 | +) |
| 45 | + |
| 46 | +prelude.constraint_setting( |
| 47 | + name = "runs_only", |
| 48 | +) |
| 49 | + |
| 50 | +prelude.constraint_value( |
| 51 | + name = "runs_only_local", |
| 52 | + constraint_setting = ":runs_only", |
| 53 | + visibility = ["PUBLIC"], |
| 54 | +) |
| 55 | + |
| 56 | +prelude.constraint_value( |
| 57 | + name = "runs_only_remote", |
| 58 | + constraint_setting = ":runs_only", |
| 59 | + visibility = ["PUBLIC"], |
| 60 | +) |
| 61 | + |
| 62 | +prelude.constraint_setting( |
| 63 | + name = "fat_platform_marker", |
| 64 | +) |
| 65 | + |
| 66 | +prelude.constraint_value( |
| 67 | + name = "fat_platform_enabled", |
| 68 | + constraint_setting = ":fat_platform_marker", |
| 69 | + visibility = ["PUBLIC"], |
| 70 | +) |
| 71 | + |
| 72 | +# This is mostly here for a rule type to add a dependency on it to mark all |
| 73 | +# instances of that rule type as incompatible with a fat platform. Ideally, |
| 74 | +# toolchains could affect the target compatibility of their users directly but |
| 75 | +# toolchains are currently all exec deps and so cannot do that. We'd like |
| 76 | +# buck2 to support a form of dep that inherited its users execution platform |
| 77 | +# so that toolchains could basically get visibility and affect both target and |
| 78 | +# execution configuration, but that's not implemented yet. |
| 79 | +export_file( |
| 80 | + name = "fat_platform_incompatible", |
| 81 | + # @oss-disable: src = "TARGETS.v2", |
| 82 | + src = "BUCK", # @oss-enable |
| 83 | + target_compatible_with = select({ |
| 84 | + ":fat_platform_enabled": ["config//:none"], |
| 85 | + "DEFAULT": [], |
| 86 | + }), |
| 87 | + visibility = ["PUBLIC"], |
| 88 | +) |
0 commit comments