fork/rules_rust
git clone https://git.julia.blue/fork/rules_rust
ba6af156
cleanup
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 @//sys/basic/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 32Dependency maps have the following structure: 33 34```python 35DEPENDENCIES_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 53Args: 54all_dependency_maps (list): A list of dicts as described above 55 56Returns: 57dict: A dictionary as described above 58""" 59dependencies = {} 60 61for workspace_deps_map in all_dependency_maps : 62for pkg_name , conditional_deps_map in workspace_deps_map . items (): 63if pkg_name not in dependencies : 64non_frozen_map = dict () 65for key , values in conditional_deps_map . items (): 66non_frozen_map . update ({ key : dict ( values . items ())}) 67dependencies . setdefault ( pkg_name , non_frozen_map ) 68 continue 69 70for condition , deps_map in conditional_deps_map . items (): 71# If the condition has not been recorded, do so and continue 72if condition not in dependencies [ pkg_name ]: 73dependencies [ pkg_name ]. setdefault ( condition , dict ( deps_map . items ())) 74 continue 75 76# Alert on any miss-matched dependencies 77inconsistent_entries = [] 78for crate_name , crate_label in deps_map . items (): 79existing = dependencies [ pkg_name ][ condition ]. get ( crate_name ) 80if existing and existing != crate_label : 81inconsistent_entries . append (( crate_name , existing , crate_label )) 82dependencies [ pkg_name ][ condition ]. update ({ crate_name : crate_label }) 83 84return 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 89Args: 90deps (list): The desired list of crate targets. 91package_name (str, optional): The package name of the set of dependencies to look up. 92Defaults to `native.package_name()`. 93 94Returns: 95list: A list of labels to generated rust targets (str) 96""" 97 98if not deps : 99return [] 100 101if package_name == None : 102package_name = native . package_name () 103 104# Join both sets of dependencies 105dependencies = _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 117flat_deps = {} 118for deps_set in dependencies . values (): 119for crate_name , crate_label in deps_set . items (): 120flat_deps . update ({ crate_name : crate_label }) 121 122missing_crates = [] 123crate_targets = [] 124for crate_target in deps : 125if crate_target not in flat_deps : 126missing_crates . append ( crate_target ) 127else : 128crate_targets . append ( flat_deps [ crate_target ]) 129 130if missing_crates : 131fail ( "Could not find crates `{}` among dependencies of `{}`. Available dependencies were `{}`" . format ( 132missing_crates , 133package_name , 134dependencies , 135)) 136 137return crate_targets 138 139def all_crate_deps ( 140normal = False , 141normal_dev = False , 142proc_macro = False , 143proc_macro_dev = False , 144build = False , 145build_proc_macro = False , 146package_name = None ): 147"""Finds the fully qualified label of all requested direct crate dependencies \ 148for the package where this macro is called. 149 150If no parameters are set, all normal dependencies are returned. Setting any one flag will 151otherwise impact the contents of the returned list. 152 153Args: 154normal (bool, optional): If True, normal dependencies are included in the 155output list. 156normal_dev (bool, optional): If True, normal dev dependencies will be 157included in the output list.. 158proc_macro (bool, optional): If True, proc_macro dependencies are included 159in the output list. 160proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are 161included in the output list. 162build (bool, optional): If True, build dependencies are included 163in the output list. 164build_proc_macro (bool, optional): If True, build proc_macro dependencies are 165included in the output list. 166package_name (str, optional): The package name of the set of dependencies to look up. 167Defaults to `native.package_name()` when unset. 168 169Returns: 170list: A list of labels to generated rust targets (str) 171""" 172 173if package_name == None : 174package_name = native . package_name () 175 176# Determine the relevant maps to use 177all_dependency_maps = [] 178if normal : 179all_dependency_maps . append ( _NORMAL_DEPENDENCIES ) 180if normal_dev : 181all_dependency_maps . append ( _NORMAL_DEV_DEPENDENCIES ) 182if proc_macro : 183all_dependency_maps . append ( _PROC_MACRO_DEPENDENCIES ) 184if proc_macro_dev : 185all_dependency_maps . append ( _PROC_MACRO_DEV_DEPENDENCIES ) 186if build : 187all_dependency_maps . append ( _BUILD_DEPENDENCIES ) 188if build_proc_macro : 189all_dependency_maps . append ( _BUILD_PROC_MACRO_DEPENDENCIES ) 190 191# Default to always using normal dependencies 192if not all_dependency_maps : 193all_dependency_maps . append ( _NORMAL_DEPENDENCIES ) 194 195dependencies = _flatten_dependency_maps ( all_dependency_maps ). pop ( package_name , None ) 196 197if not dependencies : 198if dependencies == None : 199fail ( "Tried to get all_crate_deps for package " + package_name + " but that package had no Cargo.toml file" ) 200else : 201return [] 202 203crate_deps = list ( dependencies . pop ( _COMMON_CONDITION , {}). values ()) 204for condition , deps in dependencies . items (): 205crate_deps += selects . with_or ({ 206tuple ( _CONDITIONS [ condition ]): deps . values (), 207"//conditions:default" : [], 208}) 209 210return crate_deps 211 212def aliases ( 213normal = False , 214normal_dev = False , 215proc_macro = False , 216proc_macro_dev = False , 217build = False , 218build_proc_macro = False , 219package_name = None ): 220"""Produces a map of Crate alias names to their original label 221 222If no dependency kinds are specified, `normal` and `proc_macro` are used by default. 223Setting any one flag will otherwise determine the contents of the returned dict. 224 225Args: 226normal (bool, optional): If True, normal dependencies are included in the 227output list. 228normal_dev (bool, optional): If True, normal dev dependencies will be 229included in the output list.. 230proc_macro (bool, optional): If True, proc_macro dependencies are included 231in the output list. 232proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are 233included in the output list. 234build (bool, optional): If True, build dependencies are included 235in the output list. 236build_proc_macro (bool, optional): If True, build proc_macro dependencies are 237included in the output list. 238package_name (str, optional): The package name of the set of dependencies to look up. 239Defaults to `native.package_name()` when unset. 240 241Returns: 242dict: The aliases of all associated packages 243""" 244if package_name == None : 245package_name = native . package_name () 246 247# Determine the relevant maps to use 248all_aliases_maps = [] 249if normal : 250all_aliases_maps . append ( _NORMAL_ALIASES ) 251if normal_dev : 252all_aliases_maps . append ( _NORMAL_DEV_ALIASES ) 253if proc_macro : 254all_aliases_maps . append ( _PROC_MACRO_ALIASES ) 255if proc_macro_dev : 256all_aliases_maps . append ( _PROC_MACRO_DEV_ALIASES ) 257if build : 258all_aliases_maps . append ( _BUILD_ALIASES ) 259if build_proc_macro : 260all_aliases_maps . append ( _BUILD_PROC_MACRO_ALIASES ) 261 262# Default to always using normal aliases 263if not all_aliases_maps : 264all_aliases_maps . append ( _NORMAL_ALIASES ) 265all_aliases_maps . append ( _PROC_MACRO_ALIASES ) 266 267aliases = _flatten_dependency_maps ( all_aliases_maps ). pop ( package_name , None ) 268 269if not aliases : 270return dict () 271 272common_items = aliases . pop ( _COMMON_CONDITION , {}). items () 273 274# If there are only common items in the dictionary, immediately return them 275if not len ( aliases . keys ()) == 1 : 276return dict ( common_items ) 277 278# Build a single select statement where each conditional has accounted for the 279# common set of aliases. 280crate_aliases = { "//conditions:default" : dict ( common_items )} 281for condition , deps in aliases . items (): 282condition_triples = _CONDITIONS [ condition ] 283for triple in condition_triples : 284if triple in crate_aliases : 285crate_aliases [ triple ]. update ( deps ) 286else : 287crate_aliases . update ({ triple : dict ( deps . items () + common_items )}) 288 289return select ( crate_aliases ) 290 291############################################################################### 292# WORKSPACE MEMBER DEPS AND ALIASES 293############################################################################### 294 295_NORMAL_DEPENDENCIES = { 296"" : { 297_COMMON_CONDITION : { 298"bzip2" : Label ( "@basic_sys__bzip2-0.3.3//:bzip2" ), 299}, 300}, 301} 302 303_NORMAL_ALIASES = { 304"" : { 305_COMMON_CONDITION : { 306}, 307}, 308} 309 310_NORMAL_DEV_DEPENDENCIES = { 311"" : { 312}, 313} 314 315_NORMAL_DEV_ALIASES = { 316"" : { 317}, 318} 319 320_PROC_MACRO_DEPENDENCIES = { 321"" : { 322}, 323} 324 325_PROC_MACRO_ALIASES = { 326"" : { 327}, 328} 329 330_PROC_MACRO_DEV_DEPENDENCIES = { 331"" : { 332}, 333} 334 335_PROC_MACRO_DEV_ALIASES = { 336"" : { 337}, 338} 339 340_BUILD_DEPENDENCIES = { 341"" : { 342}, 343} 344 345_BUILD_ALIASES = { 346"" : { 347}, 348} 349 350_BUILD_PROC_MACRO_DEPENDENCIES = { 351"" : { 352}, 353} 354 355_BUILD_PROC_MACRO_ALIASES = { 356"" : { 357}, 358} 359 360_CONDITIONS = { 361"aarch64-apple-darwin" : [ "@rules_rust//rust/platform:aarch64-apple-darwin" ], 362"aarch64-apple-ios" : [ "@rules_rust//rust/platform:aarch64-apple-ios" ], 363"aarch64-apple-ios-sim" : [ "@rules_rust//rust/platform:aarch64-apple-ios-sim" ], 364"aarch64-linux-android" : [ "@rules_rust//rust/platform:aarch64-linux-android" ], 365"aarch64-pc-windows-msvc" : [ "@rules_rust//rust/platform:aarch64-pc-windows-msvc" ], 366"aarch64-unknown-fuchsia" : [ "@rules_rust//rust/platform:aarch64-unknown-fuchsia" ], 367"aarch64-unknown-linux-gnu" : [ "@rules_rust//rust/platform:aarch64-unknown-linux-gnu" ], 368"aarch64-unknown-nixos-gnu" : [ "@rules_rust//rust/platform:aarch64-unknown-nixos-gnu" ], 369"aarch64-unknown-nto-qnx710" : [ "@rules_rust//rust/platform:aarch64-unknown-nto-qnx710" ], 370"arm-unknown-linux-gnueabi" : [ "@rules_rust//rust/platform:arm-unknown-linux-gnueabi" ], 371"armv7-linux-androideabi" : [ "@rules_rust//rust/platform:armv7-linux-androideabi" ], 372"armv7-unknown-linux-gnueabi" : [ "@rules_rust//rust/platform:armv7-unknown-linux-gnueabi" ], 373"i686-apple-darwin" : [ "@rules_rust//rust/platform:i686-apple-darwin" ], 374"i686-linux-android" : [ "@rules_rust//rust/platform:i686-linux-android" ], 375"i686-pc-windows-msvc" : [ "@rules_rust//rust/platform:i686-pc-windows-msvc" ], 376"i686-unknown-freebsd" : [ "@rules_rust//rust/platform:i686-unknown-freebsd" ], 377"i686-unknown-linux-gnu" : [ "@rules_rust//rust/platform:i686-unknown-linux-gnu" ], 378"powerpc-unknown-linux-gnu" : [ "@rules_rust//rust/platform:powerpc-unknown-linux-gnu" ], 379"riscv32imc-unknown-none-elf" : [ "@rules_rust//rust/platform:riscv32imc-unknown-none-elf" ], 380"riscv64gc-unknown-none-elf" : [ "@rules_rust//rust/platform:riscv64gc-unknown-none-elf" ], 381"s390x-unknown-linux-gnu" : [ "@rules_rust//rust/platform:s390x-unknown-linux-gnu" ], 382"thumbv7em-none-eabi" : [ "@rules_rust//rust/platform:thumbv7em-none-eabi" ], 383"thumbv8m.main-none-eabi" : [ "@rules_rust//rust/platform:thumbv8m.main-none-eabi" ], 384"wasm32-unknown-unknown" : [ "@rules_rust//rust/platform:wasm32-unknown-unknown" ], 385"wasm32-wasip1" : [ "@rules_rust//rust/platform:wasm32-wasip1" ], 386"x86_64-apple-darwin" : [ "@rules_rust//rust/platform:x86_64-apple-darwin" ], 387"x86_64-apple-ios" : [ "@rules_rust//rust/platform:x86_64-apple-ios" ], 388"x86_64-linux-android" : [ "@rules_rust//rust/platform:x86_64-linux-android" ], 389"x86_64-pc-windows-msvc" : [ "@rules_rust//rust/platform:x86_64-pc-windows-msvc" ], 390"x86_64-unknown-freebsd" : [ "@rules_rust//rust/platform:x86_64-unknown-freebsd" ], 391"x86_64-unknown-fuchsia" : [ "@rules_rust//rust/platform:x86_64-unknown-fuchsia" ], 392"x86_64-unknown-linux-gnu" : [ "@rules_rust//rust/platform:x86_64-unknown-linux-gnu" ], 393"x86_64-unknown-nixos-gnu" : [ "@rules_rust//rust/platform:x86_64-unknown-nixos-gnu" ], 394"x86_64-unknown-none" : [ "@rules_rust//rust/platform:x86_64-unknown-none" ], 395} 396 397############################################################################### 398 399def crate_repositories (): 400"""A macro for defining repositories for all generated crates. 401 402Returns: 403A list of repos visible to the module through the module extension. 404""" 405maybe ( 406http_archive , 407name = "basic_sys__bzip2-0.3.3" , 408sha256 = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b" , 409type = "tar.gz" , 410urls = [ "https://static.crates.io/crates/bzip2/0.3.3/download" ], 411strip_prefix = "bzip2-0.3.3" , 412build_file = Label ( "@examples//sys/basic/3rdparty/crates:BUILD.bzip2-0.3.3.bazel" ), 413) 414 415maybe ( 416http_archive , 417name = "basic_sys__bzip2-sys-0.1.11-1.0.8" , 418sha256 = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" , 419type = "tar.gz" , 420urls = [ "https://static.crates.io/crates/bzip2-sys/0.1.11+1.0.8/download" ], 421strip_prefix = "bzip2-sys-0.1.11+1.0.8" , 422build_file = Label ( "@examples//sys/basic/3rdparty/crates:BUILD.bzip2-sys-0.1.11+1.0.8.bazel" ), 423) 424 425maybe ( 426http_archive , 427name = "basic_sys__cc-1.0.77" , 428sha256 = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" , 429type = "tar.gz" , 430urls = [ "https://static.crates.io/crates/cc/1.0.77/download" ], 431strip_prefix = "cc-1.0.77" , 432build_file = Label ( "@examples//sys/basic/3rdparty/crates:BUILD.cc-1.0.77.bazel" ), 433) 434 435maybe ( 436http_archive , 437name = "basic_sys__libc-0.2.137" , 438sha256 = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" , 439type = "tar.gz" , 440urls = [ "https://static.crates.io/crates/libc/0.2.137/download" ], 441strip_prefix = "libc-0.2.137" , 442build_file = Label ( "@examples//sys/basic/3rdparty/crates:BUILD.libc-0.2.137.bazel" ), 443) 444 445maybe ( 446http_archive , 447name = "basic_sys__pkg-config-0.3.26" , 448sha256 = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" , 449type = "tar.gz" , 450urls = [ "https://static.crates.io/crates/pkg-config/0.3.26/download" ], 451strip_prefix = "pkg-config-0.3.26" , 452build_file = Label ( "@examples//sys/basic/3rdparty/crates:BUILD.pkg-config-0.3.26.bazel" ), 453) 454 455return [ 456struct ( repo = "basic_sys__bzip2-0.3.3" , is_dev_dep = False ), 457]