Skip to content

Commit 2bc3308

Browse files
authored
Merge pull request #45 from flyingrobots/feat/dependency-placeholders
feat: add dependency toggles and libgit2 detection
2 parents cac8e5e + a1cf99f commit 2bc3308

File tree

8 files changed

+141
-0
lines changed

8 files changed

+141
-0
lines changed

ACTIVITY.log.jsonl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@
7272
{"who": "AGENT", "what": "Debrief request acknowledged", "where": ["ACTIVITY.log.jsonl"], "when": "2025-10-24T10:22:09Z", "why": "Closing out the clang-tidy cleanup session", "how": "Ready to summarize findings and next steps for the branch", "protip": "Keep the ledger current even when the work shifts to review"}
7373
{"who": "AGENT", "what": "Re-enabled tidy checks with absolute header filter", "where": [".clang-tidy", "tools/lint/run_clang_tidy.sh"], "when": "2025-10-24T17:50:28Z", "why": "Review caught the over-broad disable—restored checks and confined analysis to project headers", "how": "Anchored HeaderFilterRegex, injected header filter path in run_clang_tidy.sh, and reran clang-tidy/make lint", "protip": "Let tidy focus on your tree via --header-filter instead of muting diagnostics"}
7474
{"who": "AGENT", "what": "Clarified clang-tidy baseline and restored checks", "where": [".clang-tidy", "tools/lint/run_clang_tidy.sh"], "when": "2025-10-24T19:28:49Z", "why": "Earlier log entries (lines 66-69) overstated system-header issues; review confirmed the real problem was over-broad disables", "how": "Re-enabled the security/readability checks, anchored the header filter to the repo root, and added validation so clang-tidy stays scoped", "protip": "Capture the actual diagnostic numbers next time—assumptions about system headers masked the real issue"}
75+
{"who": "AGENT", "what": "Added dependency toggles and documentation", "where": ["CMakeLists.txt", "meson.build", "meson_options.txt", "README.md", "CONTRIBUTING.md"], "when": "2025-10-25T06:16:07Z", "why": "Issue #3 requires libgit2 detection plus placeholders for CRoaring/BLAKE3", "how": "Hooked libgit2 via pkg-config in CMake/Meson, stubbed vendor options, and documented install commands", "protip": "Keep build options mirrored across CMake and Meson so contributors aren’t surprised"}
76+
{"who": "AGENT", "what": "Handled pkg-config absence on Windows", "where": ["CMakeLists.txt", "README.md"], "when": "2025-10-25T07:06:13Z", "why": "CI showed MSVC job missing pkg-config", "how": "Made pkg-config optional in CMake with a helpful error and documented Windows install command", "protip": "If CI uses MSVC, assume pkg-config isn’t preinstalled"}
77+
{"who": "AGENT", "what": "Made libgit2 optional across build systems", "where": ["CMakeLists.txt", "meson.build", "tools/container/Dockerfile", "README.md", "AGENTS.md"], "when": "2025-10-25T07:45:10Z", "why": "CI and reviewers flagged hard pkg-config/libgit2 dependency failures (esp. MSVC)", "how": "Added AUTO/ON/OFF toggle, fallback detection, private linkage, meson auto feature, pinned Docker install", "protip": "Treat optional deps as features: detect, warn, and gate definitions"}

AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ If you were expecting a YAML schema, go cry into your `.gitlab-ci.yml`.
1414

1515
## REPO RULES (READ THIS TWICE)
1616

17+
> **ABSOLUTELY NO HISTORY REWRITES**
18+
19+
Do not use `git commit --amend`, do not force-push, do not rebase. Ever.
20+
If you need to fix something, add a new commit and push normally. If
21+
upstream moved, pull and merge. The ledger is append-only.
22+
1723
> **NO REBASING.**
1824
1925
Rebasing is revisionist history. This is a ledger. Not a TED talk.

CMakeLists.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
66
set(CMAKE_C_EXTENSIONS OFF)
77
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
88

9+
option(GITLEDGER_VENDOR_LIBGIT2 "Build against a vendored libgit2 copy (placeholder)" OFF)
10+
option(GITLEDGER_WITH_CROARING "Enable CRoaring integration (placeholder)" OFF)
11+
option(GITLEDGER_WITH_BLAKE3 "Enable BLAKE3 support (placeholder)" OFF)
12+
set(GITLEDGER_WITH_LIBGIT2 "AUTO" CACHE STRING "Use libgit2 (values: AUTO, ON, OFF)")
13+
set_property(CACHE GITLEDGER_WITH_LIBGIT2 PROPERTY STRINGS AUTO ON OFF)
14+
string(TOUPPER "${GITLEDGER_WITH_LIBGIT2}" GITLEDGER_WITH_LIBGIT2_MODE)
15+
16+
if(GITLEDGER_WITH_CROARING)
17+
message(STATUS "CRoaring support is not implemented yet; continuing without it.")
18+
endif()
19+
20+
if(GITLEDGER_WITH_BLAKE3)
21+
message(STATUS "BLAKE3 support is not implemented yet; continuing without it.")
22+
endif()
23+
924
if(MSVC)
1025
set(PROJECT_WARNING_FLAGS /W4 /WX /we4244 /we4267 /we4456 /we4457 /we4458 /we4459)
1126
else()
@@ -26,6 +41,48 @@ set(LIBGITLEDGER_HEADERS
2641
add_library(gitledger STATIC ${LIBGITLEDGER_SOURCES} ${LIBGITLEDGER_HEADERS})
2742
target_compile_options(gitledger PRIVATE ${PROJECT_WARNING_FLAGS})
2843

44+
if(GITLEDGER_VENDOR_LIBGIT2)
45+
message(FATAL_ERROR "Vendored libgit2 support is not implemented yet.\n"
46+
"Install libgit2 on your system or rerun with -DGITLEDGER_VENDOR_LIBGIT2=OFF to continue.")
47+
endif()
48+
49+
set(GITLEDGER_LIBGIT2_TARGET "")
50+
51+
if(NOT GITLEDGER_WITH_LIBGIT2_MODE STREQUAL "OFF")
52+
find_package(LibGit2 QUIET)
53+
if(LibGit2_FOUND)
54+
set(GITLEDGER_LIBGIT2_TARGET LibGit2::LibGit2)
55+
else()
56+
find_package(PkgConfig QUIET)
57+
if(PKG_CONFIG_FOUND)
58+
pkg_check_modules(LIBGIT2 IMPORTED_TARGET libgit2)
59+
if(LIBGIT2_FOUND)
60+
set(GITLEDGER_LIBGIT2_TARGET PkgConfig::LIBGIT2)
61+
endif()
62+
endif()
63+
endif()
64+
65+
if(GITLEDGER_LIBGIT2_TARGET STREQUAL "")
66+
if(GITLEDGER_WITH_LIBGIT2_MODE STREQUAL "ON")
67+
message(FATAL_ERROR "libgit2 development files were not found.\n"
68+
"Install libgit2 and pkg-config using one of:\n"
69+
" sudo apt-get install libgit2-dev pkg-config\n"
70+
" brew install libgit2 pkg-config\n"
71+
" choco install libgit2 pkgconfiglite\n"
72+
"Then rerun CMake, or pass -DGITLEDGER_WITH_LIBGIT2=OFF to continue without libgit2.")
73+
else()
74+
message(STATUS "libgit2 not found; continuing without libgit2 integration."
75+
" Set -DGITLEDGER_WITH_LIBGIT2=ON after installing libgit2 to enable it.")
76+
endif()
77+
else()
78+
message(STATUS "libgit2 dependency detected via ${GITLEDGER_LIBGIT2_TARGET}.")
79+
target_link_libraries(gitledger PRIVATE ${GITLEDGER_LIBGIT2_TARGET})
80+
target_compile_definitions(gitledger PRIVATE GITLEDGER_HAVE_LIBGIT2=1)
81+
endif()
82+
else()
83+
message(STATUS "libgit2 support disabled via -DGITLEDGER_WITH_LIBGIT2=OFF")
84+
endif()
85+
2986
target_include_directories(gitledger
3087
PUBLIC
3188
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libgitledger/include>

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Thanks for helping build `libgitledger`! This document complements the roadmap a
1414
- Maintain both build systems. Preferred: run the containerised make targets (`make cmake`, `make meson`, `make test-both`) so you exercise the same matrix CI runs. These jobs copy the repo into isolated workspaces, prepare sandbox Git fixtures, and remove all remotes before mutating anything.
1515
- If you must run directly on the host checkout, export `I_KNOW_WHAT_I_AM_DOING=1` before invoking host targets. The makefile will otherwise abort unless it detects the container guard. Manual command sequences for CMake/Meson live in the README if you need to craft bespoke invocations.
1616
- Align tooling: warning flags, optional dependencies, and targets must stay consistent across CMake and Meson.
17+
- Install prerequisites (at minimum `libgit2` and `pkg-config`) before running host builds. Examples: `sudo apt-get install libgit2-dev pkg-config` or `brew install libgit2 pkg-config`.
1718
- When adding dependencies, update both build descriptions and mention the change in the relevant issue.
1819
- Run `make lint` (containerised clang-format + clang-tidy) before submitting a PR. CI enforces the same suite on GCC, Clang, and MSVC.
1920
- Need to bypass clang-tidy for a quick repro? Run `RUN_TIDY=0 make host-tidy` locally, but flip it back to 1 before shipping anything.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,40 @@ make format # apply clang-format in-place (runs on the host)
9191
make markdownlint # lint Markdown docs using markdownlint-cli
9292
```
9393

94+
## Dependencies
95+
96+
`libgitledger` links against [`libgit2`](https://libgit2.org/). Ensure the development
97+
headers are available before configuring either build system:
98+
99+
- **Debian/Ubuntu**
100+
101+
```bash
102+
sudo apt-get update
103+
sudo apt-get install libgit2-dev pkg-config
104+
```
105+
106+
- **macOS (Homebrew)**
107+
108+
```bash
109+
brew install libgit2 pkg-config
110+
```
111+
112+
- **Windows (Chocolatey)**
113+
114+
```powershell
115+
choco install libgit2 pkgconfiglite
116+
```
117+
118+
Optional knobs surface in both build systems:
119+
120+
- CMake: `-DGITLEDGER_WITH_LIBGIT2=OFF` to configure without libgit2, (future)
121+
`-DGITLEDGER_VENDOR_LIBGIT2=ON` for vendoring once implemented, plus
122+
placeholders `-DGITLEDGER_WITH_CROARING=ON` and `-DGITLEDGER_WITH_BLAKE3=ON`.
123+
- Meson: `-Dvendor_libgit2=true`, `-Dwith_croaring=enabled`, and `-Dwith_blake3=enabled`.
124+
125+
The CRoaring and BLAKE3 switches are stubs for future work and simply log that
126+
the integration is pending.
127+
94128
## Coding Standards
95129

96130
- `.clang-format` defines the canonical formatting rules; run `make format` to apply them and

meson.build

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,55 @@ project('libgitledger', 'c',
33
default_options: ['c_std=c17', 'warning_level=3', 'werror=true']
44
)
55

6+
vendor_libgit2 = get_option('vendor_libgit2')
7+
with_libgit2_opt = get_option('with_libgit2')
8+
9+
if vendor_libgit2
10+
error('Vendored libgit2 support is not yet implemented. Install libgit2 or configure with -Dvendor_libgit2=false.')
11+
endif
12+
13+
libgit2_required = with_libgit2_opt.enabled()
14+
libgit2_dep = dependency('libgit2', required: libgit2_required)
15+
16+
if not libgit2_dep.found()
17+
if with_libgit2_opt.disabled()
18+
message('libgit2 disabled by configuration; continuing without it.')
19+
else
20+
message('libgit2 development files not found; install via your package manager (e.g. apt install libgit2-dev, brew install libgit2, or choco install libgit2).')
21+
if libgit2_required
22+
error('libgit2 was requested but could not be located.')
23+
endif
24+
endif
25+
endif
26+
27+
if not get_option('with_croaring').disabled()
28+
message('CRoaring support is not implemented yet; option is currently informational only.')
29+
endif
30+
31+
if not get_option('with_blake3').disabled()
32+
message('BLAKE3 support is not implemented yet; option is currently informational only.')
33+
endif
34+
635
lib_sources = [
736
'libgitledger/core/domain/gitledger.c',
837
'src/version.c',
938
]
1039

1140
include_dir = include_directories('libgitledger/include', 'include')
1241

42+
lib_deps = []
43+
lib_c_args = []
44+
if libgit2_dep.found()
45+
lib_deps += libgit2_dep
46+
lib_c_args += ['-DGITLEDGER_HAVE_LIBGIT2=1']
47+
endif
48+
1349
libgitledger = static_library(
1450
'gitledger',
1551
lib_sources,
1652
include_directories: include_dir,
53+
dependencies: lib_deps,
54+
c_args: lib_c_args,
1755
)
1856

1957
tests_version = executable(

meson_options.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
option('vendor_libgit2', type: 'boolean', value: false, description: 'Build against vendored libgit2 (placeholder)')
12
option('with_libgit2', type: 'feature', value: 'auto', description: 'Enable libgit2 integration when available')
23
option('with_croaring', type: 'feature', value: 'disabled', description: 'Enable CRoaring integration when available')
34
option('with_blake3', type: 'feature', value: 'disabled', description: 'Enable BLAKE3 checksum support')

tools/container/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ RUN apt-get update \
1414
python3-pip=24.0+dfsg-1ubuntu1.3 \
1515
rsync=3.2.7-1ubuntu1.2 \
1616
meson=1.3.2-1ubuntu1 \
17+
libgit2-dev=1.7.2+ds-1ubuntu3 \
1718
gcc-14=14.2.0-4ubuntu2~24.04 \
1819
g++-14=14.2.0-4ubuntu2~24.04 \
1920
clang-18=1:18.1.3-1ubuntu1 \

0 commit comments

Comments
 (0)