Skip to content

Commit

Permalink
port to dune, upgrade opam metadata and remove unused code
Browse files Browse the repository at this point in the history
- removed vestigial ocamlbuild files (_tags)
- port to dune (as dune 1.7 will issue jbuild deprecation warnings)
- upgrade opam metadata to the 2.0 format
- remove ocaml <4.01 support, as minimum version is now ocaml 4.02+
- restore -inline 1000 to build rules (dropped with jbuilder port)
  • Loading branch information
avsm committed Feb 2, 2019
1 parent 7888e89 commit 0a1420e
Show file tree
Hide file tree
Showing 25 changed files with 156 additions and 476 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
_build/
*.native
*.byte
src/.merlin
tests/.merlin
ocplib-endian.install
.merlin
*.install
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
1.2
---

* Port to Dune from jbuilder (@avsm)
* Upgrade opam metadata to 2.0 format (@avsm)
* Remove code for OCaml <4.01 support, as the minimum
supported version is now OCaml 4.02+ (@avsm)

1.1
---------------

Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.PHONY: all clean test doc

all:
dune build

clean:
dune clean

test:
dune runtest

doc:
dune build @doc
45 changes: 0 additions & 45 deletions _tags

This file was deleted.

2 changes: 2 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(lang dune 1.0)
(name ocplib-endian)
21 changes: 9 additions & 12 deletions ocplib-endian.opam
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
opam-version: "1.2"
opam-version: "2.0"
name: "ocplib-endian"
version: "1.1"
descr: """
Optimised functions to read and write int16/32/64 from strings and bigarrays, based on new primitives added in version 4.01

synopsis: "Optimised functions to read and write int16/32/64 from strings and bigarrays"
description: """
The library implements three modules:
* [EndianString](https://github.com/OCamlPro/ocplib-endian/blob/master/src/endianString.mli) works directly on strings, and provides submodules BigEndian and LittleEndian, with their unsafe counter-parts;
* [EndianBytes](https://github.com/OCamlPro/ocplib-endian/blob/master/src/endianBytes.mli) works directly on bytes, and provides submodules BigEndian and LittleEndian, with their unsafe counter-parts;
* [EndianBigstring](https://github.com/OCamlPro/ocplib-endian/blob/master/src/endianBigstring.mli) works on bigstrings (Bigarrays of chars), and provides submodules BigEndian and LittleEndian, with their unsafe counter-parts;
* [EndianBigstring](https://github.com/OCamlPro/ocplib-endian/blob/master/src/endianBigstring.mli) works on bigstrings (Bigarrays of chars), and provides submodules BigEndian and LittleEndian, with their unsafe counter-parts.
"""
maintainer: "pierre.chambart@ocamlpro.com"
authors: "Pierre Chambart"
homepage: "https://github.com/OCamlPro/ocplib-endian"
bug-reports: "https://github.com/OCamlPro/ocplib-endian/issues"
depends: [
"base-bytes"
"ocaml" {>= "4.02.3"}
"cppo" {>= "1.1.0"}
"jbuilder" {build}
"dune" {build & >= "1.0"}
]
build: [
["jbuilder" "build" "--only-packages" "ocplib-endian" "--root" "." "-j" jobs "@install"]
]
build-test: [
["jbuilder" "runtest" "--only-packages" "ocplib-endian" "--root" "." "-j" jobs]
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
]
dev-repo: "git+https://github.com/OCamlPro/ocplib-endian.git"
url {
src: "https://github.com/OCamlPro/ocplib-endian/archive/1.0.tar.gz"
}
}
28 changes: 0 additions & 28 deletions src/be_ocaml_400.ml

This file was deleted.

2 changes: 2 additions & 0 deletions src/common.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[@@@warning "-32"]

let sign8 v =
(v lsl ( Sys.word_size - 9 )) asr ( Sys.word_size - 9 )

Expand Down
79 changes: 0 additions & 79 deletions src/common_400.cppo.ml

This file was deleted.

75 changes: 75 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
(rule
(targets endianString.mli)
(deps (:< endianString.cppo.mli))
(action
(run %{bin:cppo} %{<} -o %{targets})))

(rule
(targets endianString.ml)
(deps
(:< endianString.cppo.ml)
common.ml
common_401.ml)
(action
(run %{bin:cppo} %{<} -o %{targets})))

(rule
(targets endianBytes.mli)
(deps
(:< endianBytes.cppo.mli))
(action
(run %{bin:cppo} %{<} -o %{targets})))

(rule
(targets endianBytes.ml)
(deps
(:< endianBytes.cppo.ml)
common.ml
common_401.ml)
(action
(run %{bin:cppo} %{<} -o %{targets})))

(rule
(targets endianBigstring.mli)
(deps
(:< endianBigstring.cppo.mli))
(action
(run %{bin:cppo} %{<} -o %{targets})))

(rule
(targets endianBigstring.ml)
(deps
(:< endianBigstring.cppo.ml)
common.ml
common_401.ml)
(action
(run %{bin:cppo} %{<} -o %{targets})))

(rule
(targets common_401.ml)
(deps
(:< common_401.cppo.ml)
be_ocaml_401.ml
le_ocaml_401.ml
ne_ocaml_401.ml
common_float.ml)
(action
(run %{bin:cppo} %{<} -o %{targets})))

(library
(name ocplib_endian)
(public_name ocplib-endian)
(synopsis "Optimised functions to read and write int16/32/64 from strings and bytes")
(wrapped false)
(ocamlopt_flags (:standard -inline 1000))
(modules endianString endianBytes)
(libraries bytes))

(library
(name ocplib_endian_bigstring)
(public_name ocplib-endian.bigstring)
(synopsis "Optimised functions to read and write int16/32/64 from bigarrays")
(wrapped false)
(modules endianBigstring)
(ocamlopt_flags (:standard -inline 1000))
(libraries ocplib_endian bigarray bytes))
8 changes: 0 additions & 8 deletions src/endianBigstring.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ let unsafe_set_char (s:bigstring) off v =

#include "common.ml"

#if OCAML_VERSION >= (4, 01, 0)

external unsafe_get_16 : bigstring -> int -> int = "%caml_bigstring_get16u"
external unsafe_get_32 : bigstring -> int -> int32 = "%caml_bigstring_get32u"
external unsafe_get_64 : bigstring -> int -> int64 = "%caml_bigstring_get64u"
Expand All @@ -112,9 +110,3 @@ external set_32 : bigstring -> int -> int32 -> unit = "%caml_bigstring_set32"
external set_64 : bigstring -> int -> int64 -> unit = "%caml_bigstring_set64"

#include "common_401.ml"

#else

#include "common_400.ml"

#endif
2 changes: 0 additions & 2 deletions src/endianBigstring.cppo.mli
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ module LittleEndian_unsafe : sig

end

#if OCAML_VERSION >= (4, 00, 0)
module NativeEndian : sig
(** Functions reading according to machine endianness *)

Expand All @@ -127,4 +126,3 @@ module NativeEndian_unsafe : sig
include EndianBigstringSig

end
#endif
8 changes: 0 additions & 8 deletions src/endianBytes.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ let unsafe_set_char (s:Bytes.t) off v =

#include "common.ml"

#if OCAML_VERSION >= (4, 01, 0)

external unsafe_get_16 : Bytes.t -> int -> int = "%caml_string_get16u"
external unsafe_get_32 : Bytes.t -> int -> int32 = "%caml_string_get32u"
external unsafe_get_64 : Bytes.t -> int -> int64 = "%caml_string_get64u"
Expand All @@ -108,9 +106,3 @@ external set_32 : Bytes.t -> int -> int32 -> unit = "%caml_string_set32"
external set_64 : Bytes.t -> int -> int64 -> unit = "%caml_string_set64"

#include "common_401.ml"

#else

#include "common_400.ml"

#endif
2 changes: 0 additions & 2 deletions src/endianBytes.cppo.mli
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ module LittleEndian_unsafe : sig

end

#if OCAML_VERSION >= (4, 00, 0)
module NativeEndian : sig
(** Functions reading according to machine endianness *)

Expand All @@ -124,4 +123,3 @@ module NativeEndian_unsafe : sig
include EndianBytesSig

end
#endif
8 changes: 0 additions & 8 deletions src/endianString.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ let unsafe_set_char (s:Bytes.t) off v =

#include "common.ml"

#if OCAML_VERSION >= (4, 01, 0)

external unsafe_get_16 : string -> int -> int = "%caml_string_get16u"
external unsafe_get_32 : string -> int -> int32 = "%caml_string_get32u"
external unsafe_get_64 : string -> int -> int64 = "%caml_string_get64u"
Expand All @@ -104,9 +102,3 @@ external set_32 : Bytes.t -> int -> int32 -> unit = "%caml_string_set32"
external set_64 : Bytes.t -> int -> int64 -> unit = "%caml_string_set64"

#include "common_401.ml"

#else

#include "common_400.ml"

#endif
Loading

0 comments on commit 0a1420e

Please sign in to comment.