Skip to content
This repository was archived by the owner on Mar 11, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ _build
setup.data
setup.log
.*.swp
/*.install
14 changes: 13 additions & 1 deletion _tags
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
true : annot, bin_annot, principal, safe_string
true : bin_annot, principal, safe_string
true : warn(+A-4-6-44-48-58)
true : package(cstruct), package(lwt)

<lib> : include
<lib/*.ml> : package(mirage-os-shim)
<lib/mirage-entropy.{cma,cmxa}> : dynamic_link_to_unix_stubs
<lib/mirage-entropy.cmxs> : static_link_to_unix_stubs
<lib/native/*.c> : use_c_flags

<xen> : include
<xen/native/*.c> : use_c_flags,use_xen_pkgconfig_flags

<solo5> : include
<solo5/native/*.c> : use_c_flags,use_solo5_pkgconfig_flags
1 change: 1 addition & 0 deletions lib/entropy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module Cpu_native = struct
end

open Lwt.Infix
open Mirage_OS

type 'a io = 'a Lwt.t
type buffer = Cstruct.t
Expand Down
2 changes: 1 addition & 1 deletion lib/libmirage-entropy_stubs.clib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
entropy_cpu_stubs.o
native/entropy_cpu_stubs.o
1 change: 1 addition & 0 deletions lib/mirage-entropy.mldylib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entropy
File renamed without changes.
22 changes: 0 additions & 22 deletions mirage-entropy-xen.opam

This file was deleted.

30 changes: 21 additions & 9 deletions myocamlbuild.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,27 @@ let () =
dispatch begin function
| After_rules ->
copy_rule "copy generated source to xen directory"
"lib/%"
"xen/%" ;
"lib/native/%"
"xen/native/%" ;
copy_rule "copy generated source to solo5 directory"
"lib/%"
"solo5/%" ;
let flags = common_ccopt @ ccopt in
flag ["c"; "use_xen_stubs"; "compile"] &
S (flags @ pkg_config_flags "mirage-xen") ;
flag ["c"; "use_solo5_stubs"; "compile"] &
S (flags @ pkg_config_flags "ocaml-freestanding") ;
"lib/native/%"
"solo5/native/%" ;

flag ["link"; "ocaml"; "library"; "byte"; "dynamic_link_to_unix_stubs"] &
S [A "-dllib"; A "-lmirage-entropy_stubs"] ;
flag ["link"; "ocaml"; "library"; "native"; "dynamic_link_to_unix_stubs"] &
S [A "-cclib"; A "-lmirage-entropy_stubs"] ;

flag ["link"; "ocaml"; "static_link_to_unix_stubs"] &
S [A "lib/libmirage-entropy_stubs.a"] ;
dep ["link"; "ocaml"; "static_link_to_unix_stubs"] &
["lib/libmirage-entropy_stubs.a"] ;

flag ["compile"; "c"; "use_c_flags"] &
S (common_ccopt @ ccopt) ;
flag ["compile"; "c"; "use_xen_pkgconfig_flags"] &
S (pkg_config_flags "mirage-xen") ;
flag ["compile"; "c"; "use_solo5_pkgconfig_flags"] &
S (pkg_config_flags "ocaml-freestanding")
| _ -> ()
end
15 changes: 13 additions & 2 deletions mirage-entropy-solo5.opam → opam
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
opam-version: "1.2"
name: "mirage-entropy-solo5"
name: "mirage-entropy"
homepage: "https://github.com/mirage/mirage-entropy"
dev-repo: "https://github.com/mirage/mirage-entropy.git"
bug-reports: "https://github.com/mirage/mirage-entropy/issues"
Expand All @@ -8,16 +8,27 @@ maintainer: "david@numm.org"
license: "BSD2"

build: [
["ocaml" "pkg/pkg.ml" "build" "--pkg-name" name "--pinned" "%{pinned}%"]
"ocaml" "pkg/pkg.ml" "build"
"--pinned" "%{pinned}%"
"--with-mirage-xen" "%{mirage-xen:installed}%"
"--with-mirage-solo5" "%{mirage-solo5:installed}%"
"--with-ocaml-freestanding" "%{ocaml-freestanding:installed}%"
]
depends: [
"ocamlfind" {build}
"ocamlbuild" {build}
"topkg" {build & >= "0.7.6"}
"cstruct" {>= "1.4.0"}
"lwt"
"mirage-os-shim"
]
depopts: [
"mirage-solo5"
"ocaml-freestanding"
"mirage-xen"
]
conflicts: [
"mirage-xen" {<"2.2.0"}
]
tags: [ "org:mirage"]
available: [ ocaml-version >= "4.01.0" ]
7 changes: 4 additions & 3 deletions pkg/META.solo5 → pkg/META
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
description = "Entropy provider for MirageOS on Solo5"
description = "Entropy provider for MirageOS"
version = "%%VERSION_NUM%%"
requires = "lwt cstruct mirage-solo5"
requires = "lwt cstruct mirage-os-shim"
archive(byte) = "mirage-entropy.cma"
archive(native) = "mirage-entropy.cmxa"
plugin(byte) = "mirage-entropy.cma"
plugin(native) = "mirage-entropy.cmxs"
freestanding_linkopts = "-lmirage-entropy_stubs"
xen_linkopts = "-lmirage-entropy-xen_stubs"
freestanding_linkopts = "-lmirage-entropy-freestanding_stubs"
exists_if = "mirage-entropy.cma"
9 changes: 0 additions & 9 deletions pkg/META.xen

This file was deleted.

53 changes: 16 additions & 37 deletions pkg/pkg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,23 @@
#require "topkg"
open Topkg

let metas = [
Pkg.meta_file ~install:false "pkg/META.xen";
Pkg.meta_file ~install:false "pkg/META.solo5";
]
let opams = [
Pkg.opam_file "opam" ~lint_deps_excluding:
(Some ["mirage-xen"; "mirage-solo5"; "ocaml-freestanding"])
]

let opams =
let install = false in
[
Pkg.opam_file "mirage-entropy-xen.opam" ~install;
Pkg.opam_file "mirage-entropy-solo5.opam" ~install;
]
let default = false
let mirage_solo5 = Conf.with_pkg ~default "mirage-solo5"
let ocaml_freestanding = Conf.with_pkg ~default "ocaml-freestanding"
let mirage_xen = Conf.with_pkg ~default "mirage-xen"

let cmd c os files =
let ocamlbuild = Conf.tool "ocamlbuild" os in
let build_dir = Conf.build_dir c in
let debug = Cmd.(on (Conf.debug c) (v "-tag" % "debug")) in
let flags =
match Conf.pkg_name c with
| "mirage-entropy-xen" -> Cmd.(v "-pkg" % "mirage-xen" % "-tag" % "use_xen_stubs")
| "mirage-entropy-solo5" -> Cmd.(v "-pkg" % "mirage-solo5" % "-tag" % "use_solo5_stubs")
| _ -> invalid_arg "unknown package name"
in
OS.Cmd.run @@
Cmd.(ocamlbuild % "-use-ocamlfind" % "-classic-display" %% debug %
"-build-dir" % build_dir %% flags %% of_list files)

let build = Pkg.build ~cmd ()
let xen c = Conf.value c mirage_xen
let solo5 c = Conf.(value c mirage_solo5 && value c ocaml_freestanding)

let () =
Pkg.describe ~build ~metas ~opams "mirage-entropy-xen" @@ fun c ->
match Conf.pkg_name c with
| "mirage-entropy-xen" ->
Ok [ Pkg.lib "pkg/META.xen" ~dst:"META";
Pkg.clib "lib/libmirage-entropy_stubs.clib";
Pkg.mllib "lib/mirage-entropy.mllib"; ]
| "mirage-entropy-solo5" ->
Ok [ Pkg.lib "pkg/META.solo5" ~dst:"META";
Pkg.clib "lib/libmirage-entropy_stubs.clib";
Pkg.mllib "lib/mirage-entropy.mllib"; ]
| other ->
R.error_msgf "unknown package name: %s" other
Pkg.describe ~opams "mirage-entropy" @@ fun c ->
Ok [ Pkg.mllib "lib/mirage-entropy.mllib" ;
Pkg.clib "lib/libmirage-entropy_stubs.clib" ;
Pkg.clib ~cond:(xen c) "xen/libmirage-entropy-xen_stubs.clib" ;
Pkg.clib ~cond:(solo5 c) "solo5/libmirage-entropy-freestanding_stubs.clib"
]
1 change: 1 addition & 0 deletions solo5/libmirage-entropy-freestanding_stubs.clib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
native/entropy_cpu_stubs.o
1 change: 1 addition & 0 deletions xen/libmirage-entropy-xen_stubs.clib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
native/entropy_cpu_stubs.o