Lines Matching +full:repo +full:- +full:name
1 """Module extension for generating third-party crates for use in bazel."""
5 load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
6 load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
14 # A list of labels which may be relative (and if so, is within the repo the rule is generated in).
51 """Merges the set of global annotations with the repo-specific ones
55 …repo_specific_annotations (dict): The annotation tags that apply to only this repo, keyed by crate.
73 …otations (dict): The set of annotation tag classes that apply to this closure, keyed by crate name.
76 …dict): The set of extra cargo crate tags that apply to this closure, if any, keyed by package name.
79 tag_path = module_ctx.path(cfg.name)
82 regen_command = "Run 'cargo update [--workspace]'",
95 repository_name = cfg.name,
96 output_pkg = cfg.name,
97 workspace_name = cfg.name,
117 splicing_output_dir = tag_path.get_child("splicing-output")
120 "--output-dir",
122 "--config",
124 "--splicing-manifest",
129 "--cargo-lockfile",
141 "--cargo-lockfile",
143 "--config",
145 "--splicing-manifest",
147 "--repository-dir",
149 "--metadata",
151 "--repin",
152 "--lockfile",
156 crates_dir = tag_path.get_child(cfg.name)
158 name = cfg.name,
168 repo = crate["repository"]
169 if repo == None:
171 name = crate["name"]
174 # "+" isn't valid in a repo name.
175 crate_repo_name = "{repo_name}__{name}-{version}".format(
176 repo_name = cfg.name,
177 name = name,
178 version = version.replace("+", "-"),
181 … build_file_content = module_ctx.read(crates_dir.get_child("BUILD.%s-%s.bazel" % (name, version)))
182 if "Http" in repo:
184 repo = repo["Http"]
186 name = crate_repo_name,
187 patch_args = repo.get("patch_args", None),
188 patch_tool = repo.get("patch_tool", None),
189 patches = repo.get("patches", None),
191 sha256 = repo.get("sha256", None),
193 urls = [repo["url"]],
194 strip_prefix = "%s-%s" % (crate["name"], crate["version"]),
197 elif "Git" in repo:
199 repo = repo["Git"]
201 for k, v in repo["commitish"].items():
207 name = crate_repo_name,
209 patch_args = repo.get("patch_args", None),
210 patch_tool = repo.get("patch_tool", None),
211 patches = repo.get("patches", None),
212 shallow_since = repo.get("shallow_since", None),
213 remote = repo["remote"],
215 strip_prefix = repo.get("strip_prefix", None),
219 …fail("Invalid repo: expected Http or Git to exist for crate %s-%s, got %s" % (name, version, repo))
223 # If we add them as empty strings, cargo-bazel will be unhappy.
231 """Query Network Resources to local a `cargo-bazel` binary.
239 tuple(path, dict) The path to a 'cargo-bazel' binary. The pairing (dict)
252 return module_ctx.path(Label("@cargo_bazel_bootstrap//:cargo-bazel"))
263 output = module_ctx.path("cargo-bazel.exe" if "win" in module_ctx.os.name else "cargo-bazel")
304 # For the tag-based method, because it has type safety, we have to
311 # In the non-bzlmod approach, this is given as a dict
313 # With the tag-based approach used in Bzlmod, we run into an issue
344 for repo in repositories:
346 _get_or_insert(repo_specific_annotations, repo, {}),
354 if cfg.name in local_repos:
355 …fail("Defined two crate universes with the same name in the same MODULE.bazel file. Use the name t…
356 elif cfg.name in all_repos:
357 …efined two crate universes with the same name in different MODULE.bazel files. Either give one a d…
358 all_repos.append(cfg.name)
359 local_repos.append(cfg.name)
364 repo_specific_annotations.get(cfg.name),
373 # We could maybe make this reproducible by using `-minimal-version` during resolution.
374 # See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#minimal-versions
379 repo_specific_annotations.get(cfg.name),
385 for repo in repo_specific_annotations:
386 if repo not in local_repos:
387 …fail("Annotation specified for repo %s, but the module defined repositories %s" % (repo, local_rep…
396 doc = "Generates a repo @crates from a Cargo.toml / Cargo.lock pair",
398 name = attr.string(
399 doc = "The name of the repo to generate",
415 …doc = "A list of repository names specified from `crate.from_cargo(name=...)` that this annotation…
419 doc = "The name of the crate the annotation is applied to",
498 …tp_archive.patch_args](https://docs.bazel.build/versions/main/repo/http.html#http_archive-patch_ar…
501 …tp_archive.patch_tool](https://docs.bazel.build/versions/main/repo/http.html#http_archive-patch_to…
504 …[http_archive.patches](https://docs.bazel.build/versions/main/repo/http.html#http_archive-patches)…
522 …ate taget to use when something depends on this crate to allow the parent repo to provide its own …
525 …ate taget to use when something depends on this crate to allow the parent repo to provide its own …
528 …ate taget to use when something depends on this crate to allow the parent repo to provide its own …
531 …ate taget to use when something depends on this crate to allow the parent repo to provide its own …
537 doc = "Generates a repo @crates from the defined `spec` tags",
539 name = attr.string(doc = "The name of the repo to generate", default = "crates"),
551 doc = "The explicit name of the package.",
564 doc = "Maps to the `default-features` flag.",
574 …anch, tag or rev may be specified. Specifying `rev` is recommended for fully-reproducible builds.",
577 …anch, tag or rev may be specified. Specifying `rev` is recommended for fully-reproducible builds.",