Skip to content

Auto-generate Version_libclang_bindings module#15

Merged
bolt12 merged 3 commits into
mainfrom
tcard/Version_libclang_bindings
Nov 20, 2025
Merged

Auto-generate Version_libclang_bindings module#15
bolt12 merged 3 commits into
mainfrom
tcard/Version_libclang_bindings

Conversation

@TravisCardwell

Copy link
Copy Markdown
Collaborator

This PR adds clangVersionCompileTime :: Text to the Clang.Version module. It is the full version string as reported by clang_getClangVersion at compile-time. This is done so that we can use clang_getClangVersion at run-time and compare the versions (as text, not parsed versions).

This works by using autoconf to link a C program that prints the version. This program is run, and the output is captured. The version string is then written into a Haskell module template, with double quotes escaped. The module is named Version_libclang_bindings to match the naming style of other autogen modules. It is exposed internally (in other-modules), and clangVersionCompileTime is re-exported by public module Clang.Version.

$ cabal repl
...
Configuring library for libclang-bindings-0.1.0...
...
checking libclang version... clang version 21.1.4
...
config.status: creating autogen/Version_libclang_bindings.hs
...
Ok, 30 modules loaded.
λ: import Clang.Version
λ: print clangVersionCompileTime
"clang version 21.1.4"
it :: ()

This has not been tested on Windows or macOS yet, but it should work.

@bolt12
bolt12 force-pushed the tcard/Version_libclang_bindings branch from 4187d0b to ca69eeb Compare November 20, 2025 10:21
@bolt12
bolt12 enabled auto-merge November 20, 2025 10:23
@bolt12
bolt12 force-pushed the tcard/Version_libclang_bindings branch from ca69eeb to bab0424 Compare November 20, 2025 10:59
@bolt12
bolt12 disabled auto-merge November 20, 2025 11:11
@bolt12
bolt12 added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit 962a028 Nov 20, 2025
16 checks passed
@bolt12
bolt12 deleted the tcard/Version_libclang_bindings branch November 20, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants