Skip to content

Commit

Permalink
Add support for additional Cargo workspaces
Browse files Browse the repository at this point in the history
This is how I work around rust-lang/cargo#5042
to get path dependencies into vendored Rust dependencies.

The generated BUILD files are built with
google#524, because otherwise they
don't work.

This fixes google#361.
  • Loading branch information
bsilver8192 committed Sep 16, 2022
1 parent e655d34 commit 6f1ee70
Show file tree
Hide file tree
Showing 60 changed files with 3,191 additions and 185 deletions.
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
2 changes: 1 addition & 1 deletion examples/remote/binary_dependencies/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _flatten_dependency_maps(all_dependency_maps):

return dependencies

def remote_binary_dependencies_fetch_remote_crates():
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"""
maybe(
http_archive,
Expand Down
2 changes: 1 addition & 1 deletion examples/remote/build_dependencies/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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():
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"""
maybe(
http_archive,
Expand Down
2 changes: 1 addition & 1 deletion examples/remote/cargo_workspace/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _flatten_dependency_maps(all_dependency_maps):

return dependencies

def remote_cargo_workspace_fetch_remote_crates():
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"""
maybe(
http_archive,
Expand Down
2 changes: 1 addition & 1 deletion examples/remote/complicated_cargo_library/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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():
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"""
maybe(
http_archive,
Expand Down
2 changes: 1 addition & 1 deletion examples/remote/dev_dependencies/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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():
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"""
maybe(
http_archive,
Expand Down
2 changes: 1 addition & 1 deletion examples/remote/no_deps/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ 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():
def remote_no_deps_fetch_remote_crates(local_path_prefix = ""):
"""No crates were detected in the source Cargo.toml. This is a no-op"""
pass
2 changes: 1 addition & 1 deletion examples/remote/non_cratesio/cargo/crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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():
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"""
maybe(
http_archive,
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

0 comments on commit 6f1ee70

Please sign in to comment.