|
| 1 | +# Maintainer Guide |
| 2 | + |
| 3 | +This document collects notes and commands useful when maintaining |
| 4 | +`codetracer-ruby-recorder`. |
| 5 | + |
| 6 | +## Development environment |
| 7 | + |
| 8 | +This repository provides a Nix flake for the development shell. With |
| 9 | +`direnv` installed, the shell is loaded automatically when you enter the |
| 10 | +repository directory. Run `direnv allow` once to enable it. |
| 11 | + |
| 12 | +The same environment is configured for GitHub Codespaces via the |
| 13 | +provided devcontainer configuration. |
| 14 | + |
| 15 | +## Building the native extension |
| 16 | + |
| 17 | +The tracer ships with a Rust extension located in `ext/native_tracer`. |
| 18 | +To build it locally run: |
| 19 | + |
| 20 | +```bash |
| 21 | +just build-extension |
| 22 | +``` |
| 23 | + |
| 24 | +This compiles the extension in release mode using Cargo. The resulting |
| 25 | +shared library is placed under |
| 26 | +`ext/native_tracer/target/release/` and is loaded by `src/native_trace.rb`. |
| 27 | + |
| 28 | +## Running tests and benchmarks |
| 29 | + |
| 30 | +Execute the full test suite with: |
| 31 | + |
| 32 | +```bash |
| 33 | +just test |
| 34 | +``` |
| 35 | + |
| 36 | +The tests run several sample programs from `test/programs` and compare |
| 37 | +the generated traces with the fixtures under `test/fixtures`. |
| 38 | + |
| 39 | +Benchmarks can be executed with: |
| 40 | + |
| 41 | +```bash |
| 42 | +just bench |
| 43 | +``` |
| 44 | + |
| 45 | +## Publishing gems |
| 46 | + |
| 47 | +Two Ruby gems are published from this repository: |
| 48 | + |
| 49 | +* **codetracer-ruby-recorder** – the tracer with the compiled native |
| 50 | + extension. Prebuilt gems are produced per target platform using |
| 51 | + [`rb_sys`](https://github.com/oxidize-rb/rb-sys). |
| 52 | +* **codetracer_pure_ruby_recorder** – a pure Ruby fallback without the |
| 53 | + native extension. |
| 54 | + |
| 55 | +### Native extension gem |
| 56 | + |
| 57 | +1. Install the development dependencies: |
| 58 | + |
| 59 | + ```bash |
| 60 | + bundle install |
| 61 | + ``` |
| 62 | + |
| 63 | +2. For each target platform set `RB_SYS_CARGO_TARGET` and build the gem: |
| 64 | + |
| 65 | + ```bash |
| 66 | + RB_SYS_CARGO_TARGET=x86_64-unknown-linux-gnu rake cross_native_gem |
| 67 | + ``` |
| 68 | + |
| 69 | + Replace the target triple with the desired platform (for example |
| 70 | + `aarch64-apple-darwin`). |
| 71 | + |
| 72 | +3. Push the generated gem found in `pkg/` to RubyGems: |
| 73 | + |
| 74 | + ```bash |
| 75 | + gem push pkg/codetracer-ruby-recorder-<version>-x86_64-linux.gem |
| 76 | + ``` |
| 77 | + |
| 78 | +Repeat these steps for each supported platform. |
| 79 | + |
| 80 | +### Pure Ruby gem |
| 81 | + |
| 82 | +The pure Ruby tracer is packaged from the files under `src/`. Build and |
| 83 | +publish it with: |
| 84 | + |
| 85 | +```bash |
| 86 | +gem build codetracer_pure_ruby_recorder.gemspec |
| 87 | +gem push codetracer_pure_ruby_recorder-<version>.gem |
| 88 | +``` |
| 89 | + |
| 90 | +Ensure the version matches the native extension gem so that both |
| 91 | +packages can be used interchangeably. |
0 commit comments