ocaml / ocaml/dune

Configurator: allow querying pkg-config with multiple packages

Open
#9,022 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Desired Behavior

pkg-config supports being queried with multiple packages, but dune-configurator only allows querying with one package at a time. Enabling this support would simplify user code, and save a few invocations.

Example

$ pkg-config --libs --cflags xft x11 wayland-client
-I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/sysprof-6 -pthread -lXft -lX11 -lwayland-client
let from_pkg_config c =
  match C.Pkg_config.get c with
  | None -> ([], [])
  | Some pc ->
    ["xft"; "x11"; "wayland-client"] |>
    List.fold_left (fun ((cflags', libs') as acc) package ->
        match C.Pkg_config.query pc ~package with
        | None -> acc
        | Some { cflags; libs } -> cflags' @ cflags, libs' @ libs) ([], [])
        
(* it's worse imo with *)
val query_expr_err
      :  t
      -> package:string
      -> expr:string
      -> (package_conf, string) result

(* maybe the interface should be *)

val queries : t -> packages:string list -> package_conf option

val queries_exprs_err
  :  t
  -> packages:string list
  -> exprs:string list
  -> (package_conf, string) result
(* or using pairs? *)

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 with dune-configurator's C.Pkg_config.get and query API, then trace how pkg-config invocations are assembled. Compare the proposed multi-package interface options and verify that combined cflags and libs, including error handling, are returned correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.