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