diff --git a/shim/PACKAGE b/shim/PACKAGE index ea35fecd..782e6f91 100644 --- a/shim/PACKAGE +++ b/shim/PACKAGE @@ -5,8 +5,11 @@ # License, Version 2.0 found in the LICENSE-APACHE file in the root directory # of this source tree. -load(":cfg.bzl", "get_shim_modifiers") +load(":cfg.bzl", "SHIM_ALIASES", "set_cfg_constructor", "get_shim_modifiers") load("@prelude//cfg/modifier:set_cfg_modifiers.bzl", "set_cfg_modifiers") +# Activate cfg modifiers from CLI / PACKAGE / targets +set_cfg_constructor(SHIM_ALIASES) + modifiers = get_shim_modifiers() set_cfg_modifiers(modifiers) diff --git a/shim/cfg.bzl b/shim/cfg.bzl index 9c630dfa..9b63ae11 100644 --- a/shim/cfg.bzl +++ b/shim/cfg.bzl @@ -13,10 +13,10 @@ SHIM_ALIASES = { "ubuntu": "shim//os/linux/distro/constraints:ubuntu", } -CFG_CONSTRUCTOR_INITIALIZED_KEY = "buck.cfg_constructor_initialized" - def set_cfg_constructor(aliases = dict()): - if not read_parent_package_value(CFG_CONSTRUCTOR_INITIALIZED_KEY): + project_root_cell = read_root_config("cell_aliases", "root") + current_root_cell = read_config("cell_aliases", "root") + if project_root_cell == current_root_cell: native.set_cfg_constructor( stage0 = cfg_constructor_pre_constraint_analysis, stage1 = cfg_constructor_post_constraint_analysis, @@ -25,8 +25,6 @@ def set_cfg_constructor(aliases = dict()): extra_data = struct(), ) - write_package_value(CFG_CONSTRUCTOR_INITIALIZED_KEY, True) - def get_shim_modifiers(): modifiers = []