|
| 1 | +# Bazel Central Registry Submission Guide |
| 2 | + |
| 3 | +This repository is now prepared for BCR submission with TWO separate modules: |
| 4 | + |
| 5 | +## Modules |
| 6 | + |
| 7 | +### 1. `codspeed_core` (v1.4.0) |
| 8 | +**Location**: `core/` |
| 9 | +**Description**: Core CodSpeed instrumentation library for C++ |
| 10 | +**Public targets**: |
| 11 | +- `@codspeed_core//:codspeed` - Main library |
| 12 | +- `@codspeed_core//:instrument_hooks` - Low-level instrumentation |
| 13 | +- `@codspeed_core//:codspeed_mode` - Build flag (values: off, instrumentation, walltime) |
| 14 | + |
| 15 | +### 2. `codspeed_google_benchmark` (v1.4.0) |
| 16 | +**Location**: `google_benchmark/` |
| 17 | +**Description**: CodSpeed-enhanced Google Benchmark integration |
| 18 | +**Public targets**: |
| 19 | +- `@codspeed_google_benchmark//:benchmark` - Main benchmark library |
| 20 | +- `@codspeed_google_benchmark//:benchmark_main` - Benchmark main function |
| 21 | + |
| 22 | +**Dependencies**: Depends on `codspeed_core` v1.4.0 |
| 23 | + |
| 24 | +## Files Created for BCR |
| 25 | + |
| 26 | +### For `codspeed_core`: |
| 27 | +- ✅ `core/MODULE.bazel` - Module definition |
| 28 | +- ✅ `core/metadata.json` - Module metadata |
| 29 | +- ✅ `core/source.json` - Source archive info (needs SHA256 checksum) |
| 30 | +- ✅ `core/presubmit.yml` - BCR testing configuration |
| 31 | + |
| 32 | +### For `codspeed_google_benchmark`: |
| 33 | +- ✅ `google_benchmark/MODULE.bazel` - Module definition |
| 34 | +- ✅ `google_benchmark/metadata.json` - Module metadata |
| 35 | +- ✅ `google_benchmark/source.json` - Source archive info (needs SHA256 checksum) |
| 36 | +- ✅ `google_benchmark/presubmit.yml` - BCR testing configuration |
| 37 | + |
| 38 | +### Repository root: |
| 39 | +- ✅ `MODULE.bazel` - Updated with `local_path_override` for local development |
| 40 | +- ✅ `.bazelrc` - Updated flag references to use `@codspeed_core//:codspeed_mode` |
| 41 | +- ✅ `.github/workflows/ci.yml` - Updated flag references |
| 42 | + |
| 43 | +## Local Development Setup |
| 44 | + |
| 45 | +The repository uses `local_path_override` to enable local development with the module structure: |
| 46 | + |
| 47 | +```python |
| 48 | +# In root MODULE.bazel |
| 49 | +bazel_dep(name = "codspeed_core", version = "1.4.0") |
| 50 | +local_path_override(module_name = "codspeed_core", path = "core") |
| 51 | + |
| 52 | +bazel_dep(name = "codspeed_google_benchmark", version = "1.4.0") |
| 53 | +local_path_override(module_name = "codspeed_google_benchmark", path = "google_benchmark") |
| 54 | +``` |
| 55 | + |
| 56 | +This allows you to: |
| 57 | +- Build from the root: `bazel build //examples/...` |
| 58 | +- Test changes locally before BCR submission |
| 59 | +- Use the same flag syntax as end users: `--@codspeed_core//:codspeed_mode=instrumentation` |
| 60 | + |
| 61 | +## BCR Submission Steps |
| 62 | + |
| 63 | +### Before Submission |
| 64 | + |
| 65 | +1. **Create a release tag** (e.g., `v1.4.0`): |
| 66 | + ```bash |
| 67 | + git tag v1.4.0 |
| 68 | + git push origin v1.4.0 |
| 69 | + ``` |
| 70 | + |
| 71 | +2. **Generate SHA256 checksums** for the source archives: |
| 72 | + ```bash |
| 73 | + # Download the release archive |
| 74 | + wget https://github.com/CodSpeedHQ/codspeed-cpp/archive/refs/tags/v1.4.0.tar.gz |
| 75 | + |
| 76 | + # Calculate SHA256 |
| 77 | + sha256sum v1.4.0.tar.gz |
| 78 | + ``` |
| 79 | + |
| 80 | +3. **Update `source.json` files** with the actual SHA256 checksums: |
| 81 | + - Replace `TODO_REPLACE_WITH_ACTUAL_SHA256_CHECKSUM` in `core/source.json` |
| 82 | + - Replace `TODO_REPLACE_WITH_ACTUAL_SHA256_CHECKSUM` in `google_benchmark/source.json` |
| 83 | + |
| 84 | +### Submission Order |
| 85 | + |
| 86 | +**Important**: Submit `codspeed_core` FIRST, then `codspeed_google_benchmark` (since it depends on core). |
| 87 | + |
| 88 | +#### Step 1: Submit `codspeed_core` |
| 89 | + |
| 90 | +1. Fork the [bazel-central-registry repository](https://github.com/bazelbuild/bazel-central-registry) |
| 91 | +2. Create directory structure: |
| 92 | + ``` |
| 93 | + modules/codspeed_core/ |
| 94 | + ├── metadata.json (copy from core/metadata.json) |
| 95 | + └── 1.4.0/ |
| 96 | + ├── MODULE.bazel (copy from core/MODULE.bazel) |
| 97 | + ├── source.json (copy from core/source.json with SHA256) |
| 98 | + └── presubmit.yml (copy from core/presubmit.yml) |
| 99 | + ``` |
| 100 | +3. Create a PR to the BCR repository |
| 101 | +4. Wait for CI to pass and maintainers to merge |
| 102 | + |
| 103 | +#### Step 2: Submit `codspeed_google_benchmark` |
| 104 | + |
| 105 | +1. After `codspeed_core` is merged, create another directory: |
| 106 | + ``` |
| 107 | + modules/codspeed_google_benchmark/ |
| 108 | + ├── metadata.json (copy from google_benchmark/metadata.json) |
| 109 | + └── 1.4.0/ |
| 110 | + ├── MODULE.bazel (copy from google_benchmark/MODULE.bazel) |
| 111 | + ├── source.json (copy from google_benchmark/source.json with SHA256) |
| 112 | + └── presubmit.yml (copy from google_benchmark/presubmit.yml) |
| 113 | + ``` |
| 114 | +2. Create a PR to the BCR repository |
| 115 | +3. Wait for CI to pass and maintainers to merge |
| 116 | + |
| 117 | +## User Experience (After BCR Submission) |
| 118 | + |
| 119 | +Once published, users can use your modules like this: |
| 120 | + |
| 121 | +### Using google_benchmark integration: |
| 122 | + |
| 123 | +```python |
| 124 | +# In their MODULE.bazel |
| 125 | +bazel_dep(name = "codspeed_google_benchmark", version = "1.4.0") |
| 126 | + |
| 127 | +# In their BUILD.bazel |
| 128 | +cc_test( |
| 129 | + name = "my_benchmark", |
| 130 | + srcs = ["my_benchmark.cpp"], |
| 131 | + deps = ["@codspeed_google_benchmark//:benchmark"], |
| 132 | +) |
| 133 | +``` |
| 134 | + |
| 135 | +### Build with instrumentation: |
| 136 | +```bash |
| 137 | +bazel build :my_benchmark --@codspeed_core//:codspeed_mode=instrumentation |
| 138 | +``` |
| 139 | + |
| 140 | +### Build with walltime: |
| 141 | +```bash |
| 142 | +bazel build :my_benchmark --@codspeed_core//:codspeed_mode=walltime |
| 143 | +``` |
| 144 | + |
| 145 | +### Using core library directly (advanced): |
| 146 | + |
| 147 | +```python |
| 148 | +bazel_dep(name = "codspeed_core", version = "1.4.0") |
| 149 | + |
| 150 | +cc_binary( |
| 151 | + name = "my_app", |
| 152 | + deps = ["@codspeed_core//:codspeed"], |
| 153 | +) |
| 154 | +``` |
| 155 | + |
| 156 | +## Testing BCR Submission Locally |
| 157 | + |
| 158 | +Before submitting, you can test the BCR structure locally: |
| 159 | + |
| 160 | +1. Create a test workspace outside this repo |
| 161 | +2. Add your modules with `archive_override`: |
| 162 | + ```python |
| 163 | + bazel_dep(name = "codspeed_core", version = "1.4.0") |
| 164 | + archive_override( |
| 165 | + module_name = "codspeed_core", |
| 166 | + urls = ["https://github.com/CodSpeedHQ/codspeed-cpp/archive/refs/tags/v1.4.0.tar.gz"], |
| 167 | + strip_prefix = "codspeed-cpp-1.4.0/core", |
| 168 | + ) |
| 169 | + ``` |
| 170 | +3. Try building against the modules |
| 171 | + |
| 172 | +## Future Module Additions |
| 173 | + |
| 174 | +To add more framework integrations (e.g., Catch2, Criterion): |
| 175 | + |
| 176 | +1. Create `<framework>/MODULE.bazel` with: |
| 177 | + ```python |
| 178 | + module(name = "codspeed_<framework>", version = "X.Y.Z") |
| 179 | + bazel_dep(name = "codspeed_core", version = "X.Y.Z") |
| 180 | + ``` |
| 181 | +2. Update `<framework>/BUILD` to use `@codspeed_core//:codspeed` |
| 182 | +3. Add local_path_override to root MODULE.bazel |
| 183 | +4. Follow the same BCR submission process |
| 184 | + |
| 185 | +## Important Notes |
| 186 | + |
| 187 | +- ✅ `instrument_hooks` is vendored in `core/instrument-hooks/` - no external dependency needed |
| 188 | +- ✅ Version numbers are synced to 1.4.0 across all files |
| 189 | +- ✅ All builds tested successfully with local_path_override |
| 190 | +- ✅ CI workflows updated to use correct module references |
| 191 | +- ⚠️ **TODO**: Update SHA256 checksums in source.json files before submission |
| 192 | +- ⚠️ **TODO**: Create v1.4.0 release tag before submission |
| 193 | + |
| 194 | +## Questions? |
| 195 | + |
| 196 | +Refer to the [Bazel Central Registry documentation](https://github.com/bazelbuild/bazel-central-registry/blob/main/docs/README.md) for more details. |
0 commit comments