fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
92834930
rust-analyzer
1"""Helpers for testing `rust_toolchain.target_json`""" 2 3def _rules_rust_toolchain_test_target_json_repository_impl ( repository_ctx ): 4target_json_path = repository_ctx . path ( repository_ctx . attr . target_json ) 5target_json_content = repository_ctx . read ( target_json_path ) 6target_json = json . decode ( target_json_content ) 7 8repository_ctx . file ( "BUILD.bazel" , """exports_files(["defs.bzl"])""" ) 9repository_ctx . file ( "defs.bzl" , "TARGET_JSON = {}" . format ( target_json )) 10repository_ctx . file ( "WORKSPACE.bazel" , """workspace(name = "{}")""" . format ( 11repository_ctx . name , 12)) 13 14rules_rust_toolchain_test_target_json_repository = repository_rule ( 15doc = ( 16"A repository rule used for converting json files to starlark. This " + 17"rule acts as an example of how users can use json files to represent " + 18"custom rust platforms." 19), 20implementation = _rules_rust_toolchain_test_target_json_repository_impl , 21attrs = { 22"target_json" : attr . label ( 23doc = "A custom target specification. For more details see: https://doc.rust-lang.org/rustc/targets/custom.html" , 24mandatory = True , 25), 26}, 27)