ocaml / ocaml/dune

[extension] Add `(pkg_config ...)` field.

Open
#1,906 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

c-bindings config
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

As suggested in https://github.com/ocaml/dune/pull/1886 , adding a field for automatically importing pkg_config build flags could be convenient and save quite a few boilerplate for C users.

The idea would be to have a new feature:

(using pkg_config)

which would extend the (library ...) stanza to add a field:

(pkg_config gtk+-3.0 >= 3.18)

Such field should unsugar to something similar to:

(rule
 (targets
   cflag-gtk+-3.0.sexp
   clink-gtk+-3.0.sexp)
 (action (run ./dune_config.exe -pkg gtk+-3.0 -version 3.18)))
...
 (c_flags         (:include cflag-gtk+-3.0.sexp))
 (c_library_flags (:include clink-gtk+-3.0.sexp))

where dune_config is the straightforward call to configurator [that could be embedded by dune avoiding the .exe and intermediate file of course]

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked pull request 1886 and the current handling of the library stanza and extension syntax. Trace how the proposed pkg_config field could invoke configurator or dune_config.exe and provide C flags. Done means the syntax, generated flags, and version constraint behavior are implemented and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.