Skip to content

Commit

Permalink
Merge pull request #105 from mirage/new-layout
Browse files Browse the repository at this point in the history
New layout about freestanding & xen artifacts
  • Loading branch information
dinosaure authored Nov 1, 2020
2 parents 3077386 + 71f9d92 commit 17d4953
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 175 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 0.14.2
version = 0.15.0
break-infix = fit-or-vertical
parse-docstrings = true
indicate-multiline-delimiters=no
Expand Down
10 changes: 10 additions & 0 deletions .test-mirage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

set -ex

opam install -y mirage
(cd mirage && mirage configure -t unix && make depends && mirage build && ./digestif_test && mirage clean && cd ..) || exit 1
(cd mirage && mirage configure -t hvt && make depends && mirage build && mirage clean && cd ..) || exit 1
if [ $(uname -m) = "amd64" ] || [ $(uname -m) = "x86_64" ]; then
(cd mirage && mirage configure -t xen && make depend && mirage build && mirage clean && cd ..) || exit 1
fi
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ env:
- OCAML_VERSION=4.03
- OCAML_VERSION=4.04
- OCAML_VERSION=4.05
- OCAML_VERSION=4.05 DEPOPTS="mirage-xen-posix"
- OCAML_VERSION=4.06
- OCAML_VERSION=4.07
- OCAML_VERSION=4.07 DEPOPTS="ocaml-freestanding"
- OCAML_VERSION=4.08 DEPOPTS="ocaml-freestanding"
- OCAML_VERSION=4.08
- OCAML_VERSION=4.09 TESTS=false POST_INSTALL_HOOK=./.test-mirage.sh
7 changes: 3 additions & 4 deletions digestif.opam
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ install: [
depends: [
"ocaml" {>= "4.03.0"}
"dune" {>= "2.6.0"}
"conf-pkg-config" {build}
"eqaf"
"base-bytes"
"bigarray-compat"
Expand All @@ -52,13 +53,11 @@ depends: [
"rresult" {with-test}
"ocamlfind" {with-test}
]

depopts: [
"ocaml-freestanding"
"mirage-xen-posix"
]

conflicts: [
"mirage-xen-posix" {< "3.1.0"}
"ocaml-freestanding" {< "0.4.3"}
"mirage-xen" {< "6.0.0"}
"ocaml-freestanding" {< "0.6.0"}
]
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
(lang dune 2.6)
(lang dune 2.7)
(name digestif)
23 changes: 23 additions & 0 deletions freestanding/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PKG_CONFIG_PATH := $(shell opam config var prefix)/lib/pkgconfig

EXISTS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --exists ocaml-freestanding; echo $$?)

.PHONY: all clean
all: libdigestif_freestanding_stubs.a

ifeq ($(EXISTS), 1)
libdigestif_freestanding_stubs.a:
touch $@
else
CC ?= cc
FREESTANDING_CFLAGS := $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) pkg-config --cflags ocaml-freestanding)
CFLAGS := -O3 $(FREESTANDING_CFLAGS)

OBJS= blake2b.o blake2s.o md5.o ripemd160.o sha1.o sha256.o sha512.o sha3.o whirlpool.o misc.o stubs.o

libdigestif_freestanding_stubs.a: $(OBJS)
$(AR) r $@ $^
endif

clean:
$(RM) $(OBJS) libdigestif_freestanding_stubs.a
16 changes: 16 additions & 0 deletions freestanding/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(copy_files#
(alias install)
(files ../src-c/native/*))

(rule
(deps Makefile)
(targets libdigestif_freestanding_stubs.a)
(action
(no-infer
(progn
(run %{make})))))

(install
(package digestif)
(section lib)
(files libdigestif_freestanding_stubs.a))
6 changes: 1 addition & 5 deletions install/install.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
;;
#load "unix.cma"

let xen = "xen_linkopts = \"-l:rakia/xen/librakia_xen_stubs.a\""

let freestanding =
"freestanding_linkopts = \
\"-l:rakia/freestanding/librakia_freestanding_stubs.a\""
"freestanding_linkopts = \"-l:libdigestif_freestanding_stubs.a\""

let meta =
match Sys.getenv "DUNE_BUILD_DIR" with
Expand All @@ -23,6 +20,5 @@ let output_line oc line =
let () =
Unix.chmod meta 0o644 ;
let oc = open_out_gen [ Open_append ] 0o644 meta in
output_line oc xen ;
output_line oc freestanding ;
close_out oc
1 change: 1 addition & 0 deletions mirage/_tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
true: package(digestif.c)
7 changes: 7 additions & 0 deletions mirage/config.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
open Mirage

let main = foreign "Unikernel.Make" (console @-> job)

let packages = [ package "digestif" ]

let () = register ~packages "digestif-test" [ main $ default_console ]
7 changes: 7 additions & 0 deletions mirage/unikernel.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Make (Console : Mirage_console.S) = struct
let log console fmt = Format.kasprintf (Console.log console) fmt

let start console =
let hash = Digestif.SHA1.digest_string "Hello World!" in
log console "%a" Digestif.SHA1.pp hash
end
21 changes: 10 additions & 11 deletions src-c/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
(name digestif_c)
(public_name digestif.c)
(implements digestif)
(libraries stdlib-shims bigarray-compat eqaf digestif.rakia)
(libraries stdlib-shims bigarray-compat eqaf)
(private_modules digestif_native digestif_eq digestif_conv digestif_by
digestif_bi)
(foreign_stubs
(language c)
(names blake2b blake2s md5 ripemd160 sha1 sha256 sha512 sha3 whirlpool misc
stubs)
(flags
(:standard -I./native/)))
(flags
(:standard -no-keep-locs)))

(rule
(copy# ../src/digestif_bi.ml digestif_bi.ml))
(include_subdirs unqualified)

(rule
(copy# ../src/digestif_by.ml digestif_by.ml))

(rule
(copy# ../src/digestif_eq.ml digestif_eq.ml))

(rule
(copy# ../src/digestif_conv.ml digestif_conv.ml))
(copy_files#
(files ../src/*.ml))
9 changes: 0 additions & 9 deletions src-c/native/dune

This file was deleted.

4 changes: 0 additions & 4 deletions src-c/native/freestanding/cflags.sh

This file was deleted.

49 changes: 0 additions & 49 deletions src-c/native/freestanding/dune

This file was deleted.

Loading

0 comments on commit 17d4953

Please sign in to comment.