; IDE Server
(ocamllex utf8_convert config_lexer rocq_lex)

(library
 (name core)
 (public_name coqide-server.core)
 (wrapped false)
 (modules document)
 (libraries rocq-runtime.boot rocq-runtime.lib))

(executable
 (name idetop)
 (public_name coqidetop)
 (package coqide-server)
 (modules idetop)
 (libraries rocq-runtime.toplevel coqide-server.protocol platform_specific)
 (link_flags -linkall))

; IDE Client, we may want to add the macos_prehook.ml conditionally.
(library
 (name rocqide_gui)
 (wrapped false)
 (modules (:standard \ document idetop rocqide_main default_bindings_src gen_gtk_platform
    shared shared_os_specific))
 (foreign_stubs
  (language c)
  (names rocqide_os_stubs))
 (libraries coqide-server.protocol coqide-server.core lablgtk3-sourceview3 platform_specific))

(library
 (name platform_specific)
 (wrapped false)
 (modules shared shared_os_specific)
 (foreign_stubs
  (language c)
  (names shared_os_stubs))
)

(executable
 (name gen_gtk_platform)
 (modules gen_gtk_platform)
 (libraries conf))

(rule
 (targets gtk_platform.conf config.ml)
 (action (run ./gen_gtk_platform.exe)))

(rule
 (targets rocqide_os_specific.ml)
 (action (copy# rocqide_%{read:gtk_platform.conf}.ml.in %{targets})))

(rule
 (targets shared_os_specific.ml)
 (action (copy# shared_%{read:gtk_platform.conf}.ml.in %{targets})))

(rule
 (targets rocqide_os_stubs.c)
 (action (copy rocqide_%{read:gtk_platform.conf}.c.in %{targets})))

(rule
 (targets shared_os_stubs.c)
 (action (copy shared_%{read:gtk_platform.conf}.c.in %{targets})))

(executable
 (name rocqide_main)
 (public_name rocqide)
 (package rocqide)
 (modules rocqide_main)
 (modes exe byte)
 (libraries rocqide_gui))

(documentation
 (package rocqide))

; Input-method bindings
(executable
 (name default_bindings_src)
 (modules default_bindings_src))

(rule
 (targets default.bindings)
 (deps (:gen ./default_bindings_src.exe))
 (action (run %{gen} %{targets})))

; FIXME: we should install those in share/rocqide. We better do this
; once the make-based system has been phased out.
(install
 (section share_root)
 (package rocqide)
 (files
  (coq.png as coq/coq.png)
  (default.bindings as coq/default.bindings)
  (coq_style.xml as coq/coq_style.xml)
  (coq.lang as coq/coq.lang)
  (coq-ssreflect.lang as coq/coq-ssreflect.lang)))
