Skip to content

Commit

Permalink
Do not implicitely manage the installation of OPAM packages with the …
Browse files Browse the repository at this point in the history
…mirage tool
  • Loading branch information
samoht committed Jun 17, 2014
1 parent 440e781 commit c535548
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 49 deletions.
12 changes: 4 additions & 8 deletions lib/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ 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."
let xen =
mk_flag ["xen"] "Generate a Xen unikernel. Do not use in conjunction with --unix-*."
let unix =
Expand Down Expand Up @@ -64,14 +62,13 @@ let configure =
`S "DESCRIPTION";
`P "The $(b,configure) command initializes a fresh Mirage application."
] in
let configure unix xen no_opam file =
let configure unix xen file =
if unix && xen then `Help (`Pager, Some "configure")
else (
Mirage.manage_opam_packages (not no_opam);
Mirage.set_mode (mode unix xen);
let t = Mirage.load file in
`Ok (Mirage.configure t)) in
Term.(ret (pure configure $ unix $ xen $ no_opam $ file)),
Term.(ret (pure configure $ unix $ xen $ file)),
term_info "configure" ~doc ~man

(* BUILD *)
Expand Down Expand Up @@ -107,11 +104,10 @@ let clean =
`S "DESCRIPTION";
`P clean_doc;
] in
let clean file no_opam =
let clean file =
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
Term.(ret (pure clean $ file)), term_info "clean" ~doc ~man

(* HELP *)
let help =
Expand Down
31 changes: 1 addition & 30 deletions lib/mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ let configure_makefile t =
all: build\n\
\n\
prepare:\n\
\t$(OPAM) install $(PKGS)\n\
\t$(OPAM) install $(PKGS) --verbose\n\
\n\
main.native:\n\
\t$(BUILD) main.native\n\
Expand Down Expand Up @@ -1520,33 +1520,6 @@ let configure_makefile t =
let clean_makefile t =
remove (t.root / "Makefile")

let configure_opam t =
info "Installing OPAM packages.";
match packages t with
| [] -> ()
| ps ->
if command_exists "opam" then opam "install" ps
else error "OPAM is not installed."

let clean_opam t =
()
(* This is a bit too agressive, disabling for now on.
let (++) = StringSet.union in
let set mode = StringSet.of_list (packages t mode) in
let packages =
set (`Unix `Socket) ++ set (`Unix `Direct) ++ set `Xen in
match StringSet.elements packages with
| [] -> ()
| ps ->
if cmd_exists "opam" then opam "remove" ps
else error "OPAM is not installed."
*)

let manage_opam = ref true

let manage_opam_packages b =
manage_opam := b

let configure_job j =
let name = Impl.name j in
let module_name = Impl.module_name j in
Expand Down Expand Up @@ -1586,7 +1559,6 @@ let configure t =
(if List.length t.jobs = 1 then "" else "s")
(String.concat ", " (List.map Impl.functor_name t.jobs));
in_dir t.root (fun () ->
if !manage_opam then configure_opam t;
configure_myocamlbuild_ml t;
configure_makefile t;
configure_main_xl t;
Expand All @@ -1613,7 +1585,6 @@ let run t =
let clean t =
info "CLEAN: %s" (blue_s (t.root / "config.ml"));
in_dir t.root (fun () ->
if !manage_opam then clean_opam t;
clean_myocamlbuild_ml t;
clean_makefile t;
clean_main_xl t;
Expand Down
4 changes: 0 additions & 4 deletions lib/mirage.mli
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,6 @@ end

(** {2 Project configuration} *)

val manage_opam_packages: bool -> unit
(** Tell Irminsule to manage the OPAM configuration
(ie. install/remove missing packages). *)

val add_to_opam_packages: string list -> unit
(** Add some base OPAM package to install *)

Expand Down
14 changes: 7 additions & 7 deletions lib_test/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
MIRARI = ../main.native
MIRAGE = ../main.native
TESTS = console kv_ro fat net ip http combinator basic_ethif basic_stackv4 basic_http
# MODE ?= xen
MODE ?= unix
BFLAGS ?= --no-opam
MODE ?= unix
MFLAGS ?=

CONFIGS = $(patsubst %, %-configure, $(TESTS))
BUILDS = $(patsubst %, %-build, $(TESTS))
Expand All @@ -15,14 +15,14 @@ build: $(BUILDS)
clean: $(CLEANS)

%-configure:
$(MIRARI) configure $*/config.ml $(BFLAGS) --$(MODE)
$(MIRAGE) configure $*/config.ml $(MFLAGS) --$(MODE)

%-build: %-configure
$(MIRARI) build $*/config.ml
$(MIRAGE) build $*/config.ml

%-run: %-build
$(MIRARI) run $*/config.ml
$(MIRAGE) run $*/config.ml

%-clean:
rm -f $*/mir-main
$(MIRARI) clean $*/config.ml $(BFLAGS) || true
$(MIRAGE) clean $*/config.ml $(MFLAGS) || true

0 comments on commit c535548

Please sign in to comment.