diff --git a/.travis.yml b/.travis.yml index 83cafdfd..831830f6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,6 @@ env: - PACKAGE="cstruct" DISTRO="alpine" OCAML_VERSION="4.06" - PACKAGE="cstruct" DISTRO="alpine" OCAML_VERSION="4.07" - PACKAGE="cstruct-lwt" DISTRO="debian-testing" OCAML_VERSION="4.07" - - PACKAGE="cstruct-async" DISTRO="debian-unstable" OCAML_VERSION="4.07" + - PACKAGE="cstruct-async" DISTRO="centos" OCAML_VERSION="4.07" - PACKAGE="ppx_cstruct" DISTRO="debian-unstable" OCAML_VERSION="4.07" - PACKAGE="cstruct-unix" DISTRO="ubuntu" OCAML_VERSION="4.07" - - PACKAGE="cstruct-unix" DISTRO="fedora" OCAML_VERSION="4.07" diff --git a/CHANGES.md b/CHANGES.md index 9ba53176..42e6cdec 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,25 @@ +v3.3.0 2019-01-22 +----------------- + +- Support for bi-endian cstructs that generate both sets of accessor + functions (#212 by @XVilka). This generates both `BE` and `LE` + modules to use as needed. + +- Modify `of_string` and `of_bytes` to have an option `?off` + offset argument into the source bytes. (#208 by @XVilka) + +- Improve tests to work on 32-bit architectures and handle + Gc better (@samoht) + +- Do not depend explicitly on deprecated `ppx_driver`. This was + primarily there for older compilers, and new uses should be + based around `ppxlib`. (#201 by @edwintorok). + +- Upgrade opam metadata to 2.0 format. (#217 by @XVilka @avsm) + +- Upgrade to dune from jbuilder and support dune-release instead + of topkg (@avsm) + v3.2.1 2017-12-13 ----------------- diff --git a/Makefile b/Makefile index 3c52bd99..8b20a49a 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,18 @@ .PHONY: all clean fuzz build-fuzz all: - jbuilder build @install --dev + dune build clean: - jbuilder clean + dune clean test: - jbuilder runtest --dev + dune runtest build-fuzz: - jbuilder build --dev fuzz/fuzz.exe + dune build fuzz/fuzz.exe fuzz: build-fuzz mkdir -p _build/in echo > _build/in/empty afl-fuzz -i _build/in -o _build/out -- _build/default/fuzz/fuzz.exe @@ - -REPO=../../mirage/opam-repository -PACKAGES=$(REPO)/packages -# until we have https://github.com/ocaml/opam-publish/issues/38 -pkg-%: - topkg opam pkg -n $* - mkdir -p $(PACKAGES)/$* - cp -r _build/$*.* $(PACKAGES)/$*/ - cd $(PACKAGES) && git add $* - -PKGS=$(basename $(wildcard *.opam)) -opam-pkg: - $(MAKE) $(PKGS:%=pkg-%) diff --git a/async/dune b/async/dune new file mode 100644 index 00000000..2da1d296 --- /dev/null +++ b/async/dune @@ -0,0 +1,5 @@ +(library + (name async_cstruct) + (wrapped false) + (public_name cstruct-async) + (libraries core_kernel cstruct async_kernel async_unix)) diff --git a/async/jbuild b/async/jbuild deleted file mode 100644 index 422274c4..00000000 --- a/async/jbuild +++ /dev/null @@ -1,5 +0,0 @@ -(library - ((name async_cstruct) - (wrapped false) - (public_name cstruct-async) - (libraries (core_kernel cstruct async_kernel async_unix)))) diff --git a/cstruct-async.opam b/cstruct-async.opam index 6dc2f3e0..fbc73b1e 100644 --- a/cstruct-async.opam +++ b/cstruct-async.opam @@ -8,23 +8,21 @@ license: "ISC" dev-repo: "git+https://github.com/mirage/ocaml-cstruct.git" bug-reports: "https://github.com/mirage/ocaml-cstruct/issues" tags: [ "org:mirage" "org:ocamllabs" ] +doc: "https://mirage.githbu.io/ocaml-cstruct/" build: [ - ["jbuilder" "subst" "-p" name "--name" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] ] depends: [ "ocaml" {>= "4.03.0"} - "jbuilder" {build & >= "1.0+beta7"} + "dune" {build & >= "1.0"} "async_kernel" {>= "v0.9.0" & < "v0.12"} "async_unix" {>= "v0.9.0" & < "v0.12"} "core_kernel" {>= "v0.9.0" & < "v0.12"} - "cstruct" {>= "3.0.0"} + "cstruct" {>= "3.2.0"} ] synopsis: "Access C-like structures directly from OCaml" description: """ Cstruct is a library and syntax extension to make it easier to access C-like structures directly from OCaml. It supports both reading and writing to these structures, and they are accessed via the `Bigarray` module.""" -url { - src: "git+https://github.com/mirage/ocaml-cstruct.git" -} diff --git a/cstruct-lwt.opam b/cstruct-lwt.opam index 2d7aebd9..34a4d17f 100644 --- a/cstruct-lwt.opam +++ b/cstruct-lwt.opam @@ -7,17 +7,18 @@ homepage: "https://github.com/mirage/ocaml-cstruct" license: "ISC" dev-repo: "git+https://github.com/mirage/ocaml-cstruct.git" bug-reports: "https://github.com/mirage/ocaml-cstruct/issues" +doc: "https://mirage.githbu.io/ocaml-cstruct/" tags: [ "org:mirage" "org:ocamllabs" ] build: [ - ["jbuilder" "subst" "-p" name "--name" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] ] depends: [ "ocaml" {>= "4.03.0"} "base-unix" "lwt" - "cstruct" - "jbuilder" {build & >= "1.0+beta7"} + "cstruct" {>="3.2.0"} + "dune" {build & >= "1.0"} ] synopsis: "Access C-like structures directly from OCaml" description: """ diff --git a/cstruct-unix.opam b/cstruct-unix.opam index 2709a47c..6d233107 100644 --- a/cstruct-unix.opam +++ b/cstruct-unix.opam @@ -7,22 +7,23 @@ homepage: "https://github.com/mirage/ocaml-cstruct" license: "ISC" dev-repo: "git+https://github.com/mirage/ocaml-cstruct.git" bug-reports: "https://github.com/mirage/ocaml-cstruct/issues" +doc: "https://mirage.githbu.io/ocaml-cstruct/" + tags: [ "org:mirage" "org:ocamllabs" ] build: [ - ["jbuilder" "subst" "-p" name "--name" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] ] depends: [ "ocaml" {>= "4.03.0"} - "jbuilder" {build & >= "1.0+beta7"} + "dune" {build & >= "1.0"} "base-unix" - "cstruct" + "cstruct" {>="3.2.0"} ] synopsis: "Access C-like structures directly from OCaml" + description: """ Cstruct is a library and syntax extension to make it easier to access C-like -structures directly from OCaml. It supports both reading and writing to these -structures, and they are accessed via the `Bigarray` module.""" -url { - src: "git+https://github.com/mirage/ocaml-cstruct.git" -} +structures directly from OCaml. It supports both reading and writing to these +structures, and they are accessed via the `Bigarray` module. +""" diff --git a/cstruct.opam b/cstruct.opam index cd37cf93..acb1ce9c 100644 --- a/cstruct.opam +++ b/cstruct.opam @@ -7,23 +7,21 @@ homepage: "https://github.com/mirage/ocaml-cstruct" license: "ISC" dev-repo: "git+https://github.com/mirage/ocaml-cstruct.git" bug-reports: "https://github.com/mirage/ocaml-cstruct/issues" +doc: "https://mirage.githbu.io/ocaml-cstruct/" tags: [ "org:mirage" "org:ocamllabs" ] build: [ - ["jbuilder" "subst" "-p" name "--name" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] - ["jbuilder" "runtest" "-p" name] {with-test} + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] depends: [ "ocaml" {>= "4.03.0"} - "jbuilder" {build & >= "1.0+beta10"} + "dune" {build & >= "1.0"} "sexplib" {< "v0.12"} - "alcotest" {test} + "alcotest" {with-test} ] synopsis: "Access C-like structures directly from OCaml" description: """ Cstruct is a library and syntax extension to make it easier to access C-like structures directly from OCaml. It supports both reading and writing to these structures, and they are accessed via the `Bigarray` module.""" -url { - src: "git+https://github.com/mirage/ocaml-cstruct.git" -} diff --git a/dune-project b/dune-project new file mode 100644 index 00000000..5a035b1a --- /dev/null +++ b/dune-project @@ -0,0 +1,2 @@ +(lang dune 1.0) +(name cstruct) diff --git a/fuzz/dune b/fuzz/dune new file mode 100644 index 00000000..1bbce858 --- /dev/null +++ b/fuzz/dune @@ -0,0 +1,3 @@ +(executable + (name fuzz) + (libraries cstruct crowbar fmt)) diff --git a/fuzz/jbuild b/fuzz/jbuild deleted file mode 100644 index f1a8e468..00000000 --- a/fuzz/jbuild +++ /dev/null @@ -1,5 +0,0 @@ -(jbuild_version 1) - -(executable - ((name fuzz) - (libraries (cstruct crowbar fmt)))) diff --git a/js/dune b/js/dune new file mode 100644 index 00000000..589f6043 --- /dev/null +++ b/js/dune @@ -0,0 +1,4 @@ +(install + (section lib) + (files cstruct.js) + (package cstruct)) diff --git a/js/jbuild b/js/jbuild deleted file mode 100644 index 7e94dba4..00000000 --- a/js/jbuild +++ /dev/null @@ -1,6 +0,0 @@ -(jbuild_version 1) - -(install - ((section lib) - (files (cstruct.js)) - (package cstruct))) \ No newline at end of file diff --git a/lib/dune b/lib/dune new file mode 100644 index 00000000..189fc3b1 --- /dev/null +++ b/lib/dune @@ -0,0 +1,7 @@ +(library + (name cstruct) + (public_name cstruct) + (modules cstruct) + (wrapped false) + (libraries sexplib) + (c_names cstruct_stubs)) diff --git a/lib/jbuild b/lib/jbuild deleted file mode 100644 index 950f7b65..00000000 --- a/lib/jbuild +++ /dev/null @@ -1,9 +0,0 @@ -(library - ((name cstruct) - (public_name cstruct) - (modules (cstruct)) - (wrapped false) - (libraries (sexplib)) - (c_names (cstruct_stubs)) -)) -(jbuild_version 1) diff --git a/lib_test/dune b/lib_test/dune new file mode 100644 index 00000000..6b5a4fc8 --- /dev/null +++ b/lib_test/dune @@ -0,0 +1,11 @@ +(executables + (libraries cstruct alcotest) + (names tests bounds)) + +(alias + (name runtest) + (package cstruct) + (deps + (:< tests.exe)) + (action + (run %{<} -e))) diff --git a/lib_test/jbuild b/lib_test/jbuild deleted file mode 100644 index 7d6c47af..00000000 --- a/lib_test/jbuild +++ /dev/null @@ -1,11 +0,0 @@ -(jbuild_version 1) - -(executables - ((libraries (cstruct alcotest)) - (names (tests bounds)))) - -(alias - ((name runtest) - (package cstruct) - (deps (tests.exe)) - (action (run ${<} -e)))) diff --git a/lwt/dune b/lwt/dune new file mode 100644 index 00000000..b11ed4df --- /dev/null +++ b/lwt/dune @@ -0,0 +1,5 @@ +(library + (name cstruct_lwt) + (wrapped false) + (public_name cstruct-lwt) + (libraries cstruct lwt.unix)) diff --git a/lwt/jbuild b/lwt/jbuild deleted file mode 100644 index b2ff0f42..00000000 --- a/lwt/jbuild +++ /dev/null @@ -1,5 +0,0 @@ -(library - ((name cstruct_lwt) - (wrapped false) - (public_name cstruct-lwt) - (libraries (cstruct lwt.unix)))) diff --git a/pkg/pkg.ml b/pkg/pkg.ml deleted file mode 100644 index 3194b7c9..00000000 --- a/pkg/pkg.ml +++ /dev/null @@ -1,8 +0,0 @@ -#use "topfind" -#require "topkg-jbuilder" - -open Topkg - -let () = - Topkg_jbuilder.describe ~name:"cstruct" () - diff --git a/ppx/dune b/ppx/dune new file mode 100644 index 00000000..56501108 --- /dev/null +++ b/ppx/dune @@ -0,0 +1,10 @@ +(library + (name ppx_cstruct) + (public_name ppx_cstruct) + (kind ppx_rewriter) + (wrapped false) + (ppx_runtime_libraries cstruct) + (preprocess + (pps ppx_tools_versioned.metaquot_404)) + (libraries ocaml-migrate-parsetree ppx_tools_versioned + ppx_tools_versioned.metaquot_404 bigarray)) diff --git a/ppx/jbuild b/ppx/jbuild deleted file mode 100644 index ff208a1a..00000000 --- a/ppx/jbuild +++ /dev/null @@ -1,14 +0,0 @@ -(jbuild_version 1) - -(library - ((name ppx_cstruct) - (public_name ppx_cstruct) - (kind ppx_rewriter) - (wrapped false) - (ppx_runtime_libraries (cstruct)) - (preprocess (pps (ppx_tools_versioned.metaquot_404))) - (libraries - (ocaml-migrate-parsetree - ppx_tools_versioned - ppx_tools_versioned.metaquot_404 - bigarray)))) \ No newline at end of file diff --git a/ppx_cstruct.opam b/ppx_cstruct.opam index db68fd86..272e31b3 100644 --- a/ppx_cstruct.opam +++ b/ppx_cstruct.opam @@ -7,15 +7,17 @@ homepage: "https://github.com/mirage/ocaml-cstruct" license: "ISC" dev-repo: "git+https://github.com/mirage/ocaml-cstruct.git" bug-reports: "https://github.com/mirage/ocaml-cstruct/issues" +doc: "https://mirage.githbu.io/ocaml-cstruct/" + tags: [ "org:mirage" "org:ocamllabs" ] build: [ - ["jbuilder" "subst" "-p" name "--name" name] {pinned} - ["jbuilder" "build" "-p" name "-j" jobs] - ["jbuilder" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "subst"] {pinned} + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} ] depends: [ "ocaml" {>= "4.03.0"} - "jbuilder" {build & >= "1.0+beta9"} + "dune" {build & >= "1.0"} "cstruct" {>= "3.1.1"} "ounit" {with-test} "ppx_tools_versioned" {>= "5.0.1"} @@ -29,6 +31,3 @@ description: """ Cstruct is a library and syntax extension to make it easier to access C-like structures directly from OCaml. It supports both reading and writing to these structures, and they are accessed via the `Bigarray` module.""" -url { - src: "git+https://github.com/mirage/ocaml-cstruct.git" -} diff --git a/ppx_test/dune b/ppx_test/dune new file mode 100644 index 00000000..2ddaa838 --- /dev/null +++ b/ppx_test/dune @@ -0,0 +1,29 @@ +(executables + (libraries cstruct-unix) + (preprocess + (pps ppx_cstruct)) + (names pcap basic enum)) + +(alias + (name runtest) + (package ppx_cstruct) + (deps + (:< pcap.exe)) + (action + (run %{<}))) + +(alias + (name runtest) + (package ppx_cstruct) + (deps + (:< basic.exe)) + (action + (run %{<}))) + +(alias + (name runtest) + (package ppx_cstruct) + (deps + (:< enum.exe)) + (action + (run %{<}))) diff --git a/ppx_test/jbuild b/ppx_test/jbuild deleted file mode 100644 index 4c52bd1b..00000000 --- a/ppx_test/jbuild +++ /dev/null @@ -1,24 +0,0 @@ -(jbuild_version 1) - -(executables - ((libraries (cstruct-unix)) - (preprocess (pps (ppx_cstruct))) - (names (pcap basic enum)))) - -(alias - ((name runtest) - (package ppx_cstruct) - (deps (pcap.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (package ppx_cstruct) - (deps (basic.exe)) - (action (run ${<})))) - -(alias - ((name runtest) - (package ppx_cstruct) - (deps (enum.exe)) - (action (run ${<})))) diff --git a/ppx_test/with-lwt/dune b/ppx_test/with-lwt/dune new file mode 100644 index 00000000..d4fa2aaf --- /dev/null +++ b/ppx_test/with-lwt/dune @@ -0,0 +1,5 @@ +(executables + (names ppx_cstruct_and_lwt) + (preprocess + (pps lwt.ppx ppx_cstruct)) + (libraries cstruct lwt lwt.unix)) diff --git a/ppx_test/with-lwt/jbuild b/ppx_test/with-lwt/jbuild deleted file mode 100644 index d33461ab..00000000 --- a/ppx_test/with-lwt/jbuild +++ /dev/null @@ -1,12 +0,0 @@ -(jbuild_version 1) - -(executables - ((names (ppx_cstruct_and_lwt)) - (preprocess (pps (lwt.ppx ppx_cstruct))) - (libraries (cstruct lwt lwt.unix)))) - -; needs lwt 3.0dev -; (alias -; ((name runtest) -; (deps (ppx_cstruct_and_lwt.exe)) -; (action (run ${<})))) diff --git a/ppx_test/with-sexp/dune b/ppx_test/with-sexp/dune new file mode 100644 index 00000000..975f47b9 --- /dev/null +++ b/ppx_test/with-sexp/dune @@ -0,0 +1,13 @@ +(executables + (names ppx_cstruct_and_sexp) + (preprocess + (pps ppx_cstruct ppx_sexp_conv -- -no-check)) + (libraries cstruct)) + +(alias + (name runtest) + (package ppx_cstruct) + (deps + (:< ppx_cstruct_and_sexp.exe)) + (action + (run %{<}))) diff --git a/ppx_test/with-sexp/jbuild b/ppx_test/with-sexp/jbuild deleted file mode 100644 index c2d7211b..00000000 --- a/ppx_test/with-sexp/jbuild +++ /dev/null @@ -1,12 +0,0 @@ -(jbuild_version 1) - -(executables - ((names (ppx_cstruct_and_sexp)) - (preprocess (pps (ppx_cstruct ppx_sexp_conv -no-check))) - (libraries (cstruct)))) - -(alias - ((name runtest) - (package ppx_cstruct) - (deps (ppx_cstruct_and_sexp.exe)) - (action (run ${<})))) diff --git a/unix/dune b/unix/dune new file mode 100644 index 00000000..831d9286 --- /dev/null +++ b/unix/dune @@ -0,0 +1,6 @@ +(library + (name cstruct_unix) + (wrapped false) + (public_name cstruct-unix) + (flags :standard -w -3) + (libraries cstruct unix)) diff --git a/unix/jbuild b/unix/jbuild deleted file mode 100644 index 4c6854db..00000000 --- a/unix/jbuild +++ /dev/null @@ -1,8 +0,0 @@ -(library - ((name cstruct_unix) - (wrapped false) - (public_name cstruct-unix) - ; disable the deprecated warning as we can't use Unix.map_file - ; yet as it was only introduced in OCaml 4.06 - (flags (:standard -w -3)) - (libraries (cstruct unix))))