1############################################################################### 2# @generated 3# DO NOT MODIFY: This file is auto-generated by a crate_universe tool. To 4# regenerate this file, run the following: 5# 6# bazel run @//test/3rdparty:crates_vendor 7############################################################################### 8""" 9# `crates_repository` API 10 11- [aliases](#aliases) 12- [crate_deps](#crate_deps) 13- [all_crate_deps](#all_crate_deps) 14- [crate_repositories](#crate_repositories) 15 16""" 17 18load("@bazel_skylib//lib:selects.bzl", "selects") 19load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 20load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 21 22############################################################################### 23# MACROS API 24############################################################################### 25 26# An identifier that represent common dependencies (unconditional). 27_COMMON_CONDITION = "" 28 29def _flatten_dependency_maps(all_dependency_maps): 30 """Flatten a list of dependency maps into one dictionary. 31 32 Dependency maps have the following structure: 33 34 ```python 35 DEPENDENCIES_MAP = { 36 # The first key in the map is a Bazel package 37 # name of the workspace this file is defined in. 38 "workspace_member_package": { 39 40 # Not all dependencies are supported for all platforms. 41 # the condition key is the condition required to be true 42 # on the host platform. 43 "condition": { 44 45 # An alias to a crate target. # The label of the crate target the 46 # Aliases are only crate names. # package name refers to. 47 "package_name": "@full//:label", 48 } 49 } 50 } 51 ``` 52 53 Args: 54 all_dependency_maps (list): A list of dicts as described above 55 56 Returns: 57 dict: A dictionary as described above 58 """ 59 dependencies = {} 60 61 for workspace_deps_map in all_dependency_maps: 62 for pkg_name, conditional_deps_map in workspace_deps_map.items(): 63 if pkg_name not in dependencies: 64 non_frozen_map = dict() 65 for key, values in conditional_deps_map.items(): 66 non_frozen_map.update({key: dict(values.items())}) 67 dependencies.setdefault(pkg_name, non_frozen_map) 68 continue 69 70 for condition, deps_map in conditional_deps_map.items(): 71 # If the condition has not been recorded, do so and continue 72 if condition not in dependencies[pkg_name]: 73 dependencies[pkg_name].setdefault(condition, dict(deps_map.items())) 74 continue 75 76 # Alert on any miss-matched dependencies 77 inconsistent_entries = [] 78 for crate_name, crate_label in deps_map.items(): 79 existing = dependencies[pkg_name][condition].get(crate_name) 80 if existing and existing != crate_label: 81 inconsistent_entries.append((crate_name, existing, crate_label)) 82 dependencies[pkg_name][condition].update({crate_name: crate_label}) 83 84 return dependencies 85 86def crate_deps(deps, package_name = None): 87 """Finds the fully qualified label of the requested crates for the package where this macro is called. 88 89 Args: 90 deps (list): The desired list of crate targets. 91 package_name (str, optional): The package name of the set of dependencies to look up. 92 Defaults to `native.package_name()`. 93 94 Returns: 95 list: A list of labels to generated rust targets (str) 96 """ 97 98 if not deps: 99 return [] 100 101 if package_name == None: 102 package_name = native.package_name() 103 104 # Join both sets of dependencies 105 dependencies = _flatten_dependency_maps([ 106 _NORMAL_DEPENDENCIES, 107 _NORMAL_DEV_DEPENDENCIES, 108 _PROC_MACRO_DEPENDENCIES, 109 _PROC_MACRO_DEV_DEPENDENCIES, 110 _BUILD_DEPENDENCIES, 111 _BUILD_PROC_MACRO_DEPENDENCIES, 112 ]).pop(package_name, {}) 113 114 # Combine all conditional packages so we can easily index over a flat list 115 # TODO: Perhaps this should actually return select statements and maintain 116 # the conditionals of the dependencies 117 flat_deps = {} 118 for deps_set in dependencies.values(): 119 for crate_name, crate_label in deps_set.items(): 120 flat_deps.update({crate_name: crate_label}) 121 122 missing_crates = [] 123 crate_targets = [] 124 for crate_target in deps: 125 if crate_target not in flat_deps: 126 missing_crates.append(crate_target) 127 else: 128 crate_targets.append(flat_deps[crate_target]) 129 130 if missing_crates: 131 fail("Could not find crates `{}` among dependencies of `{}`. Available dependencies were `{}`".format( 132 missing_crates, 133 package_name, 134 dependencies, 135 )) 136 137 return crate_targets 138 139def all_crate_deps( 140 normal = False, 141 normal_dev = False, 142 proc_macro = False, 143 proc_macro_dev = False, 144 build = False, 145 build_proc_macro = False, 146 package_name = None): 147 """Finds the fully qualified label of all requested direct crate dependencies \ 148 for the package where this macro is called. 149 150 If no parameters are set, all normal dependencies are returned. Setting any one flag will 151 otherwise impact the contents of the returned list. 152 153 Args: 154 normal (bool, optional): If True, normal dependencies are included in the 155 output list. 156 normal_dev (bool, optional): If True, normal dev dependencies will be 157 included in the output list.. 158 proc_macro (bool, optional): If True, proc_macro dependencies are included 159 in the output list. 160 proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are 161 included in the output list. 162 build (bool, optional): If True, build dependencies are included 163 in the output list. 164 build_proc_macro (bool, optional): If True, build proc_macro dependencies are 165 included in the output list. 166 package_name (str, optional): The package name of the set of dependencies to look up. 167 Defaults to `native.package_name()` when unset. 168 169 Returns: 170 list: A list of labels to generated rust targets (str) 171 """ 172 173 if package_name == None: 174 package_name = native.package_name() 175 176 # Determine the relevant maps to use 177 all_dependency_maps = [] 178 if normal: 179 all_dependency_maps.append(_NORMAL_DEPENDENCIES) 180 if normal_dev: 181 all_dependency_maps.append(_NORMAL_DEV_DEPENDENCIES) 182 if proc_macro: 183 all_dependency_maps.append(_PROC_MACRO_DEPENDENCIES) 184 if proc_macro_dev: 185 all_dependency_maps.append(_PROC_MACRO_DEV_DEPENDENCIES) 186 if build: 187 all_dependency_maps.append(_BUILD_DEPENDENCIES) 188 if build_proc_macro: 189 all_dependency_maps.append(_BUILD_PROC_MACRO_DEPENDENCIES) 190 191 # Default to always using normal dependencies 192 if not all_dependency_maps: 193 all_dependency_maps.append(_NORMAL_DEPENDENCIES) 194 195 dependencies = _flatten_dependency_maps(all_dependency_maps).pop(package_name, None) 196 197 if not dependencies: 198 if dependencies == None: 199 fail("Tried to get all_crate_deps for package " + package_name + " but that package had no Cargo.toml file") 200 else: 201 return [] 202 203 crate_deps = list(dependencies.pop(_COMMON_CONDITION, {}).values()) 204 for condition, deps in dependencies.items(): 205 crate_deps += selects.with_or({ 206 tuple(_CONDITIONS[condition]): deps.values(), 207 "//conditions:default": [], 208 }) 209 210 return crate_deps 211 212def aliases( 213 normal = False, 214 normal_dev = False, 215 proc_macro = False, 216 proc_macro_dev = False, 217 build = False, 218 build_proc_macro = False, 219 package_name = None): 220 """Produces a map of Crate alias names to their original label 221 222 If no dependency kinds are specified, `normal` and `proc_macro` are used by default. 223 Setting any one flag will otherwise determine the contents of the returned dict. 224 225 Args: 226 normal (bool, optional): If True, normal dependencies are included in the 227 output list. 228 normal_dev (bool, optional): If True, normal dev dependencies will be 229 included in the output list.. 230 proc_macro (bool, optional): If True, proc_macro dependencies are included 231 in the output list. 232 proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are 233 included in the output list. 234 build (bool, optional): If True, build dependencies are included 235 in the output list. 236 build_proc_macro (bool, optional): If True, build proc_macro dependencies are 237 included in the output list. 238 package_name (str, optional): The package name of the set of dependencies to look up. 239 Defaults to `native.package_name()` when unset. 240 241 Returns: 242 dict: The aliases of all associated packages 243 """ 244 if package_name == None: 245 package_name = native.package_name() 246 247 # Determine the relevant maps to use 248 all_aliases_maps = [] 249 if normal: 250 all_aliases_maps.append(_NORMAL_ALIASES) 251 if normal_dev: 252 all_aliases_maps.append(_NORMAL_DEV_ALIASES) 253 if proc_macro: 254 all_aliases_maps.append(_PROC_MACRO_ALIASES) 255 if proc_macro_dev: 256 all_aliases_maps.append(_PROC_MACRO_DEV_ALIASES) 257 if build: 258 all_aliases_maps.append(_BUILD_ALIASES) 259 if build_proc_macro: 260 all_aliases_maps.append(_BUILD_PROC_MACRO_ALIASES) 261 262 # Default to always using normal aliases 263 if not all_aliases_maps: 264 all_aliases_maps.append(_NORMAL_ALIASES) 265 all_aliases_maps.append(_PROC_MACRO_ALIASES) 266 267 aliases = _flatten_dependency_maps(all_aliases_maps).pop(package_name, None) 268 269 if not aliases: 270 return dict() 271 272 common_items = aliases.pop(_COMMON_CONDITION, {}).items() 273 274 # If there are only common items in the dictionary, immediately return them 275 if not len(aliases.keys()) == 1: 276 return dict(common_items) 277 278 # Build a single select statement where each conditional has accounted for the 279 # common set of aliases. 280 crate_aliases = {"//conditions:default": dict(common_items)} 281 for condition, deps in aliases.items(): 282 condition_triples = _CONDITIONS[condition] 283 for triple in condition_triples: 284 if triple in crate_aliases: 285 crate_aliases[triple].update(deps) 286 else: 287 crate_aliases.update({triple: dict(deps.items() + common_items)}) 288 289 return select(crate_aliases) 290 291############################################################################### 292# WORKSPACE MEMBER DEPS AND ALIASES 293############################################################################### 294 295_NORMAL_DEPENDENCIES = { 296 "": { 297 _COMMON_CONDITION: { 298 "serde": Label("@t3p__serde-1.0.205//:serde"), 299 "serde_json": Label("@t3p__serde_json-1.0.122//:serde_json"), 300 }, 301 }, 302} 303 304_NORMAL_ALIASES = { 305 "": { 306 _COMMON_CONDITION: { 307 }, 308 }, 309} 310 311_NORMAL_DEV_DEPENDENCIES = { 312 "": { 313 }, 314} 315 316_NORMAL_DEV_ALIASES = { 317 "": { 318 }, 319} 320 321_PROC_MACRO_DEPENDENCIES = { 322 "": { 323 }, 324} 325 326_PROC_MACRO_ALIASES = { 327 "": { 328 }, 329} 330 331_PROC_MACRO_DEV_DEPENDENCIES = { 332 "": { 333 }, 334} 335 336_PROC_MACRO_DEV_ALIASES = { 337 "": { 338 }, 339} 340 341_BUILD_DEPENDENCIES = { 342 "": { 343 }, 344} 345 346_BUILD_ALIASES = { 347 "": { 348 }, 349} 350 351_BUILD_PROC_MACRO_DEPENDENCIES = { 352 "": { 353 }, 354} 355 356_BUILD_PROC_MACRO_ALIASES = { 357 "": { 358 }, 359} 360 361_CONDITIONS = { 362 "aarch64-apple-darwin": ["@rules_rust//rust/platform:aarch64-apple-darwin"], 363 "aarch64-apple-ios": ["@rules_rust//rust/platform:aarch64-apple-ios"], 364 "aarch64-apple-ios-sim": ["@rules_rust//rust/platform:aarch64-apple-ios-sim"], 365 "aarch64-fuchsia": ["@rules_rust//rust/platform:aarch64-fuchsia"], 366 "aarch64-linux-android": ["@rules_rust//rust/platform:aarch64-linux-android"], 367 "aarch64-pc-windows-msvc": ["@rules_rust//rust/platform:aarch64-pc-windows-msvc"], 368 "aarch64-unknown-linux-gnu": ["@rules_rust//rust/platform:aarch64-unknown-linux-gnu"], 369 "aarch64-unknown-nixos-gnu": ["@rules_rust//rust/platform:aarch64-unknown-nixos-gnu"], 370 "aarch64-unknown-nto-qnx710": ["@rules_rust//rust/platform:aarch64-unknown-nto-qnx710"], 371 "arm-unknown-linux-gnueabi": ["@rules_rust//rust/platform:arm-unknown-linux-gnueabi"], 372 "armv7-linux-androideabi": ["@rules_rust//rust/platform:armv7-linux-androideabi"], 373 "armv7-unknown-linux-gnueabi": ["@rules_rust//rust/platform:armv7-unknown-linux-gnueabi"], 374 "i686-apple-darwin": ["@rules_rust//rust/platform:i686-apple-darwin"], 375 "i686-linux-android": ["@rules_rust//rust/platform:i686-linux-android"], 376 "i686-pc-windows-msvc": ["@rules_rust//rust/platform:i686-pc-windows-msvc"], 377 "i686-unknown-freebsd": ["@rules_rust//rust/platform:i686-unknown-freebsd"], 378 "i686-unknown-linux-gnu": ["@rules_rust//rust/platform:i686-unknown-linux-gnu"], 379 "powerpc-unknown-linux-gnu": ["@rules_rust//rust/platform:powerpc-unknown-linux-gnu"], 380 "riscv32imc-unknown-none-elf": ["@rules_rust//rust/platform:riscv32imc-unknown-none-elf"], 381 "riscv64gc-unknown-none-elf": ["@rules_rust//rust/platform:riscv64gc-unknown-none-elf"], 382 "s390x-unknown-linux-gnu": ["@rules_rust//rust/platform:s390x-unknown-linux-gnu"], 383 "thumbv7em-none-eabi": ["@rules_rust//rust/platform:thumbv7em-none-eabi"], 384 "thumbv8m.main-none-eabi": ["@rules_rust//rust/platform:thumbv8m.main-none-eabi"], 385 "wasm32-unknown-unknown": ["@rules_rust//rust/platform:wasm32-unknown-unknown"], 386 "wasm32-wasi": ["@rules_rust//rust/platform:wasm32-wasi"], 387 "x86_64-apple-darwin": ["@rules_rust//rust/platform:x86_64-apple-darwin"], 388 "x86_64-apple-ios": ["@rules_rust//rust/platform:x86_64-apple-ios"], 389 "x86_64-fuchsia": ["@rules_rust//rust/platform:x86_64-fuchsia"], 390 "x86_64-linux-android": ["@rules_rust//rust/platform:x86_64-linux-android"], 391 "x86_64-pc-windows-msvc": ["@rules_rust//rust/platform:x86_64-pc-windows-msvc"], 392 "x86_64-unknown-freebsd": ["@rules_rust//rust/platform:x86_64-unknown-freebsd"], 393 "x86_64-unknown-linux-gnu": ["@rules_rust//rust/platform:x86_64-unknown-linux-gnu"], 394 "x86_64-unknown-nixos-gnu": ["@rules_rust//rust/platform:x86_64-unknown-nixos-gnu"], 395 "x86_64-unknown-none": ["@rules_rust//rust/platform:x86_64-unknown-none"], 396} 397 398############################################################################### 399 400def crate_repositories(): 401 """A macro for defining repositories for all generated crates. 402 403 Returns: 404 A list of repos visible to the module through the module extension. 405 """ 406 maybe( 407 http_archive, 408 name = "t3p__itoa-1.0.11", 409 sha256 = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b", 410 type = "tar.gz", 411 urls = ["https://static.crates.io/crates/itoa/1.0.11/download"], 412 strip_prefix = "itoa-1.0.11", 413 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.itoa-1.0.11.bazel"), 414 ) 415 416 maybe( 417 http_archive, 418 name = "t3p__memchr-2.7.4", 419 sha256 = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3", 420 type = "tar.gz", 421 urls = ["https://static.crates.io/crates/memchr/2.7.4/download"], 422 strip_prefix = "memchr-2.7.4", 423 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.memchr-2.7.4.bazel"), 424 ) 425 426 maybe( 427 http_archive, 428 name = "t3p__proc-macro2-1.0.86", 429 sha256 = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77", 430 type = "tar.gz", 431 urls = ["https://static.crates.io/crates/proc-macro2/1.0.86/download"], 432 strip_prefix = "proc-macro2-1.0.86", 433 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.proc-macro2-1.0.86.bazel"), 434 ) 435 436 maybe( 437 http_archive, 438 name = "t3p__quote-1.0.36", 439 sha256 = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7", 440 type = "tar.gz", 441 urls = ["https://static.crates.io/crates/quote/1.0.36/download"], 442 strip_prefix = "quote-1.0.36", 443 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.quote-1.0.36.bazel"), 444 ) 445 446 maybe( 447 http_archive, 448 name = "t3p__ryu-1.0.18", 449 sha256 = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f", 450 type = "tar.gz", 451 urls = ["https://static.crates.io/crates/ryu/1.0.18/download"], 452 strip_prefix = "ryu-1.0.18", 453 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.ryu-1.0.18.bazel"), 454 ) 455 456 maybe( 457 http_archive, 458 name = "t3p__serde-1.0.205", 459 sha256 = "e33aedb1a7135da52b7c21791455563facbbcc43d0f0f66165b42c21b3dfb150", 460 type = "tar.gz", 461 urls = ["https://static.crates.io/crates/serde/1.0.205/download"], 462 strip_prefix = "serde-1.0.205", 463 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.serde-1.0.205.bazel"), 464 ) 465 466 maybe( 467 http_archive, 468 name = "t3p__serde_derive-1.0.205", 469 sha256 = "692d6f5ac90220161d6774db30c662202721e64aed9058d2c394f451261420c1", 470 type = "tar.gz", 471 urls = ["https://static.crates.io/crates/serde_derive/1.0.205/download"], 472 strip_prefix = "serde_derive-1.0.205", 473 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.serde_derive-1.0.205.bazel"), 474 ) 475 476 maybe( 477 http_archive, 478 name = "t3p__serde_json-1.0.122", 479 sha256 = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da", 480 type = "tar.gz", 481 urls = ["https://static.crates.io/crates/serde_json/1.0.122/download"], 482 strip_prefix = "serde_json-1.0.122", 483 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.serde_json-1.0.122.bazel"), 484 ) 485 486 maybe( 487 http_archive, 488 name = "t3p__syn-2.0.72", 489 sha256 = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af", 490 type = "tar.gz", 491 urls = ["https://static.crates.io/crates/syn/2.0.72/download"], 492 strip_prefix = "syn-2.0.72", 493 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.syn-2.0.72.bazel"), 494 ) 495 496 maybe( 497 http_archive, 498 name = "t3p__unicode-ident-1.0.12", 499 sha256 = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b", 500 type = "tar.gz", 501 urls = ["https://static.crates.io/crates/unicode-ident/1.0.12/download"], 502 strip_prefix = "unicode-ident-1.0.12", 503 build_file = Label("@rules_rust//test/3rdparty/crates:BUILD.unicode-ident-1.0.12.bazel"), 504 ) 505 506 return [ 507 struct(repo = "t3p__serde-1.0.205", is_dev_dep = False), 508 struct(repo = "t3p__serde_json-1.0.122", is_dev_dep = False), 509 ] 510