https://github.com/chokobole/bazel_utils
https://github.com/chokobole/bazel_utils
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/chokobole/bazel_utils
- Owner: chokobole
- License: bsd-3-clause
- Created: 2019-12-30T11:34:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-02T06:22:45.000Z (over 5 years ago)
- Last Synced: 2025-02-17T03:42:58.696Z (3 months ago)
- Language: Starlark
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# Bazel Utils
This is a collection of bazel tools for internally used inside chokobole's projects.
## How to use
To use `bazel_utils`, add the followings to your `WORKSPACE` file.
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")# If you want to use a specific version, use like below.
http_archive(
name = "com_chokobole_bazel_utils",
sha256 = "", # or just omit
strip_prefix = "bazel_utils-",
urls = [
"https://github.com/chokobole/bazel_utils/archive/.tar.gz",
],
)# Or if you just try, use like below.
http_archive(
name = "com_chokobole_bazel_utils",
strip_prefix = "bazel_utils-master",
urls = [
"https://github.com/chokobole/bazel_utils/archive/master.tar.gz",
],
)
```Also add the followings to your `WORKSPACE` file for `buildifier`.
```python
load("@com_chokobole_bazel_utils//:buildifier_deps.bzl", "buildifier_deps")buildifier_deps()
load("@com_chokobole_bazel_utils//:buildifier_deps_deps.bzl", "buildifier_deps_deps")
buildifier_deps_deps()
```## Usages
### Debugging symbol for macOS
First set up your `.bazelrc`.
```bash
# Otherwise
cat bazel-your_workspace/external/com_chokobole_bazel_utils/.bazelrc.dsym >> .bazelrc
```Use `dsym` macro like below. **NOTE: you have to set "testonly = 1", if you want to leave symbols on test.**
```python
load("@com_chokobole_bazel_utils//:dsym.bzl", "dsym")dsym(name = name)
```For example, if you want to leave symbols for "hello_world" binary, you can use like below.
```python
cc_binary(
name = "hello_world",
srcs = ["..."],
)dsym(name = "hello_world")
```For convenience, you can declare macro for it.
```python
def dsym_cc_binary(
name,
**kwargs):
cc_binary(
name = name,
**kwargs
)dsym(name = name)
def dsym_cc_test(
name,
**kwargs):
cc_test(
name = name,
**kwargs
)dsym(
name = name,
testonly = 1,
)
```And then rebuild and enjoy the debugging!
```bash
bazel build --config apple_debug //your_rule
```