Repository navigation
Development Setup
Everything you need to change OpenABE and get a green pull request. Read CONTRIBUTING.md first for the PR rules.
Follow Getting Started for your platform. As a contributor you also need bison and flex (already in the package lists there). The parser is regenerated from src/zparser.yy and src/zscanner.ll whenever you change them.
The style is defined in .clang-format and enforced by CI. It is LLVM with these changes:
| Option | LLVM | OpenABE |
|---|---|---|
ColumnLimit |
80 | 100 |
PointerAlignment |
Right (int *p) |
Left (int* p) |
AllowShortFunctionsOnASingleLine |
All |
Empty |
SortIncludes |
CaseSensitive |
Never: see below |
Indentation is 2 spaces, with no tabs.
Use exactly version 18.1.8. Other releases format some constructs differently, and CI would reject your code even though it looks formatted to you:
pipx install clang-format==18.1.8 # or: pip install --user clang-format==18.1.8
clang-format --version # must print 18.1.8Format before committing:
clang-format -i --style=file path/to/changed_file.cpp
# or every C/C++ file you touched compared to master:
git diff --name-only master -- '*.c' '*.cc' '*.cpp' '*.h' '*.hh' | xargs clang-format -i --style=fileMany headers are not self-contained: they compile only because openabe.h includes their dependencies first, in a specific order. Sorting includes alphabetically breaks the build. Until every header includes what it uses, keep the existing include order and add new includes where they are needed, not where they would sort. See Known Limitations.
src/zparser.tab.cc, src/zparser.tab.hh, src/location.hh, src/position.hh, src/stack.hh and src/zscanner.cpp are bison/flex output and are listed in .clang-format-ignore. Edit zparser.yy / zscanner.ll instead and rebuild.
With the C/C++ extension (ms-vscode.cpptools), create .vscode/settings.json. It is git-ignored, so it stays on your machine:
Where the binary lives:
| Installed with | Path |
|---|---|
pipx (Linux/macOS) |
~/.local/bin/clang-format |
pip --user (Windows) |
%APPDATA%\Python\PythonXY\Scripts\clang-format.exe |
Two notes on these settings:
- Why not the bundled clang-format? The extension ships its own clang-format, whose version changes with extension updates. Pinning the path keeps your editor and CI in agreement.
-
Why
formatOnSaveMode: modifications? When VS Code formats a file it passes the code through stdin, and clang-format then ignores.clang-format-ignore. Formatting only the lines you changed keeps the generated files intact if you ever save one of them.
The bulk reformatting commit is listed in .git-blame-ignore-revs. GitHub already skips it in blame; to do the same locally:
git config blame.ignoreRevsFile .git-blame-ignore-revs. ./env
make && make test && make -C examples test
clang-format --dry-run --Werror --style=file <changed files>
git diff --checkThen fill in the PR template. Testing and CI lists everything CI will run.
OpenABE · AGPL-3.0 · Found a mistake in this wiki? Open an issue.
Using OpenABE
Reference
Contributing
Design notes
Help
{ // Point this to the clang-format 18.1.8 you installed "C_Cpp.clang_format_path": "/path/to/clang-format", "C_Cpp.clang_format_style": "file", "C_Cpp.clang_format_fallbackStyle": "none", "C_Cpp.formatting": "clangFormat", "[c]": { "editor.defaultFormatter": "ms-vscode.cpptools", "editor.formatOnSave": true, "editor.formatOnSaveMode": "modifications" }, "[cpp]": { "editor.defaultFormatter": "ms-vscode.cpptools", "editor.formatOnSave": true, "editor.formatOnSaveMode": "modifications" }, "editor.tabSize": 2, "editor.insertSpaces": true, "editor.detectIndentation": false, "editor.rulers": [100], "files.trimTrailingWhitespace": true, "files.insertFinalNewline": true }