fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

UebelAndreUpdated `//util/import` to use crate_universe (#1492)0ffde973

0.10.0
20.0 KiB548 linesraw
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 //util/import/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 dependnecies 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, normla 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({_CONDITIONS[condition]: deps.values()})
206
207    return crate_deps
208
209def aliases(
210        normal = False,
211        normal_dev = False,
212        proc_macro = False,
213        proc_macro_dev = False,
214        build = False,
215        build_proc_macro = False,
216        package_name = None):
217    """Produces a map of Crate alias names to their original label
218
219    If no dependency kinds are specified, `normal` and `proc_macro` are used by default.
220    Setting any one flag will otherwise determine the contents of the returned dict.
221
222    Args:
223        normal (bool, optional): If True, normal dependencies are included in the
224            output list.
225        normal_dev (bool, optional): If True, normla dev dependencies will be
226            included in the output list..
227        proc_macro (bool, optional): If True, proc_macro dependencies are included
228            in the output list.
229        proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are
230            included in the output list.
231        build (bool, optional): If True, build dependencies are included
232            in the output list.
233        build_proc_macro (bool, optional): If True, build proc_macro dependencies are
234            included in the output list.
235        package_name (str, optional): The package name of the set of dependencies to look up.
236            Defaults to `native.package_name()` when unset.
237
238    Returns:
239        dict: The aliases of all associated packages
240    """
241    if package_name == None:
242        package_name = native.package_name()
243
244    # Determine the relevant maps to use
245    all_aliases_maps = []
246    if normal:
247        all_aliases_maps.append(_NORMAL_ALIASES)
248    if normal_dev:
249        all_aliases_maps.append(_NORMAL_DEV_ALIASES)
250    if proc_macro:
251        all_aliases_maps.append(_PROC_MACRO_ALIASES)
252    if proc_macro_dev:
253        all_aliases_maps.append(_PROC_MACRO_DEV_ALIASES)
254    if build:
255        all_aliases_maps.append(_BUILD_ALIASES)
256    if build_proc_macro:
257        all_aliases_maps.append(_BUILD_PROC_MACRO_ALIASES)
258
259    # Default to always using normal aliases
260    if not all_aliases_maps:
261        all_aliases_maps.append(_NORMAL_ALIASES)
262        all_aliases_maps.append(_PROC_MACRO_ALIASES)
263
264    aliases = _flatten_dependency_maps(all_aliases_maps).pop(package_name, None)
265
266    if not aliases:
267        return dict()
268
269    common_items = aliases.pop(_COMMON_CONDITION, {}).items()
270
271    # If there are only common items in the dictionary, immediately return them
272    if not len(aliases.keys()) == 1:
273        return dict(common_items)
274
275    # Build a single select statement where each conditional has accounted for the
276    # common set of aliases.
277    crate_aliases = {"//conditions:default": common_items}
278    for condition, deps in aliases.items():
279        condition_triples = _CONDITIONS[condition]
280        if condition_triples in crate_aliases:
281            crate_aliases[condition_triples].update(deps)
282        else:
283            crate_aliases.update({_CONDITIONS[condition]: dict(deps.items() + common_items)})
284
285    return selects.with_or(crate_aliases)
286
287###############################################################################
288# WORKSPACE MEMBER DEPS AND ALIASES
289###############################################################################
290
291_NORMAL_DEPENDENCIES = {
292    "": {
293        _COMMON_CONDITION: {
294            "aho-corasick": "@rules_rust_util_import__aho-corasick-0.7.15//:aho_corasick",
295            "lazy_static": "@rules_rust_util_import__lazy_static-1.4.0//:lazy_static",
296            "proc-macro2": "@rules_rust_util_import__proc-macro2-1.0.33//:proc_macro2",
297            "quickcheck": "@rules_rust_util_import__quickcheck-1.0.3//:quickcheck",
298            "quote": "@rules_rust_util_import__quote-1.0.10//:quote",
299            "syn": "@rules_rust_util_import__syn-1.0.82//:syn",
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    "cfg(target_os = \"wasi\")": ["wasm32-wasi"],
363    "cfg(unix)": ["aarch64-apple-darwin", "aarch64-apple-ios", "aarch64-apple-ios-sim", "aarch64-linux-android", "aarch64-unknown-linux-gnu", "arm-unknown-linux-gnueabi", "armv7-linux-androideabi", "armv7-unknown-linux-gnueabi", "i686-apple-darwin", "i686-linux-android", "i686-unknown-freebsd", "i686-unknown-linux-gnu", "powerpc-unknown-linux-gnu", "s390x-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-apple-ios", "x86_64-linux-android", "x86_64-unknown-freebsd", "x86_64-unknown-linux-gnu"],
364}
365
366###############################################################################
367
368def crate_repositories():
369    """A macro for defining repositories for all generated crates"""
370    maybe(
371        http_archive,
372        name = "rules_rust_util_import__aho-corasick-0.7.15",
373        sha256 = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5",
374        type = "tar.gz",
375        urls = ["https://crates.io/api/v1/crates/aho-corasick/0.7.15/download"],
376        strip_prefix = "aho-corasick-0.7.15",
377        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.aho-corasick-0.7.15.bazel"),
378    )
379
380    maybe(
381        http_archive,
382        name = "rules_rust_util_import__cfg-if-1.0.0",
383        sha256 = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd",
384        type = "tar.gz",
385        urls = ["https://crates.io/api/v1/crates/cfg-if/1.0.0/download"],
386        strip_prefix = "cfg-if-1.0.0",
387        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.cfg-if-1.0.0.bazel"),
388    )
389
390    maybe(
391        http_archive,
392        name = "rules_rust_util_import__env_logger-0.8.4",
393        sha256 = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3",
394        type = "tar.gz",
395        urls = ["https://crates.io/api/v1/crates/env_logger/0.8.4/download"],
396        strip_prefix = "env_logger-0.8.4",
397        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.env_logger-0.8.4.bazel"),
398    )
399
400    maybe(
401        http_archive,
402        name = "rules_rust_util_import__getrandom-0.2.7",
403        sha256 = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6",
404        type = "tar.gz",
405        urls = ["https://crates.io/api/v1/crates/getrandom/0.2.7/download"],
406        strip_prefix = "getrandom-0.2.7",
407        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.getrandom-0.2.7.bazel"),
408    )
409
410    maybe(
411        http_archive,
412        name = "rules_rust_util_import__lazy_static-1.4.0",
413        sha256 = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646",
414        type = "tar.gz",
415        urls = ["https://crates.io/api/v1/crates/lazy_static/1.4.0/download"],
416        strip_prefix = "lazy_static-1.4.0",
417        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.lazy_static-1.4.0.bazel"),
418    )
419
420    maybe(
421        http_archive,
422        name = "rules_rust_util_import__libc-0.2.126",
423        sha256 = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836",
424        type = "tar.gz",
425        urls = ["https://crates.io/api/v1/crates/libc/0.2.126/download"],
426        strip_prefix = "libc-0.2.126",
427        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.libc-0.2.126.bazel"),
428    )
429
430    maybe(
431        http_archive,
432        name = "rules_rust_util_import__log-0.4.17",
433        sha256 = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e",
434        type = "tar.gz",
435        urls = ["https://crates.io/api/v1/crates/log/0.4.17/download"],
436        strip_prefix = "log-0.4.17",
437        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.log-0.4.17.bazel"),
438    )
439
440    maybe(
441        http_archive,
442        name = "rules_rust_util_import__memchr-2.5.0",
443        sha256 = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d",
444        type = "tar.gz",
445        urls = ["https://crates.io/api/v1/crates/memchr/2.5.0/download"],
446        strip_prefix = "memchr-2.5.0",
447        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.memchr-2.5.0.bazel"),
448    )
449
450    maybe(
451        http_archive,
452        name = "rules_rust_util_import__proc-macro2-1.0.33",
453        sha256 = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a",
454        type = "tar.gz",
455        urls = ["https://crates.io/api/v1/crates/proc-macro2/1.0.33/download"],
456        strip_prefix = "proc-macro2-1.0.33",
457        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.proc-macro2-1.0.33.bazel"),
458    )
459
460    maybe(
461        http_archive,
462        name = "rules_rust_util_import__quickcheck-1.0.3",
463        sha256 = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6",
464        type = "tar.gz",
465        urls = ["https://crates.io/api/v1/crates/quickcheck/1.0.3/download"],
466        strip_prefix = "quickcheck-1.0.3",
467        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.quickcheck-1.0.3.bazel"),
468    )
469
470    maybe(
471        http_archive,
472        name = "rules_rust_util_import__quote-1.0.10",
473        sha256 = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05",
474        type = "tar.gz",
475        urls = ["https://crates.io/api/v1/crates/quote/1.0.10/download"],
476        strip_prefix = "quote-1.0.10",
477        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.quote-1.0.10.bazel"),
478    )
479
480    maybe(
481        http_archive,
482        name = "rules_rust_util_import__rand-0.8.5",
483        sha256 = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404",
484        type = "tar.gz",
485        urls = ["https://crates.io/api/v1/crates/rand/0.8.5/download"],
486        strip_prefix = "rand-0.8.5",
487        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.rand-0.8.5.bazel"),
488    )
489
490    maybe(
491        http_archive,
492        name = "rules_rust_util_import__rand_core-0.6.3",
493        sha256 = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7",
494        type = "tar.gz",
495        urls = ["https://crates.io/api/v1/crates/rand_core/0.6.3/download"],
496        strip_prefix = "rand_core-0.6.3",
497        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.rand_core-0.6.3.bazel"),
498    )
499
500    maybe(
501        http_archive,
502        name = "rules_rust_util_import__regex-1.4.6",
503        sha256 = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759",
504        type = "tar.gz",
505        urls = ["https://crates.io/api/v1/crates/regex/1.4.6/download"],
506        strip_prefix = "regex-1.4.6",
507        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.regex-1.4.6.bazel"),
508    )
509
510    maybe(
511        http_archive,
512        name = "rules_rust_util_import__regex-syntax-0.6.27",
513        sha256 = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244",
514        type = "tar.gz",
515        urls = ["https://crates.io/api/v1/crates/regex-syntax/0.6.27/download"],
516        strip_prefix = "regex-syntax-0.6.27",
517        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.regex-syntax-0.6.27.bazel"),
518    )
519
520    maybe(
521        http_archive,
522        name = "rules_rust_util_import__syn-1.0.82",
523        sha256 = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59",
524        type = "tar.gz",
525        urls = ["https://crates.io/api/v1/crates/syn/1.0.82/download"],
526        strip_prefix = "syn-1.0.82",
527        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.syn-1.0.82.bazel"),
528    )
529
530    maybe(
531        http_archive,
532        name = "rules_rust_util_import__unicode-xid-0.2.3",
533        sha256 = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04",
534        type = "tar.gz",
535        urls = ["https://crates.io/api/v1/crates/unicode-xid/0.2.3/download"],
536        strip_prefix = "unicode-xid-0.2.3",
537        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.unicode-xid-0.2.3.bazel"),
538    )
539
540    maybe(
541        http_archive,
542        name = "rules_rust_util_import__wasi-0.11.0-wasi-snapshot-preview1",
543        sha256 = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423",
544        type = "tar.gz",
545        urls = ["https://crates.io/api/v1/crates/wasi/0.11.0+wasi-snapshot-preview1/download"],
546        strip_prefix = "wasi-0.11.0+wasi-snapshot-preview1",
547        build_file = Label("@rules_rust//util/import/3rdparty/crates:BUILD.wasi-0.11.0+wasi-snapshot-preview1.bazel"),
548    )