Add link_deps field
In some cases, the linking step requires some dependencies. For example, passing a version script to the linker. The new `(link_deps)` field uses the dependency DSL already used in other places. Closes #852 Signed-off-by: Etienne Millon <etienne@cryptosense.com>
This commit is contained in:
parent
5d6e919f04
commit
96b01c569c
|
@ -75,6 +75,9 @@ next
|
|||
* Allow setting environment variables in `findlib.conf` for cross compilation
|
||||
contexts. (#733, @rgrinberg)
|
||||
|
||||
- Add a `link_deps` field to executables, to specify link-time dependencies
|
||||
like version scripts. (#879, fix #852, @emillon)
|
||||
|
||||
1.0+beta20 (10/04/2018)
|
||||
-----------------------
|
||||
|
||||
|
|
|
@ -248,6 +248,10 @@ Executables can also be linked as object or shared object files. See
|
|||
- ``(link_flags <flags>)`` specifies additional flags to pass to the linker.
|
||||
This field supports ``(:include ...)`` forms
|
||||
|
||||
- ``(link_deps (<deps-conf list>))`` specifies the dependencies used only by the
|
||||
linker, for example when using a version script. See the `Dependency
|
||||
specification`_ section for more details.
|
||||
|
||||
- ``(modules <modules>)`` specifies which modules in the current directory
|
||||
Jbuilder should consider when building this executable. Modules not listed
|
||||
here will be ignored and cannot be used inside the executable described by
|
||||
|
|
|
@ -857,7 +857,11 @@ module Gen(P : Install_rules.Params) = struct
|
|||
in
|
||||
|
||||
let flags = SC.ocaml_flags sctx ~scope ~dir exes.buildable in
|
||||
let link_deps =
|
||||
SC.Deps.interpret sctx ~scope ~dir exes.link_deps
|
||||
in
|
||||
let link_flags =
|
||||
link_deps >>^ ignore >>>
|
||||
SC.expand_and_eval_set sctx exes.link_flags
|
||||
~scope
|
||||
~dir
|
||||
|
|
|
@ -874,6 +874,7 @@ module Executables = struct
|
|||
type t =
|
||||
{ names : (Loc.t * string) list
|
||||
; link_flags : Ordered_set_lang.Unexpanded.t
|
||||
; link_deps : Dep_conf.t list
|
||||
; modes : Link_mode.Set.t
|
||||
; buildable : Buildable.t
|
||||
}
|
||||
|
@ -887,6 +888,7 @@ module Executables = struct
|
|||
field "link_executables" bool ~default:true >>= fun _ ->
|
||||
return ())
|
||||
>>= fun () ->
|
||||
field "link_deps" (list Dep_conf.t) ~default:[] >>= fun link_deps ->
|
||||
field_oslu "link_flags" >>= fun link_flags ->
|
||||
field "modes" Link_mode.Set.t ~default:Link_mode.Set.default
|
||||
>>= fun modes ->
|
||||
|
@ -902,6 +904,7 @@ module Executables = struct
|
|||
let t =
|
||||
{ names
|
||||
; link_flags
|
||||
; link_deps
|
||||
; modes
|
||||
; buildable
|
||||
}
|
||||
|
|
|
@ -258,6 +258,7 @@ module Executables : sig
|
|||
type t =
|
||||
{ names : (Loc.t * string) list
|
||||
; link_flags : Ordered_set_lang.Unexpanded.t
|
||||
; link_deps : Dep_conf.t list
|
||||
; modes : Link_mode.Set.t
|
||||
; buildable : Buildable.t
|
||||
}
|
||||
|
|
|
@ -330,6 +330,14 @@
|
|||
test-cases/lib-available
|
||||
(progn (run ${exe:cram.exe} -test run.t) (diff? run.t run.t.corrected))))))
|
||||
|
||||
(alias
|
||||
((name link-deps)
|
||||
(deps ((package dune) (files_recursively_in test-cases/link-deps)))
|
||||
(action
|
||||
(chdir
|
||||
test-cases/link-deps
|
||||
(progn (run ${exe:cram.exe} -test run.t) (diff? run.t run.t.corrected))))))
|
||||
|
||||
(alias
|
||||
((name loop)
|
||||
(deps ((package dune) (files_recursively_in test-cases/loop)))
|
||||
|
@ -592,6 +600,7 @@
|
|||
(alias installable-dup-private-libs)
|
||||
(alias intf-only)
|
||||
(alias lib-available)
|
||||
(alias link-deps)
|
||||
(alias loop)
|
||||
(alias menhir)
|
||||
(alias merlin-tests)
|
||||
|
@ -656,6 +665,7 @@
|
|||
(alias installable-dup-private-libs)
|
||||
(alias intf-only)
|
||||
(alias lib-available)
|
||||
(alias link-deps)
|
||||
(alias loop)
|
||||
(alias merlin-tests)
|
||||
(alias meta-gen)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
(alias
|
||||
((name message)
|
||||
(deps (.link_deps.eobjs/link_deps.cmo))
|
||||
(action (echo "link\n"))
|
||||
))
|
||||
|
||||
(executable
|
||||
((name link_deps)
|
||||
(link_deps ((alias message)))
|
||||
)
|
||||
)
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
|
@ -0,0 +1,11 @@
|
|||
It is possible to add link-time dependencies.
|
||||
|
||||
In particular, these can depend on the result of the compilation (like a .cmo
|
||||
file) and be created just before linking.
|
||||
|
||||
$ dune build --display short link_deps.exe
|
||||
ocamldep link_deps.ml.d
|
||||
ocamlc .link_deps.eobjs/link_deps.{cmi,cmo,cmt}
|
||||
link
|
||||
ocamlopt .link_deps.eobjs/link_deps.{cmx,o}
|
||||
ocamlopt link_deps.exe
|
Loading…
Reference in New Issue