Skip to content

Commit e22d1ea

Browse files
committed
Nocrypto patches for compatibility with sexplib/ppx_sexp_conv > v0.11.0
ppx_sexp_conv v0.11.0 compiles successfully, but contains an undesired dependency on base, and is thus still marked as conflicting. This is fixed in ppx_sexp_conv v0.11.1. This commit submits @gasche's fixes from mirleft/ocaml-nocrypto#144 and @diml's fixes from mirleft/ocaml-nocrypto#146
1 parent 0ffd4a8 commit e22d1ea

7 files changed

+261
-2
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
From 39a20d45e68bbfc123595417651ba308947faa87 Mon Sep 17 00:00:00 2001
2+
From: Gabriel Scherer <[email protected]>
3+
Date: Mon, 26 Mar 2018 16:07:45 +0200
4+
Subject: [PATCH 1/6] pack+package: workaround ocamlbuild#272
5+
6+
ocamlbuild should pass -package(...) flags to ocamlfind when building
7+
a -pack-ed file, see
8+
9+
https://github.com/ocaml/opam-repository/pull/11628#issuecomment-375697444
10+
---
11+
myocamlbuild.ml | 8 ++++++++
12+
1 file changed, 8 insertions(+)
13+
14+
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
15+
index 2752315..03b9efb 100644
16+
--- a/myocamlbuild.ml
17+
+++ b/myocamlbuild.ml
18+
@@ -1,5 +1,13 @@
19+
open Ocamlbuild_plugin
20+
21+
+let ocamlfind_and_pack = function
22+
+ | After_rules ->
23+
+ if !Options.use_ocamlfind then
24+
+ pflag ["ocaml"; "pack"] "package"
25+
+ (fun pkg -> S [A "-package"; A pkg]);
26+
+ | _ -> ()
27+
+
28+
let () = dispatch Ocb_stubblr.(
29+
init & ccopt ~tags:["accelerate"] "-DACCELERATE -msse2 -maes"
30+
+ & ocamlfind_and_pack
31+
)
32+
--
33+
2.17.0
34+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From cad7cfe15ae8eca95c4e284f3a679c35842659f2 Mon Sep 17 00:00:00 2001
2+
From: Gabriel Scherer <[email protected]>
3+
Date: Mon, 26 Mar 2018 16:09:16 +0200
4+
Subject: [PATCH 2/6] add missing runtime dependencies in _tags
5+
6+
Binaries in <bench/*>, <tests/*> depend on ppx_sexp_conv's runtime
7+
library within ppx_sexp_conv.
8+
9+
The packed modules <src/nocrypto.cm{x,o}> also depend on the package
10+
ppx_sexp_conv: its presence at pack-creation time influences the
11+
generated .cmi interface, see
12+
13+
https://github.com/ocaml/opam-repository/pull/11628#issuecomment-375697444
14+
15+
Note: the package ppx_sexp_conv.runtime-lib would suffice, but it is
16+
only available as such under recent ppx_sexp_conv versions, so its
17+
explicit use would make the build description (needlessly)
18+
incompatible with older ppx_sexp_conv versions.
19+
---
20+
_tags | 5 +++--
21+
1 file changed, 3 insertions(+), 2 deletions(-)
22+
23+
diff --git a/_tags b/_tags
24+
index 6d4e7de..c2a6610 100644
25+
--- a/_tags
26+
+++ b/_tags
27+
@@ -7,6 +7,7 @@ true: package(bytes), package(cstruct)
28+
<src/*.ml{,i}>: package(zarith), package(sexplib), package(ppx_sexp_conv)
29+
<src/*.cm{x,o}> and not <src/nocrypto.cmx>: for-pack(Nocrypto)
30+
<src/*.cm{,x}a>: link_stubs(src/libnocrypto_stubs)
31+
+<src/nocrypto.cm{x,o}>: package(ppx_sexp_conv)
32+
33+
<unix>: include
34+
<unix/*.ml{,i}>: package(unix), package(bytes)
35+
@@ -19,7 +20,7 @@ true: package(bytes), package(cstruct)
36+
37+
<**/*.c>: ccopt(--std=c99 -Wall -Wextra -O3)
38+
39+
-<bench/*>: use_nocrypto, package(zarith), package(cstruct.unix)
40+
-<tests/*>: use_nocrypto, package(zarith), package(oUnit)
41+
+<bench/*>: use_nocrypto, package(zarith), package(ppx_sexp_conv)
42+
+<tests/*>: use_nocrypto, package(zarith), package(ppx_sexp_conv), package(oUnit)
43+
44+
<rondom>: -traverse
45+
--
46+
2.17.0
47+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 26ef01bf755b1cbc6d5bf43424ca314e2a4f594c Mon Sep 17 00:00:00 2001
2+
From: Gabriel Scherer <[email protected]>
3+
Date: Mon, 26 Mar 2018 17:15:55 +0200
4+
Subject: [PATCH 3/6] Revert "pack+package: workaround ocamlbuild#272"
5+
6+
This reverts commit 39a20d45e68bbfc123595417651ba308947faa87.
7+
---
8+
myocamlbuild.ml | 8 --------
9+
1 file changed, 8 deletions(-)
10+
11+
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
12+
index 03b9efb..2752315 100644
13+
--- a/myocamlbuild.ml
14+
+++ b/myocamlbuild.ml
15+
@@ -1,13 +1,5 @@
16+
open Ocamlbuild_plugin
17+
18+
-let ocamlfind_and_pack = function
19+
- | After_rules ->
20+
- if !Options.use_ocamlfind then
21+
- pflag ["ocaml"; "pack"] "package"
22+
- (fun pkg -> S [A "-package"; A pkg]);
23+
- | _ -> ()
24+
-
25+
let () = dispatch Ocb_stubblr.(
26+
init & ccopt ~tags:["accelerate"] "-DACCELERATE -msse2 -maes"
27+
- & ocamlfind_and_pack
28+
)
29+
--
30+
2.17.0
31+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From 55fbc3531afde59ba34cde1c14d99704439756e6 Mon Sep 17 00:00:00 2001
2+
From: Gabriel Scherer <[email protected]>
3+
Date: Tue, 27 Mar 2018 12:00:23 +0200
4+
Subject: [PATCH 4/6] add ppx_sexp_conv as a runtime dependency in the
5+
packaging metadata
6+
7+
---
8+
opam | 2 +-
9+
pkg/META | 2 +-
10+
2 files changed, 2 insertions(+), 2 deletions(-)
11+
12+
diff --git a/opam b/opam
13+
index ad1dbc7..c35570b 100644
14+
--- a/opam
15+
+++ b/opam
16+
@@ -20,7 +20,7 @@ depends: [
17+
"topkg" {build}
18+
"cpuid" {build}
19+
"ocb-stubblr" {build}
20+
- "ppx_sexp_conv" {build}
21+
+ "ppx_sexp_conv"
22+
"oUnit" {test}
23+
"cstruct"
24+
"zarith"
25+
diff --git a/pkg/META b/pkg/META
26+
index 242b2bb..a7929c7 100644
27+
--- a/pkg/META
28+
+++ b/pkg/META
29+
@@ -1,6 +1,6 @@
30+
version = "%%VERSION_NUM%%"
31+
description = "Simple crypto for the modern age"
32+
-requires = "cstruct zarith sexplib"
33+
+requires = "cstruct zarith sexplib ppx_sexp_conv"
34+
archive(byte) = "nocrypto.cma"
35+
archive(native) = "nocrypto.cmxa"
36+
plugin(byte) = "nocrypto.cma"
37+
--
38+
2.17.0
39+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
From 25e1206eb1b173acdfc7312d072e0583327c4ac0 Mon Sep 17 00:00:00 2001
2+
From: Jeremie Dimino <[email protected]>
3+
Date: Fri, 11 May 2018 15:44:47 +0200
4+
Subject: [PATCH 5/6] Auto-detect ppx_sexp_conv runtime library
5+
6+
---
7+
myocamlbuild.ml | 25 ++++++++++++++++++++++---
8+
pkg/{META => META.in} | 2 +-
9+
2 files changed, 23 insertions(+), 4 deletions(-)
10+
rename pkg/{META => META.in} (95%)
11+
12+
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
13+
index 2752315..7b29635 100644
14+
--- a/myocamlbuild.ml
15+
+++ b/myocamlbuild.ml
16+
@@ -1,5 +1,24 @@
17+
open Ocamlbuild_plugin
18+
19+
-let () = dispatch Ocb_stubblr.(
20+
- init & ccopt ~tags:["accelerate"] "-DACCELERATE -msse2 -maes"
21+
-)
22+
+let runtime_deps_of_ppx ppx =
23+
+ (Findlib.query "ppx_sexp_conv").dependencies
24+
+ |> List.filter_opt (fun { Findlib.name; _ } ->
25+
+ if name = ppx || name = "ppx_deriving" then
26+
+ None
27+
+ else
28+
+ Some name)
29+
+
30+
+let () = dispatch (fun hook ->
31+
+ Ocb_stubblr.(
32+
+ init & ccopt ~tags:["accelerate"] "-DACCELERATE -msse2 -maes"
33+
+ ) hook;
34+
+ match hook with
35+
+ | After_rules ->
36+
+ let meta = "pkg/META" in
37+
+ let meta_in = meta ^ ".in" in
38+
+ rule meta ~dep:meta_in ~prod:meta (fun _ _ ->
39+
+ let deps = String.concat " " (runtime_deps_of_ppx "ppx_sexp_conv") in
40+
+ Echo([String.subst "PPX_SEXP_CONV_RUNTIME" deps
41+
+ (Pathname.read meta_in)],
42+
+ meta))
43+
+ | _ -> ())
44+
diff --git a/pkg/META b/pkg/META.in
45+
similarity index 95%
46+
rename from pkg/META
47+
rename to pkg/META.in
48+
index a7929c7..0b263d7 100644
49+
--- a/pkg/META
50+
+++ b/pkg/META.in
51+
@@ -1,6 +1,6 @@
52+
version = "%%VERSION_NUM%%"
53+
description = "Simple crypto for the modern age"
54+
-requires = "cstruct zarith sexplib ppx_sexp_conv"
55+
+requires = "cstruct zarith sexplib PPX_SEXP_CONV_RUNTIME"
56+
archive(byte) = "nocrypto.cma"
57+
archive(native) = "nocrypto.cmxa"
58+
plugin(byte) = "nocrypto.cma"
59+
--
60+
2.17.0
61+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From 1befe5d2ab60653d1d44fa734d2b8057cf3410db Mon Sep 17 00:00:00 2001
2+
From: Gabriel Scherer <[email protected]>
3+
Date: Mon, 26 Mar 2018 16:07:45 +0200
4+
Subject: [PATCH 6/6] pack+package: workaround ocamlbuild#272
5+
6+
ocamlbuild should pass -package(...) flags to ocamlfind when building
7+
a -pack-ed file, see
8+
9+
https://github.com/ocaml/opam-repository/pull/11628#issuecomment-375697444
10+
---
11+
myocamlbuild.ml | 8 ++++++++
12+
1 file changed, 8 insertions(+)
13+
14+
diff --git a/myocamlbuild.ml b/myocamlbuild.ml
15+
index 7b29635..7a5cdb6 100644
16+
--- a/myocamlbuild.ml
17+
+++ b/myocamlbuild.ml
18+
@@ -8,9 +8,17 @@ let runtime_deps_of_ppx ppx =
19+
else
20+
Some name)
21+
22+
+let ocamlfind_and_pack = function
23+
+ | After_rules ->
24+
+ if !Options.use_ocamlfind then
25+
+ pflag ["ocaml"; "pack"] "package"
26+
+ (fun pkg -> S [A "-package"; A pkg]);
27+
+ | _ -> ()
28+
+
29+
let () = dispatch (fun hook ->
30+
Ocb_stubblr.(
31+
init & ccopt ~tags:["accelerate"] "-DACCELERATE -msse2 -maes"
32+
+ & ocamlfind_and_pack
33+
) hook;
34+
match hook with
35+
| After_rules ->
36+
--
37+
2.17.0
38+

packages/nocrypto/nocrypto.0.5.4/opam

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ depends: [
2222
"cpuid" {build}
2323
"ocb-stubblr" {build}
2424
"ppx_deriving" {build}
25-
"ppx_sexp_conv" {build & >= "113.33.01" & < "v0.11.0"}
25+
"ppx_sexp_conv" {>= "113.33.01" & != "v0.11.0"}
2626
"ounit" {test}
2727
"cstruct" {>="2.4.0"}
2828
"cstruct-lwt"
2929
"zarith"
3030
"lwt"
31-
"sexplib" {< "v0.11.0"}
31+
"sexplib"
3232
("mirage-no-xen" | ("mirage-xen" & "mirage-entropy" & "zarith-xen"))
3333
("mirage-no-solo5" | ("mirage-solo5" & "mirage-entropy" & "zarith-freestanding"))
3434
]
@@ -39,3 +39,12 @@ conflicts: [
3939
"mirage-xen" {<"2.2.0"}
4040
"sexplib" {="v0.9.0"}
4141
]
42+
43+
patches: [
44+
"0001-pack-package-workaround-ocamlbuild-272.patch"
45+
"0002-add-missing-runtime-dependencies-in-_tags.patch"
46+
"0003-Revert-pack-package-workaround-ocamlbuild-272.patch"
47+
"0004-add-ppx_sexp_conv-as-a-runtime-dependency-in-the-pac.patch"
48+
"0005-Auto-detect-ppx_sexp_conv-runtime-library.patch"
49+
"0006-pack-package-workaround-ocamlbuild-272.patch"
50+
]

0 commit comments

Comments
 (0)