Skip to content

Commit 3988bcc

Browse files
committed
update README
1 parent 09fb84c commit 3988bcc

File tree

1 file changed

+22
-96
lines changed

1 file changed

+22
-96
lines changed

README.md

Lines changed: 22 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,43 @@
11
# C Repo Template
22

3-
A template for C projects using:
3+
A C repository template using Bazel 9 + Bzlmod, LLVM toolchains, and Unity tests.
4+
Targets: macOS ARM64 and Linux x86_64.
45

5-
- **Bazel 9** with Bzlmod for dependency management
6-
- **LLVM Toolchain** (20.1.0) via `toolchains_llvm` for consistent builds across platforms
7-
- **ThrowTheSwitch Unity** for unit testing
8-
- **Target Platforms:** macOS ARM64, Linux x86_64
6+
## Requirements
97

10-
## Prerequisites
11-
12-
- [Bazel 9+](https://bazel.build/) (via Bazelisk recommended)
8+
- [Bazel 9+](https://bazel.build/) (Bazelisk recommended)
139
- Xcode Command Line Tools (macOS)
14-
- (Optional) direnv for automatic environment setup
10+
- Optional: `direnv`, `lcov` (for HTML coverage)
1511

1612
## Quick Start
1713

1814
```bash
19-
# Initialize Bazel environment (repo cache, etc.)
2015
bash tools/setup/init_bazel_env.sh
21-
22-
# Build everything
2316
bazel build //...
24-
25-
# Run tests
2617
bazel test //...
27-
28-
# Run the example application
29-
bazel run //app:example_app
30-
```
31-
32-
## Build Configurations
33-
34-
| Config | Command | Description |
35-
| -------- | ------------------------------------ | ------------------------------- |
36-
| Default | `bazel build //...` | Standard build |
37-
| Debug | `bazel build --config=debug //...` | Debug + ASAN/UBSAN |
38-
| Release | `bazel build --config=opt //...` | Optimized (`-O3 -march=native`) |
39-
| Profile | `bazel build --config=profile //...` | Profiling (`-ftime-report`) |
40-
| Coverage | `bazel coverage //...` | LLVM code coverage (lcov) |
41-
42-
## Coverage Report (HTML)
43-
44-
Das Template bringt `bazelcov` mit, um aus `bazel coverage` einen HTML‑Report
45-
zu erzeugen. Voraussetzung: `genhtml` ist installiert (z. B. via `brew install lcov`).
46-
47-
Standard-Ausgabeort: `docs/coverage`
48-
49-
```bash
50-
# HTML-Report für das gesamte Repo
51-
bazel run //:coverage_html
52-
53-
# Nur bestimmte Targets
54-
bazel run //:coverage_html -- //app/... //tests/...
55-
```
56-
57-
## Native Linux Builds
58-
59-
```bash
60-
# On Linux (native), same toolchain setup via LLVM
61-
bazel build //...
62-
```
63-
64-
## Tooling (direnv + multitool)
65-
66-
This template uses LLVM via Bazel toolchains and can fetch developer tools
67-
through `rules_multitool`.
68-
69-
### direnv
70-
71-
Enable automatic environment loading:
72-
73-
```bash
74-
direnv allow
18+
bazel run //apps/example_app:example_app
7519
```
7620

77-
Optionally add local overrides to `.env` (e.g. `CC`/`CXX`), which are loaded by
78-
`.envrc`.
79-
80-
### bazel_env
81-
82-
Activate the full developer toolchain (adds tools to your PATH):
21+
## Common Tasks
8322

84-
```bash
85-
bazel run //tools:bazel_env
86-
```
87-
88-
Refresh your shell hash table if needed:
89-
90-
```bash
91-
rehash
92-
```
93-
94-
### rules_multitool
95-
96-
The lockfile lives at `tools/tools.lock.json`. Add tools there and they become
97-
available as Bazel toolchains. Example usage:
98-
99-
```bash
100-
bazel run @multitool//tools/<tool-name>:cwd -- --help
101-
```
23+
- Debug build: `bazel build --config=debug //...`
24+
- Release build: `bazel build --config=opt //...`
25+
- Coverage: `bazel coverage //...` then `bazel run //:coverage_html`
26+
- Compile commands: `bazel run //:refresh_compile_commands`
10227

103-
## Project Structure
28+
## Structure
10429

10530
```
106-
app/ # Application targets (cc_binary, cc_library)
107-
config/platforms/ # Platform definitions (macOS, Linux, etc.)
108-
tests/unit/ # Unit tests (Unity framework)
109-
third_party/ # External library BUILD files
110-
tools/ # Build tooling, compiler flags, macros
31+
apps/example_app/ # Demo binary
32+
apps/example_lib/ # Demo library
33+
tests/test_example_lib/ # Unity tests
34+
config/platforms/ # Platform definitions
35+
third_party/ # External BUILD files
36+
tools/ # Build tooling
37+
docs/coverage/ # Coverage HTML output
11138
```
11239

113-
## Dependencies
40+
## Notes
11441

115-
All external dependencies are managed via `MODULE.bazel` (Bzlmod).
116-
See [MODULE.bazel](MODULE.bazel) for the full list.
117-
42+
- `direnv allow` enables optional environment loading via `.envrc`.
43+
- `bazel run //tools:bazel_env` adds the full developer toolchain to PATH.

0 commit comments

Comments
 (0)