Skip to content

Commit

Permalink
Merge pull request #44 from talex5/xen
Browse files Browse the repository at this point in the history
Build C stubs for Xen too
  • Loading branch information
pqwy committed Jan 26, 2015
2 parents 4a171cf + 4b7915e commit 7d61982
Show file tree
Hide file tree
Showing 13 changed files with 409 additions and 100 deletions.
10 changes: 10 additions & 0 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ eval `opam config env`
ocaml setup.ml -configure --enable-tests
ocaml setup.ml -build
ocaml setup.ml -test

# check Xen support builds too
set -eu
if opam install mirage-xen; then
./configure --enable-xen
make
ls -l _build/xen/dllnocrypto_xen_stubs.so
else
echo "Mirage not installable, so not testing Xen build."
fi
36 changes: 34 additions & 2 deletions _oasis
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ License: FreeBSD
Homepage: https://github.com/mirleft/ocaml-nocrypto
Plugins: META (0.4), DevFiles (0.4)
BuildTools: ocamlbuild
PostConfCommand: ocaml postconf.ml
Description:
A simple cryptographic library.
Categories: http://org:mirage
OCamlVersion: >= 4.01.0

Flag xen
Description: Build Xen support
Default: false

Flag "pedantic"
Description: Make the C compiler go hardcore
Default: false
Expand Down Expand Up @@ -57,15 +62,42 @@ Library "nocrypto"
native/nocrypto_stubs.h,
native/nocrypto_stubs.c,
native/nocrypto_generated_stubs.c
BuildDepends: cstruct (>= 1.2.0), zarith, ctypes (>= 0.3.3),
BuildDepends: cstruct (>= 1.2.0), zarith, ctypes,
ctypes.stubs, sexplib.syntax, type_conv
XMETARequires: cstruct, zarith, ctypes.stubs, sexplib
CCOpt: -O3 -I$pkg_ctypes/..
XMETAExtraLines: xen_linkopts = "-lnocrypto_xen_stubs"
CCOpt: -O3 -I$pkg_ctypes -I$pkg_ctypes/..
BuildTools: nocrypto_bindgen
ByteOpt: -w A-4-33-40-41-42-43-34-44
if flag(pedantic)
CCOpt: -Wall -Wpedantic

Library "nocrypto_xen"
Path: xen/
Findlibparent: nocrypto
Findlibname: xen
Build$: flag(xen)
CSources: native/bitfn.h,
native/md5.c,
native/md5.h,
native/sha1.c,
native/sha1.h,
native/sha256.c,
native/sha256.h,
native/sha512.c,
native/sha512.h,
native/rijndael.c,
native/rijndael.h,
native/d3des.c,
native/d3des.h,
native/nocrypto_stubs.h,
native/nocrypto_stubs.c,
native/nocrypto_generated_stubs.c
CCOpt: -O3 -I$pkg_ctypes -I$pkg_ctypes/.. -DNDEBUG $XEN_CFLAGS
BuildTools: nocrypto_bindgen
if flag(pedantic)
CCOpt: -Wall -Wpedantic

Executable "nocrypto_bindgen"
MainIs: nocrypto_bindgen.ml
Install: false
Expand Down
192 changes: 113 additions & 79 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 63cf109b52c4902a078813f8af7d52d6)
# DO NOT EDIT (digest: 60a98fbf27d94dc752e826d1f1bea50e)
# Ignore VCS directories, you can use the same kind of rule outside
# OASIS_START/STOP if you want to exclude directories that contains
# useless stuff for the build process
Expand All @@ -15,8 +15,29 @@ true: annot, bin_annot
"_darcs": -traverse
"_darcs": not_hygienic
# Executable nocrypto_bindgen
"src_gen/nocrypto_bindgen.byte": pkg_ctypes.stubs
<src_gen/*.ml{,i,y}>: pkg_ctypes.stubs
"src_gen/nocrypto_bindgen.byte": package(ctypes.stubs)
<src_gen/*.ml{,i,y}>: package(ctypes.stubs)
# Library nocrypto_xen
"xen/nocrypto_xen.cmxs": use_nocrypto_xen
<xen/*.ml{,i,y}>: oasis_library_nocrypto_xen_ccopt
"xen/native/md5.c": oasis_library_nocrypto_xen_ccopt
"xen/native/sha1.c": oasis_library_nocrypto_xen_ccopt
"xen/native/sha256.c": oasis_library_nocrypto_xen_ccopt
"xen/native/sha512.c": oasis_library_nocrypto_xen_ccopt
"xen/native/rijndael.c": oasis_library_nocrypto_xen_ccopt
"xen/native/d3des.c": oasis_library_nocrypto_xen_ccopt
"xen/native/nocrypto_stubs.c": oasis_library_nocrypto_xen_ccopt
"xen/native/nocrypto_generated_stubs.c": oasis_library_nocrypto_xen_ccopt
<xen/nocrypto_xen.{cma,cmxa}>: use_libnocrypto_xen_stubs
<xen/*.ml{,i,y}>: package(ctypes.stubs)
"xen/native/md5.c": package(ctypes.stubs)
"xen/native/sha1.c": package(ctypes.stubs)
"xen/native/sha256.c": package(ctypes.stubs)
"xen/native/sha512.c": package(ctypes.stubs)
"xen/native/rijndael.c": package(ctypes.stubs)
"xen/native/d3des.c": package(ctypes.stubs)
"xen/native/nocrypto_stubs.c": package(ctypes.stubs)
"xen/native/nocrypto_generated_stubs.c": package(ctypes.stubs)
# Library nocrypto
"src/nocrypto.cmxs": use_nocrypto
"src/uncommon.cmx": for-pack(Nocrypto)
Expand Down Expand Up @@ -54,92 +75,105 @@ true: annot, bin_annot
"src/native/nocrypto_stubs.c": oasis_library_nocrypto_byte
"src/native/nocrypto_generated_stubs.c": oasis_library_nocrypto_byte
<src/nocrypto.{cma,cmxa}>: use_libnocrypto_stubs
<src/*.ml{,i,y}>: pkg_cstruct
<src/*.ml{,i,y}>: pkg_ctypes
<src/*.ml{,i,y}>: pkg_ctypes.stubs
<src/*.ml{,i,y}>: pkg_sexplib.syntax
<src/*.ml{,i,y}>: pkg_zarith
"src/native/md5.c": pkg_cstruct
"src/native/md5.c": pkg_ctypes
"src/native/md5.c": pkg_ctypes.stubs
"src/native/md5.c": pkg_sexplib.syntax
"src/native/md5.c": pkg_zarith
"src/native/sha1.c": pkg_cstruct
"src/native/sha1.c": pkg_ctypes
"src/native/sha1.c": pkg_ctypes.stubs
"src/native/sha1.c": pkg_sexplib.syntax
"src/native/sha1.c": pkg_zarith
"src/native/sha256.c": pkg_cstruct
"src/native/sha256.c": pkg_ctypes
"src/native/sha256.c": pkg_ctypes.stubs
"src/native/sha256.c": pkg_sexplib.syntax
"src/native/sha256.c": pkg_zarith
"src/native/sha512.c": pkg_cstruct
"src/native/sha512.c": pkg_ctypes
"src/native/sha512.c": pkg_ctypes.stubs
"src/native/sha512.c": pkg_sexplib.syntax
"src/native/sha512.c": pkg_zarith
"src/native/rijndael.c": pkg_cstruct
"src/native/rijndael.c": pkg_ctypes
"src/native/rijndael.c": pkg_ctypes.stubs
"src/native/rijndael.c": pkg_sexplib.syntax
"src/native/rijndael.c": pkg_zarith
"src/native/d3des.c": pkg_cstruct
"src/native/d3des.c": pkg_ctypes
"src/native/d3des.c": pkg_ctypes.stubs
"src/native/d3des.c": pkg_sexplib.syntax
"src/native/d3des.c": pkg_zarith
"src/native/nocrypto_stubs.c": pkg_cstruct
"src/native/nocrypto_stubs.c": pkg_ctypes
"src/native/nocrypto_stubs.c": pkg_ctypes.stubs
"src/native/nocrypto_stubs.c": pkg_sexplib.syntax
"src/native/nocrypto_stubs.c": pkg_zarith
"src/native/nocrypto_generated_stubs.c": pkg_cstruct
"src/native/nocrypto_generated_stubs.c": pkg_ctypes
"src/native/nocrypto_generated_stubs.c": pkg_ctypes.stubs
"src/native/nocrypto_generated_stubs.c": pkg_sexplib.syntax
"src/native/nocrypto_generated_stubs.c": pkg_zarith
<src/*.ml{,i,y}>: package(cstruct)
<src/*.ml{,i,y}>: package(ctypes)
<src/*.ml{,i,y}>: package(ctypes.stubs)
<src/*.ml{,i,y}>: package(sexplib.syntax)
<src/*.ml{,i,y}>: package(type_conv)
<src/*.ml{,i,y}>: package(zarith)
"src/native/md5.c": package(cstruct)
"src/native/md5.c": package(ctypes)
"src/native/md5.c": package(ctypes.stubs)
"src/native/md5.c": package(sexplib.syntax)
"src/native/md5.c": package(type_conv)
"src/native/md5.c": package(zarith)
"src/native/sha1.c": package(cstruct)
"src/native/sha1.c": package(ctypes)
"src/native/sha1.c": package(ctypes.stubs)
"src/native/sha1.c": package(sexplib.syntax)
"src/native/sha1.c": package(type_conv)
"src/native/sha1.c": package(zarith)
"src/native/sha256.c": package(cstruct)
"src/native/sha256.c": package(ctypes)
"src/native/sha256.c": package(ctypes.stubs)
"src/native/sha256.c": package(sexplib.syntax)
"src/native/sha256.c": package(type_conv)
"src/native/sha256.c": package(zarith)
"src/native/sha512.c": package(cstruct)
"src/native/sha512.c": package(ctypes)
"src/native/sha512.c": package(ctypes.stubs)
"src/native/sha512.c": package(sexplib.syntax)
"src/native/sha512.c": package(type_conv)
"src/native/sha512.c": package(zarith)
"src/native/rijndael.c": package(cstruct)
"src/native/rijndael.c": package(ctypes)
"src/native/rijndael.c": package(ctypes.stubs)
"src/native/rijndael.c": package(sexplib.syntax)
"src/native/rijndael.c": package(type_conv)
"src/native/rijndael.c": package(zarith)
"src/native/d3des.c": package(cstruct)
"src/native/d3des.c": package(ctypes)
"src/native/d3des.c": package(ctypes.stubs)
"src/native/d3des.c": package(sexplib.syntax)
"src/native/d3des.c": package(type_conv)
"src/native/d3des.c": package(zarith)
"src/native/nocrypto_stubs.c": package(cstruct)
"src/native/nocrypto_stubs.c": package(ctypes)
"src/native/nocrypto_stubs.c": package(ctypes.stubs)
"src/native/nocrypto_stubs.c": package(sexplib.syntax)
"src/native/nocrypto_stubs.c": package(type_conv)
"src/native/nocrypto_stubs.c": package(zarith)
"src/native/nocrypto_generated_stubs.c": package(cstruct)
"src/native/nocrypto_generated_stubs.c": package(ctypes)
"src/native/nocrypto_generated_stubs.c": package(ctypes.stubs)
"src/native/nocrypto_generated_stubs.c": package(sexplib.syntax)
"src/native/nocrypto_generated_stubs.c": package(type_conv)
"src/native/nocrypto_generated_stubs.c": package(zarith)
# Library testlib
"tests/testlib.cmxs": use_testlib
# Executable test_runner
<tests/testrunner.{native,byte}>: pkg_cstruct
<tests/testrunner.{native,byte}>: pkg_cstruct.unix
<tests/testrunner.{native,byte}>: pkg_ctypes
<tests/testrunner.{native,byte}>: pkg_ctypes.stubs
<tests/testrunner.{native,byte}>: pkg_oUnit
<tests/testrunner.{native,byte}>: pkg_sexplib.syntax
<tests/testrunner.{native,byte}>: pkg_zarith
<tests/testrunner.{native,byte}>: package(cstruct)
<tests/testrunner.{native,byte}>: package(cstruct.unix)
<tests/testrunner.{native,byte}>: package(ctypes)
<tests/testrunner.{native,byte}>: package(ctypes.stubs)
<tests/testrunner.{native,byte}>: package(oUnit)
<tests/testrunner.{native,byte}>: package(sexplib.syntax)
<tests/testrunner.{native,byte}>: package(type_conv)
<tests/testrunner.{native,byte}>: package(zarith)
<tests/testrunner.{native,byte}>: use_nocrypto
<tests/testrunner.{native,byte}>: use_testlib
<tests/*.ml{,i,y}>: pkg_oUnit
<tests/*.ml{,i,y}>: package(oUnit)
<tests/*.ml{,i,y}>: use_testlib
# Executable bench
"tests/runnable.native": pkg_cstruct
"tests/runnable.native": pkg_ctypes
"tests/runnable.native": pkg_ctypes.stubs
"tests/runnable.native": pkg_lwt
"tests/runnable.native": pkg_lwt.syntax
"tests/runnable.native": pkg_lwt.unix
"tests/runnable.native": pkg_sexplib.syntax
"tests/runnable.native": pkg_zarith
"tests/runnable.native": package(cstruct)
"tests/runnable.native": package(ctypes)
"tests/runnable.native": package(ctypes.stubs)
"tests/runnable.native": package(lwt)
"tests/runnable.native": package(lwt.syntax)
"tests/runnable.native": package(lwt.unix)
"tests/runnable.native": package(sexplib.syntax)
"tests/runnable.native": package(type_conv)
"tests/runnable.native": package(zarith)
"tests/runnable.native": use_nocrypto
<tests/*.ml{,i,y}>: pkg_lwt
<tests/*.ml{,i,y}>: pkg_lwt.syntax
<tests/*.ml{,i,y}>: pkg_lwt.unix
<tests/*.ml{,i,y}>: package(lwt)
<tests/*.ml{,i,y}>: package(lwt.syntax)
<tests/*.ml{,i,y}>: package(lwt.unix)
# Executable hashbench
"tests/hashbench.native": pkg_cstruct
"tests/hashbench.native": pkg_cstruct.unix
"tests/hashbench.native": pkg_ctypes
"tests/hashbench.native": pkg_ctypes.stubs
"tests/hashbench.native": pkg_sexplib.syntax
"tests/hashbench.native": pkg_zarith
"tests/hashbench.native": package(cstruct)
"tests/hashbench.native": package(cstruct.unix)
"tests/hashbench.native": package(ctypes)
"tests/hashbench.native": package(ctypes.stubs)
"tests/hashbench.native": package(sexplib.syntax)
"tests/hashbench.native": package(type_conv)
"tests/hashbench.native": package(zarith)
"tests/hashbench.native": use_nocrypto
<tests/*.ml{,i,y}>: pkg_cstruct
<tests/*.ml{,i,y}>: pkg_cstruct.unix
<tests/*.ml{,i,y}>: pkg_ctypes
<tests/*.ml{,i,y}>: pkg_ctypes.stubs
<tests/*.ml{,i,y}>: pkg_sexplib.syntax
<tests/*.ml{,i,y}>: pkg_zarith
<tests/*.ml{,i,y}>: package(cstruct)
<tests/*.ml{,i,y}>: package(cstruct.unix)
<tests/*.ml{,i,y}>: package(ctypes)
<tests/*.ml{,i,y}>: package(ctypes.stubs)
<tests/*.ml{,i,y}>: package(sexplib.syntax)
<tests/*.ml{,i,y}>: package(type_conv)
<tests/*.ml{,i,y}>: package(zarith)
<tests/*.ml{,i,y}>: use_nocrypto
# OASIS_STOP

Expand Down
55 changes: 51 additions & 4 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(* OASIS_START *)
(* DO NOT EDIT (digest: 0aaffdaaf5cabd1232dd692a709ccdb0) *)
(* DO NOT EDIT (digest: 16fb4baec14b97060f7e4a7e9a770980) *)
module OASISGettext = struct
(* # 22 "src/oasis/OASISGettext.ml" *)

Expand Down Expand Up @@ -608,9 +608,25 @@ open Ocamlbuild_plugin;;
let package_default =
{
MyOCamlbuildBase.lib_ocaml =
[("nocrypto", ["src"], []); ("testlib", ["tests"], [])];
[
("nocrypto_xen", ["xen"], []);
("nocrypto", ["src"], []);
("testlib", ["tests"], [])
];
lib_c =
[
("nocrypto_xen",
"xen/",
[
"xen/native/bitfn.h";
"xen/native/md5.h";
"xen/native/sha1.h";
"xen/native/sha256.h";
"xen/native/sha512.h";
"xen/native/rijndael.h";
"xen/native/d3des.h";
"xen/native/nocrypto_stubs.h"
]);
("nocrypto",
"src/",
[
Expand All @@ -626,10 +642,37 @@ let package_default =
];
flags =
[
(["oasis_library_nocrypto_xen_ccopt"; "compile"],
[
(OASISExpr.EBool true,
S
[
A "-ccopt";
A "-O3";
A "-ccopt";
A "-I${pkg_ctypes}";
A "-ccopt";
A "-I${pkg_ctypes}/..";
A "-ccopt";
A "-DNDEBUG";
A "-ccopt";
A "${XEN_CFLAGS}"
]);
(OASISExpr.EFlag "pedantic",
S [A "-ccopt"; A "-Wall"; A "-ccopt"; A "-Wpedantic"])
]);
(["oasis_library_nocrypto_ccopt"; "compile"],
[
(OASISExpr.EBool true,
S [A "-ccopt"; A "-O3"; A "-ccopt"; A "-I${pkg_ctypes}/.."]);
S
[
A "-ccopt";
A "-O3";
A "-ccopt";
A "-I${pkg_ctypes}";
A "-ccopt";
A "-I${pkg_ctypes}/.."
]);
(OASISExpr.EFlag "pedantic",
S [A "-ccopt"; A "-Wall"; A "-ccopt"; A "-Wpedantic"])
]);
Expand All @@ -651,7 +694,7 @@ let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}

let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;

# 655 "myocamlbuild.ml"
# 698 "myocamlbuild.ml"
(* OASIS_STOP *)

open Ocamlbuild_plugin;;
Expand All @@ -666,6 +709,10 @@ dispatch @@ MyOCamlbuildBase.dispatch_combine [
copy_rule "cstubs: copy bindings descriptions"
"src_gen/bindings.ml"
"src/bindings.ml" ;

copy_rule "xen_cstubs: copy generated source to xen directory"
"src/native/%"
"xen/native/%"
| _ -> ()
end;
dispatch_default
Expand Down
Loading

0 comments on commit 7d61982

Please sign in to comment.