Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mirage/mirage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 67f16b6a7bf3
Choose a base ref
...
head repository: mirage/mirage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 344c4046bf06
Choose a head ref
Loading
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -20,3 +20,6 @@ lib_test/**/myocamlbuild.ml
lib_test/**/static1.ml
lib_test/**/static1.mli
lib/mirage_version.ml

*.odocl
*.docdir
9 changes: 7 additions & 2 deletions .merlin
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
B _build/*
S lib/
PKG ipaddr unix dynlink lwt cmdliner mirage-types.lwt
S lib/*
S lib_runtime/*
S lib_test/*
PKG ipaddr unix dynlink lwt cmdliner mirage-types.lwt functoria rresult fmt

FLG -w +A-4-6-7-9-40-42-44-48
FLG -strict_sequence -safe_string
8 changes: 4 additions & 4 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ bash -ex .travis-opam.sh

eval `opam config env`
opam install mirage -y
cd lib_test
make MODE=unix MIRAGE=mirage BFLAGS=
make clean
make MODE=xen MIRAGE=mirage BFLAGS=
opam source mirage-skeleton
cd mirage-skeleton.dev
MODE=unix make
MODE=xen make
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -3,6 +3,9 @@ sudo: required
install: wget https://raw.githubusercontent.com/ocaml/ocaml-travisci-skeleton/master/.travis-opam.sh
script: bash -ex .travis-ci.sh
env:
global:
- PINS="mirage-skeleton.dev:https://github.com/Drup/mirage-skeleton.git#functoria"
matrix:
- UPDATE_GCC_BINUTILS=1 OCAML_VERSION=4.02 PACKAGE=mirage
- UPDATE_GCC_BINUTILS=1 OCAML_VERSION=4.01 PACKAGE=mirage
- UPDATE_GCC_BINUTILS=1 OCAML_VERSION=4.01 PACKAGE=mirage-types
27 changes: 16 additions & 11 deletions _oasis
Original file line number Diff line number Diff line change
@@ -7,29 +7,34 @@ License: ISC
Plugins: META (0.4)
BuildTools: ocamlbuild

Library "mirage-runtime"
Path: lib_runtime
Findlibparent: mirage
Findlibname: runtime
Modules: Mirage_runtime, Mirage_info
BuildDepends: functoria.runtime, ipaddr

Library mirage
CompiledObject: best
Path: lib
Findlibname: mirage
Modules: Mirage, Mirage_misc
BuildDepends: ipaddr,unix,dynlink,lwt,mirage-types,mirage-types.lwt

Library "mirage-runtime"
Path: lib
Findlibname: runtime
Modules: Mirage_runtime
Findlibparent: mirage
Modules: Mirage, Mirage_key
InternalModules: Mirage_version
BuildDepends: ipaddr, functoria, mirage.runtime, functoria.app

Executable mirage
CompiledObject: best
Path: lib
MainIs: main.ml
Install: true
BuildDepends: mirage,cmdliner
BuildDepends: mirage, functoria

AlphaFeatures: ocamlbuild_more_args
Document "mirage"
Title: Mirage docs
Type: OCamlbuild (0.4)
BuildTools+: ocamldoc
XOCamlbuildPath: lib
XOCamlbuildLibraries: mirage
XOCamlbuildPath: .
XOCamlbuildLibraries: mirage, mirage.runtime
XOCamlbuildExtraArgs:
"-docflags '-colorize-code -short-functors -charset utf-8'"
39 changes: 23 additions & 16 deletions _tags
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OASIS_START
# DO NOT EDIT (digest: 4d21228b26e332ef6566b6f2980444a9)
# DO NOT EDIT (digest: c50d20c5631ef5b982eb1c6ead8daad3)
# 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
@@ -14,27 +14,34 @@ true: annot, bin_annot
".git": not_hygienic
"_darcs": -traverse
"_darcs": not_hygienic
# Library mirage-runtime
"lib_runtime/mirage-runtime.cmxs": use_mirage-runtime
<lib_runtime/*.ml{,i,y}>: pkg_functoria.runtime
<lib_runtime/*.ml{,i,y}>: pkg_ipaddr
# Library mirage
"lib/mirage.cmxs": use_mirage
# Library mirage-runtime
"lib/mirage-runtime.cmxs": use_mirage-runtime
# Executable mirage
<lib/main.{native,byte}>: pkg_cmdliner
<lib/main.{native,byte}>: pkg_dynlink
<lib/main.{native,byte}>: pkg_functoria
<lib/main.{native,byte}>: pkg_functoria.app
<lib/main.{native,byte}>: pkg_functoria.runtime
<lib/main.{native,byte}>: pkg_ipaddr
<lib/main.{native,byte}>: pkg_lwt
<lib/main.{native,byte}>: pkg_mirage-types
<lib/main.{native,byte}>: pkg_mirage-types.lwt
<lib/main.{native,byte}>: pkg_unix
<lib/main.{native,byte}>: use_mirage
<lib/*.ml{,i,y}>: pkg_cmdliner
<lib/*.ml{,i,y}>: pkg_dynlink
<lib/main.{native,byte}>: use_mirage-runtime
<lib/*.ml{,i,y}>: pkg_functoria
<lib/*.ml{,i,y}>: pkg_functoria.app
<lib/*.ml{,i,y}>: pkg_functoria.runtime
<lib/*.ml{,i,y}>: pkg_ipaddr
<lib/*.ml{,i,y}>: pkg_lwt
<lib/*.ml{,i,y}>: pkg_mirage-types
<lib/*.ml{,i,y}>: pkg_mirage-types.lwt
<lib/*.ml{,i,y}>: pkg_unix
<lib/*.ml{,i,y}>: use_mirage
<lib/*.ml{,i,y}>: use_mirage-runtime
# OASIS_STOP
true: debug, bin_annot, annot, principal
<types/*.mli>: pkg_cstruct, pkg_io-page, pkg_ipaddr, pkg_lwt

true: warn(+A-4-6-7-9-40-42-44-48)
true: strict_sequence, safe_string, short_paths, principal
true: debug, annot, bin_annot

# Better locations and loc in .mlis
true: keep_locs

# Force the runtime to be unix-independent.
<lib_runtime/*>: dontlink(unix)
5 changes: 3 additions & 2 deletions lib/META
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# OASIS_START
# DO NOT EDIT (digest: b6274596ee1a156bcbd890ac65d913a0)
# DO NOT EDIT (digest: 34328920c8396464d8e1495aaeddf904)
version = "2.6.1"
description = "Mirage configuration tool"
requires = "ipaddr unix dynlink lwt mirage-types mirage-types.lwt"
requires = "ipaddr functoria mirage.runtime functoria.app"
archive(byte) = "mirage.cma"
archive(byte, plugin) = "mirage.cma"
archive(native) = "mirage.cmxa"
@@ -11,6 +11,7 @@ exists_if = "mirage.cma"
package "runtime" (
version = "2.6.1"
description = "Mirage configuration tool"
requires = "functoria.runtime ipaddr"
archive(byte) = "mirage-runtime.cma"
archive(byte, plugin) = "mirage-runtime.cma"
archive(native) = "mirage-runtime.cmxa"
195 changes: 1 addition & 194 deletions lib/main.ml
Original file line number Diff line number Diff line change
@@ -14,197 +14,4 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

open Cmdliner

let global_option_section = "COMMON OPTIONS"
let help_sections = [
`S global_option_section;
`P "These options are common to all commands.";
]

(* Helpers *)
let mk_flag ?section flags doc =
let doc = Arg.info ?docs:section ~doc flags in
Arg.(value & flag & doc)

let term_info title ~doc ~man =
let man = man @ help_sections in
Term.info ~sdocs:global_option_section ~doc ~man title

let arg_list name doc conv =
let doc = Arg.info ~docv:name ~doc [] in
Arg.(value & pos_all conv [] & doc)

let no_opam =
mk_flag ["no-opam"] "Do not manage the OPAM configuration. This will result in dependent libraries not being automatically installed during the configuration phase."
let xen =
mk_flag ["xen"] "Generate a Xen unikernel. Do not use in conjunction with --unix."
let unix =
mk_flag ["unix"] "Use Unix backend. Do not use in conjunction with --xen. On MacOS X, this will use platform-specific code to be generated. To force pure Unix mode on MacOS X, set the $(b,-t) flag to $(i,unix) instead."

let no_opam_version_check =
mk_flag ["no-opam-version-check"] "Bypass the check of opam's version."

let no_depext =
mk_flag ["no-depext"] "Skip installation of external dependencies."

let target =
let doc = "Target platform to compile the unikernel for. Valid values are: $(i,xen), $(i,unix), $(i,macosx). There are short forms available via $(b,--xen) and $(b,--unix) as well." in
let e = Arg.enum [ "unix", `Unix; "macosx", `MacOSX; "xen", `Xen ] in
Arg.(value & opt (some e) None & info ["t";"target"] ~docv:"TARGET" ~doc)

(* Select the operating mode from command line flags *)
let mode unix xen target =
let default_unix =
match Mirage_misc.uname_s () with
| Some "Darwin" -> begin
(* Only use MacOS-specific functionality from Yosemite upwards *)
let is_yosemite_or_higher =
match Mirage_misc.uname_r () with
| None -> false
| Some vs ->
match Mirage_misc.split vs '.' with
| [] -> false
| hd::_ -> begin
let v = try int_of_string hd with _ -> 0 in
v >= 14
end
in
if is_yosemite_or_higher then `MacOSX else `Unix
end
| _ -> `Unix
in
(** Specifying --target takes priority over other flags *)
match target with
| Some t -> t
| None -> begin
(** For legacy reasons, Unix maps to either Unix or MacOS X *)
match xen, unix with
| true , true -> failwith "Cannot specify --unix and --xen together."
| true , false -> `Xen
| false, _ -> default_unix
end

let file =
let doc = Arg.info ~docv:"FILE"
~doc:"Configuration file for Mirage. If not specified, the current directory will be scanned. \
If one file named $(b,config.ml) is found, that file will be used. If no files \
or multiple configuration files are found, this will result in an error unless one \
is explicitly specified on the command line." [] in
Arg.(value & pos 0 (some string) None & doc)

(* CONFIGURE *)
let configure_doc = "Configure a Mirage application."
let configure =
let doc = configure_doc in
let man = [
`S "DESCRIPTION";
`P "The $(b,configure) command initializes a fresh Mirage application."
] in
let configure unix xen no_macosx no_opam no_opam_version_check no_depext file =
if unix && xen then `Help (`Pager, Some "configure")
else (
Mirage.manage_opam_packages (not no_opam);
Mirage.no_opam_version_check no_opam_version_check;
Mirage.no_depext no_depext;
Mirage.set_mode (mode unix xen no_macosx);
let t = Mirage.load file in
`Ok (Mirage.configure t)) in
Term.(ret (pure configure $ unix $ xen $ target $ no_opam $
no_opam_version_check $ no_depext $ file)),
term_info "configure" ~doc ~man

(* BUILD *)
let build_doc = "Build a Mirage application."
let build =
let doc = build_doc in
let man = [
`S "DESCRIPTION";
`P build_doc
] in
let build file =
let t = Mirage.load file in
`Ok (Mirage.build t) in
Term.(ret (pure build $ file)), term_info "build" ~doc ~man

(* CLEAN *)
let clean_doc = "Clean the files produced by Mirage for a given application."
let clean =
let doc = clean_doc in
let man = [
`S "DESCRIPTION";
`P clean_doc;
] in
let clean file no_opam =
let t = Mirage.load file in
Mirage.manage_opam_packages (not no_opam);
`Ok (Mirage.clean t) in
Term.(ret (pure clean $ file $ no_opam)), term_info "clean" ~doc ~man

(* HELP *)
let help =
let doc = "Display help about Mirage and Mirage commands." in
let man = [
`S "DESCRIPTION";
`P "Prints help about Mirage commands.";
`P "Use `$(mname) help topics' to get the full list of help topics.";
] in
let topic =
let doc = Arg.info [] ~docv:"TOPIC" ~doc:"The topic to get help on." in
Arg.(value & pos 0 (some string) None & doc )
in
let help man_format cmds topic = match topic with
| None -> `Help (`Pager, None)
| Some topic ->
let topics = "topics" :: cmds in
let conv, _ = Arg.enum (List.rev_map (fun s -> (s, s)) topics) in
match conv topic with
| `Error e -> `Error (false, e)
| `Ok t when t = "topics" -> List.iter print_endline cmds; `Ok ()
| `Ok t -> `Help (man_format, Some t) in

Term.(ret (pure help $Term.man_format $Term.choice_names $topic)),
Term.info "help" ~doc ~man

let default =
let doc = "Mirage application builder" in
let man = [
`S "DESCRIPTION";
`P "Mirage is a Mirage application builder. It glues together a set of libraries and configuration (e.g. network and storage) into a standalone unikernel or UNIX binary.";
`P "Use either $(b,mirage <command> --help) or $(b,mirage help <command>) \
for more information on a specific command.";
] @ help_sections
in
let usage () =
Printf.printf
"usage: mirage [--version]\n\
\ [--help]\n\
\ <command> [<args>]\n\
\n\
The most commonly used mirage commands are:\n\
\ configure %s\n\
\ build %s\n\
\ clean %s\n\
\n\
See 'mirage help <command>' for more information on a specific command.\n%!"
configure_doc build_doc clean_doc in
Term.(pure usage $ pure ()),
Term.info "mirage"
~version:Mirage_version.current
~sdocs:global_option_section
~doc
~man

let commands = [
configure;
build;
clean;
]

let () =
(* Do not die on Ctrl+C: necessary when mirage has to cleanup things
(like killing running kernels) before terminating. *)
Sys.catch_break true;
match Term.eval_choice default commands with
| `Error _ -> exit 1
| _ -> ()
let () = Mirage.run ()
4 changes: 0 additions & 4 deletions lib/mirage-runtime.mldylib

This file was deleted.

4 changes: 0 additions & 4 deletions lib/mirage-runtime.mllib

This file was deleted.

Loading