fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
9adfdca9
cleanup
1"""Internal transition implementations for core Rust rules""" 2 3load ( "//rust:defs.bzl" , "rust_common" ) 4 5def _import_macro_dep_bootstrap_transition ( _settings , _attr ): 6"""The implementation of the `import_macro_dep_bootstrap_transition` transition. 7 8This transition modifies the config to start using the fake macro 9implementation, so that the macro itself can be bootstrapped without 10creating a dependency cycle, even while every Rust target has an implicit 11dependency on the "import" macro (either real or fake). 12 13Args: 14_settings (dict): a dict {String:Object} of all settings declared in the 15inputs parameter to `transition()`. 16_attr (dict): A dict of attributes and values of the rule to which the 17transition is attached. 18 19Returns: 20dict: A dict of new build settings values to apply. 21""" 22return { "@rules_rust//rust/settings:use_real_import_macro" : False } 23 24import_macro_dep_bootstrap_transition = transition ( 25implementation = _import_macro_dep_bootstrap_transition , 26inputs = [], 27outputs = [ "@rules_rust//rust/settings:use_real_import_macro" ], 28) 29 30def _alias_with_import_macro_bootstrapping_mode_impl ( ctx ): 31actual = ctx . attr . actual [ 0 ] 32return [ actual [ rust_common . crate_info ], actual [ rust_common . dep_info ]] 33 34alias_with_import_macro_bootstrapping_mode = rule ( 35implementation = _alias_with_import_macro_bootstrapping_mode_impl , 36doc = "Alias-like rule to build the `actual` with `use_real_import_macro` setting disabled. Not to be used outside of the import macro bootstrap." , 37attrs = { 38# Using `actual` so tooling such as rust analyzer aspect traverses the target. 39"actual" : attr . label ( 40doc = "The target this alias refers to." , 41cfg = import_macro_dep_bootstrap_transition , 42mandatory = True , 43), 44"_allowlist_function_transition" : attr . label ( 45default = Label ( "//tools/allowlists/function_transition_allowlist" ), 46), 47}, 48)