• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 @//third-party: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, 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({_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, normal 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    "third-party": {
293        _COMMON_CONDITION: {
294            "cc": "@vendor__cc-1.0.79//:cc",
295            "clap": "@vendor__clap-4.1.4//:clap",
296            "codespan-reporting": "@vendor__codespan-reporting-0.11.1//:codespan_reporting",
297            "once_cell": "@vendor__once_cell-1.17.0//:once_cell",
298            "proc-macro2": "@vendor__proc-macro2-1.0.51//:proc_macro2",
299            "quote": "@vendor__quote-1.0.23//:quote",
300            "scratch": "@vendor__scratch-1.0.3//:scratch",
301            "syn": "@vendor__syn-1.0.107//:syn",
302        },
303    },
304}
305
306_NORMAL_ALIASES = {
307    "third-party": {
308        _COMMON_CONDITION: {
309        },
310    },
311}
312
313_NORMAL_DEV_DEPENDENCIES = {
314    "third-party": {
315    },
316}
317
318_NORMAL_DEV_ALIASES = {
319    "third-party": {
320    },
321}
322
323_PROC_MACRO_DEPENDENCIES = {
324    "third-party": {
325    },
326}
327
328_PROC_MACRO_ALIASES = {
329    "third-party": {
330    },
331}
332
333_PROC_MACRO_DEV_DEPENDENCIES = {
334    "third-party": {
335    },
336}
337
338_PROC_MACRO_DEV_ALIASES = {
339    "third-party": {
340    },
341}
342
343_BUILD_DEPENDENCIES = {
344    "third-party": {
345    },
346}
347
348_BUILD_ALIASES = {
349    "third-party": {
350    },
351}
352
353_BUILD_PROC_MACRO_DEPENDENCIES = {
354    "third-party": {
355    },
356}
357
358_BUILD_PROC_MACRO_ALIASES = {
359    "third-party": {
360    },
361}
362
363_CONDITIONS = {
364    "cfg(windows)": ["aarch64-pc-windows-msvc", "i686-pc-windows-msvc", "x86_64-pc-windows-msvc"],
365    "i686-pc-windows-gnu": [],
366    "x86_64-pc-windows-gnu": [],
367}
368
369###############################################################################
370
371def crate_repositories():
372    """A macro for defining repositories for all generated crates"""
373    maybe(
374        http_archive,
375        name = "vendor__bitflags-1.3.2",
376        sha256 = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a",
377        type = "tar.gz",
378        urls = ["https://crates.io/api/v1/crates/bitflags/1.3.2/download"],
379        strip_prefix = "bitflags-1.3.2",
380        build_file = Label("@cxx.rs//third-party/bazel:BUILD.bitflags-1.3.2.bazel"),
381    )
382
383    maybe(
384        http_archive,
385        name = "vendor__cc-1.0.79",
386        sha256 = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f",
387        type = "tar.gz",
388        urls = ["https://crates.io/api/v1/crates/cc/1.0.79/download"],
389        strip_prefix = "cc-1.0.79",
390        build_file = Label("@cxx.rs//third-party/bazel:BUILD.cc-1.0.79.bazel"),
391    )
392
393    maybe(
394        http_archive,
395        name = "vendor__clap-4.1.4",
396        sha256 = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76",
397        type = "tar.gz",
398        urls = ["https://crates.io/api/v1/crates/clap/4.1.4/download"],
399        strip_prefix = "clap-4.1.4",
400        build_file = Label("@cxx.rs//third-party/bazel:BUILD.clap-4.1.4.bazel"),
401    )
402
403    maybe(
404        http_archive,
405        name = "vendor__clap_lex-0.3.1",
406        sha256 = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade",
407        type = "tar.gz",
408        urls = ["https://crates.io/api/v1/crates/clap_lex/0.3.1/download"],
409        strip_prefix = "clap_lex-0.3.1",
410        build_file = Label("@cxx.rs//third-party/bazel:BUILD.clap_lex-0.3.1.bazel"),
411    )
412
413    maybe(
414        http_archive,
415        name = "vendor__codespan-reporting-0.11.1",
416        sha256 = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e",
417        type = "tar.gz",
418        urls = ["https://crates.io/api/v1/crates/codespan-reporting/0.11.1/download"],
419        strip_prefix = "codespan-reporting-0.11.1",
420        build_file = Label("@cxx.rs//third-party/bazel:BUILD.codespan-reporting-0.11.1.bazel"),
421    )
422
423    maybe(
424        http_archive,
425        name = "vendor__once_cell-1.17.0",
426        sha256 = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66",
427        type = "tar.gz",
428        urls = ["https://crates.io/api/v1/crates/once_cell/1.17.0/download"],
429        strip_prefix = "once_cell-1.17.0",
430        build_file = Label("@cxx.rs//third-party/bazel:BUILD.once_cell-1.17.0.bazel"),
431    )
432
433    maybe(
434        http_archive,
435        name = "vendor__os_str_bytes-6.4.1",
436        sha256 = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee",
437        type = "tar.gz",
438        urls = ["https://crates.io/api/v1/crates/os_str_bytes/6.4.1/download"],
439        strip_prefix = "os_str_bytes-6.4.1",
440        build_file = Label("@cxx.rs//third-party/bazel:BUILD.os_str_bytes-6.4.1.bazel"),
441    )
442
443    maybe(
444        http_archive,
445        name = "vendor__proc-macro2-1.0.51",
446        sha256 = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6",
447        type = "tar.gz",
448        urls = ["https://crates.io/api/v1/crates/proc-macro2/1.0.51/download"],
449        strip_prefix = "proc-macro2-1.0.51",
450        build_file = Label("@cxx.rs//third-party/bazel:BUILD.proc-macro2-1.0.51.bazel"),
451    )
452
453    maybe(
454        http_archive,
455        name = "vendor__quote-1.0.23",
456        sha256 = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b",
457        type = "tar.gz",
458        urls = ["https://crates.io/api/v1/crates/quote/1.0.23/download"],
459        strip_prefix = "quote-1.0.23",
460        build_file = Label("@cxx.rs//third-party/bazel:BUILD.quote-1.0.23.bazel"),
461    )
462
463    maybe(
464        http_archive,
465        name = "vendor__scratch-1.0.3",
466        sha256 = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2",
467        type = "tar.gz",
468        urls = ["https://crates.io/api/v1/crates/scratch/1.0.3/download"],
469        strip_prefix = "scratch-1.0.3",
470        build_file = Label("@cxx.rs//third-party/bazel:BUILD.scratch-1.0.3.bazel"),
471    )
472
473    maybe(
474        http_archive,
475        name = "vendor__syn-1.0.107",
476        sha256 = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5",
477        type = "tar.gz",
478        urls = ["https://crates.io/api/v1/crates/syn/1.0.107/download"],
479        strip_prefix = "syn-1.0.107",
480        build_file = Label("@cxx.rs//third-party/bazel:BUILD.syn-1.0.107.bazel"),
481    )
482
483    maybe(
484        http_archive,
485        name = "vendor__termcolor-1.2.0",
486        sha256 = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6",
487        type = "tar.gz",
488        urls = ["https://crates.io/api/v1/crates/termcolor/1.2.0/download"],
489        strip_prefix = "termcolor-1.2.0",
490        build_file = Label("@cxx.rs//third-party/bazel:BUILD.termcolor-1.2.0.bazel"),
491    )
492
493    maybe(
494        http_archive,
495        name = "vendor__unicode-ident-1.0.6",
496        sha256 = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc",
497        type = "tar.gz",
498        urls = ["https://crates.io/api/v1/crates/unicode-ident/1.0.6/download"],
499        strip_prefix = "unicode-ident-1.0.6",
500        build_file = Label("@cxx.rs//third-party/bazel:BUILD.unicode-ident-1.0.6.bazel"),
501    )
502
503    maybe(
504        http_archive,
505        name = "vendor__unicode-width-0.1.10",
506        sha256 = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b",
507        type = "tar.gz",
508        urls = ["https://crates.io/api/v1/crates/unicode-width/0.1.10/download"],
509        strip_prefix = "unicode-width-0.1.10",
510        build_file = Label("@cxx.rs//third-party/bazel:BUILD.unicode-width-0.1.10.bazel"),
511    )
512
513    maybe(
514        http_archive,
515        name = "vendor__winapi-0.3.9",
516        sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419",
517        type = "tar.gz",
518        urls = ["https://crates.io/api/v1/crates/winapi/0.3.9/download"],
519        strip_prefix = "winapi-0.3.9",
520        build_file = Label("@cxx.rs//third-party/bazel:BUILD.winapi-0.3.9.bazel"),
521    )
522
523    maybe(
524        http_archive,
525        name = "vendor__winapi-i686-pc-windows-gnu-0.4.0",
526        sha256 = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6",
527        type = "tar.gz",
528        urls = ["https://crates.io/api/v1/crates/winapi-i686-pc-windows-gnu/0.4.0/download"],
529        strip_prefix = "winapi-i686-pc-windows-gnu-0.4.0",
530        build_file = Label("@cxx.rs//third-party/bazel:BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel"),
531    )
532
533    maybe(
534        http_archive,
535        name = "vendor__winapi-util-0.1.5",
536        sha256 = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178",
537        type = "tar.gz",
538        urls = ["https://crates.io/api/v1/crates/winapi-util/0.1.5/download"],
539        strip_prefix = "winapi-util-0.1.5",
540        build_file = Label("@cxx.rs//third-party/bazel:BUILD.winapi-util-0.1.5.bazel"),
541    )
542
543    maybe(
544        http_archive,
545        name = "vendor__winapi-x86_64-pc-windows-gnu-0.4.0",
546        sha256 = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f",
547        type = "tar.gz",
548        urls = ["https://crates.io/api/v1/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download"],
549        strip_prefix = "winapi-x86_64-pc-windows-gnu-0.4.0",
550        build_file = Label("@cxx.rs//third-party/bazel:BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel"),
551    )
552