How do I have dune execute a shell command as a dependency to a library?

I have a library that has some C stubs which needs to be linked against some other C code that I need to compile directly with gcc.

I’m trying to do it like this, but the rule that calls gcc doesn’t seem to be executing:

(rule
    (targets libart.o)
    (deps (:c art.c) (:h art.h))
    (action 
        (run gcc -c -std=c99 -D_GNU_SOURCE -Wall -Werror -O3 -g %{c} -o %{targets})))

(library
    (name art)
    (preprocessor_deps libart.o)
    (c_flags -I lib/)
    (c_library_flags ./lib/libart.o)
    (c_names art_stubs))

The best way to do that is via the following method: https://dune.readthedocs.io/en/latest/foreign-code.html#foreign-build-sandboxing

i.e. attach the manually built object files to an OCaml library via self_build_stubs_archive

1 Like