-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As discussed with Alex Eagle on Slack recently, this PR contributes multiple Rust examples that cover roughly the top ten use cases. All examples use the new Bazelmod format. The format follows loosely the great C++ tutorial. If there is anything that needs adjustment, please let me know. Formalities: * I've signed the Google CLA * I've signed all commits --------- Signed-off-by: Marvin Hansen <marvin.hansen@gmail.com> Co-authored-by: Xùdōng Yáng <wyverald@gmail.com>
- Loading branch information
1 parent
4d9f5e6
commit a905ed1
Showing
125 changed files
with
132,374 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
imports: | ||
- android.yml | ||
- bzlmod.yml | ||
- configurations.yml | ||
- misc.yml | ||
- frontend.yml | ||
- misc.yml | ||
- rules.yml | ||
- tutorials.yml | ||
- bzlmod.yml | ||
- tutorial-cpp.yml | ||
- tutorial-java.yml | ||
- tutorial-rust.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Getting started tutorials | ||
tasks: | ||
java-tutorial-linux: | ||
name: "Java Tutorial" | ||
platform: ubuntu1804 | ||
working_directory: ../java-tutorial | ||
build_targets: | ||
- "//:ProjectRunner" | ||
java-tutorial-macos: | ||
name: "Java Tutorial" | ||
platform: macos | ||
working_directory: ../java-tutorial | ||
build_targets: | ||
- "//:ProjectRunner" | ||
java-tutorial-windows: | ||
name: "Java Tutorial" | ||
platform: windows | ||
working_directory: ../java-tutorial | ||
build_targets: | ||
- "//:ProjectRunner" | ||
|
||
query-quickstart: | ||
name: "Query Quickstart" | ||
platform: macos | ||
working_directory: ../query-quickstart | ||
build_targets: | ||
- "//:runner" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Getting started tutorials | ||
tasks: | ||
rust-01-hello-world-linux: | ||
name: "Rust Hello World" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/01-hello-world | ||
build_targets: | ||
- "//..." | ||
rust-02-hello-cross-linux: | ||
name: "Rust Cross Compilation" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/02-hello-cross | ||
build_targets: | ||
- "//:all" | ||
rust-02-hello-cross-mac: | ||
name: "Rust Cross Compilation" | ||
platform: macos | ||
working_directory: ../rust-examples/02-hello-cross | ||
build_targets: | ||
- "//:all" | ||
rust-03-comp-opt-linux: | ||
name: "Rust Compiler Optimization" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/03-comp-opt | ||
build_targets: | ||
- "//..." | ||
rust-04-ffi-linux: | ||
name: "Rust FFI" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/04-ffi | ||
build_targets: | ||
- "//..." | ||
rust-05-deps-cargo-linux: | ||
name: "Rust Cargo Deps" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/05-deps-cargo | ||
build_targets: | ||
- "//..." | ||
rust-06-deps-direct-linux: | ||
name: "Rust Direct Deps" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/06-deps-direct | ||
build_targets: | ||
- "//..." | ||
rust-07-deps-vendor-linux: | ||
name: "Rust Vendored Deps" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/07-deps-vendor | ||
build_targets: | ||
- "//..." | ||
rust-08-grpc-client-server-linux: | ||
name: "Rust grpc" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/08-grpc-client-server | ||
build_targets: | ||
- "//:all" | ||
rust-08-grpc-client-server-macos: | ||
name: "Rust grpc" | ||
platform: macos | ||
working_directory: ../rust-examples/08-grpc-client-server | ||
build_targets: | ||
- "//:all" | ||
rust-09-oci-container-linux: | ||
name: "Rust OCI" | ||
platform: ubuntu1804 | ||
working_directory: ../rust-examples/09-oci-container | ||
build_targets: | ||
- "//..." | ||
- "//tokio_oci:image" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ bazel-* | |
target/ | ||
# Xcode | ||
*.xcodeproj | ||
node_modules | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/*/bazel-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../.bazelversion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("@rules_rust//rust:defs.bzl", "rust_binary") | ||
|
||
rust_binary( | ||
name = "bin", | ||
srcs = ["src/main.rs"], | ||
visibility = ["//visibility:public"], | ||
deps = [], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module( | ||
name = "hello_world", | ||
version = "0.0.0", | ||
) | ||
|
||
# https://github.com/bazelbuild/rules_rust/releases | ||
bazel_dep(name = "rules_rust", version = "0.47.1") | ||
|
||
# Rust toolchain | ||
RUST_EDITION = "2021" | ||
|
||
RUST_VERSION = "1.79.0" | ||
|
||
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") | ||
rust.toolchain( | ||
edition = RUST_EDITION, | ||
versions = [RUST_VERSION], | ||
) | ||
use_repo(rust, "rust_toolchains") | ||
|
||
register_toolchains("@rust_toolchains//:all") |
Oops, something went wrong.