Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
56 additions
and
14 deletions.
-
+11
−1
_oasis
-
+1
−13
lib/LZ4.ml
-
+11
−0
lib_gen/LZ4_bindgen.ml
-
+13
−0
lib_gen/LZ4_bindings.ml
-
+20
−0
myocamlbuild.ml
|
@@ -12,8 +12,18 @@ Homepage : https://github.com/whitequark/ocaml-lz4 |
|
|
Library "lz4" |
|
|
Path: lib |
|
|
Modules: LZ4 |
|
|
BuildDepends: bytes, ctypes.foreign |
|
|
InternalModules: LZ4_bindings, LZ4_generated |
|
|
CSources: LZ4_stubs.c |
|
|
CCLib: -llz4 |
|
|
CCOpt: -I $pkg_ctypes_stubs/.. |
|
|
BuildDepends: bytes, ctypes.stubs |
|
|
BuildTools: lz4_bindgen |
|
|
|
|
|
Executable "lz4_bindgen" |
|
|
Install: false |
|
|
Path: lib_gen |
|
|
MainIs: LZ4_bindgen.ml |
|
|
BuildDepends: ctypes.stubs |
|
|
|
|
|
Executable "test_lz4" |
|
|
Build$: flag(tests) |
|
|
|
|
@@ -1,18 +1,6 @@ |
|
|
open Ctypes |
|
|
|
|
|
module C = struct |
|
|
open Foreign |
|
|
|
|
|
let compressBound = foreign "LZ4_compressBound" (int @-> returning int) |
|
|
let b_compress = foreign "LZ4_compress" |
|
|
(ocaml_bytes @-> ocaml_bytes @-> int @-> returning int) |
|
|
let ba_compress = foreign "LZ4_compress" |
|
|
(ptr char @-> ptr char @-> int @-> returning int) |
|
|
let b_decompress = foreign "LZ4_decompress_safe" |
|
|
(ocaml_bytes @-> ocaml_bytes @-> int @-> int @-> returning int) |
|
|
let ba_decompress = foreign "LZ4_decompress_safe" |
|
|
(ptr char @-> ptr char @-> int @-> int @-> returning int) |
|
|
end |
|
|
module C = LZ4_bindings.C(LZ4_generated) |
|
|
|
|
|
exception Input_too_large |
|
|
exception Corrupted |
|
|
|
|
@@ -0,0 +1,11 @@ |
|
|
open Ctypes |
|
|
|
|
|
let _ = |
|
|
let fmt = Format.formatter_of_out_channel (open_out "lib/LZ4_stubs.c") in |
|
|
Format.fprintf fmt "#include <caml/mlvalues.h>@."; |
|
|
Format.fprintf fmt "#include <ctypes/cstubs_internals.h>@."; |
|
|
Format.fprintf fmt "#include <lz4.h>@."; |
|
|
Cstubs.write_c fmt ~prefix:"caml_" (module LZ4_bindings.C); |
|
|
|
|
|
let fmt = Format.formatter_of_out_channel (open_out "lib/LZ4_generated.ml") in |
|
|
Cstubs.write_ml fmt ~prefix:"caml_" (module LZ4_bindings.C) |
|
|
@@ -0,0 +1,13 @@ |
|
|
open Ctypes |
|
|
|
|
|
module C(F: Cstubs.FOREIGN) = struct |
|
|
let compressBound = F.foreign "LZ4_compressBound" (int @-> returning int) |
|
|
let b_compress = F.foreign "LZ4_compress" |
|
|
(ocaml_bytes @-> ocaml_bytes @-> int @-> returning int) |
|
|
let ba_compress = F.foreign "LZ4_compress" |
|
|
(ptr char @-> ptr char @-> int @-> returning int) |
|
|
let b_decompress = F.foreign "LZ4_decompress_safe" |
|
|
(ocaml_bytes @-> ocaml_bytes @-> int @-> int @-> returning int) |
|
|
let ba_decompress = F.foreign "LZ4_decompress_safe" |
|
|
(ptr char @-> ptr char @-> int @-> int @-> returning int) |
|
|
end |
|
|
@@ -0,0 +1,20 @@ |
|
|
(* OASIS_START *) |
|
|
(* OASIS_STOP *) |
|
|
|
|
|
open Ocamlbuild_plugin;; |
|
|
|
|
|
dispatch |
|
|
(MyOCamlbuildBase.dispatch_combine [ |
|
|
begin function |
|
|
| After_rules -> |
|
|
rule "cstubs: lib/x_bindings.ml -> x_stubs.c, x_stubs.ml" |
|
|
~prods:["lib/%_stubs.c"; "lib/%_generated.ml"] |
|
|
~deps: ["lib_gen/%_bindgen.byte"] |
|
|
(fun env build -> |
|
|
Cmd (A(env "lib_gen/%_bindgen.byte"))); |
|
|
copy_rule "cstubs: lib_gen/x_bindings.ml -> lib/x_bindings.ml" |
|
|
"lib_gen/%_bindings.ml" "lib/%_bindings.ml" |
|
|
| _ -> () |
|
|
end; |
|
|
dispatch_default |
|
|
]) |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.