Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for additional Cargo workspaces #526

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ examples_repository()

load("@cargo_raze_examples//:repositories.bzl", examples_repositories = "repositories")

examples_repositories()
examples_repositories(local_path_prefix = "examples/")

load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_deps")

Expand Down
11 changes: 9 additions & 2 deletions examples/remote/binary_dependencies/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,15 @@ def _flatten_dependency_maps(all_dependency_maps):

return dependencies

def remote_binary_dependencies_fetch_remote_crates():
"""This function defines a collection of repos and should be called in a WORKSPACE file"""
def remote_binary_dependencies_fetch_remote_crates(local_path_prefix = ""):
"""This function defines a collection of repos and should be called in a WORKSPACE file.

Args:
local_path_prefix: An optional prefix to append to local paths within the Bazel repository.
Many uses should use `bazel_workspace_path` in the raze settings instead, this is only
for unusual sitations which use the same fetch_remote_crates from multiple repositories.
"""
_unused = local_path_prefix # @unused
maybe(
http_archive,
name = "remote_binary_dependencies__addr2line__0_14_0",
Expand Down
11 changes: 9 additions & 2 deletions examples/remote/build_dependencies/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load

def remote_build_dependencies_fetch_remote_crates():
"""This function defines a collection of repos and should be called in a WORKSPACE file"""
def remote_build_dependencies_fetch_remote_crates(local_path_prefix = ""):
"""This function defines a collection of repos and should be called in a WORKSPACE file.

Args:
local_path_prefix: An optional prefix to append to local paths within the Bazel repository.
Many uses should use `bazel_workspace_path` in the raze settings instead, this is only
for unusual sitations which use the same fetch_remote_crates from multiple repositories.
"""
_unused = local_path_prefix # @unused
maybe(
http_archive,
name = "remote_build_dependencies__addr2line__0_14_1",
Expand Down
11 changes: 9 additions & 2 deletions examples/remote/cargo_workspace/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,15 @@ def _flatten_dependency_maps(all_dependency_maps):

return dependencies

def remote_cargo_workspace_fetch_remote_crates():
"""This function defines a collection of repos and should be called in a WORKSPACE file"""
def remote_cargo_workspace_fetch_remote_crates(local_path_prefix = ""):
"""This function defines a collection of repos and should be called in a WORKSPACE file.

Args:
local_path_prefix: An optional prefix to append to local paths within the Bazel repository.
Many uses should use `bazel_workspace_path` in the raze settings instead, this is only
for unusual sitations which use the same fetch_remote_crates from multiple repositories.
"""
_unused = local_path_prefix # @unused
maybe(
http_archive,
name = "remote_cargo_workspace__addr2line__0_13_0",
Expand Down
11 changes: 9 additions & 2 deletions examples/remote/complicated_cargo_library/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load

def remote_complicated_cargo_library_fetch_remote_crates():
"""This function defines a collection of repos and should be called in a WORKSPACE file"""
def remote_complicated_cargo_library_fetch_remote_crates(local_path_prefix = ""):
"""This function defines a collection of repos and should be called in a WORKSPACE file.

Args:
local_path_prefix: An optional prefix to append to local paths within the Bazel repository.
Many uses should use `bazel_workspace_path` in the raze settings instead, this is only
for unusual sitations which use the same fetch_remote_crates from multiple repositories.
"""
_unused = local_path_prefix # @unused
maybe(
http_archive,
name = "remote_complicated_cargo_library__ahash__0_3_8",
Expand Down
11 changes: 9 additions & 2 deletions examples/remote/dev_dependencies/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load

def remote_dev_dependencies_fetch_remote_crates():
"""This function defines a collection of repos and should be called in a WORKSPACE file"""
def remote_dev_dependencies_fetch_remote_crates(local_path_prefix = ""):
"""This function defines a collection of repos and should be called in a WORKSPACE file.

Args:
local_path_prefix: An optional prefix to append to local paths within the Bazel repository.
Many uses should use `bazel_workspace_path` in the raze settings instead, this is only
for unusual sitations which use the same fetch_remote_crates from multiple repositories.
"""
_unused = local_path_prefix # @unused
maybe(
http_archive,
name = "remote_dev_dependencies__addr2line__0_14_1",
Expand Down
13 changes: 11 additions & 2 deletions examples/remote/no_deps/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load

def remote_no_deps_fetch_remote_crates():
"""No crates were detected in the source Cargo.toml. This is a no-op"""
def remote_no_deps_fetch_remote_crates(local_path_prefix = ""):
"""This function defines a collection of repos and should be called in a WORKSPACE file.

Args:
local_path_prefix: An optional prefix to append to local paths within the Bazel repository.
Many uses should use `bazel_workspace_path` in the raze settings instead, this is only
for unusual sitations which use the same fetch_remote_crates from multiple repositories.
"""
_unused = local_path_prefix # @unused

# No crates were detected in the source Cargo.toml. This is a no-op
pass
11 changes: 9 additions & 2 deletions examples/remote/non_cratesio/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load

def remote_non_cratesio_fetch_remote_crates():
"""This function defines a collection of repos and should be called in a WORKSPACE file"""
def remote_non_cratesio_fetch_remote_crates(local_path_prefix = ""):
"""This function defines a collection of repos and should be called in a WORKSPACE file.

Args:
local_path_prefix: An optional prefix to append to local paths within the Bazel repository.
Many uses should use `bazel_workspace_path` in the raze settings instead, this is only
for unusual sitations which use the same fetch_remote_crates from multiple repositories.
"""
_unused = local_path_prefix # @unused
maybe(
http_archive,
name = "remote_non_cratesio__aho_corasick__0_6_10",
Expand Down
24 changes: 24 additions & 0 deletions examples/remote/parent_directory_workspace/cargo/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
@generated
cargo-raze generated Bazel file.

DO NOT EDIT! Replaced on runs of cargo-raze
"""

# Export file for Stardoc support
exports_files(
glob([
"**/*.bazel",
"**/*.bzl",
]),
visibility = ["//visibility:public"],
)

filegroup(
name = "srcs",
srcs = glob([
"**/*.bazel",
"**/*.bzl",
]),
visibility = ["//visibility:public"],
)
Loading