This commit is contained in:
parent
aa2ff7b2f0
commit
2f3113f55d
11742 changed files with 1223940 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
let () = print_endline "a: init"
|
||||
let called () = print_endline "a: called"
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
let t =
|
||||
Thread.create
|
||||
(fun () -> Thread.delay 0.0001 ) ()
|
||||
|
||||
let () = Mytool.Register.register "c_thread" (fun () -> Thread.join t)
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
(library
|
||||
(name a)
|
||||
(public_name a)
|
||||
(modules a))
|
||||
|
||||
(library
|
||||
(name mytool_plugin_b)
|
||||
(public_name mytool-plugin-b)
|
||||
(modules mytool_plugin_b)
|
||||
(libraries a mytool))
|
||||
|
||||
(library
|
||||
(name mytool)
|
||||
(public_name mytool)
|
||||
(modules register))
|
||||
|
||||
(executable
|
||||
(name main)
|
||||
(modules main)
|
||||
(public_name mytool)
|
||||
(package mytool)
|
||||
(libraries mytool findlib.dynload threads))
|
||||
|
||||
(rule (copy main.ml main_with_a.ml))
|
||||
(rule (copy main.ml main_modes_byte.ml))
|
||||
|
||||
(executable
|
||||
(name main_with_a)
|
||||
(modules main_with_a)
|
||||
(public_name mytool_with_a)
|
||||
(package mytool)
|
||||
(libraries mytool findlib.dynload a threads))
|
||||
|
||||
(executable
|
||||
(name main_modes_byte)
|
||||
(modules main_modes_byte)
|
||||
(public_name mytool_modes_byte)
|
||||
(package mytool)
|
||||
(libraries mytool findlib.dynload threads)
|
||||
(modes byte))
|
||||
|
||||
(executable
|
||||
(name main_auto)
|
||||
(modules main_auto)
|
||||
(public_name mytool_auto)
|
||||
(package mytool)
|
||||
(libraries mytool findlib.dynload findlib threads))
|
||||
|
||||
(library
|
||||
(name c_thread)
|
||||
(public_name c_thread)
|
||||
(modules c_thread)
|
||||
(libraries threads mytool))
|
||||
|
|
@ -0,0 +1 @@
|
|||
(lang dune 1.0)
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
let () = print_endline "m: init"
|
||||
|
||||
let () =
|
||||
for i = 1 to (Array.length Sys.argv - 1); do
|
||||
try
|
||||
Fl_dynload.load_packages [Sys.argv.(i)]
|
||||
with
|
||||
| Fl_package_base.No_such_package(pkg, _) ->
|
||||
Printf.printf "The package %S can't be found.\n%!" pkg
|
||||
| Dynlink.Error error ->
|
||||
Printf.printf "Error during dynlink: %s\n%!" (Dynlink.error_message error)
|
||||
done
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
let () = print_endline "m: init"
|
||||
|
||||
let () = Findlib.init ()
|
||||
let () =
|
||||
let pkgs = Fl_package_base.list_packages () in
|
||||
let pkgs =
|
||||
List.filter
|
||||
(fun pkg -> 14 <= String.length pkg && String.sub pkg 0 14 = "mytool-plugin-")
|
||||
pkgs
|
||||
in
|
||||
Fl_dynload.load_packages pkgs
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
let () = print_endline "b: init"
|
||||
let called () = print_endline "b: called"; A.called ()
|
||||
|
||||
let () = Mytool.Register.register "b" called
|
||||
|
|
@ -0,0 +1 @@
|
|||
let register s f = print_endline (s^": registering"); f ()
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
$ dune build
|
||||
|
||||
$ dune exec mytool
|
||||
m: init
|
||||
|
||||
$ dune exec mytool inexistent
|
||||
m: init
|
||||
The package "inexistent" can't be found.
|
||||
|
||||
$ dune exec mytool a
|
||||
m: init
|
||||
a: init
|
||||
|
||||
$ dune exec mytool_modes_byte a
|
||||
m: init
|
||||
a: init
|
||||
|
||||
$ dune exec mytool mytool-plugin-b
|
||||
m: init
|
||||
a: init
|
||||
b: init
|
||||
b: registering
|
||||
b: called
|
||||
a: called
|
||||
|
||||
$ dune exec mytool mytool-plugin-b a
|
||||
m: init
|
||||
a: init
|
||||
b: init
|
||||
b: registering
|
||||
b: called
|
||||
a: called
|
||||
|
||||
$ dune exec mytool_with_a
|
||||
a: init
|
||||
m: init
|
||||
|
||||
$ dune exec mytool_with_a mytool-plugin-b
|
||||
a: init
|
||||
m: init
|
||||
b: init
|
||||
b: registering
|
||||
b: called
|
||||
a: called
|
||||
|
||||
$ dune exec mytool_with_a a mytool-plugin-b
|
||||
a: init
|
||||
m: init
|
||||
b: init
|
||||
b: registering
|
||||
b: called
|
||||
a: called
|
||||
|
||||
$ dune exec mytool_auto
|
||||
m: init
|
||||
a: init
|
||||
b: init
|
||||
b: registering
|
||||
b: called
|
||||
a: called
|
||||
|
||||
$ dune exec mytool c_thread
|
||||
m: init
|
||||
c_thread: registering
|
||||
|
||||
$ cat _build/default/.main.eobjs/findlib_initl.ml-gen
|
||||
Findlib.record_package Findlib.Record_core "dynlink";;
|
||||
Findlib.record_package Findlib.Record_core "findlib";;
|
||||
Findlib.record_package Findlib.Record_core "findlib.dynload";;
|
||||
Findlib.record_package Findlib.Record_core "findlib.internal";;
|
||||
Findlib.record_package Findlib.Record_core "mytool";;
|
||||
Findlib.record_package Findlib.Record_core "threads";;
|
||||
Findlib.record_package Findlib.Record_core "unix";;
|
||||
let preds =
|
||||
[ "mt"
|
||||
; "mt_posix"
|
||||
; "ppx_driver"
|
||||
]
|
||||
in
|
||||
let preds =
|
||||
(if Dynlink.is_native then "native" else "byte") :: preds
|
||||
in
|
||||
Findlib.record_package_predicates preds;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue