Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ tasks:
build_flags:
- "--enable_bzlmod"
build_targets:
- "//bindgen/3rdparty:bindgen"
- "//crate_universe:cargo_bazel_bin"
- "//proto/prost/private:prost_runtime"
- "//tools/runfiles"
- "//util/import"
- "//wasm_bindgen/3rdparty:wasm_bindgen"
ubuntu2004_clang:
name: With Clang
platform: ubuntu2004
Expand Down
109 changes: 106 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,122 @@ module(

print("WARNING: The rules_rust Bazel module is still highly experimental and subject to change at any time. Only use it to try out bzlmod for now.") # buildifier: disable=print

bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(
name = "bazel_skylib",
version = "1.5.0",
)
bazel_dep(
name = "platforms",
version = "0.0.8",
)
bazel_dep(
name = "rules_cc",
version = "0.0.9",
)
bazel_dep(
name = "rules_proto",
version = "5.3.0-21.7",
)
bazel_dep(
name = "apple_support",
version = "1.11.1",
repo_name = "build_bazel_apple_support",
)
bazel_dep(
name = "protobuf",
version = "21.7",
repo_name = "com_google_protobuf",
)

internal_deps = use_extension("//rust/private:extensions.bzl", "internal_deps")
use_repo(
internal_deps,
"bazelci_rules",
"com_google_googleapis",
"cui",
"cui__anyhow-1.0.75",
"cui__cargo-lock-9.0.0",
"cui__cargo-platform-0.1.4",
"cui__cargo_metadata-0.18.1",
"cui__cargo_toml-0.17.1",
"cui__cfg-expr-0.15.5",
"cui__clap-4.3.11",
"cui__crates-index-2.2.0",
"cui__hex-0.4.3",
"cui__indoc-2.0.4",
"cui__itertools-0.11.0",
"cui__maplit-1.0.2",
"cui__normpath-1.1.1",
"cui__pathdiff-0.2.1",
"cui__regex-1.10.2",
"cui__semver-1.0.20",
"cui__serde-1.0.190",
"cui__serde_json-1.0.108",
"cui__serde_starlark-0.1.14",
"cui__sha2-0.10.8",
"cui__spectral-0.6.0",
"cui__tempfile-3.8.1",
"cui__tera-1.19.1",
"cui__textwrap-0.16.0",
"cui__toml-0.8.6",
"cui__tracing-0.1.40",
"cui__tracing-subscriber-0.3.17",
"generated_inputs_in_external_repo",
"libc",
"llvm-raw",
"rrra__anyhow-1.0.71",
"rrra__clap-4.3.11",
"rrra__env_logger-0.10.0",
"rrra__itertools-0.11.0",
"rrra__log-0.4.19",
"rrra__serde-1.0.171",
"rrra__serde_json-1.0.102",
"rules_rust_bindgen__bindgen-0.65.1",
"rules_rust_bindgen__bindgen-cli-0.65.1",
"rules_rust_bindgen__clang-sys-1.6.1",
"rules_rust_bindgen__clap-4.3.3",
"rules_rust_bindgen__clap_complete-4.3.1",
"rules_rust_bindgen__env_logger-0.10.0",
"rules_rust_prost",
"rules_rust_prost__h2-0.3.19",
"rules_rust_prost__heck",
"rules_rust_prost__prost-0.11.9",
"rules_rust_prost__prost-types-0.11.9",
"rules_rust_prost__protoc-gen-prost-0.2.2",
"rules_rust_prost__protoc-gen-tonic-0.2.2",
"rules_rust_prost__tokio-1.28.2",
"rules_rust_prost__tokio-stream-0.1.14",
"rules_rust_prost__tonic-0.9.2",
"rules_rust_test_load_arbitrary_tool",
"rules_rust_tinyjson",
"rules_rust_toolchain_test_target_json",
"rules_rust_util_import__aho-corasick-0.7.15",
"rules_rust_util_import__lazy_static-1.4.0",
"rules_rust_util_import__proc-macro2-1.0.33",
"rules_rust_util_import__quickcheck-1.0.3",
"rules_rust_util_import__quote-1.0.10",
"rules_rust_util_import__syn-1.0.82",
"rules_rust_wasm_bindgen__anyhow-1.0.71",
"rules_rust_wasm_bindgen__assert_cmd-1.0.8",
"rules_rust_wasm_bindgen__diff-0.1.13",
"rules_rust_wasm_bindgen__docopt-1.1.1",
"rules_rust_wasm_bindgen__env_logger-0.8.4",
"rules_rust_wasm_bindgen__log-0.4.19",
"rules_rust_wasm_bindgen__predicates-1.0.8",
"rules_rust_wasm_bindgen__rayon-1.7.0",
"rules_rust_wasm_bindgen__rouille-3.6.2",
"rules_rust_wasm_bindgen__serde-1.0.171",
"rules_rust_wasm_bindgen__serde_derive-1.0.171",
"rules_rust_wasm_bindgen__serde_json-1.0.102",
"rules_rust_wasm_bindgen__tempfile-3.6.0",
"rules_rust_wasm_bindgen__ureq-2.8.0",
"rules_rust_wasm_bindgen__walrus-0.19.0",
"rules_rust_wasm_bindgen__wasm-bindgen-0.2.88",
"rules_rust_wasm_bindgen__wasm-bindgen-cli-support-0.2.88",
"rules_rust_wasm_bindgen__wasm-bindgen-shared-0.2.88",
"rules_rust_wasm_bindgen__wasmparser-0.102.0",
"rules_rust_wasm_bindgen__wasmprinter-0.2.60",
"rules_rust_wasm_bindgen_cli",
)

rust = use_extension("//rust:extensions.bzl", "rust")
Expand Down
17 changes: 14 additions & 3 deletions bindgen/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ BINDGEN_VERSION = "0.65.1"

# buildifier: disable=unnamed-macro
def rust_bindgen_dependencies():
"""Declare dependencies needed for bindgen."""
"""Declare dependencies needed for bindgen.

Returns:
list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.
"""

maybe(
http_archive,
Expand All @@ -38,17 +43,23 @@ def rust_bindgen_dependencies():
],
)

bindgen_name = "rules_rust_bindgen__bindgen-cli-{}".format(BINDGEN_VERSION)
maybe(
http_archive,
name = "rules_rust_bindgen__bindgen-cli-{}".format(BINDGEN_VERSION),
name = bindgen_name,
sha256 = "33373a4e0ec8b6fa2654e0c941ad16631b0d564cfd20e7e4b3db4c5b28f4a237",
type = "tar.gz",
urls = ["https://crates.io/api/v1/crates/bindgen-cli/{}/download".format(BINDGEN_VERSION)],
strip_prefix = "bindgen-cli-{}".format(BINDGEN_VERSION),
build_file = Label("//bindgen/3rdparty:BUILD.bindgen-cli.bazel"),
)

crate_repositories()
direct_deps = [
struct(repo = "llvm-raw", is_dev_dep = False),
struct(repo = bindgen_name, is_dev_dep = False),
]
direct_deps.extend(crate_repositories())
return direct_deps

# buildifier: disable=unnamed-macro
def rust_bindgen_register_toolchains(register_toolchains = True):
Expand Down
7 changes: 6 additions & 1 deletion crate_universe/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ def crate_universe_dependencies(rust_version = rust_common.default_version, boot
rust_version (str, optional): The version of rust to use when generating dependencies.
bootstrap (bool, optional): If true, a `cargo_bootstrap_repository` target will be generated.
**kwargs: Arguments to pass through to cargo_bazel_bootstrap.

Returns:
list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.
"""
third_party_deps()

if bootstrap:
cargo_bazel_bootstrap(rust_version = rust_version, **kwargs)

_vendor_crate_repositories()
direct_deps = _vendor_crate_repositories()

crates_vendor_deps()
cross_installer_deps()
return direct_deps
5 changes: 5 additions & 0 deletions docs/crate_universe.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,11 @@ Define dependencies of the `cargo-bazel` Rust target
| <a id="crate_universe_dependencies-bootstrap"></a>bootstrap | If true, a <code>cargo_bootstrap_repository</code> target will be generated. | `False` |
| <a id="crate_universe_dependencies-kwargs"></a>kwargs | Arguments to pass through to cargo_bazel_bootstrap. | none |

**RETURNS**

list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.


<a id="render_config"></a>

Expand Down
24 changes: 23 additions & 1 deletion docs/flatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -1750,6 +1750,11 @@ rust_bindgen_dependencies()
Declare dependencies needed for bindgen.


**RETURNS**

list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.


<a id="rust_bindgen_library"></a>

Expand Down Expand Up @@ -1803,11 +1808,22 @@ Registers the default toolchains for the `rules_rust` [bindgen][bg] rules.
## rust_prost_dependencies

<pre>
rust_prost_dependencies()
rust_prost_dependencies(<a href="#rust_prost_dependencies-bzlmod">bzlmod</a>)
</pre>

Declares repositories needed for prost.

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="rust_prost_dependencies-bzlmod"></a>bzlmod | Whether bzlmod is enabled. | `False` |

**RETURNS**

list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.


<a id="rust_prost_library"></a>
Expand Down Expand Up @@ -2120,6 +2136,12 @@ Declare dependencies needed for the `rules_rust` [wasm-bindgen][wb] rules.



**RETURNS**

list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.


<a id="rust_wasm_bindgen_register_toolchains"></a>

## rust_wasm_bindgen_register_toolchains
Expand Down
5 changes: 5 additions & 0 deletions docs/rust_bindgen.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ rust_bindgen_dependencies()
Declare dependencies needed for bindgen.


**RETURNS**

list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.


<a id="rust_bindgen_library"></a>

Expand Down
13 changes: 12 additions & 1 deletion docs/rust_proto.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,11 +377,22 @@ rust_binary(
## rust_prost_dependencies

<pre>
rust_prost_dependencies()
rust_prost_dependencies(<a href="#rust_prost_dependencies-bzlmod">bzlmod</a>)
</pre>

Declares repositories needed for prost.

**PARAMETERS**


| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="rust_prost_dependencies-bzlmod"></a>bzlmod | Whether bzlmod is enabled. | `False` |

**RETURNS**

list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.


<a id="rust_prost_library"></a>
Expand Down
6 changes: 6 additions & 0 deletions docs/rust_wasm_bindgen.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ Declare dependencies needed for the `rules_rust` [wasm-bindgen][wb] rules.



**RETURNS**

list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.


<a id="rust_wasm_bindgen_register_toolchains"></a>

## rust_wasm_bindgen_register_toolchains
Expand Down
58 changes: 40 additions & 18 deletions proto/prost/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,47 @@

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("//proto/prost/private/3rdparty/crates:crates.bzl", "crate_repositories")

def rust_prost_dependencies():
maybe(
http_archive,
name = "rules_proto",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
)
def rust_prost_dependencies(bzlmod = False):
"""Declares repositories needed for prost.

maybe(
http_archive,
name = "com_google_protobuf",
sha256 = "52b6160ae9266630adb5e96a9fc645215336371a740e87d411bfb63ea2f268a0",
strip_prefix = "protobuf-3.18.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v3.18.0/protobuf-all-3.18.0.tar.gz"],
)
Args:
bzlmod (bool): Whether bzlmod is enabled.

Returns:
list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
defined by this macro.
"""

direct_deps = [
struct(repo = "rules_rust_prost__heck", is_dev_dep = False),
]
if bzlmod:
# Without bzlmod, this function is normally called by the
# rust_prost_dependencies function in the private directory.
# However, the private directory is inaccessible, plus there's no
# reason to keep two rust_prost_dependencies functions with bzlmod.
direct_deps.extend(crate_repositories())
else:
maybe(
http_archive,
name = "rules_proto",
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
)

maybe(
http_archive,
name = "com_google_protobuf",
sha256 = "52b6160ae9266630adb5e96a9fc645215336371a740e87d411bfb63ea2f268a0",
strip_prefix = "protobuf-3.18.0",
urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v3.18.0/protobuf-all-3.18.0.tar.gz"],
)

maybe(
http_archive,
Expand All @@ -32,3 +53,4 @@ def rust_prost_dependencies():
strip_prefix = "heck-0.4.1",
build_file = Label("@rules_rust//proto/prost/private/3rdparty/crates:BUILD.heck-0.4.1.bazel"),
)
return direct_deps
Loading