https://github.com/abitofhelp/bazel_monorepo_go_rust
This repository contains a monorepo, polyglot project consisting of a library for Go and Rust.
https://github.com/abitofhelp/bazel_monorepo_go_rust
bazel cargo go golang monorepo polyglot rust
Last synced: 2 months ago
JSON representation
This repository contains a monorepo, polyglot project consisting of a library for Go and Rust.
- Host: GitHub
- URL: https://github.com/abitofhelp/bazel_monorepo_go_rust
- Owner: abitofhelp
- License: mit
- Created: 2023-11-15T01:10:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-16T09:59:25.000Z (over 1 year ago)
- Last Synced: 2024-04-24T03:21:27.287Z (about 1 year ago)
- Topics: bazel, cargo, go, golang, monorepo, polyglot, rust
- Language: Starlark
- Homepage:
- Size: 162 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## bazel\_monorepo\_go\_rust
This repository contains a monorepo, polyglot project consisting of a library for Go and Rust.
These libraries can be built using the appropriate native tool -- go build or Cargo -- and Bazel.
The source of truth for dependencies are the go.mod/vendors and Cargo files.
The Makefile contains many queries and commands for using the native tools for Go and Rust within Bazel as well as Bazel commands.## Valid Bazel Labels
* //pkg/golang:srcs
* //pkg/golang/src/grpc\_client\_lib:grpc\_client\_lib
* //pkg/golang/src/grpc\_client\_lib:grpc\_client\_lib\_test
* //pkg/rust/src:srcs
* //pkg/rust/src/grpc\_client\_lib:grpc\_client\_lib
* //pkg/rust/src/grpc\_client\_lib:grpc\_client\_lib\_test## To Change Go's and Rust's Versions
* Execute the set\_golang\_version command in the Makefile.
* Execute the set\_rust\_version command in the Makefile.## To Add A New Go Project
* Create a directory in /pkg/golang/src for the new Go project.
* Clone the files from grpc\_client\_lib to the new project's directory.
* Amend the files for the new project's needs.
* Add the relative path to the new project to the use() in go.work.
* i.e. /pkg/golang/src/mynewproject
* You may want to clone the build\_grpc\_golang\_client\_lib command in the Makefile for directly building the new project.
* Verify that you can build the Go projects by executing the go\_build\_all (go build used) command in the Makefile.
* Verify that you can build the Go projects by executing the build\_all (bazel used) command in the Makefile.## To Add A New Rust Project
* Create a directory in /pkg/rust/src for the new Rust project.
* Clone the files from grpc\_client\_lib to the new project's directory.
* Amend the files for the new project's needs.
* Add the bazel target to the new project to the crates\_repository.manifests block in the WORKSPACE file.```crates_repository( name = "crate_index", cargo_lockfile = "//:Cargo.lock", lockfile = "//:cargo-bazel-lock.json", manifests = [ "//:Cargo.toml", "//:pkg/rust/src/grpc_client_lib/Cargo.toml", "//:pkg/rust/src/mynewproject/Cargo.toml", ], )```
* You may want to clone the build\_grpc\_rust\_client\_lib command in the Makefile for directly building the new project.
* Add the relative path to the new project to the workspace.members block in Cargo.toml file.```[workspace] resolver = "2" members = [ "pkg/rust/src/grpc_client_lib", "pkg/rust/src/mynewproject", ]```
* Verify that you can build the Rust projects by executing the rust\_build\_all (Cargo used) command in the Makefile.
* Verify that you can build the Rust projects by executing the build\_all (bazel used) command in the Makefile.